{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.DynamoDB.Types.KeysAndAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
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

-- | Represents a set of primary keys and, for each key, the attributes to
-- retrieve from the table.
--
-- For each primary key, you must provide /all/ of the key attributes. For
-- example, with a simple primary key, you only need to provide the
-- partition key. For a composite primary key, you must provide /both/ the
-- partition key and the sort key.
--
-- /See:/ 'newKeysAndAttributes' smart constructor.
data KeysAndAttributes = KeysAndAttributes'
  { -- | This is a legacy parameter. Use @ProjectionExpression@ instead. For more
    -- information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.html Legacy Conditional Parameters>
    -- in the /Amazon DynamoDB Developer Guide/.
    KeysAndAttributes -> Maybe (NonEmpty Text)
attributesToGet :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The consistency of a read operation. If set to @true@, then a strongly
    -- consistent read is used; otherwise, an eventually consistent read is
    -- used.
    KeysAndAttributes -> Maybe Bool
consistentRead :: Prelude.Maybe Prelude.Bool,
    -- | 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 on expression attribute names, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Accessing Item Attributes>
    -- in the /Amazon DynamoDB Developer Guide/.
    KeysAndAttributes -> Maybe (HashMap Text Text)
expressionAttributeNames :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A string that identifies one or more attributes to retrieve from the
    -- table. These attributes can include scalars, sets, or elements of a JSON
    -- document. The attributes in the @ProjectionExpression@ must be separated
    -- by commas.
    --
    -- If no attribute names are specified, then all attributes will be
    -- returned. If any of the requested attributes are not found, they will
    -- not appear in the result.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Accessing Item Attributes>
    -- in the /Amazon DynamoDB Developer Guide/.
    KeysAndAttributes -> Maybe Text
projectionExpression :: Prelude.Maybe Prelude.Text,
    -- | The primary key attribute values that define the items and the
    -- attributes associated with the items.
    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)

-- |
-- Create a value of 'KeysAndAttributes' 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:
--
-- 'attributesToGet', 'keysAndAttributes_attributesToGet' - This is a legacy parameter. Use @ProjectionExpression@ instead. For more
-- information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.html Legacy Conditional Parameters>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'consistentRead', 'keysAndAttributes_consistentRead' - The consistency of a read operation. If set to @true@, then a strongly
-- consistent read is used; otherwise, an eventually consistent read is
-- used.
--
-- 'expressionAttributeNames', 'keysAndAttributes_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 on expression attribute names, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Accessing Item Attributes>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'projectionExpression', 'keysAndAttributes_projectionExpression' - A string that identifies one or more attributes to retrieve from the
-- table. These attributes can include scalars, sets, or elements of a JSON
-- document. The attributes in the @ProjectionExpression@ must be separated
-- by commas.
--
-- If no attribute names are specified, then all attributes will be
-- returned. If any of the requested attributes are not found, they will
-- not appear in the result.
--
-- For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Accessing Item Attributes>
-- in the /Amazon DynamoDB Developer Guide/.
--
-- 'keys', 'keysAndAttributes_keys' - The primary key attribute values that define the items and the
-- attributes associated with the items.
newKeysAndAttributes ::
  -- | 'keys'
  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_
    }

-- | This is a legacy parameter. Use @ProjectionExpression@ instead. For more
-- information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.html Legacy Conditional Parameters>
-- in the /Amazon DynamoDB Developer Guide/.
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

-- | The consistency of a read operation. If set to @true@, then a strongly
-- consistent read is used; otherwise, an eventually consistent read is
-- used.
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)

-- | 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 on expression attribute names, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Accessing Item Attributes>
-- in the /Amazon DynamoDB Developer Guide/.
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

-- | A string that identifies one or more attributes to retrieve from the
-- table. These attributes can include scalars, sets, or elements of a JSON
-- document. The attributes in the @ProjectionExpression@ must be separated
-- by commas.
--
-- If no attribute names are specified, then all attributes will be
-- returned. If any of the requested attributes are not found, they will
-- not appear in the result.
--
-- For more information, see
-- <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Accessing Item Attributes>
-- in the /Amazon DynamoDB Developer Guide/.
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)

-- | The primary key attribute values that define the items and the
-- attributes associated with the items.
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)
          ]
      )