{-# 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.PutItem
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a new item, or replaces an old item with a new item. If an item
-- that has the same primary key as the new item already exists in the
-- specified table, the new item completely replaces the existing item. You
-- can perform a conditional put operation (add a new item if one with the
-- specified primary key doesn\'t exist), or replace an existing item if it
-- has certain attribute values. You can return the item\'s attribute
-- values in the same operation, using the @ReturnValues@ parameter.
--
-- This topic provides general information about the @PutItem@ API.
--
-- For information on how to call the @PutItem@ API using the AWS SDK in
-- specific languages, see the following:
--
-- -   <http://docs.aws.amazon.com/goto/aws-cli/dynamodb-2012-08-10/PutItem PutItem in the AWS Command Line Interface>
--
-- -   <http://docs.aws.amazon.com/goto/DotNetSDKV3/dynamodb-2012-08-10/PutItem PutItem in the AWS SDK for .NET>
--
-- -   <http://docs.aws.amazon.com/goto/SdkForCpp/dynamodb-2012-08-10/PutItem PutItem in the AWS SDK for C++>
--
-- -   <http://docs.aws.amazon.com/goto/SdkForGoV1/dynamodb-2012-08-10/PutItem PutItem in the AWS SDK for Go>
--
-- -   <http://docs.aws.amazon.com/goto/SdkForJava/dynamodb-2012-08-10/PutItem PutItem in the AWS SDK for Java>
--
-- -   <http://docs.aws.amazon.com/goto/AWSJavaScriptSDK/dynamodb-2012-08-10/PutItem PutItem in the AWS SDK for JavaScript>
--
-- -   <http://docs.aws.amazon.com/goto/SdkForPHPV3/dynamodb-2012-08-10/PutItem PutItem in the AWS SDK for PHP V3>
--
-- -   <http://docs.aws.amazon.com/goto/boto3/dynamodb-2012-08-10/PutItem PutItem in the AWS SDK for Python>
--
-- -   <http://docs.aws.amazon.com/goto/SdkForRubyV2/dynamodb-2012-08-10/PutItem PutItem in the AWS SDK for Ruby V2>
--
-- When you add an item, the primary key attributes are the only required
-- attributes. Attribute values cannot be null.
--
-- Empty String and Binary attribute values are allowed. Attribute values
-- of type String and Binary must have a length greater than zero if the
-- attribute is used as a key attribute for a table or index. Set type
-- attributes cannot be empty.
--
-- Invalid Requests with empty values will be rejected with a
-- @ValidationException@ exception.
--
-- To prevent a new item from replacing an existing item, use a conditional
-- expression that contains the @attribute_not_exists@ function with the
-- name of the attribute being used as the partition key for the table.
-- Since every record must contain that attribute, the
-- @attribute_not_exists@ function will only succeed if no matching item
-- exists.
--
-- For more information about @PutItem@, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html Working with Items>
-- in the /Amazon DynamoDB Developer Guide/.
module Amazonka.DynamoDB.PutItem
  ( -- * Creating a Request
    PutItem (..),
    newPutItem,

    -- * Request Lenses
    putItem_expressionAttributeNames,
    putItem_returnValues,
    putItem_expressionAttributeValues,
    putItem_returnConsumedCapacity,
    putItem_returnItemCollectionMetrics,
    putItem_conditionExpression,
    putItem_conditionalOperator,
    putItem_expected,
    putItem_tableName,
    putItem_item,

    -- * Destructuring the Response
    PutItemResponse (..),
    newPutItemResponse,

    -- * Response Lenses
    putItemResponse_itemCollectionMetrics,
    putItemResponse_consumedCapacity,
    putItemResponse_attributes,
    putItemResponse_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 @PutItem@ operation.
--
-- /See:/ 'newPutItem' smart constructor.
data PutItem = PutItem'
  { -- | One or more substitution tokens for attribute names in an expression.
    -- The following are some use cases for using @ExpressionAttributeNames@:
    --
    -- -   To access an attribute whose name conflicts with a DynamoDB reserved
    --     word.
    --
    -- -   To create a placeholder for repeating occurrences of an attribute
    --     name in an expression.
    --
    -- -   To prevent special characters in an attribute name from being
    --     misinterpreted in an expression.
    --
    -- Use the __#__ character in an expression to dereference an attribute
    -- name. For example, consider the following attribute name:
    --
    -- -   @Percentile@
    --
    -- The name of this attribute conflicts with a reserved word, so it cannot
    -- be used directly in an expression. (For the complete list of reserved
    -- words, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html Reserved Words>
    -- in the /Amazon DynamoDB Developer Guide/). To work around this, you
    -- could specify the following for @ExpressionAttributeNames@:
    --
    -- -   @{\"#P\":\"Percentile\"}@
    --
    -- You could then use this substitution in an expression, as in this
    -- example:
    --
    -- -   @#P = :val@
    --
    -- Tokens that begin with the __:__ character are /expression attribute
    -- values/, which are placeholders for the actual value at runtime.
    --
    -- For more information on expression attribute names, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Specifying Item Attributes>
    -- in the /Amazon DynamoDB Developer Guide/.
    PutItem -> Maybe (HashMap Text Text)
expressionAttributeNames :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Use @ReturnValues@ if you want to get the item attributes as they
    -- appeared before they were updated with the @PutItem@ request. For
    -- @PutItem@, the valid values are:
    --
    -- -   @NONE@ - If @ReturnValues@ is not specified, or if its value is
    --     @NONE@, then nothing is returned. (This setting is the default for
    --     @ReturnValues@.)
    --
    -- -   @ALL_OLD@ - If @PutItem@ overwrote an attribute name-value pair,
    --     then the content of the old item is returned.
    --
    -- The @ReturnValues@ parameter is used by several DynamoDB operations;
    -- however, @PutItem@ does not recognize any values other than @NONE@ or
    -- @ALL_OLD@.
    PutItem -> Maybe ReturnValue
returnValues :: Prelude.Maybe ReturnValue,
    -- | One or more values that can be substituted in an expression.
    --
    -- Use the __:__ (colon) character in an expression to dereference an
    -- attribute value. For example, suppose that you wanted to check whether
    -- the value of the /ProductStatus/ attribute was one of the following:
    --
    -- @Available | Backordered | Discontinued@
    --
    -- You would first need to specify @ExpressionAttributeValues@ as follows:
    --
    -- @{ \":avail\":{\"S\":\"Available\"}, \":back\":{\"S\":\"Backordered\"}, \":disc\":{\"S\":\"Discontinued\"} }@
    --
    -- You could then use these values in an expression, such as this:
    --
    -- @ProductStatus IN (:avail, :back, :disc)@
    --
    -- For more information on expression attribute values, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html Condition Expressions>
    -- in the /Amazon DynamoDB Developer Guide/.
    PutItem -> Maybe (HashMap Text AttributeValue)
expressionAttributeValues :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue),
    PutItem -> 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.
    PutItem -> Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics :: Prelude.Maybe ReturnItemCollectionMetrics,
    -- | A condition that must be satisfied in order for a conditional @PutItem@
    -- operation to succeed.
    --
    -- An expression can contain any of the following:
    --
    -- -   Functions:
    --     @attribute_exists | attribute_not_exists | attribute_type | contains | begins_with | size@
    --
    --     These function names are case-sensitive.
    --
    -- -   Comparison operators: @= | \<> | \< | > | \<= | >= | BETWEEN | IN @
    --
    -- -   Logical operators: @AND | OR | NOT@
    --
    -- For more information on condition expressions, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html Condition Expressions>
    -- in the /Amazon DynamoDB Developer Guide/.
    PutItem -> Maybe Text
conditionExpression :: Prelude.Maybe Prelude.Text,
    -- | This is a legacy parameter. Use @ConditionExpression@ instead. For more
    -- information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.ConditionalOperator.html ConditionalOperator>
    -- in the /Amazon DynamoDB Developer Guide/.
    PutItem -> Maybe ConditionalOperator
conditionalOperator :: Prelude.Maybe ConditionalOperator,
    -- | This is a legacy parameter. Use @ConditionExpression@ instead. For more
    -- information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.Expected.html Expected>
    -- in the /Amazon DynamoDB Developer Guide/.
    PutItem -> Maybe (HashMap Text ExpectedAttributeValue)
expected :: Prelude.Maybe (Prelude.HashMap Prelude.Text ExpectedAttributeValue),
    -- | The name of the table to contain the item.
    PutItem -> Text
tableName :: Prelude.Text,
    -- | A map of attribute name\/value pairs, one for each attribute. Only the
    -- primary key attributes are required; you can optionally provide other
    -- attribute name-value pairs for the item.
    --
    -- You must provide all of the attributes for the primary key. 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 both values
    -- for both the partition key and the sort key.
    --
    -- 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.
    --
    -- Empty String and Binary attribute values are allowed. Attribute values
    -- of type String and Binary must have a length greater than zero if the
    -- attribute is used as a key attribute for a table or index.
    --
    -- For more information about primary keys, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html#HowItWorks.CoreComponents.PrimaryKey Primary Key>
    -- in the /Amazon DynamoDB Developer Guide/.
    --
    -- Each element in the @Item@ map is an @AttributeValue@ object.
    PutItem -> HashMap Text AttributeValue
item :: Prelude.HashMap Prelude.Text AttributeValue
  }
  deriving (PutItem -> PutItem -> Bool
(PutItem -> PutItem -> Bool)
-> (PutItem -> PutItem -> Bool) -> Eq PutItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutItem -> PutItem -> Bool
$c/= :: PutItem -> PutItem -> Bool
== :: PutItem -> PutItem -> Bool
$c== :: PutItem -> PutItem -> Bool
Prelude.Eq, ReadPrec [PutItem]
ReadPrec PutItem
Int -> ReadS PutItem
ReadS [PutItem]
(Int -> ReadS PutItem)
-> ReadS [PutItem]
-> ReadPrec PutItem
-> ReadPrec [PutItem]
-> Read PutItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutItem]
$creadListPrec :: ReadPrec [PutItem]
readPrec :: ReadPrec PutItem
$creadPrec :: ReadPrec PutItem
readList :: ReadS [PutItem]
$creadList :: ReadS [PutItem]
readsPrec :: Int -> ReadS PutItem
$creadsPrec :: Int -> ReadS PutItem
Prelude.Read, Int -> PutItem -> ShowS
[PutItem] -> ShowS
PutItem -> String
(Int -> PutItem -> ShowS)
-> (PutItem -> String) -> ([PutItem] -> ShowS) -> Show PutItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutItem] -> ShowS
$cshowList :: [PutItem] -> ShowS
show :: PutItem -> String
$cshow :: PutItem -> String
showsPrec :: Int -> PutItem -> ShowS
$cshowsPrec :: Int -> PutItem -> ShowS
Prelude.Show, (forall x. PutItem -> Rep PutItem x)
-> (forall x. Rep PutItem x -> PutItem) -> Generic PutItem
forall x. Rep PutItem x -> PutItem
forall x. PutItem -> Rep PutItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutItem x -> PutItem
$cfrom :: forall x. PutItem -> Rep PutItem x
Prelude.Generic)

-- |
-- Create a value of 'PutItem' 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:
--
-- 'expressionAttributeNames', 'putItem_expressionAttributeNames' - One or more substitution tokens for attribute names in an expression.
-- The following are some use cases for using @ExpressionAttributeNames@:
--
-- -   To access an attribute whose name conflicts with a DynamoDB reserved
--     word.
--
-- -   To create a placeholder for repeating occurrences of an attribute
--     name in an expression.
--
-- -   To prevent special characters in an attribute name from being
--     misinterpreted in an expression.
--
-- Use the __#__ character in an expression to dereference an attribute
-- name. For example, consider the following attribute name:
--
-- -   @Percentile@
--
-- The name of this attribute conflicts with a reserved word, so it cannot
-- be used directly in an expression. (For the complete list of reserved
-- words, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html Reserved Words>
-- in the /Amazon DynamoDB Developer Guide/). To work around this, you
-- could specify the following for @ExpressionAttributeNames@:
--
-- -   @{\"#P\":\"Percentile\"}@
--
-- You could then use this substitution in an expression, as in this
-- example:
--
-- -   @#P = :val@
--
-- Tokens that begin with the __:__ character are /expression attribute
-- values/, which are placeholders for the actual value at runtime.
--
-- For more information on expression attribute names, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Specifying Item Attributes>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'returnValues', 'putItem_returnValues' - Use @ReturnValues@ if you want to get the item attributes as they
-- appeared before they were updated with the @PutItem@ request. For
-- @PutItem@, the valid values are:
--
-- -   @NONE@ - If @ReturnValues@ is not specified, or if its value is
--     @NONE@, then nothing is returned. (This setting is the default for
--     @ReturnValues@.)
--
-- -   @ALL_OLD@ - If @PutItem@ overwrote an attribute name-value pair,
--     then the content of the old item is returned.
--
-- The @ReturnValues@ parameter is used by several DynamoDB operations;
-- however, @PutItem@ does not recognize any values other than @NONE@ or
-- @ALL_OLD@.
--
-- 'expressionAttributeValues', 'putItem_expressionAttributeValues' - One or more values that can be substituted in an expression.
--
-- Use the __:__ (colon) character in an expression to dereference an
-- attribute value. For example, suppose that you wanted to check whether
-- the value of the /ProductStatus/ attribute was one of the following:
--
-- @Available | Backordered | Discontinued@
--
-- You would first need to specify @ExpressionAttributeValues@ as follows:
--
-- @{ \":avail\":{\"S\":\"Available\"}, \":back\":{\"S\":\"Backordered\"}, \":disc\":{\"S\":\"Discontinued\"} }@
--
-- You could then use these values in an expression, such as this:
--
-- @ProductStatus IN (:avail, :back, :disc)@
--
-- For more information on expression attribute values, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html Condition Expressions>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'returnConsumedCapacity', 'putItem_returnConsumedCapacity' - Undocumented member.
--
-- 'returnItemCollectionMetrics', 'putItem_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.
--
-- 'conditionExpression', 'putItem_conditionExpression' - A condition that must be satisfied in order for a conditional @PutItem@
-- operation to succeed.
--
-- An expression can contain any of the following:
--
-- -   Functions:
--     @attribute_exists | attribute_not_exists | attribute_type | contains | begins_with | size@
--
--     These function names are case-sensitive.
--
-- -   Comparison operators: @= | \<> | \< | > | \<= | >= | BETWEEN | IN @
--
-- -   Logical operators: @AND | OR | NOT@
--
-- For more information on condition expressions, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html Condition Expressions>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'conditionalOperator', 'putItem_conditionalOperator' - This is a legacy parameter. Use @ConditionExpression@ instead. For more
-- information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.ConditionalOperator.html ConditionalOperator>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'expected', 'putItem_expected' - This is a legacy parameter. Use @ConditionExpression@ instead. For more
-- information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.Expected.html Expected>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'tableName', 'putItem_tableName' - The name of the table to contain the item.
--
-- 'item', 'putItem_item' - A map of attribute name\/value pairs, one for each attribute. Only the
-- primary key attributes are required; you can optionally provide other
-- attribute name-value pairs for the item.
--
-- You must provide all of the attributes for the primary key. 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 both values
-- for both the partition key and the sort key.
--
-- 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.
--
-- Empty String and Binary attribute values are allowed. Attribute values
-- of type String and Binary must have a length greater than zero if the
-- attribute is used as a key attribute for a table or index.
--
-- For more information about primary keys, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html#HowItWorks.CoreComponents.PrimaryKey Primary Key>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- Each element in the @Item@ map is an @AttributeValue@ object.
newPutItem ::
  -- | 'tableName'
  Prelude.Text ->
  PutItem
newPutItem :: Text -> PutItem
newPutItem Text
pTableName_ =
  PutItem' :: Maybe (HashMap Text Text)
-> Maybe ReturnValue
-> Maybe (HashMap Text AttributeValue)
-> Maybe ReturnConsumedCapacity
-> Maybe ReturnItemCollectionMetrics
-> Maybe Text
-> Maybe ConditionalOperator
-> Maybe (HashMap Text ExpectedAttributeValue)
-> Text
-> HashMap Text AttributeValue
-> PutItem
PutItem'
    { $sel:expressionAttributeNames:PutItem' :: Maybe (HashMap Text Text)
expressionAttributeNames =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:returnValues:PutItem' :: Maybe ReturnValue
returnValues = Maybe ReturnValue
forall a. Maybe a
Prelude.Nothing,
      $sel:expressionAttributeValues:PutItem' :: Maybe (HashMap Text AttributeValue)
expressionAttributeValues = Maybe (HashMap Text AttributeValue)
forall a. Maybe a
Prelude.Nothing,
      $sel:returnConsumedCapacity:PutItem' :: Maybe ReturnConsumedCapacity
returnConsumedCapacity = Maybe ReturnConsumedCapacity
forall a. Maybe a
Prelude.Nothing,
      $sel:returnItemCollectionMetrics:PutItem' :: Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics = Maybe ReturnItemCollectionMetrics
forall a. Maybe a
Prelude.Nothing,
      $sel:conditionExpression:PutItem' :: Maybe Text
conditionExpression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:conditionalOperator:PutItem' :: Maybe ConditionalOperator
conditionalOperator = Maybe ConditionalOperator
forall a. Maybe a
Prelude.Nothing,
      $sel:expected:PutItem' :: Maybe (HashMap Text ExpectedAttributeValue)
expected = Maybe (HashMap Text ExpectedAttributeValue)
forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:PutItem' :: Text
tableName = Text
pTableName_,
      $sel:item:PutItem' :: HashMap Text AttributeValue
item = HashMap Text AttributeValue
forall a. Monoid a => a
Prelude.mempty
    }

-- | One or more substitution tokens for attribute names in an expression.
-- The following are some use cases for using @ExpressionAttributeNames@:
--
-- -   To access an attribute whose name conflicts with a DynamoDB reserved
--     word.
--
-- -   To create a placeholder for repeating occurrences of an attribute
--     name in an expression.
--
-- -   To prevent special characters in an attribute name from being
--     misinterpreted in an expression.
--
-- Use the __#__ character in an expression to dereference an attribute
-- name. For example, consider the following attribute name:
--
-- -   @Percentile@
--
-- The name of this attribute conflicts with a reserved word, so it cannot
-- be used directly in an expression. (For the complete list of reserved
-- words, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html Reserved Words>
-- in the /Amazon DynamoDB Developer Guide/). To work around this, you
-- could specify the following for @ExpressionAttributeNames@:
--
-- -   @{\"#P\":\"Percentile\"}@
--
-- You could then use this substitution in an expression, as in this
-- example:
--
-- -   @#P = :val@
--
-- Tokens that begin with the __:__ character are /expression attribute
-- values/, which are placeholders for the actual value at runtime.
--
-- For more information on expression attribute names, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Specifying Item Attributes>
-- in the /Amazon DynamoDB Developer Guide/.
putItem_expressionAttributeNames :: Lens.Lens' PutItem (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
putItem_expressionAttributeNames :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PutItem -> f PutItem
putItem_expressionAttributeNames = (PutItem -> Maybe (HashMap Text Text))
-> (PutItem -> Maybe (HashMap Text Text) -> PutItem)
-> Lens
     PutItem
     PutItem
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItem' {Maybe (HashMap Text Text)
expressionAttributeNames :: Maybe (HashMap Text Text)
$sel:expressionAttributeNames:PutItem' :: PutItem -> Maybe (HashMap Text Text)
expressionAttributeNames} -> Maybe (HashMap Text Text)
expressionAttributeNames) (\s :: PutItem
s@PutItem' {} Maybe (HashMap Text Text)
a -> PutItem
s {$sel:expressionAttributeNames:PutItem' :: Maybe (HashMap Text Text)
expressionAttributeNames = Maybe (HashMap Text Text)
a} :: PutItem) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> PutItem -> f PutItem)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PutItem
-> f PutItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Use @ReturnValues@ if you want to get the item attributes as they
-- appeared before they were updated with the @PutItem@ request. For
-- @PutItem@, the valid values are:
--
-- -   @NONE@ - If @ReturnValues@ is not specified, or if its value is
--     @NONE@, then nothing is returned. (This setting is the default for
--     @ReturnValues@.)
--
-- -   @ALL_OLD@ - If @PutItem@ overwrote an attribute name-value pair,
--     then the content of the old item is returned.
--
-- The @ReturnValues@ parameter is used by several DynamoDB operations;
-- however, @PutItem@ does not recognize any values other than @NONE@ or
-- @ALL_OLD@.
putItem_returnValues :: Lens.Lens' PutItem (Prelude.Maybe ReturnValue)
putItem_returnValues :: (Maybe ReturnValue -> f (Maybe ReturnValue))
-> PutItem -> f PutItem
putItem_returnValues = (PutItem -> Maybe ReturnValue)
-> (PutItem -> Maybe ReturnValue -> PutItem)
-> Lens PutItem PutItem (Maybe ReturnValue) (Maybe ReturnValue)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItem' {Maybe ReturnValue
returnValues :: Maybe ReturnValue
$sel:returnValues:PutItem' :: PutItem -> Maybe ReturnValue
returnValues} -> Maybe ReturnValue
returnValues) (\s :: PutItem
s@PutItem' {} Maybe ReturnValue
a -> PutItem
s {$sel:returnValues:PutItem' :: Maybe ReturnValue
returnValues = Maybe ReturnValue
a} :: PutItem)

