{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
      { $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 :: Lens' UpdateEndpointsBatch Text
updateEndpointsBatch_applicationId = 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 :: Lens' UpdateEndpointsBatch EndpointBatchRequest
updateEndpointsBatch_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 :: (Service -> Service)
-> UpdateEndpointsBatch -> Request UpdateEndpointsBatch
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateEndpointsBatch
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEndpointsBatch)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> MessageBody -> UpdateEndpointsBatchResponse
UpdateEndpointsBatchResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)
      )

instance Prelude.Hashable UpdateEndpointsBatch where
  hashWithSalt :: Int -> UpdateEndpointsBatch -> Int
hashWithSalt Int
_salt UpdateEndpointsBatch' {Text
EndpointBatchRequest
endpointBatchRequest :: EndpointBatchRequest
applicationId :: Text
$sel:endpointBatchRequest:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> EndpointBatchRequest
$sel:applicationId:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EndpointBatchRequest
endpointBatchRequest

instance Prelude.NFData UpdateEndpointsBatch where
  rnf :: UpdateEndpointsBatch -> ()
rnf UpdateEndpointsBatch' {Text
EndpointBatchRequest
endpointBatchRequest :: EndpointBatchRequest
applicationId :: Text
$sel:endpointBatchRequest:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> EndpointBatchRequest
$sel:applicationId:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EndpointBatchRequest
endpointBatchRequest

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

instance Data.ToJSON UpdateEndpointsBatch where
  toJSON :: UpdateEndpointsBatch -> Value
toJSON UpdateEndpointsBatch' {Text
EndpointBatchRequest
endpointBatchRequest :: EndpointBatchRequest
applicationId :: Text
$sel:endpointBatchRequest:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> EndpointBatchRequest
$sel:applicationId:UpdateEndpointsBatch' :: UpdateEndpointsBatch -> Text
..} =
    forall a. ToJSON a => a -> Value
Data.toJSON EndpointBatchRequest
endpointBatchRequest

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

instance Data.ToQuery UpdateEndpointsBatch where
  toQuery :: UpdateEndpointsBatch -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
      { $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 :: Lens' UpdateEndpointsBatchResponse Int
updateEndpointsBatchResponse_httpStatus = 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 :: Lens' UpdateEndpointsBatchResponse MessageBody
updateEndpointsBatchResponse_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 where
  rnf :: UpdateEndpointsBatchResponse -> ()
rnf UpdateEndpointsBatchResponse' {Int
MessageBody
messageBody :: MessageBody
httpStatus :: Int
$sel:messageBody:UpdateEndpointsBatchResponse' :: UpdateEndpointsBatchResponse -> MessageBody
$sel:httpStatus:UpdateEndpointsBatchResponse' :: UpdateEndpointsBatchResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MessageBody
messageBody