{-# 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.KeysAndAttributes 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.WriteRequest
import qualified Amazonka.Prelude as Prelude
data KeysAndAttributes = KeysAndAttributes'
{
KeysAndAttributes -> Maybe (NonEmpty Text)
attributesToGet :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
KeysAndAttributes -> Maybe Bool
consistentRead :: Prelude.Maybe Prelude.Bool,
KeysAndAttributes -> Maybe (HashMap Text Text)
expressionAttributeNames :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
KeysAndAttributes -> Maybe Text
projectionExpression :: Prelude.Maybe Prelude.Text,
KeysAndAttributes -> NonEmpty (HashMap Text AttributeValue)
keys :: Prelude.NonEmpty (Prelude.HashMap Prelude.Text AttributeValue)
}
deriving (KeysAndAttributes -> KeysAndAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeysAndAttributes -> KeysAndAttributes -> Bool
$c/= :: KeysAndAttributes -> KeysAndAttributes -> Bool
== :: KeysAndAttributes -> KeysAndAttributes -> Bool
$c== :: KeysAndAttributes -> KeysAndAttributes -> Bool
Prelude.Eq, ReadPrec [KeysAndAttributes]
ReadPrec KeysAndAttributes
Int -> ReadS KeysAndAttributes
ReadS [KeysAndAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeysAndAttributes]
$creadListPrec :: ReadPrec [KeysAndAttributes]
readPrec :: ReadPrec KeysAndAttributes
$creadPrec :: ReadPrec KeysAndAttributes
readList :: ReadS [KeysAndAttributes]
$creadList :: ReadS [KeysAndAttributes]
readsPrec :: Int -> ReadS KeysAndAttributes
$creadsPrec :: Int -> ReadS KeysAndAttributes
Prelude.Read, Int -> KeysAndAttributes -> ShowS
[KeysAndAttributes] -> ShowS
KeysAndAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeysAndAttributes] -> ShowS
$cshowList :: [KeysAndAttributes] -> ShowS
show :: KeysAndAttributes -> String
$cshow :: KeysAndAttributes -> String
showsPrec :: Int -> KeysAndAttributes -> ShowS
$cshowsPrec :: Int -> KeysAndAttributes -> ShowS
Prelude.Show, forall x. Rep KeysAndAttributes x -> KeysAndAttributes
forall x. KeysAndAttributes -> Rep KeysAndAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KeysAndAttributes x -> KeysAndAttributes
$cfrom :: forall x. KeysAndAttributes -> Rep KeysAndAttributes x
Prelude.Generic)
newKeysAndAttributes ::
Prelude.NonEmpty (Prelude.HashMap Prelude.Text AttributeValue) ->
KeysAndAttributes
newKeysAndAttributes :: NonEmpty (HashMap Text AttributeValue) -> KeysAndAttributes
newKeysAndAttributes NonEmpty (HashMap Text AttributeValue)
pKeys_ =
KeysAndAttributes'
{ $sel:attributesToGet:KeysAndAttributes' :: Maybe (NonEmpty Text)
attributesToGet =
forall a. Maybe a
Prelude.Nothing,
$sel:consistentRead:KeysAndAttributes' :: Maybe Bool
consistentRead = forall a. Maybe a
Prelude.Nothing,
$sel:expressionAttributeNames:KeysAndAttributes' :: Maybe (HashMap Text Text)
expressionAttributeNames = forall a. Maybe a
Prelude.Nothing,
$sel:projectionExpression:KeysAndAttributes' :: Maybe Text
projectionExpression = forall a. Maybe a
Prelude.Nothing,
$sel:keys:KeysAndAttributes' :: NonEmpty (HashMap Text AttributeValue)
keys = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty (HashMap Text AttributeValue)
pKeys_
}
keysAndAttributes_attributesToGet :: Lens.Lens' KeysAndAttributes (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
keysAndAttributes_attributesToGet :: Lens' KeysAndAttributes (Maybe (NonEmpty Text))
keysAndAttributes_attributesToGet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeysAndAttributes' {Maybe (NonEmpty Text)
attributesToGet :: Maybe (NonEmpty Text)
$sel:attributesToGet:KeysAndAttributes' :: KeysAndAttributes -> Maybe (NonEmpty Text)
attributesToGet} -> Maybe (NonEmpty Text)
attributesToGet) (\s :: KeysAndAttributes
s@KeysAndAttributes' {} Maybe (NonEmpty Text)
a -> KeysAndAttributes
s {$sel:attributesToGet:KeysAndAttributes' :: Maybe (NonEmpty Text)
attributesToGet = Maybe (NonEmpty Text)
a} :: KeysAndAttributes) 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
keysAndAttributes_consistentRead :: Lens.Lens' KeysAndAttributes (Prelude.Maybe Prelude.Bool)
keysAndAttributes_consistentRead :: Lens' KeysAndAttributes (Maybe Bool)
keysAndAttributes_consistentRead = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeysAndAttributes' {Maybe Bool
consistentRead :: Maybe Bool
$sel:consistentRead:KeysAndAttributes' :: KeysAndAttributes -> Maybe Bool
consistentRead} -> Maybe Bool
consistentRead) (\s :: KeysAndAttributes
s@KeysAndAttributes' {} Maybe Bool
a -> KeysAndAttributes
s {$sel:consistentRead:KeysAndAttributes' :: Maybe Bool
consistentRead = Maybe Bool
a} :: KeysAndAttributes)
keysAndAttributes_expressionAttributeNames :: Lens.Lens' KeysAndAttributes (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
keysAndAttributes_expressionAttributeNames :: Lens' KeysAndAttributes (Maybe (HashMap Text Text))
keysAndAttributes_expressionAttributeNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeysAndAttributes' {Maybe (HashMap Text Text)
expressionAttributeNames :: Maybe (HashMap Text Text)
$sel:expressionAttributeNames:KeysAndAttributes' :: KeysAndAttributes -> Maybe (HashMap Text Text)
expressionAttributeNames} -> Maybe (HashMap Text Text)
expressionAttributeNames) (\s :: KeysAndAttributes
s@KeysAndAttributes' {} Maybe (HashMap Text Text)
a -> KeysAndAttributes
s {$sel:expressionAttributeNames:KeysAndAttributes' :: Maybe (HashMap Text Text)
expressionAttributeNames = Maybe (HashMap Text Text)
a} :: KeysAndAttributes) 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
keysAndAttributes_projectionExpression :: Lens.Lens' KeysAndAttributes (Prelude.Maybe Prelude.Text)
keysAndAttributes_projectionExpression :: Lens' KeysAndAttributes (Maybe Text)
keysAndAttributes_projectionExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeysAndAttributes' {Maybe Text
projectionExpression :: Maybe Text
$sel:projectionExpression:KeysAndAttributes' :: KeysAndAttributes -> Maybe Text
projectionExpression} -> Maybe Text
projectionExpression) (\s :: KeysAndAttributes
s@KeysAndAttributes' {} Maybe Text
a -> KeysAndAttributes
s {$sel:projectionExpression:KeysAndAttributes' :: Maybe Text
projectionExpression = Maybe Text
a} :: KeysAndAttributes)
keysAndAttributes_keys :: Lens.Lens' KeysAndAttributes (Prelude.NonEmpty (Prelude.HashMap Prelude.Text AttributeValue))
keysAndAttributes_keys :: Lens' KeysAndAttributes (NonEmpty (HashMap Text AttributeValue))
keysAndAttributes_keys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KeysAndAttributes' {NonEmpty (HashMap Text AttributeValue)
keys :: NonEmpty (HashMap Text AttributeValue)
$sel:keys:KeysAndAttributes' :: KeysAndAttributes -> NonEmpty (HashMap Text AttributeValue)
keys} -> NonEmpty (HashMap Text AttributeValue)
keys) (\s :: KeysAndAttributes
s@KeysAndAttributes' {} NonEmpty (HashMap Text AttributeValue)
a -> KeysAndAttributes
s {$sel:keys:KeysAndAttributes' :: NonEmpty (HashMap Text AttributeValue)
keys = NonEmpty (HashMap Text AttributeValue)
a} :: KeysAndAttributes) 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 Data.FromJSON KeysAndAttributes where
parseJSON :: Value -> Parser KeysAndAttributes
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"KeysAndAttributes"
( \Object
x ->
Maybe (NonEmpty Text)
-> Maybe Bool
-> Maybe (HashMap Text Text)
-> Maybe Text
-> NonEmpty (HashMap Text AttributeValue)
-> KeysAndAttributes
KeysAndAttributes'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AttributesToGet")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ConsistentRead")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExpressionAttributeNames"
forall a. Parser (Maybe a) -> a -> Parser a
Data..!= 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 -> Parser (Maybe a)
Data..:? Key
"ProjectionExpression")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Keys")
)
instance Prelude.Hashable KeysAndAttributes where
hashWithSalt :: Int -> KeysAndAttributes -> Int
hashWithSalt Int
_salt KeysAndAttributes' {Maybe Bool
Maybe (NonEmpty Text)
Maybe Text
Maybe (HashMap Text Text)
NonEmpty (HashMap Text AttributeValue)
keys :: NonEmpty (HashMap Text AttributeValue)
projectionExpression :: Maybe Text
expressionAttributeNames :: Maybe (HashMap Text Text)
consistentRead :: Maybe Bool
attributesToGet :: Maybe (NonEmpty Text)
$sel:keys:KeysAndAttributes' :: KeysAndAttributes -> NonEmpty (HashMap Text AttributeValue)
$sel:projectionExpression:KeysAndAttributes' :: KeysAndAttributes -> Maybe Text
$sel:expressionAttributeNames:KeysAndAttributes' :: KeysAndAttributes -> Maybe (HashMap Text Text)
$sel:consistentRead:KeysAndAttributes' :: KeysAndAttributes -> Maybe Bool
$sel:attributesToGet:KeysAndAttributes' :: KeysAndAttributes -> Maybe (NonEmpty Text)
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
attributesToGet
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
consistentRead
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
expressionAttributeNames
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
projectionExpression
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty (HashMap Text AttributeValue)
keys
instance Prelude.NFData KeysAndAttributes where
rnf :: KeysAndAttributes -> ()
rnf KeysAndAttributes' {Maybe Bool
Maybe (NonEmpty Text)
Maybe Text
Maybe (HashMap Text Text)
NonEmpty (HashMap Text AttributeValue)
keys :: NonEmpty (HashMap Text AttributeValue)
projectionExpression :: Maybe Text
expressionAttributeNames :: Maybe (HashMap Text Text)
consistentRead :: Maybe Bool
attributesToGet :: Maybe (NonEmpty Text)
$sel:keys:KeysAndAttributes' :: KeysAndAttributes -> NonEmpty (HashMap Text AttributeValue)
$sel:projectionExpression:KeysAndAttributes' :: KeysAndAttributes -> Maybe Text
$sel:expressionAttributeNames:KeysAndAttributes' :: KeysAndAttributes -> Maybe (HashMap Text Text)
$sel:consistentRead:KeysAndAttributes' :: KeysAndAttributes -> Maybe Bool
$sel:attributesToGet:KeysAndAttributes' :: KeysAndAttributes -> Maybe (NonEmpty Text)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
attributesToGet
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
consistentRead
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 Text
projectionExpression
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty (HashMap Text AttributeValue)
keys
instance Data.ToJSON KeysAndAttributes where
toJSON :: KeysAndAttributes -> Value
toJSON KeysAndAttributes' {Maybe Bool
Maybe (NonEmpty Text)
Maybe Text
Maybe (HashMap Text Text)
NonEmpty (HashMap Text AttributeValue)
keys :: NonEmpty (HashMap Text AttributeValue)
projectionExpression :: Maybe Text
expressionAttributeNames :: Maybe (HashMap Text Text)
consistentRead :: Maybe Bool
attributesToGet :: Maybe (NonEmpty Text)
$sel:keys:KeysAndAttributes' :: KeysAndAttributes -> NonEmpty (HashMap Text AttributeValue)
$sel:projectionExpression:KeysAndAttributes' :: KeysAndAttributes -> Maybe Text
$sel:expressionAttributeNames:KeysAndAttributes' :: KeysAndAttributes -> Maybe (HashMap Text Text)
$sel:consistentRead:KeysAndAttributes' :: KeysAndAttributes -> Maybe Bool
$sel:attributesToGet:KeysAndAttributes' :: KeysAndAttributes -> Maybe (NonEmpty Text)
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"AttributesToGet" 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 (NonEmpty Text)
attributesToGet,
(Key
"ConsistentRead" 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 Bool
consistentRead,
(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
"ProjectionExpression" 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
projectionExpression,
forall a. a -> Maybe a
Prelude.Just (Key
"Keys" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty (HashMap Text AttributeValue)
keys)
]
)