{-# 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.SNS.PublishBatch
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Publishes up to ten messages to the specified topic. This is a batch
-- version of @Publish@. For FIFO topics, multiple messages within a single
-- batch are published in the order they are sent, and messages are
-- deduplicated within the batch and across batches for 5 minutes.
--
-- The result of publishing each message is reported individually in the
-- response. Because the batch request can result in a combination of
-- successful and unsuccessful actions, you should check for batch errors
-- even when the call returns an HTTP status code of @200@.
--
-- The maximum allowed individual message size and the maximum total
-- payload size (the sum of the individual lengths of all of the batched
-- messages) are both 256 KB (262,144 bytes).
--
-- Some actions take lists of parameters. These lists are specified using
-- the @param.n@ notation. Values of @n@ are integers starting from 1. For
-- example, a parameter list with two elements looks like this:
--
-- &AttributeName.1=first
--
-- &AttributeName.2=second
--
-- If you send a batch message to a topic, Amazon SNS publishes the batch
-- message to each endpoint that is subscribed to the topic. The format of
-- the batch message depends on the notification protocol for each
-- subscribed endpoint.
--
-- When a @messageId@ is returned, the batch message is saved and Amazon
-- SNS immediately delivers the message to subscribers.
module Amazonka.SNS.PublishBatch
  ( -- * Creating a Request
    PublishBatch (..),
    newPublishBatch,

    -- * Request Lenses
    publishBatch_topicArn,
    publishBatch_publishBatchRequestEntries,

    -- * Destructuring the Response
    PublishBatchResponse (..),
    newPublishBatchResponse,

    -- * Response Lenses
    publishBatchResponse_failed,
    publishBatchResponse_successful,
    publishBatchResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SNS.Types

-- | /See:/ 'newPublishBatch' smart constructor.
data PublishBatch = PublishBatch'
  { -- | The Amazon resource name (ARN) of the topic you want to batch publish
    -- to.
    PublishBatch -> Text
topicArn :: Prelude.Text,
    -- | A list of @PublishBatch@ request entries to be sent to the SNS topic.
    PublishBatch -> [PublishBatchRequestEntry]
publishBatchRequestEntries :: [PublishBatchRequestEntry]
  }
  deriving (PublishBatch -> PublishBatch -> Bool
(PublishBatch -> PublishBatch -> Bool)
-> (PublishBatch -> PublishBatch -> Bool) -> Eq PublishBatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PublishBatch -> PublishBatch -> Bool
== :: PublishBatch -> PublishBatch -> Bool
$c/= :: PublishBatch -> PublishBatch -> Bool
/= :: PublishBatch -> PublishBatch -> Bool
Prelude.Eq, ReadPrec [PublishBatch]
ReadPrec PublishBatch
Int -> ReadS PublishBatch
ReadS [PublishBatch]
(Int -> ReadS PublishBatch)
-> ReadS [PublishBatch]
-> ReadPrec PublishBatch
-> ReadPrec [PublishBatch]
-> Read PublishBatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS PublishBatch
readsPrec :: Int -> ReadS PublishBatch
$creadList :: ReadS [PublishBatch]
readList :: ReadS [PublishBatch]
$creadPrec :: ReadPrec PublishBatch
readPrec :: ReadPrec PublishBatch
$creadListPrec :: ReadPrec [PublishBatch]
readListPrec :: ReadPrec [PublishBatch]
Prelude.Read, Int -> PublishBatch -> ShowS
[PublishBatch] -> ShowS
PublishBatch -> String
(Int -> PublishBatch -> ShowS)
-> (PublishBatch -> String)
-> ([PublishBatch] -> ShowS)
-> Show PublishBatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PublishBatch -> ShowS
showsPrec :: Int -> PublishBatch -> ShowS
$cshow :: PublishBatch -> String
show :: PublishBatch -> String
$cshowList :: [PublishBatch] -> ShowS
showList :: [PublishBatch] -> ShowS
Prelude.Show, (forall x. PublishBatch -> Rep PublishBatch x)
-> (forall x. Rep PublishBatch x -> PublishBatch)
-> Generic PublishBatch
forall x. Rep PublishBatch x -> PublishBatch
forall x. PublishBatch -> Rep PublishBatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PublishBatch -> Rep PublishBatch x
from :: forall x. PublishBatch -> Rep PublishBatch x
$cto :: forall x. Rep PublishBatch x -> PublishBatch
to :: forall x. Rep PublishBatch x -> PublishBatch
Prelude.Generic)

-- |
-- Create a value of 'PublishBatch' 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:
--
-- 'topicArn', 'publishBatch_topicArn' - The Amazon resource name (ARN) of the topic you want to batch publish
-- to.
--
-- 'publishBatchRequestEntries', 'publishBatch_publishBatchRequestEntries' - A list of @PublishBatch@ request entries to be sent to the SNS topic.
newPublishBatch ::
  -- | 'topicArn'
  Prelude.Text ->
  PublishBatch
newPublishBatch :: Text -> PublishBatch
newPublishBatch Text
pTopicArn_ =
  PublishBatch'
    { topicArn :: Text
topicArn = Text
pTopicArn_,
      publishBatchRequestEntries :: [PublishBatchRequestEntry]
publishBatchRequestEntries = [PublishBatchRequestEntry]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon resource name (ARN) of the topic you want to batch publish
-- to.
publishBatch_topicArn :: Lens.Lens' PublishBatch Prelude.Text
publishBatch_topicArn :: Lens' PublishBatch Text
publishBatch_topicArn = (PublishBatch -> Text)
-> (PublishBatch -> Text -> PublishBatch)
-> Lens' PublishBatch Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublishBatch' {Text
topicArn :: PublishBatch -> Text
topicArn :: Text
topicArn} -> Text
topicArn) (\s :: PublishBatch
s@PublishBatch' {} Text
a -> PublishBatch
s {topicArn = a} :: PublishBatch)

-- | A list of @PublishBatch@ request entries to be sent to the SNS topic.
publishBatch_publishBatchRequestEntries :: Lens.Lens' PublishBatch [PublishBatchRequestEntry]
publishBatch_publishBatchRequestEntries :: Lens' PublishBatch [PublishBatchRequestEntry]
publishBatch_publishBatchRequestEntries = (PublishBatch -> [PublishBatchRequestEntry])
-> (PublishBatch -> [PublishBatchRequestEntry] -> PublishBatch)
-> Lens' PublishBatch [PublishBatchRequestEntry]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublishBatch' {[PublishBatchRequestEntry]
publishBatchRequestEntries :: PublishBatch -> [PublishBatchRequestEntry]
publishBatchRequestEntries :: [PublishBatchRequestEntry]
publishBatchRequestEntries} -> [PublishBatchRequestEntry]
publishBatchRequestEntries) (\s :: PublishBatch
s@PublishBatch' {} [PublishBatchRequestEntry]
a -> PublishBatch
s {publishBatchRequestEntries = a} :: PublishBatch) (([PublishBatchRequestEntry] -> f [PublishBatchRequestEntry])
 -> PublishBatch -> f PublishBatch)
-> (([PublishBatchRequestEntry] -> f [PublishBatchRequestEntry])
    -> [PublishBatchRequestEntry] -> f [PublishBatchRequestEntry])
-> ([PublishBatchRequestEntry] -> f [PublishBatchRequestEntry])
-> PublishBatch
-> f PublishBatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([PublishBatchRequestEntry] -> f [PublishBatchRequestEntry])
-> [PublishBatchRequestEntry] -> f [PublishBatchRequestEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Iso
  [PublishBatchRequestEntry]
  [PublishBatchRequestEntry]
  [PublishBatchRequestEntry]
  [PublishBatchRequestEntry]
Lens.coerced

instance Core.AWSRequest PublishBatch where
  type AWSResponse PublishBatch = PublishBatchResponse
  request :: (Service -> Service) -> PublishBatch -> Request PublishBatch
request Service -> Service
overrides =
    Service -> PublishBatch -> Request PublishBatch
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PublishBatch
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PublishBatch)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse PublishBatch))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PublishBatch
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PublishBatch)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"PublishBatchResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [BatchResultErrorEntry]
-> Maybe [PublishBatchResultEntry] -> Int -> PublishBatchResponse
PublishBatchResponse'
            (Maybe [BatchResultErrorEntry]
 -> Maybe [PublishBatchResultEntry] -> Int -> PublishBatchResponse)
