{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.UpdateEndpointsBatch
-- 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)
--
-- Creates a new batch of endpoints for an application or updates the
-- settings and attributes of a batch of existing endpoints for an
-- application. You can also use this operation to define custom attributes
-- for a batch of endpoints. If an update includes one or more values for a
-- custom attribute, Amazon Pinpoint replaces (overwrites) any existing
-- values with the new values.
module Amazonka.Pinpoint.UpdateEndpointsBatch
  ( -- * Creating a Request
    UpdateEndpointsBatch (..),
    newUpdateEndpointsBatch,

    -- * Request Lenses
    updateEndpointsBatch_applicationId,
    updateEndpointsBatch_endpointBatchRequest,

    -- * Destructuring the Response
    UpdateEndpointsBatchResponse (..),
    newUpdateEndpointsBatchResponse,

    -- * Response Lenses
    updateEndpointsBatchResponse_httpStatus,
    updateEndpointsBatchResponse_messageBody,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateEndpointsBatch' smart constructor.
data UpdateEndpointsBatch = UpdateEndpointsBatch'
  { -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    UpdateEndpointsBatch -> Text
applicationId :: Prelude.Text,
    UpdateEndpointsBatch -> EndpointBatchRequest
endpointBatchRequest :: EndpointBatchRequest
  }
  deriving (UpdateEndpointsBatch -> UpdateEndpointsBatch -> Bool
(UpdateEndpointsBatch -> UpdateEndpointsBatch -> Bool)
-> (UpdateEndpointsBatch -> UpdateEndpointsBatch -> Bool)
-> Eq UpdateEndpointsBatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEndpointsBatch -> UpdateEndpointsBatch -> Bool
$c/= :: UpdateEndpointsBatch -> UpdateEndpointsBatch -> Bool
== :: UpdateEndpointsBatch -> UpdateEndpointsBatch -> Bool
$c== :: UpdateEndpointsBatch -> UpdateEndpointsBatch -> Bool
Prelude.Eq, ReadPrec [UpdateEndpointsBatch]
ReadPrec UpdateEndpointsBatch
Int -> ReadS UpdateEndpointsBatch
ReadS [UpdateEndpointsBatch]
(Int -> ReadS UpdateEndpointsBatch)
-> ReadS [UpdateEndpointsBatch]
-> ReadPrec UpdateEndpointsBatch
-> ReadPrec [UpdateEndpointsBatch]
-> Read UpdateEndpointsBatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateEndpointsBatch]
$creadListPrec :: ReadPrec [UpdateEndpointsBatch]
readPrec :: ReadPrec UpdateEndpointsBatch
$creadPrec :: ReadPrec UpdateEndpointsBatch
readList :: ReadS [UpdateEndpointsBatch]
$creadList :: ReadS [UpdateEndpointsBatch]
readsPrec :: Int -> ReadS UpdateEndpointsBatch
$creadsPrec :: Int -> ReadS UpdateEndpointsBatch
Prelude.Read, Int -> UpdateEndpointsBatch -> ShowS
[UpdateEndpointsBatch] -> ShowS
UpdateEndpointsBatch -> String
(Int -> UpdateEndpointsBatch -> ShowS)
-> (UpdateEndpointsBatch -> String)
-> ([UpdateEndpointsBatch] -> ShowS)
-> Show UpdateEndpointsBatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEndpointsBatch] -> ShowS
$cshowList :: [UpdateEndpointsBatch] -> ShowS
show :: UpdateEndpointsBatch -> String
$cshow :: UpdateEndpointsBatch -> String
showsPrec :: Int -> UpdateEndpointsBatch -> ShowS
$cshowsPrec :: Int -> UpdateEndpointsBatch -> ShowS
Prelude.Show, (forall x. UpdateEndpointsBatch -> Rep UpdateEndpointsBatch x)
-> (forall x. Rep UpdateEndpointsBatch x -> UpdateEndpointsBatch)
-> Generic UpdateEndpointsBatch
forall x. Rep UpdateEndpointsBatch x -> UpdateEndpointsBatch
forall x. UpdateEndpointsBatch -> Rep UpdateEndpointsBatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateEndpointsBatch x -> UpdateEndpointsBatch
$cfrom :: forall x. UpdateEndpointsBatch -> Rep UpdateEndpointsBatch x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEndpointsBatch' 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:
--
-- 'applicationId', 'updateEndpointsBatch_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'endpointBatchRequest', 'updateEndpointsBatch_endpointBatchRequest' - Undocumented member.
newUpdateEndpointsBatch ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'endpointBatchRequest'
  EndpointBatchRequest ->
  UpdateEndpointsBatch
newUpdateEndpointsBatch :: Text -> EndpointBatchRequest -> UpdateEndpointsBatch
newUpdateEndpointsBatch
  Text
pApplicationId_
  EndpointBatchRequest
pEndpointBatchRequest_ =
    UpdateEndpointsBatch' :: Text -> EndpointBatchRequest -> UpdateEndpointsBatch
UpdateEndpointsBatch'
      { $sel:applicationId:UpdateEndpointsBatch' :: Text
applicationId =
          Text
pApplicationId_,
        $sel:endpointBatchRequest:UpdateEndpointsBatch' :: EndpointBatchRequest
endpointBatchRequest = EndpointBatchRequest
pEndpointBatchRequest_
      }

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
updateEndpointsBatch_applicationId :: Lens.Lens' UpdateEndpointsBatch Prelude.Text
updateEndpointsBatch_applicationId :: (Text -> f Text) -> UpdateEndpointsBatch -> f UpdateEndpointsBatch
updateEndpointsBatch_applicationId = (UpdateEndpointsBatch -> Text)
-> (UpdateEndpointsBatch -> Text -> UpdateEndpointsBatch)
-> Lens UpdateEndpointsBatch UpdateEndpointsBatch Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpointsBatch' {Text
applicationId :: Text
$sel:applicationId:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> Text
applicationId} -> Text
applicationId) (\s :: UpdateEndpointsBatch
s@UpdateEndpointsBatch' {} Text
a -> UpdateEndpointsBatch
s {$sel:applicationId:UpdateEndpointsBatch' :: Text
applicationId = Text
a} :: UpdateEndpointsBatch)

-- | Undocumented member.
updateEndpointsBatch_endpointBatchRequest :: Lens.Lens' UpdateEndpointsBatch EndpointBatchRequest
updateEndpointsBatch_endpointBatchRequest :: (EndpointBatchRequest -> f EndpointBatchRequest)
-> UpdateEndpointsBatch -> f UpdateEndpointsBatch
updateEndpointsBatch_endpointBatchRequest = (UpdateEndpointsBatch -> EndpointBatchRequest)
-> (UpdateEndpointsBatch
    -> EndpointBatchRequest -> UpdateEndpointsBatch)
-> Lens
     UpdateEndpointsBatch
     UpdateEndpointsBatch
     EndpointBatchRequest
     EndpointBatchRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpointsBatch' {EndpointBatchRequest
endpointBatchRequest :: EndpointBatchRequest
$sel:endpointBatchRequest:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> EndpointBatchRequest
endpointBatchRequest} -> EndpointBatchRequest
endpointBatchRequest) (\s :: UpdateEndpointsBatch
s@UpdateEndpointsBatch' {} EndpointBatchRequest
a -> UpdateEndpointsBatch
s {$sel:endpointBatchRequest:UpdateEndpointsBatch' :: EndpointBatchRequest
endpointBatchRequest = EndpointBatchRequest
a} :: UpdateEndpointsBatch)

instance Core.AWSRequest UpdateEndpointsBatch where
  type
    AWSResponse UpdateEndpointsBatch =
      UpdateEndpointsBatchResponse
  request :: UpdateEndpointsBatch -> Request UpdateEndpointsBatch
request = Service -> UpdateEndpointsBatch -> Request UpdateEndpointsBatch
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateEndpointsBatch
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEndpointsBatch)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateEndpointsBatch))
-> Logger
-> Service
-> Proxy UpdateEndpointsBatch
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEndpointsBatch)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> MessageBody -> UpdateEndpointsBatchResponse
UpdateEndpointsBatchResponse'
            (Int -> MessageBody -> UpdateEndpointsBatchResponse)
-> Either String Int
-> Either String (MessageBody -> UpdateEndpointsBatchResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (MessageBody -> UpdateEndpointsBatchResponse)
-> Either String MessageBody
-> Either String UpdateEndpointsBatchResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String MessageBody
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable UpdateEndpointsBatch

instance Prelude.NFData UpdateEndpointsBatch

instance Core.ToHeaders UpdateEndpointsBatch where
  toHeaders :: UpdateEndpointsBatch -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateEndpointsBatch -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Core.ToPath UpdateEndpointsBatch where
  toPath :: UpdateEndpointsBatch -> ByteString
toPath UpdateEndpointsBatch' {Text
EndpointBatchRequest
endpointBatchRequest :: EndpointBatchRequest
applicationId :: Text
$sel:endpointBatchRequest:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> EndpointBatchRequest
$sel:applicationId:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/apps/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId, ByteString
"/endpoints"]

instance Core.ToQuery UpdateEndpointsBatch where
  toQuery :: UpdateEndpointsBatch -> QueryString
toQuery = QueryString -> UpdateEndpointsBatch -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateEndpointsBatchResponse' smart constructor.
data UpdateEndpointsBatchResponse = UpdateEndpointsBatchResponse'
  { -- | The response's http status code.
    UpdateEndpointsBatchResponse -> Int
httpStatus :: Prelude.Int,
    UpdateEndpointsBatchResponse -> MessageBody
messageBody :: MessageBody
  }
  deriving (UpdateEndpointsBatchResponse
-> UpdateEndpointsBatchResponse -> Bool
(UpdateEndpointsBatchResponse
 -> UpdateEndpointsBatchResponse -> Bool)
-> (UpdateEndpointsBatchResponse
    -> UpdateEndpointsBatchResponse -> Bool)
-> Eq UpdateEndpointsBatchResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEndpointsBatchResponse
-> UpdateEndpointsBatchResponse -> Bool
$c/= :: UpdateEndpointsBatchResponse
-> UpdateEndpointsBatchResponse -> Bool
== :: UpdateEndpointsBatchResponse
-> UpdateEndpointsBatchResponse -> Bool
$c== :: UpdateEndpointsBatchResponse
-> UpdateEndpointsBatchResponse -> Bool
Prelude.Eq, ReadPrec [UpdateEndpointsBatchResponse]
ReadPrec UpdateEndpointsBatchResponse
Int -> ReadS UpdateEndpointsBatchResponse
ReadS [UpdateEndpointsBatchResponse]
(Int -> ReadS UpdateEndpointsBatchResponse)
-> ReadS [UpdateEndpointsBatchResponse]
-> ReadPrec UpdateEndpointsBatchResponse
-> ReadPrec [UpdateEndpointsBatchResponse]
-> Read UpdateEndpointsBatchResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateEndpointsBatchResponse]
$creadListPrec :: ReadPrec [UpdateEndpointsBatchResponse]
readPrec :: ReadPrec UpdateEndpointsBatchResponse
$creadPrec :: ReadPrec UpdateEndpointsBatchResponse
readList :: ReadS [UpdateEndpointsBatchResponse]
$creadList :: ReadS [UpdateEndpointsBatchResponse]
readsPrec :: Int -> ReadS UpdateEndpointsBatchResponse
$creadsPrec :: Int -> ReadS UpdateEndpointsBatchResponse
Prelude.Read, Int -> UpdateEndpointsBatchResponse -> ShowS
[UpdateEndpointsBatchResponse] -> ShowS
UpdateEndpointsBatchResponse -> String
(Int -> UpdateEndpointsBatchResponse -> ShowS)
-> (UpdateEndpointsBatchResponse -> String)
-> ([UpdateEndpointsBatchResponse] -> ShowS)
-> Show UpdateEndpointsBatchResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEndpointsBatchResponse] -> ShowS
$cshowList :: [UpdateEndpointsBatchResponse] -> ShowS
show :: UpdateEndpointsBatchResponse -> String
$cshow :: UpdateEndpointsBatchResponse -> String
showsPrec :: Int -> UpdateEndpointsBatchResponse -> ShowS
$cshowsPrec :: Int -> UpdateEndpointsBatchResponse -> ShowS
Prelude.Show, (forall x.
 UpdateEndpointsBatchResponse -> Rep UpdateEndpointsBatchResponse x)
-> (forall x.
    Rep UpdateEndpointsBatchResponse x -> UpdateEndpointsBatchResponse)
-> Generic UpdateEndpointsBatchResponse
forall x.
Rep UpdateEndpointsBatchResponse x -> UpdateEndpointsBatchResponse
forall x.
UpdateEndpointsBatchResponse -> Rep UpdateEndpointsBatchResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateEndpointsBatchResponse x -> UpdateEndpointsBatchResponse
$cfrom :: forall x.
UpdateEndpointsBatchResponse -> Rep UpdateEndpointsBatchResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEndpointsBatchResponse' 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:
--
-- 'httpStatus', 'updateEndpointsBatchResponse_httpStatus' - The response's http status code.
--
-- 'messageBody', 'updateEndpointsBatchResponse_messageBody' - Undocumented member.
newUpdateEndpointsBatchResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'messageBody'
  MessageBody ->
  UpdateEndpointsBatchResponse
newUpdateEndpointsBatchResponse :: Int -> MessageBody -> UpdateEndpointsBatchResponse
newUpdateEndpointsBatchResponse
  Int
pHttpStatus_
  MessageBody
pMessageBody_ =
    UpdateEndpointsBatchResponse' :: Int -> MessageBody -> UpdateEndpointsBatchResponse
UpdateEndpointsBatchResponse'
      { $sel:httpStatus:UpdateEndpointsBatchResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:messageBody:UpdateEndpointsBatchResponse' :: MessageBody
messageBody = MessageBody
pMessageBody_
      }

-- | The response's http status code.
updateEndpointsBatchResponse_httpStatus :: Lens.Lens' UpdateEndpointsBatchResponse Prelude.Int
updateEndpointsBatchResponse_httpStatus :: (Int -> f Int)
-> UpdateEndpointsBatchResponse -> f UpdateEndpointsBatchResponse
updateEndpointsBatchResponse_httpStatus = (UpdateEndpointsBatchResponse -> Int)
-> (UpdateEndpointsBatchResponse
    -> Int -> UpdateEndpointsBatchResponse)
-> Lens
     UpdateEndpointsBatchResponse UpdateEndpointsBatchResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpointsBatchResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateEndpointsBatchResponse' :: UpdateEndpointsBatchResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateEndpointsBatchResponse
s@UpdateEndpointsBatchResponse' {} Int
a -> UpdateEndpointsBatchResponse
s {$sel:httpStatus:UpdateEndpointsBatchResponse' :: Int
httpStatus = Int
a} :: UpdateEndpointsBatchResponse)

-- | Undocumented member.
updateEndpointsBatchResponse_messageBody :: Lens.Lens' UpdateEndpointsBatchResponse MessageBody
updateEndpointsBatchResponse_messageBody :: (MessageBody -> f MessageBody)
-> UpdateEndpointsBatchResponse -> f UpdateEndpointsBatchResponse
updateEndpointsBatchResponse_messageBody = (UpdateEndpointsBatchResponse -> MessageBody)
-> (UpdateEndpointsBatchResponse
    -> MessageBody -> UpdateEndpointsBatchResponse)
-> Lens
     UpdateEndpointsBatchResponse
     UpdateEndpointsBatchResponse
     MessageBody
     MessageBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpointsBatchResponse' {MessageBody
messageBody :: MessageBody
$sel:messageBody:UpdateEndpointsBatchResponse' :: UpdateEndpointsBatchResponse -> MessageBody
messageBody} -> MessageBody
messageBody) (\s :: UpdateEndpointsBatchResponse
s@UpdateEndpointsBatchResponse' {} MessageBody
a -> UpdateEndpointsBatchResponse
s {$sel:messageBody:UpdateEndpointsBatchResponse' :: MessageBody
messageBody = MessageBody
a} :: UpdateEndpointsBatchResponse)

instance Prelude.NFData UpdateEndpointsBatchResponse