{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Pinpoint.Types.EventsRequest
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pinpoint.Types.EventsRequest where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.EventsBatch
import qualified Amazonka.Prelude as Prelude

-- | Specifies a batch of events to process.
--
-- /See:/ 'newEventsRequest' smart constructor.
data EventsRequest = EventsRequest'
  { -- | The batch of events to process. For each item in a batch, the endpoint
    -- ID acts as a key that has an EventsBatch object as its value.
    EventsRequest -> HashMap Text EventsBatch
batchItem :: Prelude.HashMap Prelude.Text EventsBatch
  }
  deriving (EventsRequest -> EventsRequest -> Bool
(EventsRequest -> EventsRequest -> Bool)
-> (EventsRequest -> EventsRequest -> Bool) -> Eq EventsRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventsRequest -> EventsRequest -> Bool
$c/= :: EventsRequest -> EventsRequest -> Bool
== :: EventsRequest -> EventsRequest -> Bool
$c== :: EventsRequest -> EventsRequest -> Bool
Prelude.Eq, ReadPrec [EventsRequest]
ReadPrec EventsRequest
Int -> ReadS EventsRequest
ReadS [EventsRequest]
(Int -> ReadS EventsRequest)
-> ReadS [EventsRequest]
-> ReadPrec EventsRequest
-> ReadPrec [EventsRequest]
-> Read EventsRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventsRequest]
$creadListPrec :: ReadPrec [EventsRequest]
readPrec :: ReadPrec EventsRequest
$creadPrec :: ReadPrec EventsRequest
readList :: ReadS [EventsRequest]
$creadList :: ReadS [EventsRequest]
readsPrec :: Int -> ReadS EventsRequest
$creadsPrec :: Int -> ReadS EventsRequest
Prelude.Read, Int -> EventsRequest -> ShowS
[EventsRequest] -> ShowS
EventsRequest -> String
(Int -> EventsRequest -> ShowS)
-> (EventsRequest -> String)
-> ([EventsRequest] -> ShowS)
-> Show EventsRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventsRequest] -> ShowS
$cshowList :: [EventsRequest] -> ShowS
show :: EventsRequest -> String
$cshow :: EventsRequest -> String
showsPrec :: Int -> EventsRequest -> ShowS
$cshowsPrec :: Int -> EventsRequest -> ShowS
Prelude.Show, (forall x. EventsRequest -> Rep EventsRequest x)
-> (forall x. Rep EventsRequest x -> EventsRequest)
-> Generic EventsRequest
forall x. Rep EventsRequest x -> EventsRequest
forall x. EventsRequest -> Rep EventsRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventsRequest x -> EventsRequest
$cfrom :: forall x. EventsRequest -> Rep EventsRequest x
Prelude.Generic)

-- |
-- Create a value of 'EventsRequest' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'batchItem', 'eventsRequest_batchItem' - The batch of events to process. For each item in a batch, the endpoint
-- ID acts as a key that has an EventsBatch object as its value.
newEventsRequest ::
  EventsRequest
newEventsRequest :: EventsRequest
newEventsRequest =
  EventsRequest' :: HashMap Text EventsBatch -> EventsRequest
EventsRequest' {$sel:batchItem:EventsRequest' :: HashMap Text EventsBatch
batchItem = HashMap Text EventsBatch
forall a. Monoid a => a
Prelude.mempty}

-- | The batch of events to process. For each item in a batch, the endpoint
-- ID acts as a key that has an EventsBatch object as its value.
eventsRequest_batchItem :: Lens.Lens' EventsRequest (Prelude.HashMap Prelude.Text EventsBatch)
eventsRequest_batchItem :: (HashMap Text EventsBatch -> f (HashMap Text EventsBatch))
-> EventsRequest -> f EventsRequest
eventsRequest_batchItem = (EventsRequest -> HashMap Text EventsBatch)
-> (EventsRequest -> HashMap Text EventsBatch -> EventsRequest)
-> Lens
     EventsRequest
     EventsRequest
     (HashMap Text EventsBatch)
     (HashMap Text EventsBatch)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventsRequest' {HashMap Text EventsBatch
batchItem :: HashMap Text EventsBatch
$sel:batchItem:EventsRequest' :: EventsRequest -> HashMap Text EventsBatch
batchItem} -> HashMap Text EventsBatch
batchItem) (\s :: EventsRequest
s@EventsRequest' {} HashMap Text EventsBatch
a -> EventsRequest
s {$sel:batchItem:EventsRequest' :: HashMap Text EventsBatch
batchItem = HashMap Text EventsBatch
a} :: EventsRequest) ((HashMap Text EventsBatch -> f (HashMap Text EventsBatch))
 -> EventsRequest -> f EventsRequest)
-> ((HashMap Text EventsBatch -> f (HashMap Text EventsBatch))
    -> HashMap Text EventsBatch -> f (HashMap Text EventsBatch))
-> (HashMap Text EventsBatch -> f (HashMap Text EventsBatch))
-> EventsRequest
-> f EventsRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text EventsBatch -> f (HashMap Text EventsBatch))
-> HashMap Text EventsBatch -> f (HashMap Text EventsBatch)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable EventsRequest

instance Prelude.NFData EventsRequest

instance Core.ToJSON EventsRequest where
  toJSON :: EventsRequest -> Value
toJSON EventsRequest' {HashMap Text EventsBatch
batchItem :: HashMap Text EventsBatch
$sel:batchItem:EventsRequest' :: EventsRequest -> HashMap Text EventsBatch
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BatchItem" Text -> HashMap Text EventsBatch -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text EventsBatch
batchItem)]
      )