-> Either String (Maybe [BatchResultErrorEntry])
-> Either
     String
     (Maybe [PublishBatchResultEntry] -> Int -> PublishBatchResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Failed" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [BatchResultErrorEntry]))
-> Either String (Maybe [BatchResultErrorEntry])
forall a b.
Either String a -> (a -> Either String b) -> Either String b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [BatchResultErrorEntry])
-> [Node] -> Either String (Maybe [BatchResultErrorEntry])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [BatchResultErrorEntry]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            Either
  String
  (Maybe [PublishBatchResultEntry] -> Int -> PublishBatchResponse)
-> Either String (Maybe [PublishBatchResultEntry])
-> Either String (Int -> PublishBatchResponse)
forall a b.
Either String (a -> b) -> Either String a -> Either String b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Successful" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [PublishBatchResultEntry]))
-> Either String (Maybe [PublishBatchResultEntry])
forall a b.
Either String a -> (a -> Either String b) -> Either String b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [PublishBatchResultEntry])
-> [Node] -> Either String (Maybe [PublishBatchResultEntry])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [PublishBatchResultEntry]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            Either String (Int -> PublishBatchResponse)
-> Either String Int -> Either String PublishBatchResponse
forall a b.
Either String (a -> b) -> Either String a -> Either String b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PublishBatch where
  hashWithSalt :: Int -> PublishBatch -> Int
