{-# 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.DynamoDB.BatchWriteItem
-- 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)
--
-- The @BatchWriteItem@ operation puts or deletes multiple items in one or
-- more tables. A single call to @BatchWriteItem@ can write up to 16 MB of
-- data, which can comprise as many as 25 put or delete requests.
-- Individual items to be written can be as large as 400 KB.
--
-- @BatchWriteItem@ cannot update items. To update items, use the
-- @UpdateItem@ action.
--
-- The individual @PutItem@ and @DeleteItem@ operations specified in
-- @BatchWriteItem@ are atomic; however @BatchWriteItem@ as a whole is not.
-- If any requested operations fail because the table\'s provisioned
-- throughput is exceeded or an internal processing failure occurs, the
-- failed operations are returned in the @UnprocessedItems@ response
-- parameter. You can investigate and optionally resend the requests.
-- Typically, you would call @BatchWriteItem@ in a loop. Each iteration
-- would check for unprocessed items and submit a new @BatchWriteItem@
-- request with those unprocessed items until all items have been
-- processed.
--
-- If /none/ of the items can be processed due to insufficient provisioned
-- throughput on all of the tables in the request, then @BatchWriteItem@
-- returns a @ProvisionedThroughputExceededException@.
--
-- If DynamoDB returns any unprocessed items, you should retry the batch
-- operation on those items. However, /we strongly recommend that you use
-- an exponential backoff algorithm/. If you retry the batch operation
-- immediately, the underlying read or write requests can still fail due to
-- throttling on the individual tables. If you delay the batch operation
-- using exponential backoff, the individual requests in the batch are much
-- more likely to succeed.
--
-- For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#Programming.Errors.BatchOperations Batch Operations and Error Handling>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- With @BatchWriteItem@, you can efficiently write or delete large amounts
-- of data, such as from Amazon EMR, or copy data from another database
-- into DynamoDB. In order to improve performance with these large-scale
-- operations, @BatchWriteItem@ does not behave in the same way as
-- individual @PutItem@ and @DeleteItem@ calls would. For example, you
-- cannot specify conditions on individual put and delete requests, and
-- @BatchWriteItem@ does not return deleted items in the response.
--
-- If you use a programming language that supports concurrency, you can use
-- threads to write items in parallel. Your application must include the
-- necessary logic to manage the threads. With languages that don\'t
-- support threading, you must update or delete the specified items one at
-- a time. In both situations, @BatchWriteItem@ performs the specified put
-- and delete operations in parallel, giving you the power of the thread
-- pool approach without having to introduce complexity into your
-- application.
--
-- Parallel processing reduces latency, but each specified put and delete
-- request consumes the same number of write capacity units whether it is
-- processed in parallel or not. Delete operations on nonexistent items
-- consume one write capacity unit.
--
-- If one or more of the following is true, DynamoDB rejects the entire
-- batch write operation:
--
-- -   One or more tables specified in the @BatchWriteItem@ request does
--     not exist.
--
-- -   Primary key attributes specified on an item in the request do not
--     match those in the corresponding table\'s primary key schema.
--
-- -   You try to perform multiple operations on the same item in the same
--     @BatchWriteItem@ request. For example, you cannot put and delete the
--     same item in the same @BatchWriteItem@ request.
--
-- -   Your request contains at least two items with identical hash and
--     range keys (which essentially is two put operations).
--
-- -   There are more than 25 requests in the batch.
--
-- -   Any individual item in a batch exceeds 400 KB.
--
-- -   The total request size exceeds 16 MB.
module Amazonka.DynamoDB.BatchWriteItem
  ( -- * Creating a Request
    BatchWriteItem (..),
    newBatchWriteItem,

    -- * Request Lenses
    batchWriteItem_returnConsumedCapacity,
    batchWriteItem_returnItemCollectionMetrics,
    batchWriteItem_requestItems,

    -- * Destructuring the Response
    BatchWriteItemResponse (..),
    newBatchWriteItemResponse,

    -- * Response Lenses
    batchWriteItemResponse_itemCollectionMetrics,
    batchWriteItemResponse_consumedCapacity,
    batchWriteItemResponse_unprocessedItems,
    batchWriteItemResponse_httpStatus,
  )
where

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

