{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_attributeUpdates,
    updateItem_conditionExpression,
    updateItem_conditionalOperator,
    updateItem_expected,
    updateItem_expressionAttributeNames,
    updateItem_expressionAttributeValues,
    updateItem_returnConsumedCapacity,
    updateItem_returnItemCollectionMetrics,
    updateItem_returnValues,
    updateItem_updateExpression,
    updateItem_tableName,
    updateItem_key,

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

    -- * Response Lenses
    updateItemResponse_attributes,
    updateItemResponse_consumedCapacity,
    updateItemResponse_itemCollectionMetrics,
    updateItemResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types
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'
  { -- | 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),
    -- | 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),
    -- | 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),
    -- | 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),
    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,
    -- | 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,
    -- | 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
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]
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
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. 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:
--
-- '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/.
--
-- '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/.
--
-- '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/.
--
-- '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/.
--
-- '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.
--
-- '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/.
--
-- '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'
    { $sel:attributeUpdates:UpdateItem' :: Maybe (HashMap Text AttributeValueUpdate)
attributeUpdates = forall a. Maybe a
Prelude.Nothing,
      $sel:conditionExpression:UpdateItem' :: Maybe Text
conditionExpression = forall a. Maybe a
Prelude.Nothing,
      $sel:conditionalOperator:UpdateItem' :: Maybe ConditionalOperator
conditionalOperator = forall a. Maybe a
Prelude.Nothing,
      $sel:expected:UpdateItem' :: Maybe (HashMap Text ExpectedAttributeValue)
expected = forall a. Maybe a
Prelude.Nothing,
      $sel:expressionAttributeNames:UpdateItem' :: Maybe (HashMap Text Text)
expressionAttributeNames = forall a. Maybe a
Prelude.Nothing,
      $sel:expressionAttributeValues:UpdateItem' :: Maybe (HashMap Text AttributeValue)
expressionAttributeValues = forall a. Maybe a
Prelude.Nothing,
      $sel:returnConsumedCapacity:UpdateItem' :: Maybe ReturnConsumedCapacity
returnConsumedCapacity = forall a. Maybe a
Prelude.Nothing,
      $sel:returnItemCollectionMetrics:UpdateItem' :: Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics = forall a. Maybe a
Prelude.Nothing,
      $sel:returnValues:UpdateItem' :: Maybe ReturnValue
returnValues = forall a. Maybe a
Prelude.Nothing,
      $sel:updateExpression:UpdateItem' :: Maybe Text
updateExpression = forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:UpdateItem' :: Text
tableName = Text
pTableName_,
      $sel:key:UpdateItem' :: HashMap Text AttributeValue
key = forall a. Monoid a => a
Prelude.mempty
    }

-- | 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 :: Lens' UpdateItem (Maybe (HashMap Text AttributeValueUpdate))
updateItem_attributeUpdates = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' UpdateItem (Maybe Text)
updateItem_conditionExpression = 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 :: Lens' UpdateItem (Maybe ConditionalOperator)
updateItem_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 :: Lens' UpdateItem (Maybe (HashMap Text ExpectedAttributeValue))
updateItem_expected = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' UpdateItem (Maybe (HashMap Text Text))
updateItem_expressionAttributeNames = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' UpdateItem (Maybe (HashMap Text AttributeValue))
updateItem_expressionAttributeValues = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' UpdateItem (Maybe ReturnConsumedCapacity)
updateItem_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 :: Lens' UpdateItem (Maybe ReturnItemCollectionMetrics)
updateItem_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)

-- | 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 :: Lens' UpdateItem (Maybe ReturnValue)
updateItem_returnValues = 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 :: Lens' UpdateItem (Maybe Text)
updateItem_updateExpression = 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)

-- | The name of the table containing the item to update.
updateItem_tableName :: Lens.Lens' UpdateItem Prelude.Text
updateItem_tableName :: Lens' UpdateItem Text
updateItem_tableName = 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 :: Lens' UpdateItem (HashMap Text AttributeValue)
updateItem_key = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: (Service -> Service) -> UpdateItem -> Request UpdateItem
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateItem
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateItem)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe (HashMap Text AttributeValue)
-> Maybe ConsumedCapacity
-> Maybe ItemCollectionMetrics
-> Int
-> UpdateItemResponse
UpdateItemResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Attributes" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ConsumedCapacity")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ItemCollectionMetrics")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateItem where
  hashWithSalt :: Int -> UpdateItem -> Int
hashWithSalt Int
_salt UpdateItem' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text AttributeValue)
Maybe (HashMap Text ExpectedAttributeValue)
Maybe (HashMap Text AttributeValueUpdate)
Maybe ReturnValue
Maybe ReturnItemCollectionMetrics
Maybe ReturnConsumedCapacity
Maybe ConditionalOperator
Text
HashMap Text AttributeValue
key :: HashMap Text AttributeValue
tableName :: Text
updateExpression :: Maybe Text
returnValues :: Maybe ReturnValue
returnItemCollectionMetrics :: Maybe ReturnItemCollectionMetrics
returnConsumedCapacity :: Maybe ReturnConsumedCapacity
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
expressionAttributeNames :: Maybe (HashMap Text Text)
expected :: Maybe (HashMap Text ExpectedAttributeValue)
conditionalOperator :: Maybe ConditionalOperator
conditionExpression :: Maybe Text
attributeUpdates :: Maybe (HashMap Text AttributeValueUpdate)
$sel:key:UpdateItem' :: UpdateItem -> HashMap Text AttributeValue
$sel:tableName:UpdateItem' :: UpdateItem -> Text
$sel:updateExpression:UpdateItem' :: UpdateItem -> Maybe Text
$sel:returnValues:UpdateItem' :: UpdateItem -> Maybe ReturnValue
$sel:returnItemCollectionMetrics:UpdateItem' :: UpdateItem -> Maybe ReturnItemCollectionMetrics
$sel:returnConsumedCapacity:UpdateItem' :: UpdateItem -> Maybe ReturnConsumedCapacity
$sel:expressionAttributeValues:UpdateItem' :: UpdateItem -> Maybe (HashMap Text AttributeValue)
$sel:expressionAttributeNames:UpdateItem' :: UpdateItem -> Maybe (HashMap Text Text)
$sel:expected:UpdateItem' :: UpdateItem -> Maybe (HashMap Text ExpectedAttributeValue)
$sel:conditionalOperator:UpdateItem' :: UpdateItem -> Maybe ConditionalOperator
$sel:conditionExpression:UpdateItem' :: UpdateItem -> Maybe Text
$sel:attributeUpdates:UpdateItem' :: UpdateItem -> Maybe (HashMap Text AttributeValueUpdate)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text AttributeValueUpdate)
attributeUpdates
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
conditionExpression
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConditionalOperator
conditionalOperator
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text ExpectedAttributeValue)
expected
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
expressionAttributeNames
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text AttributeValue)
expressionAttributeValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ReturnConsumedCapacity
returnConsumedCapacity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ReturnValue
returnValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
updateExpression
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text AttributeValue
key

instance Prelude.NFData UpdateItem where
  rnf :: UpdateItem -> ()
rnf UpdateItem' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text AttributeValue)
Maybe (HashMap Text ExpectedAttributeValue)
Maybe (HashMap Text AttributeValueUpdate)
Maybe ReturnValue
Maybe ReturnItemCollectionMetrics
Maybe ReturnConsumedCapacity
Maybe ConditionalOperator
Text
HashMap Text AttributeValue
key :: HashMap Text AttributeValue
tableName :: Text
updateExpression :: Maybe Text
returnValues :: Maybe ReturnValue
returnItemCollectionMetrics :: Maybe ReturnItemCollectionMetrics
returnConsumedCapacity :: Maybe ReturnConsumedCapacity
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
expressionAttributeNames :: Maybe (HashMap Text Text)
expected :: Maybe (HashMap Text ExpectedAttributeValue)
conditionalOperator :: Maybe ConditionalOperator
conditionExpression :: Maybe Text
attributeUpdates :: Maybe (HashMap Text AttributeValueUpdate)
$sel:key:UpdateItem' :: UpdateItem -> HashMap Text AttributeValue
$sel:tableName:UpdateItem' :: UpdateItem -> Text
$sel:updateExpression:UpdateItem' :: UpdateItem -> Maybe Text
$sel:returnValues:UpdateItem' :: UpdateItem -> Maybe ReturnValue
$sel:returnItemCollectionMetrics:UpdateItem' :: UpdateItem -> Maybe ReturnItemCollectionMetrics
$sel:returnConsumedCapacity:UpdateItem' :: UpdateItem -> Maybe ReturnConsumedCapacity
$sel:expressionAttributeValues:UpdateItem' :: UpdateItem -> Maybe (HashMap Text AttributeValue)
$sel:expressionAttributeNames:UpdateItem' :: UpdateItem -> Maybe (HashMap Text Text)
$sel:expected:UpdateItem' :: UpdateItem -> Maybe (HashMap Text ExpectedAttributeValue)
$sel:conditionalOperator:UpdateItem' :: UpdateItem -> Maybe ConditionalOperator
$sel:conditionExpression:UpdateItem' :: UpdateItem -> Maybe Text
$sel:attributeUpdates:UpdateItem' :: UpdateItem -> Maybe (HashMap Text AttributeValueUpdate)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text AttributeValueUpdate)
attributeUpdates
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
conditionExpression
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ConditionalOperator
conditionalOperator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text ExpectedAttributeValue)
expected
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
expressionAttributeNames
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text AttributeValue)
expressionAttributeValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ReturnConsumedCapacity
returnConsumedCapacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ReturnValue
returnValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
updateExpression
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tableName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text AttributeValue
key

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

instance Data.ToJSON UpdateItem where
  toJSON :: UpdateItem -> Value