-- | One or more values that can be substituted in an expression.
--
-- Use the __:__ (colon) character in an expression to dereference an
-- attribute value. For example, suppose that you wanted to check whether
-- the value of the /ProductStatus/ attribute was one of the following:
--
-- @Available | Backordered | Discontinued@
--
-- You would first need to specify @ExpressionAttributeValues@ as follows:
--
-- @{ \":avail\":{\"S\":\"Available\"}, \":back\":{\"S\":\"Backordered\"}, \":disc\":{\"S\":\"Discontinued\"} }@
--
-- You could then use these values in an expression, such as this:
--
-- @ProductStatus IN (:avail, :back, :disc)@
--
-- For more information on expression attribute values, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html Condition Expressions>
-- in the /Amazon DynamoDB Developer Guide/.
putItem_expressionAttributeValues :: Lens.Lens' PutItem (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue))
putItem_expressionAttributeValues :: (Maybe (HashMap Text AttributeValue)
 -> f (Maybe (HashMap Text AttributeValue)))
-> PutItem -> f PutItem
putItem_expressionAttributeValues = (PutItem -> Maybe (HashMap Text AttributeValue))
-> (PutItem -> Maybe (HashMap Text AttributeValue) -> PutItem)
-> Lens
     PutItem
     PutItem
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItem' {Maybe (HashMap Text AttributeValue)
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
$sel:expressionAttributeValues:PutItem' :: PutItem -> Maybe (HashMap Text AttributeValue)
expressionAttributeValues} -> Maybe (HashMap Text AttributeValue)
expressionAttributeValues) (\s :: PutItem
s@PutItem' {} Maybe (HashMap Text AttributeValue)
a -> PutItem
s {$sel:expressionAttributeValues:PutItem' :: Maybe (HashMap Text AttributeValue)
expressionAttributeValues = Maybe (HashMap Text AttributeValue)
a} :: PutItem) ((Maybe (HashMap Text AttributeValue)
  -> f (Maybe (HashMap Text AttributeValue)))
 -> PutItem -> f PutItem)
