{-# 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 Amazonka.DynamoDB.Types.AttributeValue
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data KeysAndAttributes = KeysAndAttributes'
{
KeysAndAttributes -> Maybe Text
projectionExpression :: Prelude.Maybe Prelude.Text,
KeysAndAttributes -> Maybe (NonEmpty Text)
attributesToGet :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
KeysAndAttributes -> Maybe (HashMap Text Text)
expressionAttributeNames :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
KeysAndAttributes -> Maybe Bool
consistentRead :: Prelude.Maybe Prelude.Bool,
KeysAndAttributes -> NonEmpty (HashMap Text AttributeValue)
keys :: Prelude.NonEmpty (Prelude.HashMap Prelude.Text AttributeValue)
}
deriving (KeysAndAttributes -> KeysAndAttributes -> Bool
(KeysAndAttributes -> KeysAndAttributes -> Bool)
-> (KeysAndAttributes -> KeysAndAttributes -> Bool)
-> Eq KeysAndAttributes
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]
(Int -> ReadS KeysAndAttributes)
-> ReadS [KeysAndAttributes]
-> ReadPrec KeysAndAttributes
-> ReadPrec [KeysAndAttributes]
-> Read 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
(Int -> KeysAndAttributes -> ShowS)
-> (KeysAndAttributes -> String)
-> ([KeysAndAttributes] -> ShowS)
-> Show KeysAndAttributes
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. KeysAndAttributes -> Rep KeysAndAttributes x)
-> (forall x. Rep KeysAndAttributes x -> KeysAndAttributes)
-> Generic KeysAndAttributes
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' :: Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe (HashMap Text Text)
-> Maybe Bool
-> NonEmpty (HashMap Text AttributeValue)
-> KeysAndAttributes
KeysAndAttributes'
{ $sel:projectionExpression:KeysAndAttributes' :: Maybe Text
projectionExpression =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:attributesToGet:KeysAndAttributes' :: Maybe (NonEmpty Text)
attributesToGet = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
$sel:expressionAttributeNames:KeysAndAttributes' :: Maybe (HashMap Text Text)
expressionAttributeNames = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:consistentRead:KeysAndAttributes' :: Maybe Bool
consistentRead = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:keys:KeysAndAttributes' :: NonEmpty (HashMap Text AttributeValue)
keys = Tagged
(NonEmpty (HashMap Text AttributeValue))
(Identity (NonEmpty (HashMap Text AttributeValue)))
-> Tagged
(NonEmpty (HashMap Text AttributeValue))
(Identity (NonEmpty (HashMap Text AttributeValue)))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty (HashMap Text AttributeValue))
(Identity (NonEmpty (HashMap Text AttributeValue)))
-> Tagged
(NonEmpty (HashMap Text AttributeValue))
(Identity (NonEmpty (HashMap Text AttributeValue))))
-> NonEmpty (HashMap Text AttributeValue)
-> NonEmpty (HashMap Text AttributeValue)
forall t b. AReview t b -> b -> t
Lens.# NonEmpty (HashMap Text AttributeValue)
pKeys_
}
keysAndAttributes_projectionExpression :: Lens.Lens' KeysAndAttributes (Prelude.Maybe Prelude.Text)
keysAndAttributes_projectionExpression :: (Maybe Text -> f (Maybe Text))
-> KeysAndAttributes -> f KeysAndAttributes
keysAndAttributes_projectionExpression = (KeysAndAttributes -> Maybe Text)
-> (KeysAndAttributes -> Maybe Text -> KeysAndAttributes)
-> Lens
KeysAndAttributes KeysAndAttributes (Maybe Text) (Maybe Text)
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_attributesToGet :: Lens.Lens' KeysAndAttributes (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
keysAndAttributes_attributesToGet :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> KeysAndAttributes -> f KeysAndAttributes
keysAndAttributes_attributesToGet = (KeysAndAttributes -> Maybe (NonEmpty Text))
-> (KeysAndAttributes
-> Maybe (NonEmpty Text) -> KeysAndAttributes)
-> Lens
KeysAndAttributes
KeysAndAttributes
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
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) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> KeysAndAttributes -> f KeysAndAttributes)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> KeysAndAttributes
-> f KeysAndAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
keysAndAttributes_expressionAttributeNames :: Lens.Lens' KeysAndAttributes (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
keysAndAttributes_expressionAttributeNames :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> KeysAndAttributes -> f KeysAndAttributes
keysAndAttributes_expressionAttributeNames = (KeysAndAttributes -> Maybe (HashMap Text Text))
-> (KeysAndAttributes
-> Maybe (HashMap Text Text) -> KeysAndAttributes)
-> Lens
KeysAndAttributes
KeysAndAttributes
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> KeysAndAttributes -> f KeysAndAttributes)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> KeysAndAttributes
-> f KeysAndAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
keysAndAttributes_consistentRead :: Lens.Lens' KeysAndAttributes (Prelude.Maybe Prelude.Bool)
keysAndAttributes_consistentRead :: (Maybe Bool -> f (Maybe Bool))
-> KeysAndAttributes -> f KeysAndAttributes
keysAndAttributes_consistentRead = (KeysAndAttributes -> Maybe Bool)
-> (KeysAndAttributes -> Maybe Bool -> KeysAndAttributes)
-> Lens
KeysAndAttributes KeysAndAttributes (Maybe Bool) (Maybe Bool)
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_keys :: Lens.Lens' KeysAndAttributes (Prelude.NonEmpty (Prelude.HashMap Prelude.Text AttributeValue))
keysAndAttributes_keys :: (NonEmpty (HashMap Text AttributeValue)
-> f (NonEmpty (HashMap Text AttributeValue)))
-> KeysAndAttributes -> f KeysAndAttributes
keysAndAttributes_keys = (KeysAndAttributes -> NonEmpty (HashMap Text AttributeValue))
-> (KeysAndAttributes
-> NonEmpty (HashMap Text AttributeValue) -> KeysAndAttributes)
-> Lens
KeysAndAttributes
KeysAndAttributes
(NonEmpty (HashMap Text AttributeValue))
(NonEmpty (HashMap Text AttributeValue))
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) ((NonEmpty (HashMap Text AttributeValue)
-> f (NonEmpty (HashMap Text AttributeValue)))
-> KeysAndAttributes -> f KeysAndAttributes)
-> ((NonEmpty (HashMap Text AttributeValue)
-> f (NonEmpty (HashMap Text AttributeValue)))
-> NonEmpty (HashMap Text AttributeValue)
-> f (NonEmpty (HashMap Text AttributeValue)))
-> (NonEmpty (HashMap Text AttributeValue)
-> f (NonEmpty (HashMap Text AttributeValue)))
-> KeysAndAttributes
-> f KeysAndAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty (HashMap Text AttributeValue)
-> f (NonEmpty (HashMap Text AttributeValue)))
-> NonEmpty (HashMap Text AttributeValue)
-> f (NonEmpty (HashMap Text AttributeValue))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON KeysAndAttributes where
parseJSON :: Value -> Parser KeysAndAttributes
parseJSON =
String
-> (Object -> Parser KeysAndAttributes)
-> Value
-> Parser KeysAndAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"KeysAndAttributes"
( \Object
x ->
Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe (HashMap Text Text)
-> Maybe Bool
-> NonEmpty (HashMap Text AttributeValue)
-> KeysAndAttributes
KeysAndAttributes'
(Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe (HashMap Text Text)
-> Maybe Bool
-> NonEmpty (HashMap Text AttributeValue)
-> KeysAndAttributes)
-> Parser (Maybe Text)
-> Parser
(Maybe (NonEmpty Text)
-> Maybe (HashMap Text Text)
-> Maybe Bool
-> NonEmpty (HashMap Text AttributeValue)
-> KeysAndAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProjectionExpression")
Parser
(Maybe (NonEmpty Text)
-> Maybe (HashMap Text Text)
-> Maybe Bool
-> NonEmpty (HashMap Text AttributeValue)
-> KeysAndAttributes)
-> Parser (Maybe (NonEmpty Text))
-> Parser
(Maybe (HashMap Text Text)
-> Maybe Bool
-> NonEmpty (HashMap Text AttributeValue)
-> KeysAndAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttributesToGet")
Parser
(Maybe (HashMap Text Text)
-> Maybe Bool
-> NonEmpty (HashMap Text AttributeValue)
-> KeysAndAttributes)
-> Parser (Maybe (HashMap Text Text))
-> Parser
(Maybe Bool
-> NonEmpty (HashMap Text AttributeValue) -> KeysAndAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExpressionAttributeNames"
Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty
)
Parser
(Maybe Bool
-> NonEmpty (HashMap Text AttributeValue) -> KeysAndAttributes)
-> Parser (Maybe Bool)
-> Parser
(NonEmpty (HashMap Text AttributeValue) -> KeysAndAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConsistentRead")
Parser
(NonEmpty (HashMap Text AttributeValue) -> KeysAndAttributes)
-> Parser (NonEmpty (HashMap Text AttributeValue))
-> Parser KeysAndAttributes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty (HashMap Text AttributeValue))
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Keys")
)
instance Prelude.Hashable KeysAndAttributes
instance Prelude.NFData KeysAndAttributes
instance Core.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)
consistentRead :: Maybe Bool
expressionAttributeNames :: Maybe (HashMap Text Text)
attributesToGet :: Maybe (NonEmpty Text)
projectionExpression :: Maybe Text
$sel:keys:KeysAndAttributes' :: KeysAndAttributes -> NonEmpty (HashMap Text AttributeValue)
$sel:consistentRead:KeysAndAttributes' :: KeysAndAttributes -> Maybe Bool
$sel:expressionAttributeNames:KeysAndAttributes' :: KeysAndAttributes -> Maybe (HashMap Text Text)
$sel:attributesToGet:KeysAndAttributes' :: KeysAndAttributes -> Maybe (NonEmpty Text)
$sel:projectionExpression:KeysAndAttributes' :: KeysAndAttributes -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ProjectionExpression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
projectionExpression,
(Text
"AttributesToGet" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
attributesToGet,
(Text
"ExpressionAttributeNames" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
expressionAttributeNames,
(Text
"ConsistentRead" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
consistentRead,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Keys" Text -> NonEmpty (HashMap Text AttributeValue) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty (HashMap Text AttributeValue)
keys)
]
)