hashWithSalt Int
_salt PublishBatch' {[PublishBatchRequestEntry]
Text
topicArn :: PublishBatch -> Text
publishBatchRequestEntries :: PublishBatch -> [PublishBatchRequestEntry]
topicArn :: Text
publishBatchRequestEntries :: [PublishBatchRequestEntry]
..} =
    Int
_salt
      Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
topicArn
      Int -> [PublishBatchRequestEntry] -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [PublishBatchRequestEntry]
publishBatchRequestEntries

instance Prelude.NFData PublishBatch where
  rnf :: PublishBatch -> ()
rnf PublishBatch' {[PublishBatchRequestEntry]
Text
topicArn :: PublishBatch -> Text
publishBatchRequestEntries :: PublishBatch -> [PublishBatchRequestEntry]
topicArn :: Text
publishBatchRequestEntries :: [PublishBatchRequestEntry]
..} =
    Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Text
topicArn () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
      [PublishBatchRequestEntry] -> ()
forall a. NFData a => a -> ()
Prelude.rnf [PublishBatchRequestEntry]
publishBatchRequestEntries

instance Data.ToHeaders PublishBatch where
  toHeaders :: PublishBatch -> ResponseHeaders
toHeaders = ResponseHeaders -> PublishBatch -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath PublishBatch where
  toPath :: PublishBatch -> ByteString
toPath = ByteString -> PublishBatch -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery PublishBatch where
  toQuery :: PublishBatch -> QueryString
toQuery PublishBatch' {[PublishBatchRequestEntry]
Text
topicArn :: PublishBatch -> Text
publishBatchRequestEntries :: PublishBatch -> [PublishBatchRequestEntry]
topicArn :: Text
publishBatchRequestEntries :: [PublishBatchRequestEntry]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"PublishBatch" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"TopicArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
topicArn,
        ByteString
"PublishBatchRequestEntries"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ByteString -> [PublishBatchRequestEntry] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [PublishBatchRequestEntry]
publishBatchRequestEntries
      ]