-- | Represents the input of a @BatchWriteItem@ operation.
--
-- /See:/ 'newBatchWriteItem' smart constructor.
data BatchWriteItem = BatchWriteItem'
  { BatchWriteItem -> Maybe ReturnConsumedCapacity
returnConsumedCapacity :: Prelude.Maybe ReturnConsumedCapacity,
    -- | Determines whether item collection metrics are returned. If set to
    -- @SIZE@, the response includes statistics about item collections, if any,
    -- that were modified during the operation are returned in the response. If
    -- set to @NONE@ (the default), no statistics are returned.
    BatchWriteItem -> Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics :: Prelude.Maybe ReturnItemCollectionMetrics,
    -- | A map of one or more table names and, for each table, a list of
    -- operations to be performed (@DeleteRequest@ or @PutRequest@). Each
    -- element in the map consists of the following:
    --
    -- -   @DeleteRequest@ - Perform a @DeleteItem@ operation on the specified
    --     item. The item to be deleted is identified by a @Key@ subelement:
    --
    --     -   @Key@ - A map of primary key attribute values that uniquely
    --         identify the item. Each entry in this map consists of an
    --         attribute name and an attribute value. For each primary key, you
    --         must provide /all/ of the key attributes. For example, with a
    --         simple primary key, you only need to provide a value for the
    --         partition key. For a composite primary key, you must provide
    --         values for /both/ the partition key and the sort key.
    --
    -- -   @PutRequest@ - Perform a @PutItem@ operation on the specified item.
    --     The item to be put is identified by an @Item@ subelement:
    --
    --     -   @Item@ - A map of attributes and their values. Each entry in
    --         this map consists of an attribute name and an attribute value.
    --         Attribute values must not be null; string and binary type
    --         attributes must have lengths greater than zero; and set type
    --         attributes must not be empty. Requests that contain empty values
    --         are rejected with a @ValidationException@ exception.
    --
    --         If you specify any attributes that are part of an index key,
    --         then the data types for those attributes must match those of the
    --         schema in the table\'s attribute definition.
    BatchWriteItem -> HashMap Text (NonEmpty WriteRequest)
requestItems :: Prelude.HashMap Prelude.Text (Prelude.NonEmpty WriteRequest)
  }
  deriving (BatchWriteItem -> BatchWriteItem -> Bool
(BatchWriteItem -> BatchWriteItem -> Bool)
-> (BatchWriteItem -> BatchWriteItem -> Bool) -> Eq BatchWriteItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchWriteItem -> BatchWriteItem -> Bool
$c/= :: BatchWriteItem -> BatchWriteItem -> Bool
== :: BatchWriteItem -> BatchWriteItem -> Bool
$c== :: BatchWriteItem -> BatchWriteItem -> Bool
Prelude.Eq, ReadPrec [BatchWriteItem]
ReadPrec BatchWriteItem
Int -> ReadS BatchWriteItem
ReadS [BatchWriteItem]
(Int -> ReadS BatchWriteItem)
-> ReadS [BatchWriteItem]
-> ReadPrec BatchWriteItem
-> ReadPrec [BatchWriteItem]
-> Read BatchWriteItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchWriteItem]
$creadListPrec :: ReadPrec [BatchWriteItem]
readPrec :: ReadPrec BatchWriteItem
$creadPrec :: ReadPrec BatchWriteItem
readList :: ReadS [BatchWriteItem]
$creadList :: ReadS [BatchWriteItem]
readsPrec :: Int -> ReadS BatchWriteItem
$creadsPrec :: Int -> ReadS BatchWriteItem
Prelude.Read, Int -> BatchWriteItem -> ShowS
[BatchWriteItem] -> ShowS
BatchWriteItem -> String
(Int -> BatchWriteItem -> ShowS)
-> (BatchWriteItem -> String)
-> ([BatchWriteItem] -> ShowS)
-> Show BatchWriteItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchWriteItem] -> ShowS
$cshowList :: [BatchWriteItem] -> ShowS
show :: BatchWriteItem -> String
$cshow :: BatchWriteItem -> String
showsPrec :: Int -> BatchWriteItem -> ShowS
$cshowsPrec :: Int -> BatchWriteItem -> ShowS
Prelude.Show, (forall x. BatchWriteItem -> Rep BatchWriteItem x)
-> (forall x. Rep BatchWriteItem x -> BatchWriteItem)
-> Generic BatchWriteItem
forall x. Rep BatchWriteItem x -> BatchWriteItem
forall x. BatchWriteItem -> Rep BatchWriteItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchWriteItem x -> BatchWriteItem
$cfrom :: forall x. BatchWriteItem -> Rep BatchWriteItem x
Prelude.Generic)

-- |
-- Create a value of 'BatchWriteItem' 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:
--
-- 'returnConsumedCapacity', 'batchWriteItem_returnConsumedCapacity' - Undocumented member.
--
-- 'returnItemCollectionMetrics', 'batchWriteItem_returnItemCollectionMetrics' - Determines whether item collection metrics are returned. If set to
-- @SIZE@, the response includes statistics about item collections, if any,
-- that were modified during the operation are returned in the response. If
-- set to @NONE@ (the default), no statistics are returned.
--
-- 'requestItems', 'batchWriteItem_requestItems' - A map of one or more table names and, for each table, a list of
-- operations to be performed (@DeleteRequest@ or @PutRequest@). Each
-- element in the map consists of the following:
--
-- -   @DeleteRequest@ - Perform a @DeleteItem@ operation on the specified
--     item. The item to be deleted is identified by a @Key@ subelement:
--
--     -   @Key@ - A map of primary key attribute values that uniquely
--         identify the item. Each entry in this map consists of an
--         attribute name and an attribute value. For each primary key, you
--         must provide /all/ of the key attributes. For example, with a
--         simple primary key, you only need to provide a value for the
--         partition key. For a composite primary key, you must provide
--         values for /both/ the partition key and the sort key.
--
-- -   @PutRequest@ - Perform a @PutItem@ operation on the specified item.
--     The item to be put is identified by an @Item@ subelement:
--
--     -   @Item@ - A map of attributes and their values. Each entry in
--         this map consists of an attribute name and an attribute value.
--         Attribute values must not be null; string and binary type
--         attributes must have lengths greater than zero; and set type
--         attributes must not be empty. Requests that contain empty values
--         are rejected with a @ValidationException@ exception.
--
--         If you specify any attributes that are part of an index key,
--         then the data types for those attributes must match those of the
--         schema in the table\'s attribute definition.
newBatchWriteItem ::
  BatchWriteItem
newBatchWriteItem :: BatchWriteItem
newBatchWriteItem =
  BatchWriteItem' :: Maybe ReturnConsumedCapacity
