{-# 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.UpdateItem
-- 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)
--
-- Edits an existing item\'s attributes, or adds a new item to the table if
-- it does not already exist. You can put, delete, or add attribute values.
-- You can also perform a conditional update on an existing item (insert a
-- new attribute name-value pair if it doesn\'t exist, or replace an
-- existing name-value pair if it has certain expected attribute values).
--
-- You can also return the item\'s attribute values in the same
-- @UpdateItem@ operation using the @ReturnValues@ parameter.
module Amazonka.DynamoDB.UpdateItem
  ( -- * Creating a Request
    UpdateItem (..),
    newUpdateItem,

    -- * Request Lenses
    updateItem_expressionAttributeNames,
    updateItem_returnValues,
    updateItem_updateExpression,
    updateItem_expressionAttributeValues,
    updateItem_attributeUpdates,
    updateItem_returnConsumedCapacity,
    updateItem_returnItemCollectionMetrics,
    updateItem_conditionExpression,
    updateItem_conditionalOperator,
    updateItem_expected,
    updateItem_tableName,
    updateItem_key,

    -- * Destructuring the Response
    UpdateItemResponse (..),
    newUpdateItemResponse,

    -- * Response Lenses
    updateItemResponse_itemCollectionMetrics,
    updateItemResponse_consumedCapacity,
    updateItemResponse_attributes,
    updateItemResponse_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 an @UpdateItem@ operation.
--
-- /See:/ 'newUpdateItem' smart constructor.
data UpdateItem = UpdateItem'
  { -- | 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 about expression attribute names, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Specifying Item Attributes>
    -- in the /Amazon DynamoDB Developer Guide/.
    UpdateItem -> 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 appear
    -- before or after they are updated. For @UpdateItem@, 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@ - Returns all of the attributes of the item, as they
    --     appeared before the UpdateItem operation.
    --
    -- -   @UPDATED_OLD@ - Returns only the updated attributes, as they
    --     appeared before the UpdateItem operation.
    --
    -- -   @ALL_NEW@ - Returns all of the attributes of the item, as they
    --     appear after the UpdateItem operation.
    --
    -- -   @UPDATED_NEW@ - Returns only the updated attributes, as they appear
    --     after the UpdateItem operation.
    --
    -- There is no additional cost associated with requesting a return value
    -- aside from the small network and processing overhead of receiving a
    -- larger response. No read capacity units are consumed.
    --
    -- The values returned are strongly consistent.
    UpdateItem -> Maybe ReturnValue
returnValues :: Prelude.Maybe ReturnValue,
    -- | An expression that defines one or more attributes to be updated, the
    -- action to be performed on them, and new values for them.
    --
    -- The following action values are available for @UpdateExpression@.
    --
    -- -   @SET@ - Adds one or more attributes and values to an item. If any of
    --     these attributes already exist, they are replaced by the new values.
    --     You can also use @SET@ to add or subtract from an attribute that is
    --     of type Number. For example: @SET myNum = myNum + :val@
    --
    --     @SET@ supports the following functions:
    --
    --     -   @if_not_exists (path, operand)@ - if the item does not contain
    --         an attribute at the specified path, then @if_not_exists@
    --         evaluates to operand; otherwise, it evaluates to path. You can
    --         use this function to avoid overwriting an attribute that may
    --         already be present in the item.
    --
    --     -   @list_append (operand, operand)@ - evaluates to a list with a
    --         new element added to it. You can append the new element to the
    --         start or the end of the list by reversing the order of the
    --         operands.
    --
    --     These function names are case-sensitive.
    --
    -- -   @REMOVE@ - Removes one or more attributes from an item.
    --
    -- -   @ADD@ - Adds the specified value to the item, if the attribute does
    --     not already exist. If the attribute does exist, then the behavior of
    --     @ADD@ depends on the data type of the attribute:
    --
    --     -   If the existing attribute is a number, and if @Value@ is also a
    --         number, then @Value@ is mathematically added to the existing
    --         attribute. If @Value@ is a negative number, then it is
    --         subtracted from the existing attribute.
    --
    --         If you use @ADD@ to increment or decrement a number value for an
    --         item that doesn\'t exist before the update, DynamoDB uses @0@ as
    --         the initial value.
    --
    --         Similarly, if you use @ADD@ for an existing item to increment or
    --         decrement an attribute value that doesn\'t exist before the
    --         update, DynamoDB uses @0@ as the initial value. For example,
    --         suppose that the item you want to update doesn\'t have an
    --         attribute named @itemcount@, but you decide to @ADD@ the number
    --         @3@ to this attribute anyway. DynamoDB will create the
    --         @itemcount@ attribute, set its initial value to @0@, and finally
    --         add @3@ to it. The result will be a new @itemcount@ attribute in
    --         the item, with a value of @3@.
    --
    --     -   If the existing data type is a set and if @Value@ is also a set,
    --         then @Value@ is added to the existing set. For example, if the
    --         attribute value is the set @[1,2]@, and the @ADD@ action
    --         specified @[3]@, then the final attribute value is @[1,2,3]@. An
    --         error occurs if an @ADD@ action is specified for a set attribute
    --         and the attribute type specified does not match the existing set
    --         type.
    --
    --         Both sets must have the same primitive data type. For example,
    --         if the existing data type is a set of strings, the @Value@ must
    --         also be a set of strings.
    --
    --     The @ADD@ action only supports Number and set data types. In
    --     addition, @ADD@ can only be used on top-level attributes, not nested
    --     attributes.
    --
    -- -   @DELETE@ - Deletes an element from a set.
    --
    --     If a set of values is specified, then those values are subtracted
    --     from the old set. For example, if the attribute value was the set
    --     @[a,b,c]@ and the @DELETE@ action specifies @[a,c]@, then the final
    --     attribute value is @[b]@. Specifying an empty set is an error.
    --
    --     The @DELETE@ action only supports set data types. In addition,
    --     @DELETE@ can only be used on top-level attributes, not nested
    --     attributes.
    --
    -- You can have many actions in a single expression, such as the following:
    -- @SET a=:value1, b=:value2 DELETE :value3, :value4, :value5@
    --
    -- For more information on update expressions, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Modifying.html Modifying Items and Attributes>
    -- in the /Amazon DynamoDB Developer Guide/.
    UpdateItem -> Maybe Text
updateExpression :: Prelude.Maybe Prelude.Text,
    -- | 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/.
    UpdateItem -> Maybe (HashMap Text AttributeValue)
expressionAttributeValues :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue),
    -- | This is a legacy parameter. Use @UpdateExpression@ instead. For more
    -- information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.AttributeUpdates.html AttributeUpdates>
    -- in the /Amazon DynamoDB Developer Guide/.
    UpdateItem -> Maybe (HashMap Text AttributeValueUpdate)
attributeUpdates :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValueUpdate),
    UpdateItem -> 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.
    UpdateItem -> Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics :: Prelude.Maybe ReturnItemCollectionMetrics,
    -- | A condition that must be satisfied in order for a conditional update 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 about condition expressions, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html Specifying Conditions>
    -- in the /Amazon DynamoDB Developer Guide/.
    UpdateItem -> 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/.
    UpdateItem -> 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/.
    UpdateItem -> Maybe (HashMap Text ExpectedAttributeValue)
expected :: Prelude.Maybe (Prelude.HashMap Prelude.Text ExpectedAttributeValue),
    -- | The name of the table containing the item to update.
    UpdateItem -> Text
tableName :: Prelude.Text,
    -- | The primary key of the item to be updated. Each element consists of an
    -- attribute name and a value for that attribute.
    --
    -- For the primary key, you must provide all of the 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.
    UpdateItem -> HashMap Text AttributeValue
key :: Prelude.HashMap Prelude.Text AttributeValue
  }
  deriving (UpdateItem -> UpdateItem -> Bool
(UpdateItem -> UpdateItem -> Bool)
-> (UpdateItem -> UpdateItem -> Bool) -> Eq UpdateItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateItem -> UpdateItem -> Bool
$c/= :: UpdateItem -> UpdateItem -> Bool
== :: UpdateItem -> UpdateItem -> Bool
$c== :: UpdateItem -> UpdateItem -> Bool
Prelude.Eq, ReadPrec [UpdateItem]
ReadPrec UpdateItem
Int -> ReadS UpdateItem
ReadS [UpdateItem]
(Int -> ReadS UpdateItem)
-> ReadS [UpdateItem]
-> ReadPrec UpdateItem
-> ReadPrec [UpdateItem]
-> Read UpdateItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateItem]
$creadListPrec :: ReadPrec [UpdateItem]
readPrec :: ReadPrec UpdateItem
$creadPrec :: ReadPrec UpdateItem
readList :: ReadS [UpdateItem]
$creadList :: ReadS [UpdateItem]
readsPrec :: Int -> ReadS UpdateItem
$creadsPrec :: Int -> ReadS UpdateItem
Prelude.Read, Int -> UpdateItem -> ShowS
[UpdateItem] -> ShowS
UpdateItem -> String
(Int -> UpdateItem -> ShowS)
-> (UpdateItem -> String)
-> ([UpdateItem] -> ShowS)
-> Show UpdateItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateItem] -> ShowS
$cshowList :: [UpdateItem] -> ShowS
show :: UpdateItem -> String
$cshow :: UpdateItem -> String
showsPrec :: Int -> UpdateItem -> ShowS
$cshowsPrec :: Int -> UpdateItem -> ShowS
Prelude.Show, (forall x. UpdateItem -> Rep UpdateItem x)
-> (forall x. Rep UpdateItem x -> UpdateItem) -> Generic UpdateItem
forall x. Rep UpdateItem x -> UpdateItem
forall x. UpdateItem -> Rep UpdateItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateItem x -> UpdateItem
$cfrom :: forall x. UpdateItem -> Rep UpdateItem x
Prelude.Generic)

