{-# 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.ExecuteTransaction
(
ExecuteTransaction (..),
newExecuteTransaction,
executeTransaction_clientRequestToken,
executeTransaction_transactStatements,
ExecuteTransactionResponse (..),
newExecuteTransactionResponse,
executeTransactionResponse_responses,
executeTransactionResponse_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 ExecuteTransaction = ExecuteTransaction'
{
ExecuteTransaction -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
ExecuteTransaction -> NonEmpty ParameterizedStatement
transactStatements :: Prelude.NonEmpty ParameterizedStatement
}
deriving (ExecuteTransaction -> ExecuteTransaction -> Bool
(ExecuteTransaction -> ExecuteTransaction -> Bool)
-> (ExecuteTransaction -> ExecuteTransaction -> Bool)
-> Eq ExecuteTransaction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteTransaction -> ExecuteTransaction -> Bool
$c/= :: ExecuteTransaction -> ExecuteTransaction -> Bool
== :: ExecuteTransaction -> ExecuteTransaction -> Bool
$c== :: ExecuteTransaction -> ExecuteTransaction -> Bool
Prelude.Eq, ReadPrec [ExecuteTransaction]
ReadPrec ExecuteTransaction
Int -> ReadS ExecuteTransaction
ReadS [ExecuteTransaction]
(Int -> ReadS ExecuteTransaction)
-> ReadS [ExecuteTransaction]
-> ReadPrec ExecuteTransaction
-> ReadPrec [ExecuteTransaction]
-> Read ExecuteTransaction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteTransaction]
$creadListPrec :: ReadPrec [ExecuteTransaction]
readPrec :: ReadPrec ExecuteTransaction
$creadPrec :: ReadPrec ExecuteTransaction
readList :: ReadS [ExecuteTransaction]
$creadList :: ReadS [ExecuteTransaction]
readsPrec :: Int -> ReadS ExecuteTransaction
$creadsPrec :: Int -> ReadS ExecuteTransaction
Prelude.Read, Int -> ExecuteTransaction -> ShowS
[ExecuteTransaction] -> ShowS
ExecuteTransaction -> String
(Int -> ExecuteTransaction -> ShowS)
-> (ExecuteTransaction -> String)
-> ([ExecuteTransaction] -> ShowS)
-> Show ExecuteTransaction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteTransaction] -> ShowS
$cshowList :: [ExecuteTransaction] -> ShowS
show :: ExecuteTransaction -> String
$cshow :: ExecuteTransaction -> String
showsPrec :: Int -> ExecuteTransaction -> ShowS
$cshowsPrec :: Int -> ExecuteTransaction -> ShowS
Prelude.Show, (forall x. ExecuteTransaction -> Rep ExecuteTransaction x)
-> (forall x. Rep ExecuteTransaction x -> ExecuteTransaction)
-> Generic ExecuteTransaction
forall x. Rep ExecuteTransaction x -> ExecuteTransaction
forall x. ExecuteTransaction -> Rep ExecuteTransaction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecuteTransaction x -> ExecuteTransaction
$cfrom :: forall x. ExecuteTransaction -> Rep ExecuteTransaction x
Prelude.Generic)
newExecuteTransaction ::
Prelude.NonEmpty ParameterizedStatement ->
ExecuteTransaction
newExecuteTransaction :: NonEmpty ParameterizedStatement -> ExecuteTransaction
newExecuteTransaction NonEmpty ParameterizedStatement
pTransactStatements_ =
ExecuteTransaction' :: Maybe Text -> NonEmpty ParameterizedStatement -> ExecuteTransaction
ExecuteTransaction'
{ $sel:clientRequestToken:ExecuteTransaction' :: Maybe Text
clientRequestToken =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:transactStatements:ExecuteTransaction' :: NonEmpty ParameterizedStatement
transactStatements =
Tagged
(NonEmpty ParameterizedStatement)
(Identity (NonEmpty ParameterizedStatement))
-> Tagged
(NonEmpty ParameterizedStatement)
(Identity (NonEmpty ParameterizedStatement))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty ParameterizedStatement)
(Identity (NonEmpty ParameterizedStatement))
-> Tagged
(NonEmpty ParameterizedStatement)
(Identity (NonEmpty ParameterizedStatement)))
-> NonEmpty ParameterizedStatement
-> NonEmpty ParameterizedStatement
forall t b. AReview t b -> b -> t
Lens.# NonEmpty ParameterizedStatement
pTransactStatements_
}
executeTransaction_clientRequestToken :: Lens.Lens' ExecuteTransaction (Prelude.Maybe Prelude.Text)
executeTransaction_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> ExecuteTransaction -> f ExecuteTransaction
executeTransaction_clientRequestToken = (ExecuteTransaction -> Maybe Text)
-> (ExecuteTransaction -> Maybe Text -> ExecuteTransaction)
-> Lens
ExecuteTransaction ExecuteTransaction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteTransaction' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:ExecuteTransaction' :: ExecuteTransaction -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: ExecuteTransaction
s@ExecuteTransaction' {} Maybe Text
a -> ExecuteTransaction
s {$sel:clientRequestToken:ExecuteTransaction' :: Maybe Text
clientRequestToken = Maybe Text
a} :: ExecuteTransaction)
executeTransaction_transactStatements :: Lens.Lens' ExecuteTransaction (Prelude.NonEmpty ParameterizedStatement)
executeTransaction_transactStatements :: (NonEmpty ParameterizedStatement
-> f (NonEmpty ParameterizedStatement))
-> ExecuteTransaction -> f ExecuteTransaction
executeTransaction_transactStatements = (ExecuteTransaction -> NonEmpty ParameterizedStatement)
-> (ExecuteTransaction
-> NonEmpty ParameterizedStatement -> ExecuteTransaction)
-> Lens
ExecuteTransaction
ExecuteTransaction
(NonEmpty ParameterizedStatement)
(NonEmpty ParameterizedStatement)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteTransaction' {NonEmpty ParameterizedStatement
transactStatements :: NonEmpty ParameterizedStatement
$sel:transactStatements:ExecuteTransaction' :: ExecuteTransaction -> NonEmpty ParameterizedStatement
transactStatements} -> NonEmpty ParameterizedStatement
transactStatements) (\s :: ExecuteTransaction
s@ExecuteTransaction' {} NonEmpty ParameterizedStatement
a -> ExecuteTransaction
s {$sel:transactStatements:ExecuteTransaction' :: NonEmpty ParameterizedStatement
transactStatements = NonEmpty ParameterizedStatement
a} :: ExecuteTransaction) ((NonEmpty ParameterizedStatement
-> f (NonEmpty ParameterizedStatement))
-> ExecuteTransaction -> f ExecuteTransaction)
-> ((NonEmpty ParameterizedStatement
-> f (NonEmpty ParameterizedStatement))
-> NonEmpty ParameterizedStatement
-> f (NonEmpty ParameterizedStatement))
-> (NonEmpty ParameterizedStatement
-> f (NonEmpty ParameterizedStatement))
-> ExecuteTransaction
-> f ExecuteTransaction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty ParameterizedStatement
-> f (NonEmpty ParameterizedStatement))
-> NonEmpty ParameterizedStatement
-> f (NonEmpty ParameterizedStatement)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest ExecuteTransaction where
type
AWSResponse ExecuteTransaction =
ExecuteTransactionResponse
request :: ExecuteTransaction -> Request ExecuteTransaction
request = Service -> ExecuteTransaction -> Request ExecuteTransaction
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ExecuteTransaction
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ExecuteTransaction)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ExecuteTransaction))
-> Logger
-> Service
-> Proxy ExecuteTransaction
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ExecuteTransaction)))
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 (NonEmpty ItemResponse) -> Int -> ExecuteTransactionResponse
ExecuteTransactionResponse'
(Maybe (NonEmpty ItemResponse)
-> Int -> ExecuteTransactionResponse)
-> Either String (Maybe (NonEmpty ItemResponse))
-> Either String (Int -> ExecuteTransactionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (NonEmpty ItemResponse))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Responses")
Either String (Int -> ExecuteTransactionResponse)
-> Either String Int -> Either String ExecuteTransactionResponse
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 ExecuteTransaction
instance Prelude.NFData ExecuteTransaction
instance Core.ToHeaders ExecuteTransaction where
toHeaders :: ExecuteTransaction -> ResponseHeaders
toHeaders =
ResponseHeaders -> ExecuteTransaction -> 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.ExecuteTransaction" ::
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 ExecuteTransaction where
toJSON :: ExecuteTransaction -> Value
toJSON ExecuteTransaction' {Maybe Text
NonEmpty ParameterizedStatement
transactStatements :: NonEmpty ParameterizedStatement
clientRequestToken :: Maybe Text
$sel:transactStatements:ExecuteTransaction' :: ExecuteTransaction -> NonEmpty ParameterizedStatement
$sel:clientRequestToken:ExecuteTransaction' :: ExecuteTransaction -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ClientRequestToken" 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
clientRequestToken,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"TransactStatements" Text -> NonEmpty ParameterizedStatement -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty ParameterizedStatement
transactStatements)
]
)
instance Core.ToPath ExecuteTransaction where
toPath :: ExecuteTransaction -> ByteString
toPath = ByteString -> ExecuteTransaction -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ExecuteTransaction where
toQuery :: ExecuteTransaction -> QueryString
toQuery = QueryString -> ExecuteTransaction -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ExecuteTransactionResponse = ExecuteTransactionResponse'
{
ExecuteTransactionResponse -> Maybe (NonEmpty ItemResponse)
responses :: Prelude.Maybe (Prelude.NonEmpty ItemResponse),
ExecuteTransactionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ExecuteTransactionResponse -> ExecuteTransactionResponse -> Bool
(ExecuteTransactionResponse -> ExecuteTransactionResponse -> Bool)
-> (ExecuteTransactionResponse
-> ExecuteTransactionResponse -> Bool)
-> Eq ExecuteTransactionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteTransactionResponse -> ExecuteTransactionResponse -> Bool
$c/= :: ExecuteTransactionResponse -> ExecuteTransactionResponse -> Bool
== :: ExecuteTransactionResponse -> ExecuteTransactionResponse -> Bool
$c== :: ExecuteTransactionResponse -> ExecuteTransactionResponse -> Bool
Prelude.Eq, ReadPrec [ExecuteTransactionResponse]
ReadPrec ExecuteTransactionResponse
Int -> ReadS ExecuteTransactionResponse
ReadS [ExecuteTransactionResponse]
(Int -> ReadS ExecuteTransactionResponse)
-> ReadS [ExecuteTransactionResponse]
-> ReadPrec ExecuteTransactionResponse
-> ReadPrec [ExecuteTransactionResponse]
-> Read ExecuteTransactionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteTransactionResponse]
$creadListPrec :: ReadPrec [ExecuteTransactionResponse]
readPrec :: ReadPrec ExecuteTransactionResponse
$creadPrec :: ReadPrec ExecuteTransactionResponse
readList :: ReadS [ExecuteTransactionResponse]
$creadList :: ReadS [ExecuteTransactionResponse]
readsPrec :: Int -> ReadS ExecuteTransactionResponse
$creadsPrec :: Int -> ReadS ExecuteTransactionResponse
Prelude.Read, Int -> ExecuteTransactionResponse -> ShowS
[ExecuteTransactionResponse] -> ShowS
ExecuteTransactionResponse -> String
(Int -> ExecuteTransactionResponse -> ShowS)
-> (ExecuteTransactionResponse -> String)
-> ([ExecuteTransactionResponse] -> ShowS)
-> Show ExecuteTransactionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteTransactionResponse] -> ShowS
$cshowList :: [ExecuteTransactionResponse] -> ShowS
show :: ExecuteTransactionResponse -> String
$cshow :: ExecuteTransactionResponse -> String
showsPrec :: Int -> ExecuteTransactionResponse -> ShowS
$cshowsPrec :: Int -> ExecuteTransactionResponse -> ShowS
Prelude.Show, (forall x.
ExecuteTransactionResponse -> Rep ExecuteTransactionResponse x)
-> (forall x.
Rep ExecuteTransactionResponse x -> ExecuteTransactionResponse)
-> Generic ExecuteTransactionResponse
forall x.
Rep ExecuteTransactionResponse x -> ExecuteTransactionResponse
forall x.
ExecuteTransactionResponse -> Rep ExecuteTransactionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExecuteTransactionResponse x -> ExecuteTransactionResponse
$cfrom :: forall x.
ExecuteTransactionResponse -> Rep ExecuteTransactionResponse x
Prelude.Generic)
newExecuteTransactionResponse ::
Prelude.Int ->
ExecuteTransactionResponse
newExecuteTransactionResponse :: Int -> ExecuteTransactionResponse
newExecuteTransactionResponse Int
pHttpStatus_ =
ExecuteTransactionResponse' :: Maybe (NonEmpty ItemResponse) -> Int -> ExecuteTransactionResponse
ExecuteTransactionResponse'
{ $sel:responses:ExecuteTransactionResponse' :: Maybe (NonEmpty ItemResponse)
responses =
Maybe (NonEmpty ItemResponse)
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ExecuteTransactionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
executeTransactionResponse_responses :: Lens.Lens' ExecuteTransactionResponse (Prelude.Maybe (Prelude.NonEmpty ItemResponse))
executeTransactionResponse_responses :: (Maybe (NonEmpty ItemResponse)
-> f (Maybe (NonEmpty ItemResponse)))
-> ExecuteTransactionResponse -> f ExecuteTransactionResponse
executeTransactionResponse_responses = (ExecuteTransactionResponse -> Maybe (NonEmpty ItemResponse))
-> (ExecuteTransactionResponse
-> Maybe (NonEmpty ItemResponse) -> ExecuteTransactionResponse)
-> Lens
ExecuteTransactionResponse
ExecuteTransactionResponse
(Maybe (NonEmpty ItemResponse))
(Maybe (NonEmpty ItemResponse))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteTransactionResponse' {Maybe (NonEmpty ItemResponse)
responses :: Maybe (NonEmpty ItemResponse)
$sel:responses:ExecuteTransactionResponse' :: ExecuteTransactionResponse -> Maybe (NonEmpty ItemResponse)
responses} -> Maybe (NonEmpty ItemResponse)
responses) (\s :: ExecuteTransactionResponse
s@ExecuteTransactionResponse' {} Maybe (NonEmpty ItemResponse)
a -> ExecuteTransactionResponse
s {$sel:responses:ExecuteTransactionResponse' :: Maybe (NonEmpty ItemResponse)
responses = Maybe (NonEmpty ItemResponse)
a} :: ExecuteTransactionResponse) ((Maybe (NonEmpty ItemResponse)
-> f (Maybe (NonEmpty ItemResponse)))
-> ExecuteTransactionResponse -> f ExecuteTransactionResponse)
-> ((Maybe (NonEmpty ItemResponse)
-> f (Maybe (NonEmpty ItemResponse)))
-> Maybe (NonEmpty ItemResponse)
-> f (Maybe (NonEmpty ItemResponse)))
-> (Maybe (NonEmpty ItemResponse)
-> f (Maybe (NonEmpty ItemResponse)))
-> ExecuteTransactionResponse
-> f ExecuteTransactionResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty ItemResponse)
(NonEmpty ItemResponse)
(NonEmpty ItemResponse)
(NonEmpty ItemResponse)
-> Iso
(Maybe (NonEmpty ItemResponse))
(Maybe (NonEmpty ItemResponse))
(Maybe (NonEmpty ItemResponse))
(Maybe (NonEmpty ItemResponse))
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 ItemResponse)
(NonEmpty ItemResponse)
(NonEmpty ItemResponse)
(NonEmpty ItemResponse)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
executeTransactionResponse_httpStatus :: Lens.Lens' ExecuteTransactionResponse Prelude.Int
executeTransactionResponse_httpStatus :: (Int -> f Int)
-> ExecuteTransactionResponse -> f ExecuteTransactionResponse
executeTransactionResponse_httpStatus = (ExecuteTransactionResponse -> Int)
-> (ExecuteTransactionResponse
-> Int -> ExecuteTransactionResponse)
-> Lens
ExecuteTransactionResponse ExecuteTransactionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteTransactionResponse' {Int
httpStatus :: Int
$sel:httpStatus:ExecuteTransactionResponse' :: ExecuteTransactionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ExecuteTransactionResponse
s@ExecuteTransactionResponse' {} Int
a -> ExecuteTransactionResponse
s {$sel:httpStatus:ExecuteTransactionResponse' :: Int
httpStatus = Int
a} :: ExecuteTransactionResponse)
instance Prelude.NFData ExecuteTransactionResponse