-> Maybe ReturnItemCollectionMetrics
-> HashMap Text (NonEmpty WriteRequest)
-> BatchWriteItem
BatchWriteItem'
    { $sel:returnConsumedCapacity:BatchWriteItem' :: Maybe ReturnConsumedCapacity
returnConsumedCapacity =
        Maybe ReturnConsumedCapacity
forall a. Maybe a
Prelude.Nothing,
      $sel:returnItemCollectionMetrics:BatchWriteItem' :: Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics = Maybe ReturnItemCollectionMetrics
forall a. Maybe a
Prelude.Nothing,
      $sel:requestItems:BatchWriteItem' :: HashMap Text (NonEmpty WriteRequest)
requestItems = HashMap Text (NonEmpty WriteRequest)
forall a. Monoid a => a
Prelude.mempty
    }

-- | Undocumented member.
batchWriteItem_returnConsumedCapacity :: Lens.Lens' BatchWriteItem (Prelude.Maybe ReturnConsumedCapacity)
batchWriteItem_returnConsumedCapacity :: (Maybe ReturnConsumedCapacity -> f (Maybe ReturnConsumedCapacity))
-> BatchWriteItem -> f BatchWriteItem
batchWriteItem_returnConsumedCapacity = (BatchWriteItem -> Maybe ReturnConsumedCapacity)
-> (BatchWriteItem
    -> Maybe ReturnConsumedCapacity -> BatchWriteItem)
-> Lens
     BatchWriteItem
     BatchWriteItem
     (Maybe ReturnConsumedCapacity)
     (Maybe ReturnConsumedCapacity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWriteItem' {Maybe ReturnConsumedCapacity
returnConsumedCapacity :: Maybe ReturnConsumedCapacity
$sel:returnConsumedCapacity:BatchWriteItem' :: BatchWriteItem -> Maybe ReturnConsumedCapacity
returnConsumedCapacity} -> Maybe ReturnConsumedCapacity
returnConsumedCapacity) (\s :: BatchWriteItem
s@BatchWriteItem' {} Maybe ReturnConsumedCapacity
a -> BatchWriteItem
s {$sel:returnConsumedCapacity:BatchWriteItem' :: Maybe ReturnConsumedCapacity
returnConsumedCapacity = Maybe ReturnConsumedCapacity
a} :: BatchWriteItem)

-- | Determines whether item collection metrics are returned. If set to
-- @SIZE@, the response includes statistics about item collections, if any,
-- that were modified during the operation are returned in the response. If
-- set to @NONE@ (the default), no statistics are returned.
batchWriteItem_returnItemCollectionMetrics :: Lens.Lens' BatchWriteItem (Prelude.Maybe ReturnItemCollectionMetrics)
batchWriteItem_returnItemCollectionMetrics :: (Maybe ReturnItemCollectionMetrics
 -> f (Maybe ReturnItemCollectionMetrics))
-> BatchWriteItem -> f BatchWriteItem
batchWriteItem_returnItemCollectionMetrics = (BatchWriteItem -> Maybe ReturnItemCollectionMetrics)
-> (BatchWriteItem
    -> Maybe ReturnItemCollectionMetrics -> BatchWriteItem)
-> Lens
     BatchWriteItem
     BatchWriteItem
     (Maybe ReturnItemCollectionMetrics)
     (Maybe ReturnItemCollectionMetrics)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWriteItem' {Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics :: Maybe ReturnItemCollectionMetrics
$sel:returnItemCollectionMetrics:BatchWriteItem' :: BatchWriteItem -> Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics} -> Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics) (\s :: BatchWriteItem
s@BatchWriteItem' {} Maybe ReturnItemCollectionMetrics
a -> BatchWriteItem
s {$sel:returnItemCollectionMetrics:BatchWriteItem' :: Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics = Maybe ReturnItemCollectionMetrics
a} :: BatchWriteItem)

-- | A map of one or more table names and, for each table, a list of
-- operations to be performed (@DeleteRequest@ or @PutRequest@). Each
-- element in the map consists of the following:
--
-- -   @DeleteRequest@ - Perform a @DeleteItem@ operation on the specified
--     item. The item to be deleted is identified by a @Key@ subelement:
--
--     -   @Key@ - A map of primary key attribute values that uniquely
--         identify the item. Each entry in this map consists of an
--         attribute name and an attribute value. For each primary key, you
--         must provide /all/ of the key attributes. For example, with a
--         simple primary key, you only need to provide a value for the
--         partition key. For a composite primary key, you must provide
--         values for /both/ the partition key and the sort key.
--
-- -   @PutRequest@ - Perform a @PutItem@ operation on the specified item.
--     The item to be put is identified by an @Item@ subelement:
--
--     -   @Item@ - A map of attributes and their values. Each entry in
--         this map consists of an attribute name and an attribute value.
--         Attribute values must not be null; string and binary type
--         attributes must have lengths greater than zero; and set type
--         attributes must not be empty. Requests that contain empty values
--         are rejected with a @ValidationException@ exception.
--
--         If you specify any attributes that are part of an index key,
--         then the data types for those attributes must match those of the
--         schema in the table\'s attribute definition.
batchWriteItem_requestItems :: Lens.Lens' BatchWriteItem (Prelude.HashMap Prelude.Text (Prelude.NonEmpty WriteRequest))
batchWriteItem_requestItems :: (HashMap Text (NonEmpty WriteRequest)
 -> f (HashMap Text (NonEmpty WriteRequest)))
-> BatchWriteItem -> f BatchWriteItem
batchWriteItem_requestItems = (BatchWriteItem -> HashMap Text (NonEmpty WriteRequest))
-> (BatchWriteItem
    -> HashMap Text (NonEmpty WriteRequest) -> BatchWriteItem)
-> Lens
     BatchWriteItem
     BatchWriteItem
     (HashMap Text (NonEmpty WriteRequest))
     (HashMap Text (NonEmpty WriteRequest))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWriteItem' {HashMap Text (NonEmpty WriteRequest)