-- |
-- Create a value of 'UpdateItem' 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', 'updateItem_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 about 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', 'updateItem_returnValues' - Use @ReturnValues@ if you want to get the item attributes as they appear
-- before or after they are updated. For @UpdateItem@, 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@ - Returns all of the attributes of the item, as they
--     appeared before the UpdateItem operation.
--
-- -   @UPDATED_OLD@ - Returns only the updated attributes, as they
--     appeared before the UpdateItem operation.
--
-- -   @ALL_NEW@ - Returns all of the attributes of the item, as they
--     appear after the UpdateItem operation.
--
-- -   @UPDATED_NEW@ - Returns only the updated attributes, as they appear
--     after the UpdateItem operation.
--
-- There is no additional cost associated with requesting a return value
-- aside from the small network and processing overhead of receiving a
-- larger response. No read capacity units are consumed.
--
-- The values returned are strongly consistent.
--
-- 'updateExpression', 'updateItem_updateExpression' - An expression that defines one or more attributes to be updated, the
-- action to be performed on them, and new values for them.
--
-- The following action values are available for @UpdateExpression@.
--
-- -   @SET@ - Adds one or more attributes and values to an item. If any of
--     these attributes already exist, they are replaced by the new values.
--     You can also use @SET@ to add or subtract from an attribute that is
--     of type Number. For example: @SET myNum = myNum + :val@
--
--     @SET@ supports the following functions:
--
--     -   @if_not_exists (path, operand)@ - if the item does not contain
--         an attribute at the specified path, then @if_not_exists@
--         evaluates to operand; otherwise, it evaluates to path. You can
--         use this function to avoid overwriting an attribute that may
--         already be present in the item.
--
--     -   @list_append (operand, operand)@ - evaluates to a list with a
--         new element added to it. You can append the new element to the
--         start or the end of the list by reversing the order of the
--         operands.
--
--     These function names are case-sensitive.
--
-- -   @REMOVE@ - Removes one or more attributes from an item.
--
-- -   @ADD@ - Adds the specified value to the item, if the attribute does
--     not already exist. If the attribute does exist, then the behavior of
--     @ADD@ depends on the data type of the attribute:
--
--     -   If the existing attribute is a number, and if @Value@ is also a
--         number, then @Value@ is mathematically added to the existing
--         attribute. If @Value@ is a negative number, then it is
--         subtracted from the existing attribute.
--
--         If you use @ADD@ to increment or decrement a number value for an
--         item that doesn\'t exist before the update, DynamoDB uses @0@ as
--         the initial value.
--
--         Similarly, if you use @ADD@ for an existing item to increment or
--         decrement an attribute value that doesn\'t exist before the
--         update, DynamoDB uses @0@ as the initial value. For example,
--         suppose that the item you want to update doesn\'t have an
--         attribute named @itemcount@, but you decide to @ADD@ the number
--         @3@ to this attribute anyway. DynamoDB will create the
--         @itemcount@ attribute, set its initial value to @0@, and finally
--         add @3@ to it. The result will be a new @itemcount@ attribute in
--         the item, with a value of @3@.
--
--     -   If the existing data type is a set and if @Value@ is also a set,
--         then @Value@ is added to the existing set. For example, if the
--         attribute value is the set @[1,2]@, and the @ADD@ action
--         specified @[3]@, then the final attribute value is @[1,2,3]@. An
--         error occurs if an @ADD@ action is specified for a set attribute
--         and the attribute type specified does not match the existing set
--         type.
--
--         Both sets must have the same primitive data type. For example,
--         if the existing data type is a set of strings, the @Value@ must
--         also be a set of strings.
--
--     The @ADD@ action only supports Number and set data types. In
--     addition, @ADD@ can only be used on top-level attributes, not nested
--     attributes.
--
-- -   @DELETE@ - Deletes an element from a set.
--
--     If a set of values is specified, then those values are subtracted
--     from the old set. For example, if the attribute value was the set
--     @[a,b,c]@ and the @DELETE@ action specifies @[a,c]@, then the final
--     attribute value is @[b]@. Specifying an empty set is an error.
--
--     The @DELETE@ action only supports set data types. In addition,
--     @DELETE@ can only be used on top-level attributes, not nested
--     attributes.
--
-- You can have many actions in a single expression, such as the following:
-- @SET a=:value1, b=:value2 DELETE :value3, :value4, :value5@
--
-- For more information on update expressions, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Modifying.html Modifying Items and Attributes>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'expressionAttributeValues', 'updateItem_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/.
--
-- 'attributeUpdates', 'updateItem_attributeUpdates' - This is a legacy parameter. Use @UpdateExpression@ instead. For more
-- information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.AttributeUpdates.html AttributeUpdates>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'returnConsumedCapacity', 'updateItem_returnConsumedCapacity' - Undocumented member.
--
-- 'returnItemCollectionMetrics', 'updateItem_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', 'updateItem_conditionExpression' - A condition that must be satisfied in order for a conditional update 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 about condition expressions, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html Specifying Conditions>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'conditionalOperator', 'updateItem_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', 'updateItem_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', 'updateItem_tableName' - The name of the table containing the item to update.
--
-- 'key', 'updateItem_key' - The primary key of the item to be updated. Each element consists of an
-- attribute name and a value for that attribute.
--
-- For the primary key, you must provide all of the 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.
newUpdateItem ::
  -- | 'tableName'
  Prelude.Text ->
  UpdateItem
newUpdateItem :: Text -> UpdateItem
newUpdateItem Text
pTableName_ =
  UpdateItem' :: Maybe (HashMap Text Text)