-- | /See:/ 'newPublishBatchResponse' smart constructor.
data PublishBatchResponse = PublishBatchResponse'
  { -- | A list of failed @PublishBatch@ responses.
    PublishBatchResponse -> Maybe [BatchResultErrorEntry]
failed :: Prelude.Maybe [BatchResultErrorEntry],
    -- | A list of successful @PublishBatch@ responses.
    PublishBatchResponse -> Maybe [PublishBatchResultEntry]
successful :: Prelude.Maybe [PublishBatchResultEntry],
    -- | The response's http status code.
    PublishBatchResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PublishBatchResponse -> PublishBatchResponse -> Bool
(PublishBatchResponse -> PublishBatchResponse -> Bool)
-> (PublishBatchResponse -> PublishBatchResponse -> Bool)
-> Eq PublishBatchResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PublishBatchResponse -> PublishBatchResponse -> Bool
== :: PublishBatchResponse -> PublishBatchResponse -> Bool
$c/= :: PublishBatchResponse -> PublishBatchResponse -> Bool
/= :: PublishBatchResponse -> PublishBatchResponse -> Bool
Prelude.Eq, ReadPrec [PublishBatchResponse]
ReadPrec PublishBatchResponse
Int -> ReadS PublishBatchResponse
ReadS [PublishBatchResponse]
(Int -> ReadS PublishBatchResponse)
-> ReadS [PublishBatchResponse]
-> ReadPrec PublishBatchResponse
-> ReadPrec [PublishBatchResponse]
-> Read PublishBatchResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS PublishBatchResponse
readsPrec :: Int -> ReadS PublishBatchResponse
$creadList :: ReadS [PublishBatchResponse]
readList :: ReadS [PublishBatchResponse]
$creadPrec :: ReadPrec PublishBatchResponse
readPrec :: ReadPrec PublishBatchResponse
$creadListPrec :: ReadPrec [PublishBatchResponse]
readListPrec :: ReadPrec [PublishBatchResponse]
Prelude.Read, Int -> PublishBatchResponse -> ShowS
[PublishBatchResponse] -> ShowS
PublishBatchResponse -> String
(Int -> PublishBatchResponse -> ShowS)
-> (PublishBatchResponse -> String)
-> ([PublishBatchResponse] -> ShowS)
-> Show PublishBatchResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PublishBatchResponse -> ShowS
showsPrec :: Int -> PublishBatchResponse -> ShowS
$cshow :: PublishBatchResponse -> String
show :: PublishBatchResponse -> String
$cshowList :: [PublishBatchResponse] -> ShowS
showList :: [PublishBatchResponse] -> ShowS
Prelude.Show, (forall x. PublishBatchResponse -> Rep PublishBatchResponse x)
-> (forall x. Rep PublishBatchResponse x -> PublishBatchResponse)
-> Generic PublishBatchResponse
forall x. Rep PublishBatchResponse x -> PublishBatchResponse
forall x. PublishBatchResponse -> Rep PublishBatchResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PublishBatchResponse -> Rep PublishBatchResponse x
from :: forall x. PublishBatchResponse -> Rep PublishBatchResponse x
$cto :: forall x. Rep PublishBatchResponse x -> PublishBatchResponse
to :: forall x. Rep PublishBatchResponse x -> PublishBatchResponse
Prelude.Generic)

-- |
-- Create a value of 'PublishBatchResponse' 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:
--
-- 'failed', 'publishBatchResponse_failed' - A list of failed @PublishBatch@ responses.
--
-- 'successful', 'publishBatchResponse_successful' - A list of successful @PublishBatch@ responses.
--
-- 'httpStatus', 'publishBatchResponse_httpStatus' - The response's http status code.
newPublishBatchResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PublishBatchResponse
newPublishBatchResponse :: Int -> PublishBatchResponse
newPublishBatchResponse Int
pHttpStatus_ =
  PublishBatchResponse'
    { failed :: Maybe [BatchResultErrorEntry]
failed = Maybe [BatchResultErrorEntry]
forall a. Maybe a
Prelude.Nothing,
      successful :: Maybe [PublishBatchResultEntry]
successful = Maybe [PublishBatchResultEntry]
forall a. Maybe a
Prelude.Nothing,
      httpStatus :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of failed @PublishBatch@ responses.
publishBatchResponse_failed :: Lens.Lens' PublishBatchResponse (Prelude.Maybe [BatchResultErrorEntry])
publishBatchResponse_failed :: Lens' PublishBatchResponse (Maybe [BatchResultErrorEntry])
publishBatchResponse_failed = (PublishBatchResponse -> Maybe [BatchResultErrorEntry])
-> (PublishBatchResponse
    -> Maybe [BatchResultErrorEntry] -> PublishBatchResponse)
-> Lens' PublishBatchResponse (Maybe [BatchResultErrorEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublishBatchResponse' {Maybe [BatchResultErrorEntry]
failed :: PublishBatchResponse -> Maybe [BatchResultErrorEntry]
failed :: Maybe [BatchResultErrorEntry]
failed} -> Maybe [BatchResultErrorEntry]
failed) (\s :: PublishBatchResponse
s@PublishBatchResponse' {} Maybe [BatchResultErrorEntry]
a -> PublishBatchResponse
s {failed = a} :: PublishBatchResponse) ((Maybe [BatchResultErrorEntry]
  -> f (Maybe [BatchResultErrorEntry]))
 -> PublishBatchResponse -> f PublishBatchResponse)