-> ((Maybe (HashMap Text AttributeValue)
     -> f (Maybe (HashMap Text AttributeValue)))
    -> Maybe (HashMap Text AttributeValue)
    -> f (Maybe (HashMap Text AttributeValue)))
-> (Maybe (HashMap Text AttributeValue)
    -> f (Maybe (HashMap Text AttributeValue)))
-> PutItem
-> f PutItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
-> Iso
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
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 AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | 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.
putItem_returnItemCollectionMetrics :: Lens.Lens' PutItem (Prelude.Maybe ReturnItemCollectionMetrics)
putItem_returnItemCollectionMetrics :: (Maybe ReturnItemCollectionMetrics
 -> f (Maybe ReturnItemCollectionMetrics))
-> PutItem -> f PutItem
putItem_returnItemCollectionMetrics = (PutItem -> Maybe ReturnItemCollectionMetrics)
-> (PutItem -> Maybe ReturnItemCollectionMetrics -> PutItem)
-> Lens
     PutItem
     PutItem
     (Maybe ReturnItemCollectionMetrics)
     (Maybe ReturnItemCollectionMetrics)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItem' {Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics :: Maybe ReturnItemCollectionMetrics
$sel:returnItemCollectionMetrics:PutItem' :: PutItem -> Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics} -> Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics) (\s :: PutItem
s@PutItem' {} Maybe ReturnItemCollectionMetrics
a -> PutItem
s {$sel:returnItemCollectionMetrics:PutItem' :: Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics = Maybe ReturnItemCollectionMetrics
a} :: PutItem)

-- | A condition that must be satisfied in order for a conditional @PutItem@
-- operation to succeed.
--
-- An expression can contain any of the following:
--
-- -   Functions:
--     @attribute_exists | attribute_not_exists | attribute_type | contains | begins_with | size@
--
--     These function names are case-sensitive.
--
-- -   Comparison operators: @= | \<> | \< | > | \<= | >= | BETWEEN | IN @
--
-- -   Logical operators: @AND | OR | NOT@
--
-- For more information on condition expressions, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html Condition Expressions>
-- in the /Amazon DynamoDB Developer Guide/.
putItem_conditionExpression :: Lens.Lens' PutItem (Prelude.Maybe Prelude.Text)
putItem_conditionExpression :: (Maybe Text -> f (Maybe Text)) -> PutItem -> f PutItem
putItem_conditionExpression = (PutItem -> Maybe Text)
-> (PutItem -> Maybe Text -> PutItem)
-> Lens PutItem PutItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItem' {Maybe Text
conditionExpression :: Maybe Text
$sel:conditionExpression:PutItem' :: PutItem -> Maybe Text
conditionExpression} -> Maybe Text
conditionExpression) (\s :: PutItem
s@PutItem' {} Maybe Text
a -> PutItem
s {$sel:conditionExpression:PutItem' :: Maybe Text
conditionExpression = Maybe Text
a} :: PutItem)

-- | This is a legacy parameter. Use @ConditionExpression@ instead. For more
-- information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.ConditionalOperator.html ConditionalOperator>
-- in the /Amazon DynamoDB Developer Guide/.
putItem_conditionalOperator :: Lens.Lens' PutItem (Prelude.Maybe ConditionalOperator)
putItem_conditionalOperator :: (Maybe ConditionalOperator -> f (Maybe ConditionalOperator))
-> PutItem -> f PutItem
putItem_conditionalOperator = (PutItem -> Maybe ConditionalOperator)
-> (PutItem -> Maybe ConditionalOperator -> PutItem)
-> Lens
     PutItem
     PutItem
     (Maybe ConditionalOperator)
     (Maybe ConditionalOperator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItem' {Maybe ConditionalOperator
conditionalOperator :: Maybe ConditionalOperator
$sel:conditionalOperator:PutItem' :: PutItem -> Maybe ConditionalOperator
conditionalOperator} -> Maybe ConditionalOperator
conditionalOperator) (\s :: PutItem
s@PutItem' {} Maybe ConditionalOperator
a -> PutItem
s {$sel:conditionalOperator:PutItem' :: Maybe ConditionalOperator
conditionalOperator = Maybe ConditionalOperator
a} :: PutItem)

-- | This is a legacy parameter. Use @ConditionExpression@ instead. For more
-- information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.Expected.html Expected>
-- in the /Amazon DynamoDB Developer Guide/.
putItem_expected :: Lens.Lens' PutItem (Prelude.Maybe (Prelude.HashMap Prelude.Text ExpectedAttributeValue))
putItem_expected :: (Maybe (HashMap Text ExpectedAttributeValue)
 -> f (Maybe (HashMap Text ExpectedAttributeValue)))
-> PutItem -> f PutItem
putItem_expected = (PutItem -> Maybe (HashMap Text ExpectedAttributeValue))
-> (PutItem
    -> Maybe (HashMap Text ExpectedAttributeValue) -> PutItem)
-> Lens
     PutItem
     PutItem
     (Maybe (HashMap Text ExpectedAttributeValue))
     (Maybe (HashMap Text ExpectedAttributeValue))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItem' {Maybe (HashMap Text ExpectedAttributeValue)
expected :: Maybe (HashMap Text ExpectedAttributeValue)
$sel:expected:PutItem' :: PutItem -> Maybe (HashMap Text ExpectedAttributeValue)
expected} -> Maybe (HashMap Text ExpectedAttributeValue)
expected) (\s :: PutItem
s@PutItem' {} Maybe (HashMap Text ExpectedAttributeValue)
a -> PutItem
s {$sel:expected:PutItem' :: Maybe (HashMap Text ExpectedAttributeValue)
expected = Maybe (HashMap Text ExpectedAttributeValue)
a} :: PutItem) ((Maybe (HashMap Text ExpectedAttributeValue)
  -> f (Maybe (HashMap Text ExpectedAttributeValue)))
 -> PutItem -> f PutItem)
-> ((Maybe (HashMap Text ExpectedAttributeValue)
     -> f (Maybe (HashMap Text ExpectedAttributeValue)))
    -> Maybe (HashMap Text ExpectedAttributeValue)
    -> f (Maybe (HashMap Text ExpectedAttributeValue)))
-> (Maybe (HashMap Text ExpectedAttributeValue)
    -> f (Maybe (HashMap Text ExpectedAttributeValue)))
-> PutItem
-> f PutItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text ExpectedAttributeValue)
  (HashMap Text ExpectedAttributeValue)
  (HashMap Text ExpectedAttributeValue)
  (HashMap Text ExpectedAttributeValue)
-> Iso
     (Maybe (HashMap Text ExpectedAttributeValue))
     (Maybe (HashMap Text ExpectedAttributeValue))
     (Maybe (HashMap Text ExpectedAttributeValue))
     (Maybe (HashMap Text ExpectedAttributeValue))
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 ExpectedAttributeValue)
  (HashMap Text ExpectedAttributeValue)
  (HashMap Text ExpectedAttributeValue)
  (HashMap Text ExpectedAttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the table to contain the item.
putItem_tableName :: Lens.Lens' PutItem Prelude.Text
putItem_tableName :: (Text -> f Text) -> PutItem -> f PutItem
putItem_tableName = (PutItem -> Text)
-> (PutItem -> Text -> PutItem) -> Lens PutItem PutItem Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItem' {Text
tableName :: Text
$sel:tableName:PutItem' :: PutItem -> Text
tableName} -> Text
tableName) (\s :: PutItem
s@PutItem' {} Text
a -> PutItem
s {$sel:tableName:PutItem' :: Text
tableName = Text
a} :: PutItem)

-- | A map of attribute name\/value pairs, one for each attribute. Only the
-- primary key attributes are required; you can optionally provide other
-- attribute name-value pairs for the item.
--
-- You must provide all of the attributes for the primary key. 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 both values
-- for both the partition key and the sort key.
--
-- 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.
--
-- Empty String and Binary attribute values are allowed. Attribute values
-- of type String and Binary must have a length greater than zero if the
-- attribute is used as a key attribute for a table or index.
--
-- For more information about primary keys, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html#HowItWorks.CoreComponents.PrimaryKey Primary Key>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- Each element in the @Item@ map is an @AttributeValue@ object.
putItem_item :: Lens.Lens' PutItem (Prelude.HashMap Prelude.Text AttributeValue)
putItem_item :: (HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> PutItem -> f PutItem
putItem_item = (PutItem -> HashMap Text AttributeValue)
-> (PutItem -> HashMap Text AttributeValue -> PutItem)
-> Lens
     PutItem
     PutItem
     (HashMap Text AttributeValue)
     (HashMap Text AttributeValue)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItem' {HashMap Text AttributeValue
item :: HashMap Text AttributeValue
$sel:item:PutItem' :: PutItem -> HashMap Text AttributeValue
item} -> HashMap Text AttributeValue
item) (\s :: PutItem
s@PutItem' {} HashMap Text AttributeValue
a -> PutItem
s {$sel:item:PutItem' :: HashMap Text AttributeValue
item = HashMap Text AttributeValue
a} :: PutItem) ((HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
 -> PutItem -> f PutItem)
-> ((HashMap Text AttributeValue
     -> f (HashMap Text AttributeValue))
    -> HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> (HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> PutItem
-> f PutItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> HashMap Text AttributeValue -> f (HashMap Text AttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData PutItem

instance Core.ToHeaders PutItem where
  toHeaders :: PutItem -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutItem -> 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.PutItem" :: 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 PutItem where
  toJSON :: PutItem -> Value
toJSON PutItem' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text AttributeValue)
Maybe (HashMap Text ExpectedAttributeValue)
Maybe ConditionalOperator
Maybe ReturnConsumedCapacity
Maybe ReturnItemCollectionMetrics
Maybe ReturnValue
Text
HashMap Text AttributeValue
item :: HashMap Text AttributeValue
tableName :: Text
expected :: Maybe (HashMap Text ExpectedAttributeValue)
conditionalOperator :: Maybe ConditionalOperator
conditionExpression :: Maybe Text
returnItemCollectionMetrics :: Maybe ReturnItemCollectionMetrics
returnConsumedCapacity :: Maybe ReturnConsumedCapacity
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
returnValues :: Maybe ReturnValue
expressionAttributeNames :: Maybe (HashMap Text Text)
$sel:item:PutItem' :: PutItem -> HashMap Text AttributeValue
$sel:tableName:PutItem' :: PutItem -> Text
$sel:expected:PutItem' :: PutItem -> Maybe (HashMap Text ExpectedAttributeValue)
$sel:conditionalOperator:PutItem' :: PutItem -> Maybe ConditionalOperator
$sel:conditionExpression:PutItem' :: PutItem -> Maybe Text
$sel:returnItemCollectionMetrics:PutItem' :: PutItem -> Maybe ReturnItemCollectionMetrics
$sel:returnConsumedCapacity:PutItem' :: PutItem -> Maybe ReturnConsumedCapacity
$sel:expressionAttributeValues:PutItem' :: PutItem -> Maybe (HashMap Text AttributeValue)
$sel:returnValues:PutItem' :: PutItem -> Maybe ReturnValue
$sel:expressionAttributeNames:PutItem' :: PutItem -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ExpressionAttributeNames" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
expressionAttributeNames,
            (Text
"ReturnValues" Text -> ReturnValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ReturnValue -> Pair) -> Maybe ReturnValue -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReturnValue
returnValues,
            (Text
"ExpressionAttributeValues" Text -> HashMap Text AttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text AttributeValue -> Pair)
-> Maybe (HashMap Text AttributeValue) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text AttributeValue)
expressionAttributeValues,
            (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,
            (Text
"ConditionExpression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
conditionExpression,
            (Text
"ConditionalOperator" Text -> ConditionalOperator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ConditionalOperator -> Pair)
-> Maybe ConditionalOperator -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ConditionalOperator
conditionalOperator,
            (Text
"Expected" Text -> HashMap Text ExpectedAttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text ExpectedAttributeValue -> Pair)
-> Maybe (HashMap Text ExpectedAttributeValue) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text ExpectedAttributeValue)
expected,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tableName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Item" Text -> HashMap Text AttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text AttributeValue
item)
          ]
      )

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

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

-- | Represents the output of a @PutItem@ operation.
--
-- /See:/ 'newPutItemResponse' smart constructor.
data PutItemResponse = PutItemResponse'
  { -- | Information about item collections, if any, that were affected by the
    -- @PutItem@ operation. @ItemCollectionMetrics@ is only returned if the
    -- @ReturnItemCollectionMetrics@ parameter was specified. If the table does
    -- not have any local secondary indexes, this information is not returned
    -- in the response.
    --
    -- Each @ItemCollectionMetrics@ element consists of:
    --
    -- -   @ItemCollectionKey@ - The partition key value of the item
    --     collection. This is the same as the partition key value of the item
    --     itself.
    --
    -- -   @SizeEstimateRangeGB@ - An estimate of item collection size, in
    --     gigabytes. This value 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 that 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.
    PutItemResponse -> Maybe ItemCollectionMetrics
itemCollectionMetrics :: Prelude.Maybe ItemCollectionMetrics,
    -- | The capacity units consumed by the @PutItem@ operation. The data
    -- returned includes the total provisioned throughput consumed, along with
    -- statistics for the table and any indexes involved in the operation.
    -- @ConsumedCapacity@ is only returned if the @ReturnConsumedCapacity@
    -- parameter was specified. For more information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ProvisionedThroughputIntro.html Read\/Write Capacity Mode>
    -- in the /Amazon DynamoDB Developer Guide/.
    PutItemResponse -> Maybe ConsumedCapacity
consumedCapacity :: Prelude.Maybe ConsumedCapacity,
    -- | The attribute values as they appeared before the @PutItem@ operation,
    -- but only if @ReturnValues@ is specified as @ALL_OLD@ in the request.
    -- Each element consists of an attribute name and an attribute value.
    PutItemResponse -> Maybe (HashMap Text AttributeValue)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue),
    -- | The response's http status code.
    PutItemResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutItemResponse -> PutItemResponse -> Bool
(PutItemResponse -> PutItemResponse -> Bool)
-> (PutItemResponse -> PutItemResponse -> Bool)
-> Eq PutItemResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutItemResponse -> PutItemResponse -> Bool
$c/= :: PutItemResponse -> PutItemResponse -> Bool
== :: PutItemResponse -> PutItemResponse -> Bool
$c== :: PutItemResponse -> PutItemResponse -> Bool
Prelude.Eq, ReadPrec [PutItemResponse]
ReadPrec PutItemResponse
Int -> ReadS PutItemResponse
ReadS [PutItemResponse]
(Int -> ReadS PutItemResponse)
-> ReadS [PutItemResponse]
-> ReadPrec PutItemResponse
-> ReadPrec [PutItemResponse]
-> Read PutItemResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutItemResponse]
$creadListPrec :: ReadPrec [PutItemResponse]
readPrec :: ReadPrec PutItemResponse
$creadPrec :: ReadPrec PutItemResponse
readList :: ReadS [PutItemResponse]
$creadList :: ReadS [PutItemResponse]
readsPrec :: Int -> ReadS PutItemResponse
$creadsPrec :: Int -> ReadS PutItemResponse
Prelude.Read, Int -> PutItemResponse -> ShowS
[PutItemResponse] -> ShowS
PutItemResponse -> String
(Int -> PutItemResponse -> ShowS)
-> (PutItemResponse -> String)
-> ([PutItemResponse] -> ShowS)
-> Show PutItemResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutItemResponse] -> ShowS
$cshowList :: [PutItemResponse] -> ShowS
show :: PutItemResponse -> String
$cshow :: PutItemResponse -> String
showsPrec :: Int -> PutItemResponse -> ShowS
$cshowsPrec :: Int -> PutItemResponse -> ShowS
Prelude.Show, (forall x. PutItemResponse -> Rep PutItemResponse x)
-> (forall x. Rep PutItemResponse x -> PutItemResponse)
-> Generic PutItemResponse
forall x. Rep PutItemResponse x -> PutItemResponse
forall x. PutItemResponse -> Rep PutItemResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutItemResponse x -> PutItemResponse
$cfrom :: forall x. PutItemResponse -> Rep PutItemResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutItemResponse' 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', 'putItemResponse_itemCollectionMetrics' - Information about item collections, if any, that were affected by the
-- @PutItem@ operation. @ItemCollectionMetrics@ is only returned if the
-- @ReturnItemCollectionMetrics@ parameter was specified. If the table does
-- not have any local secondary indexes, this information is not returned
-- in the response.
--
-- Each @ItemCollectionMetrics@ element consists of:
--
-- -   @ItemCollectionKey@ - The partition key value of the item
--     collection. This is the same as the partition key value of the item
--     itself.
--
-- -   @SizeEstimateRangeGB@ - An estimate of item collection size, in
--     gigabytes. This value 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 that 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', 'putItemResponse_consumedCapacity' - The capacity units consumed by the @PutItem@ operation. The data
-- returned includes the total provisioned throughput consumed, along with
-- statistics for the table and any indexes involved in the operation.
-- @ConsumedCapacity@ is only returned if the @ReturnConsumedCapacity@
-- parameter was specified. For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ProvisionedThroughputIntro.html Read\/Write Capacity Mode>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'attributes', 'putItemResponse_attributes' - The attribute values as they appeared before the @PutItem@ operation,
-- but only if @ReturnValues@ is specified as @ALL_OLD@ in the request.
-- Each element consists of an attribute name and an attribute value.
--
-- 'httpStatus', 'putItemResponse_httpStatus' - The response's http status code.
newPutItemResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutItemResponse
newPutItemResponse :: Int -> PutItemResponse
newPutItemResponse Int
pHttpStatus_ =
  PutItemResponse' :: Maybe ItemCollectionMetrics
-> Maybe ConsumedCapacity
-> Maybe (HashMap Text AttributeValue)
-> Int
-> PutItemResponse
PutItemResponse'
    { $sel:itemCollectionMetrics:PutItemResponse' :: Maybe ItemCollectionMetrics
itemCollectionMetrics =
        Maybe ItemCollectionMetrics
forall a. Maybe a
Prelude.Nothing,
      $sel:consumedCapacity:PutItemResponse' :: Maybe ConsumedCapacity
consumedCapacity = Maybe ConsumedCapacity
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:PutItemResponse' :: Maybe (HashMap Text AttributeValue)
attributes = Maybe (HashMap Text AttributeValue)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutItemResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about item collections, if any, that were affected by the
-- @PutItem@ operation. @ItemCollectionMetrics@ is only returned if the
-- @ReturnItemCollectionMetrics@ parameter was specified. If the table does
-- not have any local secondary indexes, this information is not returned
-- in the response.
--
-- Each @ItemCollectionMetrics@ element consists of:
--
-- -   @ItemCollectionKey@ - The partition key value of the item
--     collection. This is the same as the partition key value of the item
--     itself.
--
-- -   @SizeEstimateRangeGB@ - An estimate of item collection size, in
--     gigabytes. This value 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 that 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.
putItemResponse_itemCollectionMetrics :: Lens.Lens' PutItemResponse (Prelude.Maybe ItemCollectionMetrics)
putItemResponse_itemCollectionMetrics :: (Maybe ItemCollectionMetrics -> f (Maybe ItemCollectionMetrics))
-> PutItemResponse -> f PutItemResponse
putItemResponse_itemCollectionMetrics = (PutItemResponse -> Maybe ItemCollectionMetrics)
-> (PutItemResponse
    -> Maybe ItemCollectionMetrics -> PutItemResponse)
-> Lens
     PutItemResponse
     PutItemResponse
     (Maybe ItemCollectionMetrics)
     (Maybe ItemCollectionMetrics)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItemResponse' {Maybe ItemCollectionMetrics
itemCollectionMetrics :: Maybe ItemCollectionMetrics
$sel:itemCollectionMetrics:PutItemResponse' :: PutItemResponse -> Maybe ItemCollectionMetrics
itemCollectionMetrics} -> Maybe ItemCollectionMetrics
itemCollectionMetrics) (\s :: PutItemResponse
s@PutItemResponse' {} Maybe ItemCollectionMetrics
a -> PutItemResponse
s {$sel:itemCollectionMetrics:PutItemResponse' :: Maybe ItemCollectionMetrics
itemCollectionMetrics = Maybe ItemCollectionMetrics
a} :: PutItemResponse)

-- | The capacity units consumed by the @PutItem@ operation. The data
-- returned includes the total provisioned throughput consumed, along with
-- statistics for the table and any indexes involved in the operation.
-- @ConsumedCapacity@ is only returned if the @ReturnConsumedCapacity@
-- parameter was specified. For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ProvisionedThroughputIntro.html Read\/Write Capacity Mode>
-- in the /Amazon DynamoDB Developer Guide/.
putItemResponse_consumedCapacity :: Lens.Lens' PutItemResponse (Prelude.Maybe ConsumedCapacity)
putItemResponse_consumedCapacity :: (Maybe ConsumedCapacity -> f (Maybe ConsumedCapacity))
-> PutItemResponse -> f PutItemResponse
putItemResponse_consumedCapacity = (PutItemResponse -> Maybe ConsumedCapacity)
-> (PutItemResponse -> Maybe ConsumedCapacity -> PutItemResponse)
-> Lens
     PutItemResponse
     PutItemResponse
     (Maybe ConsumedCapacity)
     (Maybe ConsumedCapacity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItemResponse' {Maybe ConsumedCapacity
consumedCapacity :: Maybe ConsumedCapacity
$sel:consumedCapacity:PutItemResponse' :: PutItemResponse -> Maybe ConsumedCapacity
consumedCapacity} -> Maybe ConsumedCapacity
consumedCapacity) (\s :: PutItemResponse
s@PutItemResponse' {} Maybe ConsumedCapacity
a -> PutItemResponse
s {$sel:consumedCapacity:PutItemResponse' :: Maybe ConsumedCapacity
consumedCapacity = Maybe ConsumedCapacity
a} :: PutItemResponse)

-- | The attribute values as they appeared before the @PutItem@ operation,
-- but only if @ReturnValues@ is specified as @ALL_OLD@ in the request.
-- Each element consists of an attribute name and an attribute value.
putItemResponse_attributes :: Lens.Lens' PutItemResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue))
putItemResponse_attributes :: (Maybe (HashMap Text AttributeValue)
 -> f (Maybe (HashMap Text AttributeValue)))
-> PutItemResponse -> f PutItemResponse
putItemResponse_attributes = (PutItemResponse -> Maybe (HashMap Text AttributeValue))
-> (PutItemResponse
    -> Maybe (HashMap Text AttributeValue) -> PutItemResponse)
-> Lens
     PutItemResponse
     PutItemResponse
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutItemResponse' {Maybe (HashMap Text AttributeValue)
attributes :: Maybe (HashMap Text AttributeValue)
$sel:attributes:PutItemResponse' :: PutItemResponse -> Maybe (HashMap Text AttributeValue)
attributes} -> Maybe (HashMap Text AttributeValue)
attributes) (\s :: PutItemResponse
s@PutItemResponse' {} Maybe (HashMap Text AttributeValue)
a -> PutItemResponse
s {$sel:attributes:PutItemResponse' :: Maybe (HashMap Text AttributeValue)
attributes = Maybe (HashMap Text AttributeValue)
a} :: PutItemResponse) ((Maybe (HashMap Text AttributeValue)
  -> f (Maybe (HashMap Text AttributeValue)))
 -> PutItemResponse -> f PutItemResponse)
-> ((Maybe (HashMap Text AttributeValue)
     -> f (Maybe (HashMap Text AttributeValue)))
    -> Maybe (HashMap Text AttributeValue)
    -> f (Maybe (HashMap Text AttributeValue)))
-> (Maybe (HashMap Text AttributeValue)
    -> f (Maybe (HashMap Text AttributeValue)))
-> PutItemResponse
-> f PutItemResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
-> Iso
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
     (Maybe (HashMap Text AttributeValue))
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 AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
  (HashMap Text AttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData PutItemResponse