-> Maybe ReturnValue
-> Maybe Text
-> Maybe (HashMap Text AttributeValue)
-> Maybe (HashMap Text AttributeValueUpdate)
-> Maybe ReturnConsumedCapacity
-> Maybe ReturnItemCollectionMetrics
-> Maybe Text
-> Maybe ConditionalOperator
-> Maybe (HashMap Text ExpectedAttributeValue)
-> Text
-> HashMap Text AttributeValue
-> UpdateItem
UpdateItem'
    { $sel:expressionAttributeNames:UpdateItem' :: Maybe (HashMap Text Text)
expressionAttributeNames =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:returnValues:UpdateItem' :: Maybe ReturnValue
returnValues = Maybe ReturnValue
forall a. Maybe a
Prelude.Nothing,
      $sel:updateExpression:UpdateItem' :: Maybe Text
updateExpression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expressionAttributeValues:UpdateItem' :: Maybe (HashMap Text AttributeValue)
expressionAttributeValues = Maybe (HashMap Text AttributeValue)
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeUpdates:UpdateItem' :: Maybe (HashMap Text AttributeValueUpdate)
attributeUpdates = Maybe (HashMap Text AttributeValueUpdate)
forall a. Maybe a
Prelude.Nothing,
      $sel:returnConsumedCapacity:UpdateItem' :: Maybe ReturnConsumedCapacity
returnConsumedCapacity = Maybe ReturnConsumedCapacity
forall a. Maybe a
Prelude.Nothing,
      $sel:returnItemCollectionMetrics:UpdateItem' :: Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics = Maybe ReturnItemCollectionMetrics
forall a. Maybe a
Prelude.Nothing,
      $sel:conditionExpression:UpdateItem' :: Maybe Text
conditionExpression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:conditionalOperator:UpdateItem' :: Maybe ConditionalOperator
conditionalOperator = Maybe ConditionalOperator
forall a. Maybe a
Prelude.Nothing,
      $sel:expected:UpdateItem' :: Maybe (HashMap Text ExpectedAttributeValue)
expected = Maybe (HashMap Text ExpectedAttributeValue)
forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:UpdateItem' :: Text
tableName = Text
pTableName_,
      $sel:key:UpdateItem' :: HashMap Text AttributeValue
key = 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 about expression attribute names, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Specifying Item Attributes>
-- in the /Amazon DynamoDB Developer Guide/.
updateItem_expressionAttributeNames :: Lens.Lens' UpdateItem (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
updateItem_expressionAttributeNames :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> UpdateItem -> f UpdateItem
updateItem_expressionAttributeNames = (UpdateItem -> Maybe (HashMap Text Text))
-> (UpdateItem -> Maybe (HashMap Text Text) -> UpdateItem)
-> Lens
     UpdateItem
     UpdateItem
     (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 (\UpdateItem' {Maybe (HashMap Text Text)
expressionAttributeNames :: Maybe (HashMap Text Text)
$sel:expressionAttributeNames:UpdateItem' :: UpdateItem -> Maybe (HashMap Text Text)
expressionAttributeNames} -> Maybe (HashMap Text Text)
expressionAttributeNames) (\s :: UpdateItem
s@UpdateItem' {} Maybe (HashMap Text Text)
a -> UpdateItem
s {$sel:expressionAttributeNames:UpdateItem' :: Maybe (HashMap Text Text)
expressionAttributeNames = Maybe (HashMap Text Text)
a} :: UpdateItem) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> UpdateItem -> f UpdateItem)
-> ((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)))
-> UpdateItem
-> f UpdateItem
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 appear
-- before or after they are updated. For @UpdateItem@, 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@ - Returns all of the attributes of the item, as they
--     appeared before the UpdateItem operation.
--
-- -   @UPDATED_OLD@ - Returns only the updated attributes, as they
--     appeared before the UpdateItem operation.
--
-- -   @ALL_NEW@ - Returns all of the attributes of the item, as they
--     appear after the UpdateItem operation.
--
-- -   @UPDATED_NEW@ - Returns only the updated attributes, as they appear
--     after the UpdateItem operation.
--
-- There is no additional cost associated with requesting a return value
-- aside from the small network and processing overhead of receiving a
-- larger response. No read capacity units are consumed.
--
-- The values returned are strongly consistent.
updateItem_returnValues :: Lens.Lens' UpdateItem (Prelude.Maybe ReturnValue)
updateItem_returnValues :: (Maybe ReturnValue -> f (Maybe ReturnValue))
-> UpdateItem -> f UpdateItem
updateItem_returnValues = (UpdateItem -> Maybe ReturnValue)
-> (UpdateItem -> Maybe ReturnValue -> UpdateItem)
-> Lens
     UpdateItem UpdateItem (Maybe ReturnValue) (Maybe ReturnValue)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateItem' {Maybe ReturnValue
returnValues :: Maybe ReturnValue
$sel:returnValues:UpdateItem' :: UpdateItem -> Maybe ReturnValue
returnValues} -> Maybe ReturnValue
returnValues) (\s :: UpdateItem
s@UpdateItem' {} Maybe ReturnValue
a -> UpdateItem
s {$sel:returnValues:UpdateItem' :: Maybe ReturnValue
returnValues = Maybe ReturnValue
a} :: UpdateItem)

-- | An expression that defines one or more attributes to be updated, the
-- action to be performed on them, and new values for them.
--
-- The following action values are available for @UpdateExpression@.
--
-- -   @SET@ - Adds one or more attributes and values to an item. If any of
--     these attributes already exist, they are replaced by the new values.
--     You can also use @SET@ to add or subtract from an attribute that is
--     of type Number. For example: @SET myNum = myNum + :val@
--
--     @SET@ supports the following functions:
--
--     -   @if_not_exists (path, operand)@ - if the item does not contain
--         an attribute at the specified path, then @if_not_exists@
--         evaluates to operand; otherwise, it evaluates to path. You can
--         use this function to avoid overwriting an attribute that may
--         already be present in the item.
--
--     -   @list_append (operand, operand)@ - evaluates to a list with a
--         new element added to it. You can append the new element to the
--         start or the end of the list by reversing the order of the
--         operands.
--
--     These function names are case-sensitive.
--
-- -   @REMOVE@ - Removes one or more attributes from an item.
--
-- -   @ADD@ - Adds the specified value to the item, if the attribute does
--     not already exist. If the attribute does exist, then the behavior of
--     @ADD@ depends on the data type of the attribute:
--
--     -   If the existing attribute is a number, and if @Value@ is also a
--         number, then @Value@ is mathematically added to the existing
--         attribute. If @Value@ is a negative number, then it is
--         subtracted from the existing attribute.
--
--         If you use @ADD@ to increment or decrement a number value for an
--         item that doesn\'t exist before the update, DynamoDB uses @0@ as
--         the initial value.
--
--         Similarly, if you use @ADD@ for an existing item to increment or
--         decrement an attribute value that doesn\'t exist before the
--         update, DynamoDB uses @0@ as the initial value. For example,
--         suppose that the item you want to update doesn\'t have an
--         attribute named @itemcount@, but you decide to @ADD@ the number
--         @3@ to this attribute anyway. DynamoDB will create the
--         @itemcount@ attribute, set its initial value to @0@, and finally
--         add @3@ to it. The result will be a new @itemcount@ attribute in
--         the item, with a value of @3@.
--
--     -   If the existing data type is a set and if @Value@ is also a set,
--         then @Value@ is added to the existing set. For example, if the
--         attribute value is the set @[1,2]@, and the @ADD@ action
--         specified @[3]@, then the final attribute value is @[1,2,3]@. An
--         error occurs if an @ADD@ action is specified for a set attribute
--         and the attribute type specified does not match the existing set
--         type.
--
--         Both sets must have the same primitive data type. For example,
--         if the existing data type is a set of strings, the @Value@ must
--         also be a set of strings.
--
--     The @ADD@ action only supports Number and set data types. In
--     addition, @ADD@ can only be used on top-level attributes, not nested
--     attributes.
--
-- -   @DELETE@ - Deletes an element from a set.
--
--     If a set of values is specified, then those values are subtracted
--     from the old set. For example, if the attribute value was the set
--     @[a,b,c]@ and the @DELETE@ action specifies @[a,c]@, then the final
--     attribute value is @[b]@. Specifying an empty set is an error.
--
--     The @DELETE@ action only supports set data types. In addition,
--     @DELETE@ can only be used on top-level attributes, not nested
--     attributes.
--
-- You can have many actions in a single expression, such as the following:
-- @SET a=:value1, b=:value2 DELETE :value3, :value4, :value5@
--
-- For more information on update expressions, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Modifying.html Modifying Items and Attributes>
-- in the /Amazon DynamoDB Developer Guide/.
updateItem_updateExpression :: Lens.Lens' UpdateItem (Prelude.Maybe Prelude.Text)
updateItem_updateExpression :: (Maybe Text -> f (Maybe Text)) -> UpdateItem -> f UpdateItem
updateItem_updateExpression = (UpdateItem -> Maybe Text)
-> (UpdateItem -> Maybe Text -> UpdateItem)
-> Lens UpdateItem UpdateItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateItem' {Maybe Text
updateExpression :: Maybe Text
$sel:updateExpression:UpdateItem' :: UpdateItem -> Maybe Text
updateExpression} -> Maybe Text
updateExpression) (\s :: UpdateItem
s@UpdateItem' {} Maybe Text
a -> UpdateItem
s {$sel:updateExpression:UpdateItem' :: Maybe Text
updateExpression = Maybe Text
a} :: UpdateItem)

-- | 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/.
updateItem_expressionAttributeValues :: Lens.Lens' UpdateItem (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue))
updateItem_expressionAttributeValues :: (Maybe (HashMap Text AttributeValue)
 -> f (Maybe (HashMap Text AttributeValue)))
-> UpdateItem -> f UpdateItem
updateItem_expressionAttributeValues = (UpdateItem -> Maybe (HashMap Text AttributeValue))
-> (UpdateItem
    -> Maybe (HashMap Text AttributeValue) -> UpdateItem)
-> Lens
     UpdateItem
     UpdateItem
     (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 (\UpdateItem' {Maybe (HashMap Text AttributeValue)
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
$sel:expressionAttributeValues:UpdateItem' :: UpdateItem -> Maybe (HashMap Text AttributeValue)
expressionAttributeValues} -> Maybe (HashMap Text AttributeValue)
expressionAttributeValues) (\s :: UpdateItem
s@UpdateItem' {} Maybe (HashMap Text AttributeValue)
a -> UpdateItem
s {$sel:expressionAttributeValues:UpdateItem' :: Maybe (HashMap Text AttributeValue)
expressionAttributeValues = Maybe (HashMap Text AttributeValue)
a} :: UpdateItem) ((Maybe (HashMap Text AttributeValue)
  -> f (Maybe (HashMap Text AttributeValue)))
 -> UpdateItem -> f UpdateItem)
-> ((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)))
-> UpdateItem
-> f UpdateItem
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

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

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

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

-- | A condition that must be satisfied in order for a conditional update 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 about condition expressions, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html Specifying Conditions>
-- in the /Amazon DynamoDB Developer Guide/.
updateItem_conditionExpression :: Lens.Lens' UpdateItem (Prelude.Maybe Prelude.Text)
updateItem_conditionExpression :: (Maybe Text -> f (Maybe Text)) -> UpdateItem -> f UpdateItem
updateItem_conditionExpression = (UpdateItem -> Maybe Text)
-> (UpdateItem -> Maybe Text -> UpdateItem)
-> Lens UpdateItem UpdateItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateItem' {Maybe Text
conditionExpression :: Maybe Text
$sel:conditionExpression:UpdateItem' :: UpdateItem -> Maybe Text
conditionExpression} -> Maybe Text
conditionExpression) (\s :: UpdateItem
s@UpdateItem' {} Maybe Text
a -> UpdateItem
s {$sel:conditionExpression:UpdateItem' :: Maybe Text
conditionExpression = Maybe Text
a} :: UpdateItem)

-- | 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/.
updateItem_conditionalOperator :: Lens.Lens' UpdateItem (Prelude.Maybe ConditionalOperator)
updateItem_conditionalOperator :: (Maybe ConditionalOperator -> f (Maybe ConditionalOperator))
-> UpdateItem -> f UpdateItem
updateItem_conditionalOperator = (UpdateItem -> Maybe ConditionalOperator)
-> (UpdateItem -> Maybe ConditionalOperator -> UpdateItem)
-> Lens
     UpdateItem
     UpdateItem
     (Maybe ConditionalOperator)
     (Maybe ConditionalOperator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateItem' {Maybe ConditionalOperator
conditionalOperator :: Maybe ConditionalOperator
$sel:conditionalOperator:UpdateItem' :: UpdateItem -> Maybe ConditionalOperator
conditionalOperator} -> Maybe ConditionalOperator
conditionalOperator) (\s :: UpdateItem
s@UpdateItem' {} Maybe ConditionalOperator
a -> UpdateItem
s {$sel:conditionalOperator:UpdateItem' :: Maybe ConditionalOperator
conditionalOperator = Maybe ConditionalOperator
a} :: UpdateItem)

-- | 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/.
updateItem_expected :: Lens.Lens' UpdateItem (Prelude.Maybe (Prelude.HashMap Prelude.Text ExpectedAttributeValue))
updateItem_expected :: (Maybe (HashMap Text ExpectedAttributeValue)
 -> f (Maybe (HashMap Text ExpectedAttributeValue)))
-> UpdateItem -> f UpdateItem
updateItem_expected = (UpdateItem -> Maybe (HashMap Text ExpectedAttributeValue))
-> (UpdateItem
    -> Maybe (HashMap Text ExpectedAttributeValue) -> UpdateItem)
