{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.DynamoDB.Types.Update 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.AttributeValue
import Amazonka.DynamoDB.Types.ReturnValuesOnConditionCheckFailure
import Amazonka.DynamoDB.Types.WriteRequest
import qualified Amazonka.Prelude as Prelude
data Update = Update'
{
Update -> Maybe Text
conditionExpression :: Prelude.Maybe Prelude.Text,
Update -> Maybe (HashMap Text Text)
expressionAttributeNames :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
Update -> Maybe (HashMap Text AttributeValue)
expressionAttributeValues :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue),
Update -> Maybe ReturnValuesOnConditionCheckFailure
returnValuesOnConditionCheckFailure :: Prelude.Maybe ReturnValuesOnConditionCheckFailure,
Update -> HashMap Text AttributeValue
key :: Prelude.HashMap Prelude.Text AttributeValue,
Update -> Text
updateExpression :: Prelude.Text,
Update -> Text
tableName :: Prelude.Text
}
deriving (Update -> Update -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Update -> Update -> Bool
$c/= :: Update -> Update -> Bool
== :: Update -> Update -> Bool
$c== :: Update -> Update -> Bool
Prelude.Eq, ReadPrec [Update]
ReadPrec Update
Int -> ReadS Update
ReadS [Update]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Update]
$creadListPrec :: ReadPrec [Update]
readPrec :: ReadPrec Update
$creadPrec :: ReadPrec Update
readList :: ReadS [Update]
$creadList :: ReadS [Update]
readsPrec :: Int -> ReadS Update
$creadsPrec :: Int -> ReadS Update
Prelude.Read, Int -> Update -> ShowS
[Update] -> ShowS
Update -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Update] -> ShowS
$cshowList :: [Update] -> ShowS
show :: Update -> String
$cshow :: Update -> String
showsPrec :: Int -> Update -> ShowS
$cshowsPrec :: Int -> Update -> ShowS
Prelude.Show, forall x. Rep Update x -> Update
forall x. Update -> Rep Update x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Update x -> Update
$cfrom :: forall x. Update -> Rep Update x
Prelude.Generic)
newUpdate ::
Prelude.Text ->
Prelude.Text ->
Update
newUpdate :: Text -> Text -> Update
newUpdate Text
pUpdateExpression_ Text
pTableName_ =
Update'
{ $sel:conditionExpression:Update' :: Maybe Text
conditionExpression = forall a. Maybe a
Prelude.Nothing,
$sel:expressionAttributeNames:Update' :: Maybe (HashMap Text Text)
expressionAttributeNames = forall a. Maybe a
Prelude.Nothing,
$sel:expressionAttributeValues:Update' :: Maybe (HashMap Text AttributeValue)
expressionAttributeValues = forall a. Maybe a
Prelude.Nothing,
$sel:returnValuesOnConditionCheckFailure:Update' :: Maybe ReturnValuesOnConditionCheckFailure
returnValuesOnConditionCheckFailure =
forall a. Maybe a
Prelude.Nothing,
$sel:key:Update' :: HashMap Text AttributeValue
key = forall a. Monoid a => a
Prelude.mempty,
$sel:updateExpression:Update' :: Text
updateExpression = Text
pUpdateExpression_,
$sel:tableName:Update' :: Text
tableName = Text
pTableName_
}
update_conditionExpression :: Lens.Lens' Update (Prelude.Maybe Prelude.Text)
update_conditionExpression :: Lens' Update (Maybe Text)
update_conditionExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe Text
conditionExpression :: Maybe Text
$sel:conditionExpression:Update' :: Update -> Maybe Text
conditionExpression} -> Maybe Text
conditionExpression) (\s :: Update
s@Update' {} Maybe Text
a -> Update
s {$sel:conditionExpression:Update' :: Maybe Text
conditionExpression = Maybe Text
a} :: Update)
update_expressionAttributeNames :: Lens.Lens' Update (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
update_expressionAttributeNames :: Lens' Update (Maybe (HashMap Text Text))
update_expressionAttributeNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe (HashMap Text Text)
expressionAttributeNames :: Maybe (HashMap Text Text)
$sel:expressionAttributeNames:Update' :: Update -> Maybe (HashMap Text Text)
expressionAttributeNames} -> Maybe (HashMap Text Text)
expressionAttributeNames) (\s :: Update
s@Update' {} Maybe (HashMap Text Text)
a -> Update
s {$sel:expressionAttributeNames:Update' :: Maybe (HashMap Text Text)
expressionAttributeNames = Maybe (HashMap Text Text)
a} :: Update) 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
update_expressionAttributeValues :: Lens.Lens' Update (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeValue))
update_expressionAttributeValues :: Lens' Update (Maybe (HashMap Text AttributeValue))
update_expressionAttributeValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe (HashMap Text AttributeValue)
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
$sel:expressionAttributeValues:Update' :: Update -> Maybe (HashMap Text AttributeValue)
expressionAttributeValues} -> Maybe (HashMap Text AttributeValue)
expressionAttributeValues) (\s :: Update
s@Update' {} Maybe (HashMap Text AttributeValue)
a -> Update
s {$sel:expressionAttributeValues:Update' :: Maybe (HashMap Text AttributeValue)
expressionAttributeValues = Maybe (HashMap Text AttributeValue)
a} :: Update) 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
update_returnValuesOnConditionCheckFailure :: Lens.Lens' Update (Prelude.Maybe ReturnValuesOnConditionCheckFailure)
update_returnValuesOnConditionCheckFailure :: Lens' Update (Maybe ReturnValuesOnConditionCheckFailure)
update_returnValuesOnConditionCheckFailure = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Maybe ReturnValuesOnConditionCheckFailure
returnValuesOnConditionCheckFailure :: Maybe ReturnValuesOnConditionCheckFailure
$sel:returnValuesOnConditionCheckFailure:Update' :: Update -> Maybe ReturnValuesOnConditionCheckFailure
returnValuesOnConditionCheckFailure} -> Maybe ReturnValuesOnConditionCheckFailure
returnValuesOnConditionCheckFailure) (\s :: Update
s@Update' {} Maybe ReturnValuesOnConditionCheckFailure
a -> Update
s {$sel:returnValuesOnConditionCheckFailure:Update' :: Maybe ReturnValuesOnConditionCheckFailure
returnValuesOnConditionCheckFailure = Maybe ReturnValuesOnConditionCheckFailure
a} :: Update)
update_key :: Lens.Lens' Update (Prelude.HashMap Prelude.Text AttributeValue)
update_key :: Lens' Update (HashMap Text AttributeValue)
update_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {HashMap Text AttributeValue
key :: HashMap Text AttributeValue
$sel:key:Update' :: Update -> HashMap Text AttributeValue
key} -> HashMap Text AttributeValue
key) (\s :: Update
s@Update' {} HashMap Text AttributeValue
a -> Update
s {$sel:key:Update' :: HashMap Text AttributeValue
key = HashMap Text AttributeValue
a} :: Update) 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
update_updateExpression :: Lens.Lens' Update Prelude.Text
update_updateExpression :: Lens' Update Text
update_updateExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Text
updateExpression :: Text
$sel:updateExpression:Update' :: Update -> Text
updateExpression} -> Text
updateExpression) (\s :: Update
s@Update' {} Text
a -> Update
s {$sel:updateExpression:Update' :: Text
updateExpression = Text
a} :: Update)
update_tableName :: Lens.Lens' Update Prelude.Text
update_tableName :: Lens' Update Text
update_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Update' {Text
tableName :: Text
$sel:tableName:Update' :: Update -> Text
tableName} -> Text
tableName) (\s :: Update
s@Update' {} Text
a -> Update
s {$sel:tableName:Update' :: Text
tableName = Text
a} :: Update)
instance Prelude.Hashable Update where
hashWithSalt :: Int -> Update -> Int
hashWithSalt Int
_salt Update' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text AttributeValue)
Maybe ReturnValuesOnConditionCheckFailure
Text
HashMap Text AttributeValue
tableName :: Text
updateExpression :: Text
key :: HashMap Text AttributeValue
returnValuesOnConditionCheckFailure :: Maybe ReturnValuesOnConditionCheckFailure
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
expressionAttributeNames :: Maybe (HashMap Text Text)
conditionExpression :: Maybe Text
$sel:tableName:Update' :: Update -> Text
$sel:updateExpression:Update' :: Update -> Text
$sel:key:Update' :: Update -> HashMap Text AttributeValue
$sel:returnValuesOnConditionCheckFailure:Update' :: Update -> Maybe ReturnValuesOnConditionCheckFailure
$sel:expressionAttributeValues:Update' :: Update -> Maybe (HashMap Text AttributeValue)
$sel:expressionAttributeNames:Update' :: Update -> Maybe (HashMap Text Text)
$sel:conditionExpression:Update' :: Update -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
conditionExpression
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 ReturnValuesOnConditionCheckFailure
returnValuesOnConditionCheckFailure
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text AttributeValue
key
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
updateExpression
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName
instance Prelude.NFData Update where
rnf :: Update -> ()
rnf Update' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text AttributeValue)
Maybe ReturnValuesOnConditionCheckFailure
Text
HashMap Text AttributeValue
tableName :: Text
updateExpression :: Text
key :: HashMap Text AttributeValue
returnValuesOnConditionCheckFailure :: Maybe ReturnValuesOnConditionCheckFailure
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
expressionAttributeNames :: Maybe (HashMap Text Text)
conditionExpression :: Maybe Text
$sel:tableName:Update' :: Update -> Text
$sel:updateExpression:Update' :: Update -> Text
$sel:key:Update' :: Update -> HashMap Text AttributeValue
$sel:returnValuesOnConditionCheckFailure:Update' :: Update -> Maybe ReturnValuesOnConditionCheckFailure
$sel:expressionAttributeValues:Update' :: Update -> Maybe (HashMap Text AttributeValue)
$sel:expressionAttributeNames:Update' :: Update -> Maybe (HashMap Text Text)
$sel:conditionExpression:Update' :: Update -> Maybe Text
..} =
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 (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 ReturnValuesOnConditionCheckFailure
returnValuesOnConditionCheckFailure
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text AttributeValue
key
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
updateExpression
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tableName
instance Data.ToJSON Update where
toJSON :: Update -> Value
toJSON Update' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text AttributeValue)
Maybe ReturnValuesOnConditionCheckFailure
Text
HashMap Text AttributeValue
tableName :: Text
updateExpression :: Text
key :: HashMap Text AttributeValue
returnValuesOnConditionCheckFailure :: Maybe ReturnValuesOnConditionCheckFailure
expressionAttributeValues :: Maybe (HashMap Text AttributeValue)
expressionAttributeNames :: Maybe (HashMap Text Text)
conditionExpression :: Maybe Text
$sel:tableName:Update' :: Update -> Text
$sel:updateExpression:Update' :: Update -> Text
$sel:key:Update' :: Update -> HashMap Text AttributeValue
$sel:returnValuesOnConditionCheckFailure:Update' :: Update -> Maybe ReturnValuesOnConditionCheckFailure
$sel:expressionAttributeValues:Update' :: Update -> Maybe (HashMap Text AttributeValue)
$sel:expressionAttributeNames:Update' :: Update -> Maybe (HashMap Text Text)
$sel:conditionExpression:Update' :: Update -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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
"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
"ReturnValuesOnConditionCheckFailure" 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 ReturnValuesOnConditionCheckFailure
returnValuesOnConditionCheckFailure,
forall a. a -> Maybe a
Prelude.Just (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HashMap Text AttributeValue
key),
forall a. a -> Maybe a
Prelude.Just
(Key
"UpdateExpression" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
updateExpression),
forall a. a -> Maybe a
Prelude.Just (Key
"TableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName)
]
)