{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.ExecuteStatement
-- 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)
--
-- This operation allows you to perform reads and singleton writes on data
-- stored in DynamoDB, using PartiQL.
module Amazonka.DynamoDB.ExecuteStatement
  ( -- * Creating a Request
    ExecuteStatement (..),
    newExecuteStatement,

    -- * Request Lenses
    executeStatement_consistentRead,
    executeStatement_nextToken,
    executeStatement_parameters,
    executeStatement_statement,

    -- * Destructuring the Response
    ExecuteStatementResponse (..),
    newExecuteStatementResponse,

    -- * Response Lenses
    executeStatementResponse_items,
    executeStatementResponse_nextToken,
    executeStatementResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newExecuteStatement' smart constructor.
data ExecuteStatement = ExecuteStatement'
  { -- | The consistency of a read operation. If set to @true@, then a strongly
    -- consistent read is used; otherwise, an eventually consistent read is
    -- used.
    ExecuteStatement -> Maybe Bool
consistentRead :: Prelude.Maybe Prelude.Bool,
    -- | Set this value to get remaining results, if @NextToken@ was returned in
    -- the statement response.
    ExecuteStatement -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The parameters for the PartiQL statement, if any.
    ExecuteStatement -> Maybe (NonEmpty AttributeValue)
parameters :: Prelude.Maybe (Prelude.NonEmpty AttributeValue),
    -- | The PartiQL statement representing the operation to run.
    ExecuteStatement -> Text
statement :: Prelude.Text
  }
  deriving (ExecuteStatement -> ExecuteStatement -> Bool
(ExecuteStatement -> ExecuteStatement -> Bool)
-> (ExecuteStatement -> ExecuteStatement -> Bool)
-> Eq ExecuteStatement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteStatement -> ExecuteStatement -> Bool
$c/= :: ExecuteStatement -> ExecuteStatement -> Bool
== :: ExecuteStatement -> ExecuteStatement -> Bool
$c== :: ExecuteStatement -> ExecuteStatement -> Bool
Prelude.Eq, ReadPrec [ExecuteStatement]
ReadPrec ExecuteStatement
Int -> ReadS ExecuteStatement
ReadS [ExecuteStatement]
(Int -> ReadS ExecuteStatement)
-> ReadS [ExecuteStatement]
-> ReadPrec ExecuteStatement
-> ReadPrec [ExecuteStatement]
-> Read ExecuteStatement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteStatement]
$creadListPrec :: ReadPrec [ExecuteStatement]
readPrec :: ReadPrec ExecuteStatement
$creadPrec :: ReadPrec ExecuteStatement
readList :: ReadS [ExecuteStatement]
$creadList :: ReadS [ExecuteStatement]
readsPrec :: Int -> ReadS ExecuteStatement
$creadsPrec :: Int -> ReadS ExecuteStatement
Prelude.Read, Int -> ExecuteStatement -> ShowS
[ExecuteStatement] -> ShowS
ExecuteStatement -> String
(Int -> ExecuteStatement -> ShowS)
-> (ExecuteStatement -> String)
-> ([ExecuteStatement] -> ShowS)
-> Show ExecuteStatement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteStatement] -> ShowS
$cshowList :: [ExecuteStatement] -> ShowS
show :: ExecuteStatement -> String
$cshow :: ExecuteStatement -> String
showsPrec :: Int -> ExecuteStatement -> ShowS
$cshowsPrec :: Int -> ExecuteStatement -> ShowS
Prelude.Show, (forall x. ExecuteStatement -> Rep ExecuteStatement x)
-> (forall x. Rep ExecuteStatement x -> ExecuteStatement)
-> Generic ExecuteStatement
forall x. Rep ExecuteStatement x -> ExecuteStatement
forall x. ExecuteStatement -> Rep ExecuteStatement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecuteStatement x -> ExecuteStatement
$cfrom :: forall x. ExecuteStatement -> Rep ExecuteStatement x
Prelude.Generic)

-- |
-- Create a value of 'ExecuteStatement' 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:
--
-- 'consistentRead', 'executeStatement_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.
--
-- 'nextToken', 'executeStatement_nextToken' - Set this value to get remaining results, if @NextToken@ was returned in
-- the statement response.
--
-- 'parameters', 'executeStatement_parameters' - The parameters for the PartiQL statement, if any.
--
-- 'statement', 'executeStatement_statement' - The PartiQL statement representing the operation to run.
newExecuteStatement ::
  -- | 'statement'
  Prelude.Text ->
  ExecuteStatement
newExecuteStatement :: Text -> ExecuteStatement
newExecuteStatement Text
pStatement_ =
  ExecuteStatement' :: Maybe Bool
-> Maybe Text
-> Maybe (NonEmpty AttributeValue)
-> Text
-> ExecuteStatement
ExecuteStatement'
    { $sel:consistentRead:ExecuteStatement' :: Maybe Bool
consistentRead = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ExecuteStatement' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:ExecuteStatement' :: Maybe (NonEmpty AttributeValue)
parameters = Maybe (NonEmpty AttributeValue)
forall a. Maybe a
Prelude.Nothing,
      $sel:statement:ExecuteStatement' :: Text
statement = Text
pStatement_
    }

-- | The consistency of a read operation. If set to @true@, then a strongly
-- consistent read is used; otherwise, an eventually consistent read is
-- used.
executeStatement_consistentRead :: Lens.Lens' ExecuteStatement (Prelude.Maybe Prelude.Bool)
executeStatement_consistentRead :: (Maybe Bool -> f (Maybe Bool))
-> ExecuteStatement -> f ExecuteStatement
executeStatement_consistentRead = (ExecuteStatement -> Maybe Bool)
-> (ExecuteStatement -> Maybe Bool -> ExecuteStatement)
-> Lens ExecuteStatement ExecuteStatement (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatement' {Maybe Bool
consistentRead :: Maybe Bool
$sel:consistentRead:ExecuteStatement' :: ExecuteStatement -> Maybe Bool
consistentRead} -> Maybe Bool
consistentRead) (\s :: ExecuteStatement
s@ExecuteStatement' {} Maybe Bool
a -> ExecuteStatement
s {$sel:consistentRead:ExecuteStatement' :: Maybe Bool
consistentRead = Maybe Bool
a} :: ExecuteStatement)

-- | Set this value to get remaining results, if @NextToken@ was returned in
-- the statement response.
executeStatement_nextToken :: Lens.Lens' ExecuteStatement (Prelude.Maybe Prelude.Text)
executeStatement_nextToken :: (Maybe Text -> f (Maybe Text))
-> ExecuteStatement -> f ExecuteStatement
executeStatement_nextToken = (ExecuteStatement -> Maybe Text)
-> (ExecuteStatement -> Maybe Text -> ExecuteStatement)
-> Lens ExecuteStatement ExecuteStatement (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatement' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ExecuteStatement' :: ExecuteStatement -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ExecuteStatement
s@ExecuteStatement' {} Maybe Text
a -> ExecuteStatement
s {$sel:nextToken:ExecuteStatement' :: Maybe Text
nextToken = Maybe Text
a} :: ExecuteStatement)

-- | The parameters for the PartiQL statement, if any.
executeStatement_parameters :: Lens.Lens' ExecuteStatement (Prelude.Maybe (Prelude.NonEmpty AttributeValue))
executeStatement_parameters :: (Maybe (NonEmpty AttributeValue)
 -> f (Maybe (NonEmpty AttributeValue)))
-> ExecuteStatement -> f ExecuteStatement
executeStatement_parameters = (ExecuteStatement -> Maybe (NonEmpty AttributeValue))
-> (ExecuteStatement
    -> Maybe (NonEmpty AttributeValue) -> ExecuteStatement)
-> Lens
     ExecuteStatement
     ExecuteStatement
     (Maybe (NonEmpty AttributeValue))
     (Maybe (NonEmpty AttributeValue))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatement' {Maybe (NonEmpty AttributeValue)
parameters :: Maybe (NonEmpty AttributeValue)
$sel:parameters:ExecuteStatement' :: ExecuteStatement -> Maybe (NonEmpty AttributeValue)
parameters} -> Maybe (NonEmpty AttributeValue)
parameters) (\s :: ExecuteStatement
s@ExecuteStatement' {} Maybe (NonEmpty AttributeValue)
a -> ExecuteStatement
s {$sel:parameters:ExecuteStatement' :: Maybe (NonEmpty AttributeValue)
parameters = Maybe (NonEmpty AttributeValue)
a} :: ExecuteStatement) ((Maybe (NonEmpty AttributeValue)
  -> f (Maybe (NonEmpty AttributeValue)))
 -> ExecuteStatement -> f ExecuteStatement)
-> ((Maybe (NonEmpty AttributeValue)
     -> f (Maybe (NonEmpty AttributeValue)))
    -> Maybe (NonEmpty AttributeValue)
    -> f (Maybe (NonEmpty AttributeValue)))
-> (Maybe (NonEmpty AttributeValue)
    -> f (Maybe (NonEmpty AttributeValue)))
-> ExecuteStatement
-> f ExecuteStatement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
-> Iso
     (Maybe (NonEmpty AttributeValue))
     (Maybe (NonEmpty AttributeValue))
     (Maybe (NonEmpty AttributeValue))
     (Maybe (NonEmpty AttributeValue))
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 AttributeValue)
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The PartiQL statement representing the operation to run.
executeStatement_statement :: Lens.Lens' ExecuteStatement Prelude.Text
executeStatement_statement :: (Text -> f Text) -> ExecuteStatement -> f ExecuteStatement
executeStatement_statement = (ExecuteStatement -> Text)
-> (ExecuteStatement -> Text -> ExecuteStatement)
-> Lens ExecuteStatement ExecuteStatement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatement' {Text
statement :: Text
$sel:statement:ExecuteStatement' :: ExecuteStatement -> Text
statement} -> Text
statement) (\s :: ExecuteStatement
s@ExecuteStatement' {} Text
a -> ExecuteStatement
s {$sel:statement:ExecuteStatement' :: Text
statement = Text
a} :: ExecuteStatement)

instance Core.AWSRequest ExecuteStatement where
  type
    AWSResponse ExecuteStatement =
      ExecuteStatementResponse
  request :: ExecuteStatement -> Request ExecuteStatement
request = Service -> ExecuteStatement -> Request ExecuteStatement
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ExecuteStatement
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExecuteStatement)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ExecuteStatement))
-> Logger
-> Service
-> Proxy ExecuteStatement
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExecuteStatement)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [HashMap Text AttributeValue]
-> Maybe Text -> Int -> ExecuteStatementResponse
ExecuteStatementResponse'
            (Maybe [HashMap Text AttributeValue]
 -> Maybe Text -> Int -> ExecuteStatementResponse)
-> Either String (Maybe [HashMap Text AttributeValue])
-> Either String (Maybe Text -> Int -> ExecuteStatementResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Either String (Maybe (Maybe [HashMap Text AttributeValue]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Items" Either String (Maybe (Maybe [HashMap Text AttributeValue]))
-> Maybe [HashMap Text AttributeValue]
-> Either String (Maybe [HashMap Text AttributeValue])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [HashMap Text AttributeValue]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> ExecuteStatementResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ExecuteStatementResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> ExecuteStatementResponse)
-> Either String Int -> Either String ExecuteStatementResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ExecuteStatement

instance Prelude.NFData ExecuteStatement

instance Core.ToHeaders ExecuteStatement where
  toHeaders :: ExecuteStatement -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ExecuteStatement -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DynamoDB_20120810.ExecuteStatement" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ExecuteStatement where
  toJSON :: ExecuteStatement -> Value
toJSON ExecuteStatement' {Maybe Bool
Maybe (NonEmpty AttributeValue)
Maybe Text
Text
statement :: Text
parameters :: Maybe (NonEmpty AttributeValue)
nextToken :: Maybe Text
consistentRead :: Maybe Bool
$sel:statement:ExecuteStatement' :: ExecuteStatement -> Text
$sel:parameters:ExecuteStatement' :: ExecuteStatement -> Maybe (NonEmpty AttributeValue)
$sel:nextToken:ExecuteStatement' :: ExecuteStatement -> Maybe Text
$sel:consistentRead:ExecuteStatement' :: ExecuteStatement -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            (Text
"NextToken" 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
nextToken,
            (Text
"Parameters" Text -> NonEmpty AttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty AttributeValue -> Pair)
-> Maybe (NonEmpty AttributeValue) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty AttributeValue)
parameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Statement" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
statement)
          ]
      )

instance Core.ToPath ExecuteStatement where
  toPath :: ExecuteStatement -> ByteString
toPath = ByteString -> ExecuteStatement -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ExecuteStatement where
  toQuery :: ExecuteStatement -> QueryString
toQuery = QueryString -> ExecuteStatement -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newExecuteStatementResponse' smart constructor.
data ExecuteStatementResponse = ExecuteStatementResponse'
  { -- | If a read operation was used, this property will contain the result of
    -- the reade operation; a map of attribute names and their values. For the
    -- write operations this value will be empty.
    ExecuteStatementResponse -> Maybe [HashMap Text AttributeValue]
items :: Prelude.Maybe [Prelude.HashMap Prelude.Text AttributeValue],
    -- | If the response of a read request exceeds the response payload limit
    -- DynamoDB will set this value in the response. If set, you can use that
    -- this value in the subsequent request to get the remaining results.
    ExecuteStatementResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ExecuteStatementResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ExecuteStatementResponse -> ExecuteStatementResponse -> Bool
(ExecuteStatementResponse -> ExecuteStatementResponse -> Bool)
-> (ExecuteStatementResponse -> ExecuteStatementResponse -> Bool)
-> Eq ExecuteStatementResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteStatementResponse -> ExecuteStatementResponse -> Bool
$c/= :: ExecuteStatementResponse -> ExecuteStatementResponse -> Bool
== :: ExecuteStatementResponse -> ExecuteStatementResponse -> Bool
$c== :: ExecuteStatementResponse -> ExecuteStatementResponse -> Bool
Prelude.Eq, ReadPrec [ExecuteStatementResponse]
ReadPrec ExecuteStatementResponse
Int -> ReadS ExecuteStatementResponse
ReadS [ExecuteStatementResponse]
(Int -> ReadS ExecuteStatementResponse)
-> ReadS [ExecuteStatementResponse]
-> ReadPrec ExecuteStatementResponse
-> ReadPrec [ExecuteStatementResponse]
-> Read ExecuteStatementResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteStatementResponse]
$creadListPrec :: ReadPrec [ExecuteStatementResponse]
readPrec :: ReadPrec ExecuteStatementResponse
$creadPrec :: ReadPrec ExecuteStatementResponse
readList :: ReadS [ExecuteStatementResponse]
$creadList :: ReadS [ExecuteStatementResponse]
readsPrec :: Int -> ReadS ExecuteStatementResponse
$creadsPrec :: Int -> ReadS ExecuteStatementResponse
Prelude.Read, Int -> ExecuteStatementResponse -> ShowS
[ExecuteStatementResponse] -> ShowS
ExecuteStatementResponse -> String
(Int -> ExecuteStatementResponse -> ShowS)
-> (ExecuteStatementResponse -> String)
-> ([ExecuteStatementResponse] -> ShowS)
-> Show ExecuteStatementResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteStatementResponse] -> ShowS
$cshowList :: [ExecuteStatementResponse] -> ShowS
show :: ExecuteStatementResponse -> String
$cshow :: ExecuteStatementResponse -> String
showsPrec :: Int -> ExecuteStatementResponse -> ShowS
$cshowsPrec :: Int -> ExecuteStatementResponse -> ShowS
Prelude.Show, (forall x.
 ExecuteStatementResponse -> Rep ExecuteStatementResponse x)
-> (forall x.
    Rep ExecuteStatementResponse x -> ExecuteStatementResponse)
-> Generic ExecuteStatementResponse
forall x.
Rep ExecuteStatementResponse x -> ExecuteStatementResponse
forall x.
ExecuteStatementResponse -> Rep ExecuteStatementResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExecuteStatementResponse x -> ExecuteStatementResponse
$cfrom :: forall x.
ExecuteStatementResponse -> Rep ExecuteStatementResponse x
Prelude.Generic)

-- |
-- Create a value of 'ExecuteStatementResponse' 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:
--
-- 'items', 'executeStatementResponse_items' - If a read operation was used, this property will contain the result of
-- the reade operation; a map of attribute names and their values. For the
-- write operations this value will be empty.
--
-- 'nextToken', 'executeStatementResponse_nextToken' - If the response of a read request exceeds the response payload limit
-- DynamoDB will set this value in the response. If set, you can use that
-- this value in the subsequent request to get the remaining results.
--
-- 'httpStatus', 'executeStatementResponse_httpStatus' - The response's http status code.
newExecuteStatementResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ExecuteStatementResponse
newExecuteStatementResponse :: Int -> ExecuteStatementResponse
newExecuteStatementResponse Int
pHttpStatus_ =
  ExecuteStatementResponse' :: Maybe [HashMap Text AttributeValue]
-> Maybe Text -> Int -> ExecuteStatementResponse
ExecuteStatementResponse'
    { $sel:items:ExecuteStatementResponse' :: Maybe [HashMap Text AttributeValue]
items = Maybe [HashMap Text AttributeValue]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ExecuteStatementResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ExecuteStatementResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If a read operation was used, this property will contain the result of
-- the reade operation; a map of attribute names and their values. For the
-- write operations this value will be empty.
executeStatementResponse_items :: Lens.Lens' ExecuteStatementResponse (Prelude.Maybe [Prelude.HashMap Prelude.Text AttributeValue])
executeStatementResponse_items :: (Maybe [HashMap Text AttributeValue]
 -> f (Maybe [HashMap Text AttributeValue]))
-> ExecuteStatementResponse -> f ExecuteStatementResponse
executeStatementResponse_items = (ExecuteStatementResponse -> Maybe [HashMap Text AttributeValue])
-> (ExecuteStatementResponse
    -> Maybe [HashMap Text AttributeValue] -> ExecuteStatementResponse)
-> Lens
     ExecuteStatementResponse
     ExecuteStatementResponse
     (Maybe [HashMap Text AttributeValue])
     (Maybe [HashMap Text AttributeValue])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatementResponse' {Maybe [HashMap Text AttributeValue]
items :: Maybe [HashMap Text AttributeValue]
$sel:items:ExecuteStatementResponse' :: ExecuteStatementResponse -> Maybe [HashMap Text AttributeValue]
items} -> Maybe [HashMap Text AttributeValue]
items) (\s :: ExecuteStatementResponse
s@ExecuteStatementResponse' {} Maybe [HashMap Text AttributeValue]
a -> ExecuteStatementResponse
s {$sel:items:ExecuteStatementResponse' :: Maybe [HashMap Text AttributeValue]
items = Maybe [HashMap Text AttributeValue]
a} :: ExecuteStatementResponse) ((Maybe [HashMap Text AttributeValue]
  -> f (Maybe [HashMap Text AttributeValue]))
 -> ExecuteStatementResponse -> f ExecuteStatementResponse)
-> ((Maybe [HashMap Text AttributeValue]
     -> f (Maybe [HashMap Text AttributeValue]))
    -> Maybe [HashMap Text AttributeValue]
    -> f (Maybe [HashMap Text AttributeValue]))
-> (Maybe [HashMap Text AttributeValue]
    -> f (Maybe [HashMap Text AttributeValue]))
-> ExecuteStatementResponse
-> f ExecuteStatementResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [HashMap Text AttributeValue]
  [HashMap Text AttributeValue]
  [HashMap Text AttributeValue]
  [HashMap Text AttributeValue]
-> Iso
     (Maybe [HashMap Text AttributeValue])
     (Maybe [HashMap Text AttributeValue])
     (Maybe [HashMap Text AttributeValue])
     (Maybe [HashMap Text AttributeValue])
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 AttributeValue]
  [HashMap Text AttributeValue]
  [HashMap Text AttributeValue]
  [HashMap Text AttributeValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If the response of a read request exceeds the response payload limit
-- DynamoDB will set this value in the response. If set, you can use that
-- this value in the subsequent request to get the remaining results.
executeStatementResponse_nextToken :: Lens.Lens' ExecuteStatementResponse (Prelude.Maybe Prelude.Text)
executeStatementResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ExecuteStatementResponse -> f ExecuteStatementResponse
executeStatementResponse_nextToken = (ExecuteStatementResponse -> Maybe Text)
-> (ExecuteStatementResponse
    -> Maybe Text -> ExecuteStatementResponse)
-> Lens
     ExecuteStatementResponse
     ExecuteStatementResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatementResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ExecuteStatementResponse' :: ExecuteStatementResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ExecuteStatementResponse
s@ExecuteStatementResponse' {} Maybe Text
a -> ExecuteStatementResponse
s {$sel:nextToken:ExecuteStatementResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ExecuteStatementResponse)

-- | The response's http status code.
executeStatementResponse_httpStatus :: Lens.Lens' ExecuteStatementResponse Prelude.Int
executeStatementResponse_httpStatus :: (Int -> f Int)
-> ExecuteStatementResponse -> f ExecuteStatementResponse
executeStatementResponse_httpStatus = (ExecuteStatementResponse -> Int)
-> (ExecuteStatementResponse -> Int -> ExecuteStatementResponse)
-> Lens ExecuteStatementResponse ExecuteStatementResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatementResponse' {Int
httpStatus :: Int
$sel:httpStatus:ExecuteStatementResponse' :: ExecuteStatementResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ExecuteStatementResponse
s@ExecuteStatementResponse' {} Int
a -> ExecuteStatementResponse
s {$sel:httpStatus:ExecuteStatementResponse' :: Int
httpStatus = Int
a} :: ExecuteStatementResponse)

instance Prelude.NFData ExecuteStatementResponse