-> ((Maybe [BatchResultErrorEntry]
     -> f (Maybe [BatchResultErrorEntry]))
    -> Maybe [BatchResultErrorEntry]
    -> f (Maybe [BatchResultErrorEntry]))
-> (Maybe [BatchResultErrorEntry]
    -> f (Maybe [BatchResultErrorEntry]))
-> PublishBatchResponse
-> f PublishBatchResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [BatchResultErrorEntry]
  [BatchResultErrorEntry]
  [BatchResultErrorEntry]
  [BatchResultErrorEntry]
-> Iso
     (Maybe [BatchResultErrorEntry])
     (Maybe [BatchResultErrorEntry])
     (Maybe [BatchResultErrorEntry])
     (Maybe [BatchResultErrorEntry])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [BatchResultErrorEntry]
  [BatchResultErrorEntry]
  [BatchResultErrorEntry]
  [BatchResultErrorEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Iso
  [BatchResultErrorEntry]
  [BatchResultErrorEntry]
  [BatchResultErrorEntry]
  [BatchResultErrorEntry]
Lens.coerced

-- | A list of successful @PublishBatch@ responses.
publishBatchResponse_successful :: Lens.Lens' PublishBatchResponse (Prelude.Maybe [PublishBatchResultEntry])
publishBatchResponse_successful :: Lens' PublishBatchResponse (Maybe [PublishBatchResultEntry])
publishBatchResponse_successful = (PublishBatchResponse -> Maybe [PublishBatchResultEntry])
-> (PublishBatchResponse
    -> Maybe [PublishBatchResultEntry] -> PublishBatchResponse)
-> Lens' PublishBatchResponse (Maybe [PublishBatchResultEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublishBatchResponse' {Maybe [PublishBatchResultEntry]
successful :: PublishBatchResponse -> Maybe [PublishBatchResultEntry]
successful :: Maybe [PublishBatchResultEntry]
successful} -> Maybe [PublishBatchResultEntry]
successful) (\s :: PublishBatchResponse
s@PublishBatchResponse' {} Maybe [PublishBatchResultEntry]
a -> PublishBatchResponse
s {successful = a} :: PublishBatchResponse) ((Maybe [PublishBatchResultEntry]
  -> f (Maybe [PublishBatchResultEntry]))
 -> PublishBatchResponse -> f PublishBatchResponse)
-> ((Maybe [PublishBatchResultEntry]
     -> f (Maybe [PublishBatchResultEntry]))
    -> Maybe [PublishBatchResultEntry]
    -> f (Maybe [PublishBatchResultEntry]))
-> (Maybe [PublishBatchResultEntry]
    -> f (Maybe [PublishBatchResultEntry]))
-> PublishBatchResponse
-> f PublishBatchResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PublishBatchResultEntry]
  [PublishBatchResultEntry]
  [PublishBatchResultEntry]
  [PublishBatchResultEntry]
-> Iso
     (Maybe [PublishBatchResultEntry])
     (Maybe [PublishBatchResultEntry])
     (Maybe [PublishBatchResultEntry])
     (Maybe [PublishBatchResultEntry])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [PublishBatchResultEntry]
  [PublishBatchResultEntry]
  [PublishBatchResultEntry]
  [PublishBatchResultEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Iso
  [PublishBatchResultEntry]
  [PublishBatchResultEntry]
  [PublishBatchResultEntry]
  [PublishBatchResultEntry]
Lens.coerced

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

instance Prelude.NFData PublishBatchResponse where
  rnf :: PublishBatchResponse -> ()
rnf PublishBatchResponse' {Int
Maybe [BatchResultErrorEntry]
Maybe [PublishBatchResultEntry]
failed :: PublishBatchResponse -> Maybe [BatchResultErrorEntry]
successful :: PublishBatchResponse -> Maybe [PublishBatchResultEntry]
httpStatus :: PublishBatchResponse -> Int
failed :: Maybe [BatchResultErrorEntry]
successful :: Maybe [PublishBatchResultEntry]
httpStatus :: Int
..} =
    Maybe [BatchResultErrorEntry] -> ()
forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchResultErrorEntry]
failed () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
      Maybe [PublishBatchResultEntry] -> ()
forall a. NFData a => a -> ()
Prelude.rnf Maybe [PublishBatchResultEntry]
successful () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
        Int -> ()
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus