{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
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

-- | 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'
  { -- | 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,
    -- | 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),
    -- | 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),
    -- | 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,
    -- | 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
(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)

-- |
-- 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:
--
-- '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/.
--
-- '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/.
--
-- '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/.
--
-- '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.
--
-- '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' :: 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_
    }

-- | 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 :: (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)

-- | 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 :: (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

-- | 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 :: (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

-- | 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 :: (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)

-- | 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 :: (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)
          ]
      )