-> Lens
     UpdateItem
     UpdateItem
     (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 (\UpdateItem' {Maybe (HashMap Text ExpectedAttributeValue)
expected :: Maybe (HashMap Text ExpectedAttributeValue)
$sel:expected:UpdateItem' :: UpdateItem -> Maybe (HashMap Text ExpectedAttributeValue)
expected} -> Maybe (HashMap Text ExpectedAttributeValue)
expected) (\s :: UpdateItem
s@UpdateItem' {} Maybe (HashMap Text ExpectedAttributeValue)
a -> UpdateItem
s {$sel:expected:UpdateItem' :: Maybe (HashMap Text ExpectedAttributeValue)
expected = Maybe (HashMap Text ExpectedAttributeValue)
a} :: UpdateItem) ((Maybe (HashMap Text ExpectedAttributeValue)
  -> f (Maybe (HashMap Text ExpectedAttributeValue)))
 -> UpdateItem -> f UpdateItem)
-> ((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)))
-> UpdateItem
-> f UpdateItem
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 containing the item to update.
updateItem_tableName :: Lens.Lens' UpdateItem Prelude.Text
updateItem_tableName :: (Text -> f Text) -> UpdateItem -> f UpdateItem
updateItem_tableName = (UpdateItem -> Text)
-> (UpdateItem -> Text -> UpdateItem)
-> Lens UpdateItem UpdateItem Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateItem' {Text
tableName :: Text
$sel:tableName:UpdateItem' :: UpdateItem -> Text
tableName} -> Text
tableName) (\s :: UpdateItem
s@UpdateItem' {} Text
a -> UpdateItem
s {$sel:tableName:UpdateItem' :: Text
tableName = Text
a} :: UpdateItem)

-- | The primary key of the item to be updated. Each element consists of an
-- attribute name and a value for that attribute.
--
-- For the primary key, you must provide all of the 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.
updateItem_key :: Lens.Lens' UpdateItem (Prelude.HashMap Prelude.Text AttributeValue)
updateItem_key :: (HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> UpdateItem -> f UpdateItem
updateItem_key = (UpdateItem -> HashMap Text AttributeValue)
-> (UpdateItem -> HashMap Text AttributeValue -> UpdateItem)
-> Lens
     UpdateItem
     UpdateItem
     (HashMap Text AttributeValue)
     (HashMap Text AttributeValue)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateItem' {HashMap Text AttributeValue
key :: HashMap Text AttributeValue
$sel:key:UpdateItem' :: UpdateItem -> HashMap Text AttributeValue
key} -> HashMap Text AttributeValue
key) (\s :: UpdateItem
s@UpdateItem' {} HashMap Text AttributeValue
a -> UpdateItem
s {$sel:key:UpdateItem' :: HashMap Text AttributeValue
key = HashMap Text AttributeValue
a} :: UpdateItem) ((HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
 -> UpdateItem -> f UpdateItem)
-> ((HashMap Text AttributeValue
     -> f (HashMap Text AttributeValue))
    -> HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> (HashMap Text AttributeValue -> f (HashMap Text AttributeValue))
-> UpdateItem
-> f UpdateItem
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 UpdateItem where
  type AWSResponse UpdateItem = UpdateItemResponse
  request :: UpdateItem -> Request UpdateItem
request = Service -> UpdateItem -> Request UpdateItem
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateItem
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateItem)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateItem))
-> Logger
-> Service
-> Proxy UpdateItem
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateItem)))
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
-> UpdateItemResponse
UpdateItemResponse'
            (Maybe ItemCollectionMetrics
 -> Maybe ConsumedCapacity
 -> Maybe (HashMap Text AttributeValue)
 -> Int
 -> UpdateItemResponse)
-> Either String (Maybe ItemCollectionMetrics)
-> Either
     String
     (Maybe ConsumedCapacity
      -> Maybe (HashMap Text AttributeValue)
      -> Int
      -> UpdateItemResponse)
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
   -> UpdateItemResponse)
-> Either String (Maybe ConsumedCapacity)
-> Either
     String
     (Maybe (HashMap Text AttributeValue) -> Int -> UpdateItemResponse)
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 -> UpdateItemResponse)
-> Either String (Maybe (HashMap Text AttributeValue))
-> Either String (Int -> UpdateItemResponse)
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 -> UpdateItemResponse)
-> Either String Int -> Either String UpdateItemResponse
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 UpdateItem

instance Prelude.NFData UpdateItem

instance Core.ToHeaders UpdateItem where
  toHeaders :: UpdateItem -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateItem -> 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.UpdateItem" ::
                          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 UpdateItem where
  toJSON :: UpdateItem -> Value
toJSON UpdateItem' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text AttributeValue)
Maybe (HashMap Text AttributeValueUpdate)
Maybe (HashMap Text ExpectedAttributeValue)
Maybe ConditionalOperator
Maybe ReturnConsumedCapacity
Maybe ReturnItemCollectionMetrics
Maybe ReturnValue
Text
HashMap Text AttributeValue
key :: HashMap Text AttributeValue
tableName :: Text
expected :: Maybe (HashMap Text ExpectedAttributeValue)
conditionalOperator :: Maybe ConditionalOperator
conditionExpression :: Maybe Text
returnItemCollectionMetrics :: Maybe ReturnItemCollectionMetrics
returnConsumedCapacity :: Maybe ReturnConsumedCapacity
attributeUpdates :: Maybe (HashMap Text AttributeValueUpdate)
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
updateExpression :: Maybe Text
returnValues :: Maybe ReturnValue
expressionAttributeNames :: Maybe (HashMap Text Text)
$sel:key:UpdateItem' :: UpdateItem -> HashMap Text AttributeValue
$sel:tableName:UpdateItem' :: UpdateItem -> Text
$sel:expected:UpdateItem' :: UpdateItem -> Maybe (HashMap Text ExpectedAttributeValue)
$sel:conditionalOperator:UpdateItem' :: UpdateItem -> Maybe ConditionalOperator
$sel:conditionExpression:UpdateItem' :: UpdateItem -> Maybe Text
$sel:returnItemCollectionMetrics:UpdateItem' :: UpdateItem -> Maybe ReturnItemCollectionMetrics
$sel:returnConsumedCapacity:UpdateItem' :: UpdateItem -> Maybe ReturnConsumedCapacity
$sel:attributeUpdates:UpdateItem' :: UpdateItem -> Maybe (HashMap Text AttributeValueUpdate)
$sel:expressionAttributeValues:UpdateItem' :: UpdateItem -> Maybe (HashMap Text AttributeValue)
$sel:updateExpression:UpdateItem' :: UpdateItem -> Maybe Text
$sel:returnValues:UpdateItem' :: UpdateItem -> Maybe ReturnValue
$sel:expressionAttributeNames:UpdateItem' :: UpdateItem -> 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
"UpdateExpression" 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
updateExpression,
            (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
"AttributeUpdates" Text -> HashMap Text AttributeValueUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text AttributeValueUpdate -> Pair)
-> Maybe (HashMap Text AttributeValueUpdate) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text AttributeValueUpdate)
attributeUpdates,
            (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
"Key" Text -> HashMap Text AttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text AttributeValue
key)
          ]
      )

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

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

-- | Represents the output of an @UpdateItem@ operation.
--
-- /See:/ 'newUpdateItemResponse' smart constructor.
data UpdateItemResponse = UpdateItemResponse'
  { -- | Information about item collections, if any, that were affected by the
    -- @UpdateItem@ 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.
    UpdateItemResponse -> Maybe ItemCollectionMetrics
itemCollectionMetrics :: Prelude.Maybe ItemCollectionMetrics,
    -- | The capacity units consumed by the @UpdateItem@ 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 Provisioned Throughput>
    -- in the /Amazon DynamoDB Developer Guide/.
    UpdateItemResponse -> Maybe ConsumedCapacity
consumedCapacity :: Prelude.Maybe ConsumedCapacity,
    -- | A map of attribute values as they appear before or after the
    -- @UpdateItem@ operation, as determined by the @ReturnValues@ parameter.
    --
    -- The @Attributes@ map is only present if @ReturnValues@ was specified as
    -- something other than @NONE@ in the request. Each element represents one
    -- attribute.
    UpdateItemResponse -> Maybe (HashMap Text AttributeValue)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue),
    -- | The response's http status code.
    UpdateItemResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateItemResponse -> UpdateItemResponse -> Bool
(UpdateItemResponse -> UpdateItemResponse -> Bool)
-> (UpdateItemResponse -> UpdateItemResponse -> Bool)
-> Eq UpdateItemResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateItemResponse -> UpdateItemResponse -> Bool
$c/= :: UpdateItemResponse -> UpdateItemResponse -> Bool
== :: UpdateItemResponse -> UpdateItemResponse -> Bool
$c== :: UpdateItemResponse -> UpdateItemResponse -> Bool
Prelude.Eq, ReadPrec [UpdateItemResponse]
ReadPrec UpdateItemResponse
Int -> ReadS UpdateItemResponse
ReadS [UpdateItemResponse]
(Int -> ReadS UpdateItemResponse)
-> ReadS [UpdateItemResponse]
-> ReadPrec UpdateItemResponse
-> ReadPrec [UpdateItemResponse]
-> Read UpdateItemResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateItemResponse]
$creadListPrec :: ReadPrec [UpdateItemResponse]
readPrec :: ReadPrec UpdateItemResponse
$creadPrec :: ReadPrec UpdateItemResponse
readList :: ReadS [UpdateItemResponse]
$creadList :: ReadS [UpdateItemResponse]
readsPrec :: Int -> ReadS UpdateItemResponse
$creadsPrec :: Int -> ReadS UpdateItemResponse
Prelude.Read, Int -> UpdateItemResponse -> ShowS
[UpdateItemResponse] -> ShowS
UpdateItemResponse -> String
(Int -> UpdateItemResponse -> ShowS)
-> (UpdateItemResponse -> String)
-> ([UpdateItemResponse] -> ShowS)
-> Show UpdateItemResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateItemResponse] -> ShowS
$cshowList :: [UpdateItemResponse] -> ShowS
show :: UpdateItemResponse -> String
$cshow :: UpdateItemResponse -> String
showsPrec :: Int -> UpdateItemResponse -> ShowS
$cshowsPrec :: Int -> UpdateItemResponse -> ShowS
Prelude.Show, (forall x. UpdateItemResponse -> Rep UpdateItemResponse x)
-> (forall x. Rep UpdateItemResponse x -> UpdateItemResponse)
-> Generic UpdateItemResponse
forall x. Rep UpdateItemResponse x -> UpdateItemResponse
forall x. UpdateItemResponse -> Rep UpdateItemResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateItemResponse x -> UpdateItemResponse
$cfrom :: forall x. UpdateItemResponse -> Rep UpdateItemResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateItemResponse' 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', 'updateItemResponse_itemCollectionMetrics' - Information about item collections, if any, that were affected by the
-- @UpdateItem@ 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', 'updateItemResponse_consumedCapacity' - The capacity units consumed by the @UpdateItem@ 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 Provisioned Throughput>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'attributes', 'updateItemResponse_attributes' - A map of attribute values as they appear before or after the
-- @UpdateItem@ operation, as determined by the @ReturnValues@ parameter.
--
-- The @Attributes@ map is only present if @ReturnValues@ was specified as
-- something other than @NONE@ in the request. Each element represents one
-- attribute.
--
-- 'httpStatus', 'updateItemResponse_httpStatus' - The response's http status code.
newUpdateItemResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateItemResponse
newUpdateItemResponse :: Int -> UpdateItemResponse
newUpdateItemResponse Int
pHttpStatus_ =
  UpdateItemResponse' :: Maybe ItemCollectionMetrics