requestItems :: HashMap Text (NonEmpty WriteRequest)
$sel:requestItems:BatchWriteItem' :: BatchWriteItem -> HashMap Text (NonEmpty WriteRequest)
requestItems} -> HashMap Text (NonEmpty WriteRequest)
requestItems) (\s :: BatchWriteItem
s@BatchWriteItem' {} HashMap Text (NonEmpty WriteRequest)
a -> BatchWriteItem
s {$sel:requestItems:BatchWriteItem' :: HashMap Text (NonEmpty WriteRequest)
requestItems = HashMap Text (NonEmpty WriteRequest)
a} :: BatchWriteItem) ((HashMap Text (NonEmpty WriteRequest)
  -> f (HashMap Text (NonEmpty WriteRequest)))
 -> BatchWriteItem -> f BatchWriteItem)
-> ((HashMap Text (NonEmpty WriteRequest)
     -> f (HashMap Text (NonEmpty WriteRequest)))
    -> HashMap Text (NonEmpty WriteRequest)
    -> f (HashMap Text (NonEmpty WriteRequest)))
-> (HashMap Text (NonEmpty WriteRequest)
    -> f (HashMap Text (NonEmpty WriteRequest)))
-> BatchWriteItem
-> f BatchWriteItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text (NonEmpty WriteRequest)
 -> f (HashMap Text (NonEmpty WriteRequest)))
-> HashMap Text (NonEmpty WriteRequest)
-> f (HashMap Text (NonEmpty WriteRequest))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchWriteItem where
  type
    AWSResponse BatchWriteItem =
      BatchWriteItemResponse
  request :: BatchWriteItem -> Request BatchWriteItem
request = Service -> BatchWriteItem -> Request BatchWriteItem
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchWriteItem
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchWriteItem)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchWriteItem))
-> Logger
-> Service
-> Proxy BatchWriteItem
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchWriteItem)))
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 ->
          Maybe (HashMap Text [ItemCollectionMetrics])
-> Maybe [ConsumedCapacity]
-> Maybe (HashMap Text (NonEmpty WriteRequest))
-> Int
-> BatchWriteItemResponse
BatchWriteItemResponse'
            (Maybe (HashMap Text [ItemCollectionMetrics])
 -> Maybe [ConsumedCapacity]
 -> Maybe (HashMap Text (NonEmpty WriteRequest))
 -> Int
 -> BatchWriteItemResponse)
-> Either String (Maybe (HashMap Text [ItemCollectionMetrics]))
-> Either
     String
     (Maybe [ConsumedCapacity]
      -> Maybe (HashMap Text (NonEmpty WriteRequest))
      -> Int
      -> BatchWriteItemResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text
-> Either
     String (Maybe (Maybe (HashMap Text [ItemCollectionMetrics])))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ItemCollectionMetrics"
                            Either
  String (Maybe (Maybe (HashMap Text [ItemCollectionMetrics])))
-> Maybe (HashMap Text [ItemCollectionMetrics])
-> Either String (Maybe (HashMap Text [ItemCollectionMetrics]))
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe (HashMap Text [ItemCollectionMetrics])
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String
  (Maybe [ConsumedCapacity]
   -> Maybe (HashMap Text (NonEmpty WriteRequest))
   -> Int
   -> BatchWriteItemResponse)
-> Either String (Maybe [ConsumedCapacity])
-> Either
     String
     (Maybe (HashMap Text (NonEmpty WriteRequest))
      -> Int -> BatchWriteItemResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [ConsumedCapacity]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ConsumedCapacity"
                            Either String (Maybe (Maybe [ConsumedCapacity]))
-> Maybe [ConsumedCapacity]
-> Either String (Maybe [ConsumedCapacity])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ConsumedCapacity]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String
  (Maybe (HashMap Text (NonEmpty WriteRequest))
   -> Int -> BatchWriteItemResponse)
-> Either String (Maybe (HashMap Text (NonEmpty WriteRequest)))
-> Either String (Int -> BatchWriteItemResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text
-> Either
     String (Maybe (Maybe (HashMap Text (NonEmpty WriteRequest))))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"UnprocessedItems"
                            Either
  String (Maybe (Maybe (HashMap Text (NonEmpty WriteRequest))))
-> Maybe (HashMap Text (NonEmpty WriteRequest))
-> Either String (Maybe (HashMap Text (NonEmpty WriteRequest)))
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe (HashMap Text (NonEmpty WriteRequest))
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> BatchWriteItemResponse)
-> Either String Int -> Either String BatchWriteItemResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable BatchWriteItem

instance Prelude.NFData BatchWriteItem

instance Core.ToHeaders BatchWriteItem where
  toHeaders :: BatchWriteItem -> ResponseHeaders
toHeaders =
    ResponseHeaders -> BatchWriteItem -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DynamoDB_20120810.BatchWriteItem" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON BatchWriteItem where
  toJSON :: BatchWriteItem -> Value
toJSON BatchWriteItem' {Maybe ReturnConsumedCapacity
Maybe ReturnItemCollectionMetrics
HashMap Text (NonEmpty WriteRequest)
requestItems :: HashMap Text (NonEmpty WriteRequest)
returnItemCollectionMetrics :: Maybe ReturnItemCollectionMetrics
returnConsumedCapacity :: Maybe ReturnConsumedCapacity
$sel:requestItems:BatchWriteItem' :: BatchWriteItem -> HashMap Text (NonEmpty WriteRequest)
$sel:returnItemCollectionMetrics:BatchWriteItem' :: BatchWriteItem -> Maybe ReturnItemCollectionMetrics
$sel:returnConsumedCapacity:BatchWriteItem' :: BatchWriteItem -> Maybe ReturnConsumedCapacity
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ReturnConsumedCapacity" Text -> ReturnConsumedCapacity -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ReturnConsumedCapacity -> Pair)
-> Maybe ReturnConsumedCapacity -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReturnConsumedCapacity
returnConsumedCapacity,
            (Text
"ReturnItemCollectionMetrics" Text -> ReturnItemCollectionMetrics -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ReturnItemCollectionMetrics -> Pair)
-> Maybe ReturnItemCollectionMetrics -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RequestItems" Text -> HashMap Text (NonEmpty WriteRequest) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text (NonEmpty WriteRequest)
requestItems)
          ]
      )

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

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

-- | Represents the output of a @BatchWriteItem@ operation.
--
-- /See:/ 'newBatchWriteItemResponse' smart constructor.
data BatchWriteItemResponse = BatchWriteItemResponse'
  { -- | A list of tables that were processed by @BatchWriteItem@ and, for each
    -- table, information about any item collections that were affected by
    -- individual @DeleteItem@ or @PutItem@ operations.
    --
    -- Each entry consists of the following subelements:
    --
    -- -   @ItemCollectionKey@ - The partition key value of the item
    --     collection. This is the same as the partition key value of the item.
    --
    -- -   @SizeEstimateRangeGB@ - An estimate of item collection size,
    --     expressed in GB. This is a two-element array containing a lower
    --     bound and an upper bound for the estimate. The estimate includes the
    --     size of all the items in the table, plus the size of all attributes
    --     projected into all of the local secondary indexes on the table. Use
    --     this estimate to measure whether a local secondary index is
    --     approaching its size limit.
    --
    --     The estimate is subject to change over time; therefore, do not rely
    --     on the precision or accuracy of the estimate.
    BatchWriteItemResponse
-> Maybe (HashMap Text [ItemCollectionMetrics])
itemCollectionMetrics :: Prelude.Maybe (Prelude.HashMap Prelude.Text [ItemCollectionMetrics]),
    -- | The capacity units consumed by the entire @BatchWriteItem@ operation.
    --
    -- Each element consists of:
    --
    -- -   @TableName@ - The table that consumed the provisioned throughput.
    --
    -- -   @CapacityUnits@ - The total number of capacity units consumed.
    BatchWriteItemResponse -> Maybe [ConsumedCapacity]
consumedCapacity :: Prelude.Maybe [ConsumedCapacity],
    -- | A map of tables and requests against those tables that were not
    -- processed. The @UnprocessedItems@ value is in the same form as
    -- @RequestItems@, so you can provide this value directly to a subsequent
    -- @BatchGetItem@ operation. For more information, see @RequestItems@ in
    -- the Request Parameters section.
    --
    -- Each @UnprocessedItems@ entry consists of a table name and, for that
    -- table, a list of operations to perform (@DeleteRequest@ or
    -- @PutRequest@).
    --
    -- -   @DeleteRequest@ - Perform a @DeleteItem@ operation on the specified
    --     item. The item to be deleted is identified by a @Key@ subelement:
    --
    --     -   @Key@ - A map of primary key attribute values that uniquely
    --         identify the item. Each entry in this map consists of an
    --         attribute name and an attribute value.
    --
    -- -   @PutRequest@ - Perform a @PutItem@ operation on the specified item.
    --     The item to be put is identified by an @Item@ subelement:
    --
    --     -   @Item@ - A map of attributes and their values. Each entry in
    --         this map consists of an attribute name and an attribute value.
    --         Attribute values must not be null; string and binary type
    --         attributes must have lengths greater than zero; and set type
    --         attributes must not be empty. Requests that contain empty values
    --         will be rejected with a @ValidationException@ exception.
    --
    --         If you specify any attributes that are part of an index key,
    --         then the data types for those attributes must match those of the
    --         schema in the table\'s attribute definition.
    --
    -- If there are no unprocessed items remaining, the response contains an
    -- empty @UnprocessedItems@ map.
    BatchWriteItemResponse
-> Maybe (HashMap Text (NonEmpty WriteRequest))
unprocessedItems :: Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.NonEmpty WriteRequest)),
    -- | The response's http status code.
    BatchWriteItemResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
(BatchWriteItemResponse -> BatchWriteItemResponse -> Bool)
-> (BatchWriteItemResponse -> BatchWriteItemResponse -> Bool)
-> Eq BatchWriteItemResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
$c/= :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
== :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
$c== :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
Prelude.Eq, ReadPrec [BatchWriteItemResponse]
ReadPrec BatchWriteItemResponse
Int -> ReadS BatchWriteItemResponse
ReadS [BatchWriteItemResponse]
(Int -> ReadS BatchWriteItemResponse)
-> ReadS [BatchWriteItemResponse]
-> ReadPrec BatchWriteItemResponse
-> ReadPrec [BatchWriteItemResponse]
-> Read BatchWriteItemResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchWriteItemResponse]
$creadListPrec :: ReadPrec [BatchWriteItemResponse]
readPrec :: ReadPrec BatchWriteItemResponse
$creadPrec :: ReadPrec BatchWriteItemResponse
readList :: ReadS [BatchWriteItemResponse]
$creadList :: ReadS [BatchWriteItemResponse]
readsPrec :: Int -> ReadS BatchWriteItemResponse
$creadsPrec :: Int -> ReadS BatchWriteItemResponse
Prelude.Read, Int -> BatchWriteItemResponse -> ShowS
[BatchWriteItemResponse] -> ShowS
BatchWriteItemResponse -> String
(Int -> BatchWriteItemResponse -> ShowS)
-> (BatchWriteItemResponse -> String)
-> ([BatchWriteItemResponse] -> ShowS)
-> Show BatchWriteItemResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchWriteItemResponse] -> ShowS
$cshowList :: [BatchWriteItemResponse] -> ShowS
show :: BatchWriteItemResponse -> String
$cshow :: BatchWriteItemResponse -> String
showsPrec :: Int -> BatchWriteItemResponse -> ShowS
$cshowsPrec :: Int -> BatchWriteItemResponse -> ShowS
Prelude.Show, (forall x. BatchWriteItemResponse -> Rep BatchWriteItemResponse x)
-> (forall x.
    Rep BatchWriteItemResponse x -> BatchWriteItemResponse)
-> Generic BatchWriteItemResponse
forall x. Rep BatchWriteItemResponse x -> BatchWriteItemResponse
forall x. BatchWriteItemResponse -> Rep BatchWriteItemResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchWriteItemResponse x -> BatchWriteItemResponse
$cfrom :: forall x. BatchWriteItemResponse -> Rep BatchWriteItemResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchWriteItemResponse' 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:
--
-- 'itemCollectionMetrics', 'batchWriteItemResponse_itemCollectionMetrics' - A list of tables that were processed by @BatchWriteItem@ and, for each
-- table, information about any item collections that were affected by
-- individual @DeleteItem@ or @PutItem@ operations.
--
-- Each entry consists of the following subelements:
--
-- -   @ItemCollectionKey@ - The partition key value of the item
--     collection. This is the same as the partition key value of the item.
--
-- -   @SizeEstimateRangeGB@ - An estimate of item collection size,
--     expressed in GB. This is a two-element array containing a lower
--     bound and an upper bound for the estimate. The estimate includes the
--     size of all the items in the table, plus the size of all attributes
--     projected into all of the local secondary indexes on the table. Use
--     this estimate to measure whether a local secondary index is
--     approaching its size limit.
--
--     The estimate is subject to change over time; therefore, do not rely
--     on the precision or accuracy of the estimate.
--
-- 'consumedCapacity', 'batchWriteItemResponse_consumedCapacity' - The capacity units consumed by the entire @BatchWriteItem@ operation.
--
-- Each element consists of:
--
-- -   @TableName@ - The table that consumed the provisioned throughput.
--
-- -   @CapacityUnits@ - The total number of capacity units consumed.
--
-- 'unprocessedItems', 'batchWriteItemResponse_unprocessedItems' - A map of tables and requests against those tables that were not
-- processed. The @UnprocessedItems@ value is in the same form as
-- @RequestItems@, so you can provide this value directly to a subsequent
-- @BatchGetItem@ operation. For more information, see @RequestItems@ in
-- the Request Parameters section.
--
-- Each @UnprocessedItems@ entry consists of a table name and, for that
-- table, a list of operations to perform (@DeleteRequest@ or
-- @PutRequest@).
--
-- -   @DeleteRequest@ - Perform a @DeleteItem@ operation on the specified
--     item. The item to be deleted is identified by a @Key@ subelement:
--
--     -   @Key@ - A map of primary key attribute values that uniquely
--         identify the item. Each entry in this map consists of an
--         attribute name and an attribute value.
--
-- -   @PutRequest@ - Perform a @PutItem@ operation on the specified item.
--     The item to be put is identified by an @Item@ subelement:
--
--     -   @Item@ - A map of attributes and their values. Each entry in
--         this map consists of an attribute name and an attribute value.
--         Attribute values must not be null; string and binary type
--         attributes must have lengths greater than zero; and set type
--         attributes must not be empty. Requests that contain empty values
--         will be rejected with a @ValidationException@ exception.
--
--         If you specify any attributes that are part of an index key,
--         then the data types for those attributes must match those of the
--         schema in the table\'s attribute definition.
--
-- If there are no unprocessed items remaining, the response contains an
-- empty @UnprocessedItems@ map.
--
-- 'httpStatus', 'batchWriteItemResponse_httpStatus' - The response's http status code.
newBatchWriteItemResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchWriteItemResponse
newBatchWriteItemResponse :: Int -> BatchWriteItemResponse
newBatchWriteItemResponse Int
pHttpStatus_ =
  BatchWriteItemResponse' :: Maybe (HashMap Text [ItemCollectionMetrics])
-> Maybe [ConsumedCapacity]
-> Maybe (HashMap Text (NonEmpty WriteRequest))
-> Int
-> BatchWriteItemResponse
BatchWriteItemResponse'
    { $sel:itemCollectionMetrics:BatchWriteItemResponse' :: Maybe (HashMap Text [ItemCollectionMetrics])
itemCollectionMetrics =
        Maybe (HashMap Text [ItemCollectionMetrics])
forall a. Maybe a
Prelude.Nothing,
      $sel:consumedCapacity:BatchWriteItemResponse' :: Maybe [ConsumedCapacity]
consumedCapacity = Maybe [ConsumedCapacity]
forall a. Maybe a
Prelude.Nothing,
      $sel:unprocessedItems:BatchWriteItemResponse' :: Maybe (HashMap Text (NonEmpty WriteRequest))
unprocessedItems = Maybe (HashMap Text (NonEmpty WriteRequest))
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchWriteItemResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of tables that were processed by @BatchWriteItem@ and, for each
-- table, information about any item collections that were affected by
-- individual @DeleteItem@ or @PutItem@ operations.
--
-- Each entry consists of the following subelements:
--
-- -   @ItemCollectionKey@ - The partition key value of the item
--     collection. This is the same as the partition key value of the item.
--
-- -   @SizeEstimateRangeGB@ - An estimate of item collection size,
--     expressed in GB. This is a two-element array containing a lower
--     bound and an upper bound for the estimate. The estimate includes the
--     size of all the items in the table, plus the size of all attributes
--     projected into all of the local secondary indexes on the table. Use
--     this estimate to measure whether a local secondary index is
--     approaching its size limit.
--
--     The estimate is subject to change over time; therefore, do not rely
--     on the precision or accuracy of the estimate.
batchWriteItemResponse_itemCollectionMetrics :: Lens.Lens' BatchWriteItemResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text [ItemCollectionMetrics]))
batchWriteItemResponse_itemCollectionMetrics :: (Maybe (HashMap Text [ItemCollectionMetrics])
 -> f (Maybe (HashMap Text [ItemCollectionMetrics])))
-> BatchWriteItemResponse -> f BatchWriteItemResponse
batchWriteItemResponse_itemCollectionMetrics = (BatchWriteItemResponse
 -> Maybe (HashMap Text [ItemCollectionMetrics]))
-> (BatchWriteItemResponse
    -> Maybe (HashMap Text [ItemCollectionMetrics])
    -> BatchWriteItemResponse)
-> Lens
     BatchWriteItemResponse
     BatchWriteItemResponse
     (Maybe (HashMap Text [ItemCollectionMetrics]))
     (Maybe (HashMap Text [ItemCollectionMetrics]))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWriteItemResponse' {Maybe (HashMap Text [ItemCollectionMetrics])
itemCollectionMetrics :: Maybe (HashMap Text [ItemCollectionMetrics])
$sel:itemCollectionMetrics:BatchWriteItemResponse' :: BatchWriteItemResponse
-> Maybe (HashMap Text [ItemCollectionMetrics])
itemCollectionMetrics} -> Maybe (HashMap Text [ItemCollectionMetrics])
itemCollectionMetrics) (\s :: BatchWriteItemResponse
s@BatchWriteItemResponse' {} Maybe (HashMap Text [ItemCollectionMetrics])
a -> BatchWriteItemResponse
s {$sel:itemCollectionMetrics:BatchWriteItemResponse' :: Maybe (HashMap Text [ItemCollectionMetrics])
itemCollectionMetrics = Maybe (HashMap Text [ItemCollectionMetrics])
a} :: BatchWriteItemResponse) ((Maybe (HashMap Text [ItemCollectionMetrics])
  -> f (Maybe (HashMap Text [ItemCollectionMetrics])))
 -> BatchWriteItemResponse -> f BatchWriteItemResponse)
-> ((Maybe (HashMap Text [ItemCollectionMetrics])
     -> f (Maybe (HashMap Text [ItemCollectionMetrics])))
    -> Maybe (HashMap Text [ItemCollectionMetrics])
    -> f (Maybe (HashMap Text [ItemCollectionMetrics])))
-> (Maybe (HashMap Text [ItemCollectionMetrics])
    -> f (Maybe (HashMap Text [ItemCollectionMetrics])))
-> BatchWriteItemResponse
-> f BatchWriteItemResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text [ItemCollectionMetrics])
  (HashMap Text [ItemCollectionMetrics])
  (HashMap Text [ItemCollectionMetrics])
  (HashMap Text [ItemCollectionMetrics])
-> Iso
     (Maybe (HashMap Text [ItemCollectionMetrics]))
     (Maybe (HashMap Text [ItemCollectionMetrics]))
     (Maybe (HashMap Text [ItemCollectionMetrics]))
     (Maybe (HashMap Text [ItemCollectionMetrics]))
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
  (HashMap Text [ItemCollectionMetrics])
  (HashMap Text [ItemCollectionMetrics])
  (HashMap Text [ItemCollectionMetrics])
  (HashMap Text [ItemCollectionMetrics])
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The capacity units consumed by the entire @BatchWriteItem@ operation.
--
-- Each element consists of:
--
-- -   @TableName@ - The table that consumed the provisioned throughput.
--
-- -   @CapacityUnits@ - The total number of capacity units consumed.
batchWriteItemResponse_consumedCapacity :: Lens.Lens' BatchWriteItemResponse (Prelude.Maybe [ConsumedCapacity])
batchWriteItemResponse_consumedCapacity :: (Maybe [ConsumedCapacity] -> f (Maybe [ConsumedCapacity]))
-> BatchWriteItemResponse -> f BatchWriteItemResponse
batchWriteItemResponse_consumedCapacity = (BatchWriteItemResponse -> Maybe [ConsumedCapacity])
-> (BatchWriteItemResponse
    -> Maybe [ConsumedCapacity] -> BatchWriteItemResponse)
-> Lens
     BatchWriteItemResponse
     BatchWriteItemResponse
     (Maybe [ConsumedCapacity])
     (Maybe [ConsumedCapacity])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWriteItemResponse' {Maybe [ConsumedCapacity]
consumedCapacity :: Maybe [ConsumedCapacity]
$sel:consumedCapacity:BatchWriteItemResponse' :: BatchWriteItemResponse -> Maybe [ConsumedCapacity]
consumedCapacity} -> Maybe [ConsumedCapacity]
consumedCapacity) (\s :: BatchWriteItemResponse
s@BatchWriteItemResponse' {} Maybe [ConsumedCapacity]
a -> BatchWriteItemResponse
s {$sel:consumedCapacity:BatchWriteItemResponse' :: Maybe [ConsumedCapacity]
consumedCapacity = Maybe [ConsumedCapacity]
a} :: BatchWriteItemResponse) ((Maybe [ConsumedCapacity] -> f (Maybe [ConsumedCapacity]))
 -> BatchWriteItemResponse -> f BatchWriteItemResponse)
-> ((Maybe [ConsumedCapacity] -> f (Maybe [ConsumedCapacity]))
    -> Maybe [ConsumedCapacity] -> f (Maybe [ConsumedCapacity]))
-> (Maybe [ConsumedCapacity] -> f (Maybe [ConsumedCapacity]))
-> BatchWriteItemResponse
-> f BatchWriteItemResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ConsumedCapacity]
  [ConsumedCapacity]
  [ConsumedCapacity]
  [ConsumedCapacity]
-> Iso
     (Maybe [ConsumedCapacity])
     (Maybe [ConsumedCapacity])
     (Maybe [ConsumedCapacity])
     (Maybe [ConsumedCapacity])
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
  [ConsumedCapacity]
  [ConsumedCapacity]
  [ConsumedCapacity]
  [ConsumedCapacity]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A map of tables and requests against those tables that were not
-- processed. The @UnprocessedItems@ value is in the same form as
-- @RequestItems@, so you can provide this value directly to a subsequent
-- @BatchGetItem@ operation. For more information, see @RequestItems@ in
-- the Request Parameters section.
--
-- Each @UnprocessedItems@ entry consists of a table name and, for that
-- table, a list of operations to perform (@DeleteRequest@ or
-- @PutRequest@).
--
-- -   @DeleteRequest@ - Perform a @DeleteItem@ operation on the specified
--     item. The item to be deleted is identified by a @Key@ subelement:
--
--     -   @Key@ - A map of primary key attribute values that uniquely
--         identify the item. Each entry in this map consists of an
--         attribute name and an attribute value.
--
-- -   @PutRequest@ - Perform a @PutItem@ operation on the specified item.
--     The item to be put is identified by an @Item@ subelement:
--
--     -   @Item@ - A map of attributes and their values. Each entry in
--         this map consists of an attribute name and an attribute value.
--         Attribute values must not be null; string and binary type
--         attributes must have lengths greater than zero; and set type
--         attributes must not be empty. Requests that contain empty values
--         will be rejected with a @ValidationException@ exception.
--
--         If you specify any attributes that are part of an index key,
--         then the data types for those attributes must match those of the
--         schema in the table\'s attribute definition.
--
-- If there are no unprocessed items remaining, the response contains an
-- empty @UnprocessedItems@ map.
batchWriteItemResponse_unprocessedItems :: Lens.Lens' BatchWriteItemResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.NonEmpty WriteRequest)))
batchWriteItemResponse_unprocessedItems :: (Maybe (HashMap Text (NonEmpty WriteRequest))
 -> f (Maybe (HashMap Text (NonEmpty WriteRequest))))
-> BatchWriteItemResponse -> f BatchWriteItemResponse
batchWriteItemResponse_unprocessedItems = (BatchWriteItemResponse
 -> Maybe (HashMap Text (NonEmpty WriteRequest)))
-> (BatchWriteItemResponse
    -> Maybe (HashMap Text (NonEmpty WriteRequest))
    -> BatchWriteItemResponse)
-> Lens
     BatchWriteItemResponse
     BatchWriteItemResponse
     (Maybe (HashMap Text (NonEmpty WriteRequest)))
     (Maybe (HashMap Text (NonEmpty WriteRequest)))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchWriteItemResponse' {Maybe (HashMap Text (NonEmpty WriteRequest))
unprocessedItems :: Maybe (HashMap Text (NonEmpty WriteRequest))
$sel:unprocessedItems:BatchWriteItemResponse' :: BatchWriteItemResponse
-> Maybe (HashMap Text (NonEmpty WriteRequest))
unprocessedItems} -> Maybe (HashMap Text (NonEmpty WriteRequest))
unprocessedItems) (\s :: BatchWriteItemResponse
s@BatchWriteItemResponse' {} Maybe (HashMap Text (NonEmpty WriteRequest))
a -> BatchWriteItemResponse
s {$sel:unprocessedItems:BatchWriteItemResponse' :: Maybe (HashMap Text (NonEmpty WriteRequest))
unprocessedItems = Maybe (HashMap Text (NonEmpty WriteRequest))
a} :: BatchWriteItemResponse) ((Maybe (HashMap Text (NonEmpty WriteRequest))
  -> f (Maybe (HashMap Text (NonEmpty WriteRequest))))
 -> BatchWriteItemResponse -> f BatchWriteItemResponse)
-> ((Maybe (HashMap Text (NonEmpty WriteRequest))
     -> f (Maybe (HashMap Text (NonEmpty WriteRequest))))
    -> Maybe (HashMap Text (NonEmpty WriteRequest))
    -> f (Maybe (HashMap Text (NonEmpty WriteRequest))))
-> (Maybe (HashMap Text (NonEmpty WriteRequest))
    -> f (Maybe (HashMap Text (NonEmpty WriteRequest))))
-> BatchWriteItemResponse
-> f BatchWriteItemResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text (NonEmpty WriteRequest))
  (HashMap Text (NonEmpty WriteRequest))
  (HashMap Text (NonEmpty WriteRequest))
  (HashMap Text (NonEmpty WriteRequest))
-> Iso
     (Maybe (HashMap Text (NonEmpty WriteRequest)))
     (Maybe (HashMap Text (NonEmpty WriteRequest)))
     (Maybe (HashMap Text (NonEmpty WriteRequest)))
     (Maybe (HashMap Text (NonEmpty WriteRequest)))
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
  (HashMap Text (NonEmpty WriteRequest))
  (HashMap Text (NonEmpty WriteRequest))
  (HashMap Text (NonEmpty WriteRequest))
  (HashMap Text (NonEmpty WriteRequest))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchWriteItemResponse