{-# 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 #-}
module Amazonka.DynamoDB.BatchExecuteStatement
(
BatchExecuteStatement (..),
newBatchExecuteStatement,
batchExecuteStatement_statements,
BatchExecuteStatementResponse (..),
newBatchExecuteStatementResponse,
batchExecuteStatementResponse_responses,
batchExecuteStatementResponse_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
data BatchExecuteStatement = BatchExecuteStatement'
{
BatchExecuteStatement -> NonEmpty BatchStatementRequest
statements :: Prelude.NonEmpty BatchStatementRequest
}
deriving (BatchExecuteStatement -> BatchExecuteStatement -> Bool
(BatchExecuteStatement -> BatchExecuteStatement -> Bool)
-> (BatchExecuteStatement -> BatchExecuteStatement -> Bool)
-> Eq BatchExecuteStatement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchExecuteStatement -> BatchExecuteStatement -> Bool
$c/= :: BatchExecuteStatement -> BatchExecuteStatement -> Bool
== :: BatchExecuteStatement -> BatchExecuteStatement -> Bool
$c== :: BatchExecuteStatement -> BatchExecuteStatement -> Bool
Prelude.Eq, ReadPrec [BatchExecuteStatement]
ReadPrec BatchExecuteStatement
Int -> ReadS BatchExecuteStatement
ReadS [BatchExecuteStatement]
(Int -> ReadS BatchExecuteStatement)
-> ReadS [BatchExecuteStatement]
-> ReadPrec BatchExecuteStatement
-> ReadPrec [BatchExecuteStatement]
-> Read BatchExecuteStatement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchExecuteStatement]
$creadListPrec :: ReadPrec [BatchExecuteStatement]
readPrec :: ReadPrec BatchExecuteStatement
$creadPrec :: ReadPrec BatchExecuteStatement
readList :: ReadS [BatchExecuteStatement]
$creadList :: ReadS [BatchExecuteStatement]
readsPrec :: Int -> ReadS BatchExecuteStatement
$creadsPrec :: Int -> ReadS BatchExecuteStatement
Prelude.Read, Int -> BatchExecuteStatement -> ShowS
[BatchExecuteStatement] -> ShowS
BatchExecuteStatement -> String
(Int -> BatchExecuteStatement -> ShowS)
-> (BatchExecuteStatement -> String)
-> ([BatchExecuteStatement] -> ShowS)
-> Show BatchExecuteStatement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchExecuteStatement] -> ShowS
$cshowList :: [BatchExecuteStatement] -> ShowS
show :: BatchExecuteStatement -> String
$cshow :: BatchExecuteStatement -> String
showsPrec :: Int -> BatchExecuteStatement -> ShowS
$cshowsPrec :: Int -> BatchExecuteStatement -> ShowS
Prelude.Show, (forall x. BatchExecuteStatement -> Rep BatchExecuteStatement x)
-> (forall x. Rep BatchExecuteStatement x -> BatchExecuteStatement)
-> Generic BatchExecuteStatement
forall x. Rep BatchExecuteStatement x -> BatchExecuteStatement
forall x. BatchExecuteStatement -> Rep BatchExecuteStatement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchExecuteStatement x -> BatchExecuteStatement
$cfrom :: forall x. BatchExecuteStatement -> Rep BatchExecuteStatement x
Prelude.Generic)
newBatchExecuteStatement ::
Prelude.NonEmpty BatchStatementRequest ->
BatchExecuteStatement
newBatchExecuteStatement :: NonEmpty BatchStatementRequest -> BatchExecuteStatement
newBatchExecuteStatement NonEmpty BatchStatementRequest
pStatements_ =
BatchExecuteStatement' :: NonEmpty BatchStatementRequest -> BatchExecuteStatement
BatchExecuteStatement'
{ $sel:statements:BatchExecuteStatement' :: NonEmpty BatchStatementRequest
statements =
Tagged
(NonEmpty BatchStatementRequest)
(Identity (NonEmpty BatchStatementRequest))
-> Tagged
(NonEmpty BatchStatementRequest)
(Identity (NonEmpty BatchStatementRequest))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty BatchStatementRequest)
(Identity (NonEmpty BatchStatementRequest))
-> Tagged
(NonEmpty BatchStatementRequest)
(Identity (NonEmpty BatchStatementRequest)))
-> NonEmpty BatchStatementRequest -> NonEmpty BatchStatementRequest
forall t b. AReview t b -> b -> t
Lens.# NonEmpty BatchStatementRequest
pStatements_
}
batchExecuteStatement_statements :: Lens.Lens' BatchExecuteStatement (Prelude.NonEmpty BatchStatementRequest)
batchExecuteStatement_statements :: (NonEmpty BatchStatementRequest
-> f (NonEmpty BatchStatementRequest))
-> BatchExecuteStatement -> f BatchExecuteStatement
batchExecuteStatement_statements = (BatchExecuteStatement -> NonEmpty BatchStatementRequest)
-> (BatchExecuteStatement
-> NonEmpty BatchStatementRequest -> BatchExecuteStatement)
-> Lens
BatchExecuteStatement
BatchExecuteStatement
(NonEmpty BatchStatementRequest)
(NonEmpty BatchStatementRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatement' {NonEmpty BatchStatementRequest
statements :: NonEmpty BatchStatementRequest
$sel:statements:BatchExecuteStatement' :: BatchExecuteStatement -> NonEmpty BatchStatementRequest
statements} -> NonEmpty BatchStatementRequest
statements) (\s :: BatchExecuteStatement
s@BatchExecuteStatement' {} NonEmpty BatchStatementRequest
a -> BatchExecuteStatement
s {$sel:statements:BatchExecuteStatement' :: NonEmpty BatchStatementRequest
statements = NonEmpty BatchStatementRequest
a} :: BatchExecuteStatement) ((NonEmpty BatchStatementRequest
-> f (NonEmpty BatchStatementRequest))
-> BatchExecuteStatement -> f BatchExecuteStatement)
-> ((NonEmpty BatchStatementRequest
-> f (NonEmpty BatchStatementRequest))
-> NonEmpty BatchStatementRequest
-> f (NonEmpty BatchStatementRequest))
-> (NonEmpty BatchStatementRequest
-> f (NonEmpty BatchStatementRequest))
-> BatchExecuteStatement
-> f BatchExecuteStatement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty BatchStatementRequest
-> f (NonEmpty BatchStatementRequest))
-> NonEmpty BatchStatementRequest
-> f (NonEmpty BatchStatementRequest)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest BatchExecuteStatement where
type
AWSResponse BatchExecuteStatement =
BatchExecuteStatementResponse
request :: BatchExecuteStatement -> Request BatchExecuteStatement
request = Service -> BatchExecuteStatement -> Request BatchExecuteStatement
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy BatchExecuteStatement
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchExecuteStatement)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse BatchExecuteStatement))
-> Logger
-> Service
-> Proxy BatchExecuteStatement
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchExecuteStatement)))
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 [BatchStatementResponse]
-> Int -> BatchExecuteStatementResponse
BatchExecuteStatementResponse'
(Maybe [BatchStatementResponse]
-> Int -> BatchExecuteStatementResponse)
-> Either String (Maybe [BatchStatementResponse])
-> Either String (Int -> BatchExecuteStatementResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Key -> Either String (Maybe (Maybe [BatchStatementResponse]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"Responses" Either String (Maybe (Maybe [BatchStatementResponse]))
-> Maybe [BatchStatementResponse]
-> Either String (Maybe [BatchStatementResponse])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [BatchStatementResponse]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> BatchExecuteStatementResponse)
-> Either String Int -> Either String BatchExecuteStatementResponse
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 BatchExecuteStatement
instance Prelude.NFData BatchExecuteStatement
instance Core.ToHeaders BatchExecuteStatement where
toHeaders :: BatchExecuteStatement -> ResponseHeaders
toHeaders =
ResponseHeaders -> BatchExecuteStatement -> 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.BatchExecuteStatement" ::
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 BatchExecuteStatement where
toJSON :: BatchExecuteStatement -> Value
toJSON BatchExecuteStatement' {NonEmpty BatchStatementRequest
statements :: NonEmpty BatchStatementRequest
$sel:statements:BatchExecuteStatement' :: BatchExecuteStatement -> NonEmpty BatchStatementRequest
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Key
"Statements" Key -> NonEmpty BatchStatementRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= NonEmpty BatchStatementRequest
statements)]
)
instance Core.ToPath BatchExecuteStatement where
toPath :: BatchExecuteStatement -> ByteString
toPath = ByteString -> BatchExecuteStatement -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery BatchExecuteStatement where
toQuery :: BatchExecuteStatement -> QueryString
toQuery = QueryString -> BatchExecuteStatement -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data BatchExecuteStatementResponse = BatchExecuteStatementResponse'
{
BatchExecuteStatementResponse -> Maybe [BatchStatementResponse]
responses :: Prelude.Maybe [BatchStatementResponse],
BatchExecuteStatementResponse -> Int
httpStatus :: Prelude.Int
}
deriving (BatchExecuteStatementResponse
-> BatchExecuteStatementResponse -> Bool
(BatchExecuteStatementResponse
-> BatchExecuteStatementResponse -> Bool)
-> (BatchExecuteStatementResponse
-> BatchExecuteStatementResponse -> Bool)
-> Eq BatchExecuteStatementResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchExecuteStatementResponse
-> BatchExecuteStatementResponse -> Bool
$c/= :: BatchExecuteStatementResponse
-> BatchExecuteStatementResponse -> Bool
== :: BatchExecuteStatementResponse
-> BatchExecuteStatementResponse -> Bool
$c== :: BatchExecuteStatementResponse
-> BatchExecuteStatementResponse -> Bool
Prelude.Eq, ReadPrec [BatchExecuteStatementResponse]
ReadPrec BatchExecuteStatementResponse
Int -> ReadS BatchExecuteStatementResponse
ReadS [BatchExecuteStatementResponse]
(Int -> ReadS BatchExecuteStatementResponse)
-> ReadS [BatchExecuteStatementResponse]
-> ReadPrec BatchExecuteStatementResponse
-> ReadPrec [BatchExecuteStatementResponse]
-> Read BatchExecuteStatementResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchExecuteStatementResponse]
$creadListPrec :: ReadPrec [BatchExecuteStatementResponse]
readPrec :: ReadPrec BatchExecuteStatementResponse
$creadPrec :: ReadPrec BatchExecuteStatementResponse
readList :: ReadS [BatchExecuteStatementResponse]
$creadList :: ReadS [BatchExecuteStatementResponse]
readsPrec :: Int -> ReadS BatchExecuteStatementResponse
$creadsPrec :: Int -> ReadS BatchExecuteStatementResponse
Prelude.Read, Int -> BatchExecuteStatementResponse -> ShowS
[BatchExecuteStatementResponse] -> ShowS
BatchExecuteStatementResponse -> String
(Int -> BatchExecuteStatementResponse -> ShowS)
-> (BatchExecuteStatementResponse -> String)
-> ([BatchExecuteStatementResponse] -> ShowS)
-> Show BatchExecuteStatementResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchExecuteStatementResponse] -> ShowS
$cshowList :: [BatchExecuteStatementResponse] -> ShowS
show :: BatchExecuteStatementResponse -> String
$cshow :: BatchExecuteStatementResponse -> String
showsPrec :: Int -> BatchExecuteStatementResponse -> ShowS
$cshowsPrec :: Int -> BatchExecuteStatementResponse -> ShowS
Prelude.Show, (forall x.
BatchExecuteStatementResponse
-> Rep BatchExecuteStatementResponse x)
-> (forall x.
Rep BatchExecuteStatementResponse x
-> BatchExecuteStatementResponse)
-> Generic BatchExecuteStatementResponse
forall x.
Rep BatchExecuteStatementResponse x
-> BatchExecuteStatementResponse
forall x.
BatchExecuteStatementResponse
-> Rep BatchExecuteStatementResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchExecuteStatementResponse x
-> BatchExecuteStatementResponse
$cfrom :: forall x.
BatchExecuteStatementResponse
-> Rep BatchExecuteStatementResponse x
Prelude.Generic)
newBatchExecuteStatementResponse ::
Prelude.Int ->
BatchExecuteStatementResponse
newBatchExecuteStatementResponse :: Int -> BatchExecuteStatementResponse
newBatchExecuteStatementResponse Int
pHttpStatus_ =
BatchExecuteStatementResponse' :: Maybe [BatchStatementResponse]
-> Int -> BatchExecuteStatementResponse
BatchExecuteStatementResponse'
{ $sel:responses:BatchExecuteStatementResponse' :: Maybe [BatchStatementResponse]
responses =
Maybe [BatchStatementResponse]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:BatchExecuteStatementResponse' :: Int
httpStatus = Int
pHttpStatus_
}
batchExecuteStatementResponse_responses :: Lens.Lens' BatchExecuteStatementResponse (Prelude.Maybe [BatchStatementResponse])
batchExecuteStatementResponse_responses :: (Maybe [BatchStatementResponse]
-> f (Maybe [BatchStatementResponse]))
-> BatchExecuteStatementResponse -> f BatchExecuteStatementResponse
batchExecuteStatementResponse_responses = (BatchExecuteStatementResponse -> Maybe [BatchStatementResponse])
-> (BatchExecuteStatementResponse
-> Maybe [BatchStatementResponse] -> BatchExecuteStatementResponse)
-> Lens
BatchExecuteStatementResponse
BatchExecuteStatementResponse
(Maybe [BatchStatementResponse])
(Maybe [BatchStatementResponse])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatementResponse' {Maybe [BatchStatementResponse]
responses :: Maybe [BatchStatementResponse]
$sel:responses:BatchExecuteStatementResponse' :: BatchExecuteStatementResponse -> Maybe [BatchStatementResponse]
responses} -> Maybe [BatchStatementResponse]
responses) (\s :: BatchExecuteStatementResponse
s@BatchExecuteStatementResponse' {} Maybe [BatchStatementResponse]
a -> BatchExecuteStatementResponse
s {$sel:responses:BatchExecuteStatementResponse' :: Maybe [BatchStatementResponse]
responses = Maybe [BatchStatementResponse]
a} :: BatchExecuteStatementResponse) ((Maybe [BatchStatementResponse]
-> f (Maybe [BatchStatementResponse]))
-> BatchExecuteStatementResponse
-> f BatchExecuteStatementResponse)
-> ((Maybe [BatchStatementResponse]
-> f (Maybe [BatchStatementResponse]))
-> Maybe [BatchStatementResponse]
-> f (Maybe [BatchStatementResponse]))
-> (Maybe [BatchStatementResponse]
-> f (Maybe [BatchStatementResponse]))
-> BatchExecuteStatementResponse
-> f BatchExecuteStatementResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[BatchStatementResponse]
[BatchStatementResponse]
[BatchStatementResponse]
[BatchStatementResponse]
-> Iso
(Maybe [BatchStatementResponse])
(Maybe [BatchStatementResponse])
(Maybe [BatchStatementResponse])
(Maybe [BatchStatementResponse])
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
[BatchStatementResponse]
[BatchStatementResponse]
[BatchStatementResponse]
[BatchStatementResponse]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchExecuteStatementResponse_httpStatus :: Lens.Lens' BatchExecuteStatementResponse Prelude.Int
batchExecuteStatementResponse_httpStatus :: (Int -> f Int)
-> BatchExecuteStatementResponse -> f BatchExecuteStatementResponse
batchExecuteStatementResponse_httpStatus = (BatchExecuteStatementResponse -> Int)
-> (BatchExecuteStatementResponse
-> Int -> BatchExecuteStatementResponse)
-> Lens
BatchExecuteStatementResponse BatchExecuteStatementResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatementResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchExecuteStatementResponse' :: BatchExecuteStatementResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchExecuteStatementResponse
s@BatchExecuteStatementResponse' {} Int
a -> BatchExecuteStatementResponse
s {$sel:httpStatus:BatchExecuteStatementResponse' :: Int
httpStatus = Int
a} :: BatchExecuteStatementResponse)
instance Prelude.NFData BatchExecuteStatementResponse