-> Maybe ConsumedCapacity
-> Maybe (HashMap Text AttributeValue)
-> Int
-> UpdateItemResponse
UpdateItemResponse'
    { $sel:itemCollectionMetrics:UpdateItemResponse' :: Maybe ItemCollectionMetrics
itemCollectionMetrics =
        Maybe ItemCollectionMetrics
forall a. Maybe a
Prelude.Nothing,
      $sel:consumedCapacity:UpdateItemResponse' :: Maybe ConsumedCapacity
consumedCapacity = Maybe ConsumedCapacity
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:UpdateItemResponse' :: Maybe (HashMap Text AttributeValue)
attributes = Maybe (HashMap Text AttributeValue)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateItemResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about item collections, if any, that were affected by the
-- @UpdateItem@ 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.
updateItemResponse_itemCollectionMetrics :: Lens.Lens' UpdateItemResponse (Prelude.Maybe ItemCollectionMetrics)
updateItemResponse_itemCollectionMetrics :: (Maybe ItemCollectionMetrics -> f (Maybe ItemCollectionMetrics))
-> UpdateItemResponse -> f UpdateItemResponse
updateItemResponse_itemCollectionMetrics = (UpdateItemResponse -> Maybe ItemCollectionMetrics)
-> (UpdateItemResponse
    -> Maybe ItemCollectionMetrics -> UpdateItemResponse)
-> Lens
     UpdateItemResponse
     UpdateItemResponse
     (Maybe ItemCollectionMetrics)
     (Maybe ItemCollectionMetrics)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateItemResponse' {Maybe ItemCollectionMetrics
itemCollectionMetrics :: Maybe ItemCollectionMetrics
$sel:itemCollectionMetrics:UpdateItemResponse' :: UpdateItemResponse -> Maybe ItemCollectionMetrics
itemCollectionMetrics} -> Maybe ItemCollectionMetrics
itemCollectionMetrics) (\s :: UpdateItemResponse
s@UpdateItemResponse' {} Maybe ItemCollectionMetrics
a -> UpdateItemResponse
s {$sel:itemCollectionMetrics:UpdateItemResponse' :: Maybe ItemCollectionMetrics
itemCollectionMetrics = Maybe ItemCollectionMetrics
a} :: UpdateItemResponse)

-- | The capacity units consumed by the @UpdateItem@ 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 Provisioned Throughput>
-- in the /Amazon DynamoDB Developer Guide/.
updateItemResponse_consumedCapacity :: Lens.Lens' UpdateItemResponse (Prelude.Maybe ConsumedCapacity)
updateItemResponse_consumedCapacity :: (Maybe ConsumedCapacity -> f (Maybe ConsumedCapacity))
-> UpdateItemResponse -> f UpdateItemResponse
updateItemResponse_consumedCapacity = (UpdateItemResponse -> Maybe ConsumedCapacity)
-> (UpdateItemResponse
    -> Maybe ConsumedCapacity -> UpdateItemResponse)
-> Lens
     UpdateItemResponse
     UpdateItemResponse
     (Maybe ConsumedCapacity)
     (Maybe ConsumedCapacity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateItemResponse' {Maybe ConsumedCapacity
consumedCapacity :: Maybe ConsumedCapacity
$sel:consumedCapacity:UpdateItemResponse' :: UpdateItemResponse -> Maybe ConsumedCapacity
consumedCapacity} -> Maybe ConsumedCapacity
consumedCapacity) (\s :: UpdateItemResponse
s@UpdateItemResponse' {} Maybe ConsumedCapacity
a -> UpdateItemResponse
s {$sel:consumedCapacity:UpdateItemResponse' :: Maybe ConsumedCapacity
consumedCapacity = Maybe ConsumedCapacity
a} :: UpdateItemResponse)

-- | A map of attribute values as they appear before or after the
-- @UpdateItem@ operation, as determined by the @ReturnValues@ parameter.
--
-- The @Attributes@ map is only present if @ReturnValues@ was specified as
-- something other than @NONE@ in the request. Each element represents one
-- attribute.
updateItemResponse_attributes :: Lens.Lens' UpdateItemResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue))
updateItemResponse_attributes :: (Maybe (HashMap Text AttributeValue)
 -> f (Maybe (HashMap Text AttributeValue)))
-> UpdateItemResponse -> f UpdateItemResponse
updateItemResponse_attributes = (UpdateItemResponse -> Maybe (HashMap Text AttributeValue))
-> (UpdateItemResponse
    -> Maybe (HashMap Text AttributeValue) -> UpdateItemResponse)
-> Lens
     UpdateItemResponse
     UpdateItemResponse
     (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 (\UpdateItemResponse' {Maybe (HashMap Text AttributeValue)
attributes :: Maybe (HashMap Text AttributeValue)
$sel:attributes:UpdateItemResponse' :: UpdateItemResponse -> Maybe (HashMap Text AttributeValue)
attributes} -> Maybe (HashMap Text AttributeValue)
attributes) (\s :: UpdateItemResponse
s@UpdateItemResponse' {} Maybe (HashMap Text AttributeValue)
a -> UpdateItemResponse
s {$sel:attributes:UpdateItemResponse' :: Maybe (HashMap Text AttributeValue)
attributes = Maybe (HashMap Text AttributeValue)
a} :: UpdateItemResponse) ((Maybe (HashMap Text AttributeValue)
  -> f (Maybe (HashMap Text AttributeValue)))
 -> UpdateItemResponse -> f UpdateItemResponse)
-> ((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)))
-> UpdateItemResponse
-> f UpdateItemResponse
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.
updateItemResponse_httpStatus :: Lens.Lens' UpdateItemResponse Prelude.Int
updateItemResponse_httpStatus :: (Int -> f Int) -> UpdateItemResponse -> f UpdateItemResponse
updateItemResponse_httpStatus = (UpdateItemResponse -> Int)
-> (UpdateItemResponse -> Int -> UpdateItemResponse)
-> Lens UpdateItemResponse UpdateItemResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateItemResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateItemResponse' :: UpdateItemResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateItemResponse
s@UpdateItemResponse' {} Int
a -> UpdateItemResponse
s {$sel:httpStatus:UpdateItemResponse' :: Int
httpStatus = Int
a} :: UpdateItemResponse)

instance Prelude.NFData UpdateItemResponse