{-# 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.EndpointBatchRequest
-- 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.EndpointBatchRequest where

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

-- | Specifies a batch of endpoints to create or update and the settings and
-- attributes to set or change for each endpoint.
--
-- /See:/ 'newEndpointBatchRequest' smart constructor.
data EndpointBatchRequest = EndpointBatchRequest'
  { -- | An array that defines the endpoints to create or update and, for each
    -- endpoint, the property values to set or change. An array can contain a
    -- maximum of 100 items.
    EndpointBatchRequest -> [EndpointBatchItem]
item :: [EndpointBatchItem]
  }
  deriving (EndpointBatchRequest -> EndpointBatchRequest -> Bool
(EndpointBatchRequest -> EndpointBatchRequest -> Bool)
-> (EndpointBatchRequest -> EndpointBatchRequest -> Bool)
-> Eq EndpointBatchRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointBatchRequest -> EndpointBatchRequest -> Bool
$c/= :: EndpointBatchRequest -> EndpointBatchRequest -> Bool
== :: EndpointBatchRequest -> EndpointBatchRequest -> Bool
$c== :: EndpointBatchRequest -> EndpointBatchRequest -> Bool
Prelude.Eq, ReadPrec [EndpointBatchRequest]
ReadPrec EndpointBatchRequest
Int -> ReadS EndpointBatchRequest
ReadS [EndpointBatchRequest]
(Int -> ReadS EndpointBatchRequest)
-> ReadS [EndpointBatchRequest]
-> ReadPrec EndpointBatchRequest
-> ReadPrec [EndpointBatchRequest]
-> Read EndpointBatchRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndpointBatchRequest]
$creadListPrec :: ReadPrec [EndpointBatchRequest]
readPrec :: ReadPrec EndpointBatchRequest
$creadPrec :: ReadPrec EndpointBatchRequest
readList :: ReadS [EndpointBatchRequest]
$creadList :: ReadS [EndpointBatchRequest]
readsPrec :: Int -> ReadS EndpointBatchRequest
$creadsPrec :: Int -> ReadS EndpointBatchRequest
Prelude.Read, Int -> EndpointBatchRequest -> ShowS
[EndpointBatchRequest] -> ShowS
EndpointBatchRequest -> String
(Int -> EndpointBatchRequest -> ShowS)
-> (EndpointBatchRequest -> String)
-> ([EndpointBatchRequest] -> ShowS)
-> Show EndpointBatchRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointBatchRequest] -> ShowS
$cshowList :: [EndpointBatchRequest] -> ShowS
show :: EndpointBatchRequest -> String
$cshow :: EndpointBatchRequest -> String
showsPrec :: Int -> EndpointBatchRequest -> ShowS
$cshowsPrec :: Int -> EndpointBatchRequest -> ShowS
Prelude.Show, (forall x. EndpointBatchRequest -> Rep EndpointBatchRequest x)
-> (forall x. Rep EndpointBatchRequest x -> EndpointBatchRequest)
-> Generic EndpointBatchRequest
forall x. Rep EndpointBatchRequest x -> EndpointBatchRequest
forall x. EndpointBatchRequest -> Rep EndpointBatchRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EndpointBatchRequest x -> EndpointBatchRequest
$cfrom :: forall x. EndpointBatchRequest -> Rep EndpointBatchRequest x
Prelude.Generic)

-- |
-- Create a value of 'EndpointBatchRequest' 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:
--
-- 'item', 'endpointBatchRequest_item' - An array that defines the endpoints to create or update and, for each
-- endpoint, the property values to set or change. An array can contain a
-- maximum of 100 items.
newEndpointBatchRequest ::
  EndpointBatchRequest
newEndpointBatchRequest :: EndpointBatchRequest
newEndpointBatchRequest =
  EndpointBatchRequest' :: [EndpointBatchItem] -> EndpointBatchRequest
EndpointBatchRequest' {$sel:item:EndpointBatchRequest' :: [EndpointBatchItem]
item = [EndpointBatchItem]
forall a. Monoid a => a
Prelude.mempty}

-- | An array that defines the endpoints to create or update and, for each
-- endpoint, the property values to set or change. An array can contain a
-- maximum of 100 items.
endpointBatchRequest_item :: Lens.Lens' EndpointBatchRequest [EndpointBatchItem]
endpointBatchRequest_item :: ([EndpointBatchItem] -> f [EndpointBatchItem])
-> EndpointBatchRequest -> f EndpointBatchRequest
endpointBatchRequest_item = (EndpointBatchRequest -> [EndpointBatchItem])
-> (EndpointBatchRequest
    -> [EndpointBatchItem] -> EndpointBatchRequest)
-> Lens
     EndpointBatchRequest
     EndpointBatchRequest
     [EndpointBatchItem]
     [EndpointBatchItem]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointBatchRequest' {[EndpointBatchItem]
item :: [EndpointBatchItem]
$sel:item:EndpointBatchRequest' :: EndpointBatchRequest -> [EndpointBatchItem]
item} -> [EndpointBatchItem]
item) (\s :: EndpointBatchRequest
s@EndpointBatchRequest' {} [EndpointBatchItem]
a -> EndpointBatchRequest
s {$sel:item:EndpointBatchRequest' :: [EndpointBatchItem]
item = [EndpointBatchItem]
a} :: EndpointBatchRequest) (([EndpointBatchItem] -> f [EndpointBatchItem])
 -> EndpointBatchRequest -> f EndpointBatchRequest)
-> (([EndpointBatchItem] -> f [EndpointBatchItem])
    -> [EndpointBatchItem] -> f [EndpointBatchItem])
-> ([EndpointBatchItem] -> f [EndpointBatchItem])
-> EndpointBatchRequest
-> f EndpointBatchRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([EndpointBatchItem] -> f [EndpointBatchItem])
-> [EndpointBatchItem] -> f [EndpointBatchItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable EndpointBatchRequest

instance Prelude.NFData EndpointBatchRequest

instance Core.ToJSON EndpointBatchRequest where
  toJSON :: EndpointBatchRequest -> Value
toJSON EndpointBatchRequest' {[EndpointBatchItem]
item :: [EndpointBatchItem]
$sel:item:EndpointBatchRequest' :: EndpointBatchRequest -> [EndpointBatchItem]
..} =
    [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
"Item" Text -> [EndpointBatchItem] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [EndpointBatchItem]
item)]
      )