toJSON UpdateItem' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text AttributeValue)
Maybe (HashMap Text ExpectedAttributeValue)
Maybe (HashMap Text AttributeValueUpdate)
Maybe ReturnValue
Maybe ReturnItemCollectionMetrics
Maybe ReturnConsumedCapacity
Maybe ConditionalOperator
Text
HashMap Text AttributeValue
key :: HashMap Text AttributeValue
tableName :: Text
updateExpression :: Maybe Text
returnValues :: Maybe ReturnValue
returnItemCollectionMetrics :: Maybe ReturnItemCollectionMetrics
returnConsumedCapacity :: Maybe ReturnConsumedCapacity
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
expressionAttributeNames :: Maybe (HashMap Text Text)
expected :: Maybe (HashMap Text ExpectedAttributeValue)
conditionalOperator :: Maybe ConditionalOperator
conditionExpression :: Maybe Text
attributeUpdates :: Maybe (HashMap Text AttributeValueUpdate)
$sel:key:UpdateItem' :: UpdateItem -> HashMap Text AttributeValue
$sel:tableName:UpdateItem' :: UpdateItem -> Text
$sel:updateExpression:UpdateItem' :: UpdateItem -> Maybe Text
$sel:returnValues:UpdateItem' :: UpdateItem -> Maybe ReturnValue
$sel:returnItemCollectionMetrics:UpdateItem' :: UpdateItem -> Maybe ReturnItemCollectionMetrics
$sel:returnConsumedCapacity:UpdateItem' :: UpdateItem -> Maybe ReturnConsumedCapacity
$sel:expressionAttributeValues:UpdateItem' :: UpdateItem -> Maybe (HashMap Text AttributeValue)
$sel:expressionAttributeNames:UpdateItem' :: UpdateItem -> Maybe (HashMap Text Text)
$sel:expected:UpdateItem' :: UpdateItem -> Maybe (HashMap Text ExpectedAttributeValue)
$sel:conditionalOperator:UpdateItem' :: UpdateItem -> Maybe ConditionalOperator
$sel:conditionExpression:UpdateItem' :: UpdateItem -> Maybe Text
$sel:attributeUpdates:UpdateItem' :: UpdateItem -> Maybe (HashMap Text AttributeValueUpdate)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AttributeUpdates" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text AttributeValueUpdate)
attributeUpdates,
            (Key
"ConditionExpression" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
conditionExpression,
            (Key
"ConditionalOperator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ConditionalOperator
conditionalOperator,
            (Key
"Expected" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text ExpectedAttributeValue)
expected,
            (Key
"ExpressionAttributeNames" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
expressionAttributeNames,
            (Key
"ExpressionAttributeValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text AttributeValue)
expressionAttributeValues,
            (Key
"ReturnConsumedCapacity" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReturnConsumedCapacity
returnConsumedCapacity,
            (Key
"ReturnItemCollectionMetrics" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReturnItemCollectionMetrics
returnItemCollectionMetrics,
            (Key
"ReturnValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReturnValue
returnValues,
            (Key
"UpdateExpression" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
updateExpression,
            forall a. a -> Maybe a
Prelude.Just (Key
"TableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HashMap Text AttributeValue
key)
          ]
      )

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

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

-- | Represents the output of an @UpdateItem@ operation.
--
-- /See:/ 'newUpdateItemResponse' smart constructor.
data UpdateItemResponse = 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 -> Maybe (HashMap Text AttributeValue)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue),
    -- | 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,
    -- | 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 response's http status code.
    UpdateItemResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateItemResponse -> UpdateItemResponse -> Bool
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]
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
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. 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:
--
-- '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.
--
-- '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/.
--
-- '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.
--
-- 'httpStatus', 'updateItemResponse_httpStatus' - The response's http status code.
newUpdateItemResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateItemResponse
newUpdateItemResponse :: Int -> UpdateItemResponse
newUpdateItemResponse Int
pHttpStatus_ =
  UpdateItemResponse'
    { $sel:attributes:UpdateItemResponse' :: Maybe (HashMap Text AttributeValue)
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:consumedCapacity:UpdateItemResponse' :: Maybe ConsumedCapacity
consumedCapacity = forall a. Maybe a
Prelude.Nothing,
      $sel:itemCollectionMetrics:UpdateItemResponse' :: Maybe ItemCollectionMetrics
itemCollectionMetrics = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateItemResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | 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 :: Lens' UpdateItemResponse (Maybe (HashMap Text AttributeValue))
updateItemResponse_attributes = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' UpdateItemResponse (Maybe ConsumedCapacity)
updateItemResponse_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)

-- | 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 :: Lens' UpdateItemResponse (Maybe ItemCollectionMetrics)
updateItemResponse_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 response's http status code.
updateItemResponse_httpStatus :: Lens.Lens' UpdateItemResponse Prelude.Int
updateItemResponse_httpStatus :: Lens' UpdateItemResponse Int
updateItemResponse_httpStatus = 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 where
  rnf :: UpdateItemResponse -> ()
rnf UpdateItemResponse' {Int
Maybe (HashMap Text AttributeValue)
Maybe ItemCollectionMetrics
Maybe ConsumedCapacity
httpStatus :: Int
itemCollectionMetrics :: Maybe ItemCollectionMetrics
consumedCapacity :: Maybe ConsumedCapacity
attributes :: Maybe (HashMap Text AttributeValue)
$sel:httpStatus:UpdateItemResponse' :: UpdateItemResponse -> Int
$sel:itemCollectionMetrics:UpdateItemResponse' :: UpdateItemResponse -> Maybe ItemCollectionMetrics
$sel:consumedCapacity:UpdateItemResponse' :: UpdateItemResponse -> Maybe ConsumedCapacity
$sel:attributes:UpdateItemResponse' :: UpdateItemResponse -> Maybe (HashMap Text AttributeValue)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text AttributeValue)
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ConsumedCapacity
consumedCapacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ItemCollectionMetrics
itemCollectionMetrics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus