{-# 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.RDSData.BeginTransaction
(
BeginTransaction (..),
newBeginTransaction,
beginTransaction_database,
beginTransaction_schema,
beginTransaction_resourceArn,
beginTransaction_secretArn,
BeginTransactionResponse (..),
newBeginTransactionResponse,
beginTransactionResponse_transactionId,
beginTransactionResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDSData.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data BeginTransaction = BeginTransaction'
{
BeginTransaction -> Maybe Text
database :: Prelude.Maybe Prelude.Text,
BeginTransaction -> Maybe Text
schema :: Prelude.Maybe Prelude.Text,
BeginTransaction -> Text
resourceArn :: Prelude.Text,
BeginTransaction -> Text
secretArn :: Prelude.Text
}
deriving (BeginTransaction -> BeginTransaction -> Bool
(BeginTransaction -> BeginTransaction -> Bool)
-> (BeginTransaction -> BeginTransaction -> Bool)
-> Eq BeginTransaction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BeginTransaction -> BeginTransaction -> Bool
$c/= :: BeginTransaction -> BeginTransaction -> Bool
== :: BeginTransaction -> BeginTransaction -> Bool
$c== :: BeginTransaction -> BeginTransaction -> Bool
Prelude.Eq, ReadPrec [BeginTransaction]
ReadPrec BeginTransaction
Int -> ReadS BeginTransaction
ReadS [BeginTransaction]
(Int -> ReadS BeginTransaction)
-> ReadS [BeginTransaction]
-> ReadPrec BeginTransaction
-> ReadPrec [BeginTransaction]
-> Read BeginTransaction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BeginTransaction]
$creadListPrec :: ReadPrec [BeginTransaction]
readPrec :: ReadPrec BeginTransaction
$creadPrec :: ReadPrec BeginTransaction
readList :: ReadS [BeginTransaction]
$creadList :: ReadS [BeginTransaction]
readsPrec :: Int -> ReadS BeginTransaction
$creadsPrec :: Int -> ReadS BeginTransaction
Prelude.Read, Int -> BeginTransaction -> ShowS
[BeginTransaction] -> ShowS
BeginTransaction -> String
(Int -> BeginTransaction -> ShowS)
-> (BeginTransaction -> String)
-> ([BeginTransaction] -> ShowS)
-> Show BeginTransaction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BeginTransaction] -> ShowS
$cshowList :: [BeginTransaction] -> ShowS
show :: BeginTransaction -> String
$cshow :: BeginTransaction -> String
showsPrec :: Int -> BeginTransaction -> ShowS
$cshowsPrec :: Int -> BeginTransaction -> ShowS
Prelude.Show, (forall x. BeginTransaction -> Rep BeginTransaction x)
-> (forall x. Rep BeginTransaction x -> BeginTransaction)
-> Generic BeginTransaction
forall x. Rep BeginTransaction x -> BeginTransaction
forall x. BeginTransaction -> Rep BeginTransaction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BeginTransaction x -> BeginTransaction
$cfrom :: forall x. BeginTransaction -> Rep BeginTransaction x
Prelude.Generic)
newBeginTransaction ::
Prelude.Text ->
Prelude.Text ->
BeginTransaction
newBeginTransaction :: Text -> Text -> BeginTransaction
newBeginTransaction Text
pResourceArn_ Text
pSecretArn_ =
BeginTransaction' :: Maybe Text -> Maybe Text -> Text -> Text -> BeginTransaction
BeginTransaction'
{ $sel:database:BeginTransaction' :: Maybe Text
database = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:schema:BeginTransaction' :: Maybe Text
schema = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:resourceArn:BeginTransaction' :: Text
resourceArn = Text
pResourceArn_,
$sel:secretArn:BeginTransaction' :: Text
secretArn = Text
pSecretArn_
}
beginTransaction_database :: Lens.Lens' BeginTransaction (Prelude.Maybe Prelude.Text)
beginTransaction_database :: (Maybe Text -> f (Maybe Text))
-> BeginTransaction -> f BeginTransaction
beginTransaction_database = (BeginTransaction -> Maybe Text)
-> (BeginTransaction -> Maybe Text -> BeginTransaction)
-> Lens BeginTransaction BeginTransaction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BeginTransaction' {Maybe Text
database :: Maybe Text
$sel:database:BeginTransaction' :: BeginTransaction -> Maybe Text
database} -> Maybe Text
database) (\s :: BeginTransaction
s@BeginTransaction' {} Maybe Text
a -> BeginTransaction
s {$sel:database:BeginTransaction' :: Maybe Text
database = Maybe Text
a} :: BeginTransaction)
beginTransaction_schema :: Lens.Lens' BeginTransaction (Prelude.Maybe Prelude.Text)
beginTransaction_schema :: (Maybe Text -> f (Maybe Text))
-> BeginTransaction -> f BeginTransaction
beginTransaction_schema = (BeginTransaction -> Maybe Text)
-> (BeginTransaction -> Maybe Text -> BeginTransaction)
-> Lens BeginTransaction BeginTransaction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BeginTransaction' {Maybe Text
schema :: Maybe Text
$sel:schema:BeginTransaction' :: BeginTransaction -> Maybe Text
schema} -> Maybe Text
schema) (\s :: BeginTransaction
s@BeginTransaction' {} Maybe Text
a -> BeginTransaction
s {$sel:schema:BeginTransaction' :: Maybe Text
schema = Maybe Text
a} :: BeginTransaction)
beginTransaction_resourceArn :: Lens.Lens' BeginTransaction Prelude.Text
beginTransaction_resourceArn :: (Text -> f Text) -> BeginTransaction -> f BeginTransaction
beginTransaction_resourceArn = (BeginTransaction -> Text)
-> (BeginTransaction -> Text -> BeginTransaction)
-> Lens BeginTransaction BeginTransaction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BeginTransaction' {Text
resourceArn :: Text
$sel:resourceArn:BeginTransaction' :: BeginTransaction -> Text
resourceArn} -> Text
resourceArn) (\s :: BeginTransaction
s@BeginTransaction' {} Text
a -> BeginTransaction
s {$sel:resourceArn:BeginTransaction' :: Text
resourceArn = Text
a} :: BeginTransaction)
beginTransaction_secretArn :: Lens.Lens' BeginTransaction Prelude.Text
beginTransaction_secretArn :: (Text -> f Text) -> BeginTransaction -> f BeginTransaction
beginTransaction_secretArn = (BeginTransaction -> Text)
-> (BeginTransaction -> Text -> BeginTransaction)
-> Lens BeginTransaction BeginTransaction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BeginTransaction' {Text
secretArn :: Text
$sel:secretArn:BeginTransaction' :: BeginTransaction -> Text
secretArn} -> Text
secretArn) (\s :: BeginTransaction
s@BeginTransaction' {} Text
a -> BeginTransaction
s {$sel:secretArn:BeginTransaction' :: Text
secretArn = Text
a} :: BeginTransaction)
instance Core.AWSRequest BeginTransaction where
type
AWSResponse BeginTransaction =
BeginTransactionResponse
request :: BeginTransaction -> Request BeginTransaction
request = Service -> BeginTransaction -> Request BeginTransaction
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy BeginTransaction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BeginTransaction)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse BeginTransaction))
-> Logger
-> Service
-> Proxy BeginTransaction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BeginTransaction)))
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 Text -> Int -> BeginTransactionResponse
BeginTransactionResponse'
(Maybe Text -> Int -> BeginTransactionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> BeginTransactionResponse)
forall (f :: * -> *) a b. Functor 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
"transactionId")
Either String (Int -> BeginTransactionResponse)
-> Either String Int -> Either String BeginTransactionResponse
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 BeginTransaction
instance Prelude.NFData BeginTransaction
instance Core.ToHeaders BeginTransaction where
toHeaders :: BeginTransaction -> ResponseHeaders
toHeaders =
ResponseHeaders -> BeginTransaction -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON BeginTransaction where
toJSON :: BeginTransaction -> Value
toJSON BeginTransaction' {Maybe Text
Text
secretArn :: Text
resourceArn :: Text
schema :: Maybe Text
database :: Maybe Text
$sel:secretArn:BeginTransaction' :: BeginTransaction -> Text
$sel:resourceArn:BeginTransaction' :: BeginTransaction -> Text
$sel:schema:BeginTransaction' :: BeginTransaction -> Maybe Text
$sel:database:BeginTransaction' :: BeginTransaction -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"database" 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
database,
(Text
"schema" 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
schema,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"resourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"secretArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
secretArn)
]
)
instance Core.ToPath BeginTransaction where
toPath :: BeginTransaction -> ByteString
toPath = ByteString -> BeginTransaction -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/BeginTransaction"
instance Core.ToQuery BeginTransaction where
toQuery :: BeginTransaction -> QueryString
toQuery = QueryString -> BeginTransaction -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data BeginTransactionResponse = BeginTransactionResponse'
{
BeginTransactionResponse -> Maybe Text
transactionId :: Prelude.Maybe Prelude.Text,
BeginTransactionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (BeginTransactionResponse -> BeginTransactionResponse -> Bool
(BeginTransactionResponse -> BeginTransactionResponse -> Bool)
-> (BeginTransactionResponse -> BeginTransactionResponse -> Bool)
-> Eq BeginTransactionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BeginTransactionResponse -> BeginTransactionResponse -> Bool
$c/= :: BeginTransactionResponse -> BeginTransactionResponse -> Bool
== :: BeginTransactionResponse -> BeginTransactionResponse -> Bool
$c== :: BeginTransactionResponse -> BeginTransactionResponse -> Bool
Prelude.Eq, ReadPrec [BeginTransactionResponse]
ReadPrec BeginTransactionResponse
Int -> ReadS BeginTransactionResponse
ReadS [BeginTransactionResponse]
(Int -> ReadS BeginTransactionResponse)
-> ReadS [BeginTransactionResponse]
-> ReadPrec BeginTransactionResponse
-> ReadPrec [BeginTransactionResponse]
-> Read BeginTransactionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BeginTransactionResponse]
$creadListPrec :: ReadPrec [BeginTransactionResponse]
readPrec :: ReadPrec BeginTransactionResponse
$creadPrec :: ReadPrec BeginTransactionResponse
readList :: ReadS [BeginTransactionResponse]
$creadList :: ReadS [BeginTransactionResponse]
readsPrec :: Int -> ReadS BeginTransactionResponse
$creadsPrec :: Int -> ReadS BeginTransactionResponse
Prelude.Read, Int -> BeginTransactionResponse -> ShowS
[BeginTransactionResponse] -> ShowS
BeginTransactionResponse -> String
(Int -> BeginTransactionResponse -> ShowS)
-> (BeginTransactionResponse -> String)
-> ([BeginTransactionResponse] -> ShowS)
-> Show BeginTransactionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BeginTransactionResponse] -> ShowS
$cshowList :: [BeginTransactionResponse] -> ShowS
show :: BeginTransactionResponse -> String
$cshow :: BeginTransactionResponse -> String
showsPrec :: Int -> BeginTransactionResponse -> ShowS
$cshowsPrec :: Int -> BeginTransactionResponse -> ShowS
Prelude.Show, (forall x.
BeginTransactionResponse -> Rep BeginTransactionResponse x)
-> (forall x.
Rep BeginTransactionResponse x -> BeginTransactionResponse)
-> Generic BeginTransactionResponse
forall x.
Rep BeginTransactionResponse x -> BeginTransactionResponse
forall x.
BeginTransactionResponse -> Rep BeginTransactionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BeginTransactionResponse x -> BeginTransactionResponse
$cfrom :: forall x.
BeginTransactionResponse -> Rep BeginTransactionResponse x
Prelude.Generic)
newBeginTransactionResponse ::
Prelude.Int ->
BeginTransactionResponse
newBeginTransactionResponse :: Int -> BeginTransactionResponse
newBeginTransactionResponse Int
pHttpStatus_ =
BeginTransactionResponse' :: Maybe Text -> Int -> BeginTransactionResponse
BeginTransactionResponse'
{ $sel:transactionId:BeginTransactionResponse' :: Maybe Text
transactionId =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:BeginTransactionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
beginTransactionResponse_transactionId :: Lens.Lens' BeginTransactionResponse (Prelude.Maybe Prelude.Text)
beginTransactionResponse_transactionId :: (Maybe Text -> f (Maybe Text))
-> BeginTransactionResponse -> f BeginTransactionResponse
beginTransactionResponse_transactionId = (BeginTransactionResponse -> Maybe Text)
-> (BeginTransactionResponse
-> Maybe Text -> BeginTransactionResponse)
-> Lens
BeginTransactionResponse
BeginTransactionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BeginTransactionResponse' {Maybe Text
transactionId :: Maybe Text
$sel:transactionId:BeginTransactionResponse' :: BeginTransactionResponse -> Maybe Text
transactionId} -> Maybe Text
transactionId) (\s :: BeginTransactionResponse
s@BeginTransactionResponse' {} Maybe Text
a -> BeginTransactionResponse
s {$sel:transactionId:BeginTransactionResponse' :: Maybe Text
transactionId = Maybe Text
a} :: BeginTransactionResponse)
beginTransactionResponse_httpStatus :: Lens.Lens' BeginTransactionResponse Prelude.Int
beginTransactionResponse_httpStatus :: (Int -> f Int)
-> BeginTransactionResponse -> f BeginTransactionResponse
beginTransactionResponse_httpStatus = (BeginTransactionResponse -> Int)
-> (BeginTransactionResponse -> Int -> BeginTransactionResponse)
-> Lens BeginTransactionResponse BeginTransactionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BeginTransactionResponse' {Int
httpStatus :: Int
$sel:httpStatus:BeginTransactionResponse' :: BeginTransactionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BeginTransactionResponse
s@BeginTransactionResponse' {} Int
a -> BeginTransactionResponse
s {$sel:httpStatus:BeginTransactionResponse' :: Int
httpStatus = Int
a} :: BeginTransactionResponse)
instance Prelude.NFData BeginTransactionResponse