{-# 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.RDSData.BatchExecuteStatement
-- 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)
--
-- Runs a batch SQL statement over an array of data.
--
-- You can run bulk update and insert operations for multiple records using
-- a DML statement with different parameter sets. Bulk operations can
-- provide a significant performance improvement over individual insert and
-- update operations.
--
-- If a call isn\'t part of a transaction because it doesn\'t include the
-- @transactionID@ parameter, changes that result from the call are
-- committed automatically.
module Amazonka.RDSData.BatchExecuteStatement
  ( -- * Creating a Request
    BatchExecuteStatement (..),
    newBatchExecuteStatement,

    -- * Request Lenses
    batchExecuteStatement_database,
    batchExecuteStatement_parameterSets,
    batchExecuteStatement_transactionId,
    batchExecuteStatement_schema,
    batchExecuteStatement_resourceArn,
    batchExecuteStatement_secretArn,
    batchExecuteStatement_sql,

    -- * Destructuring the Response
    BatchExecuteStatementResponse (..),
    newBatchExecuteStatementResponse,

    -- * Response Lenses
    batchExecuteStatementResponse_updateResults,
    batchExecuteStatementResponse_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

-- | The request parameters represent the input of a SQL statement over an
-- array of data.
--
-- /See:/ 'newBatchExecuteStatement' smart constructor.
data BatchExecuteStatement = BatchExecuteStatement'
  { -- | The name of the database.
    BatchExecuteStatement -> Maybe Text
database :: Prelude.Maybe Prelude.Text,
    -- | The parameter set for the batch operation.
    --
    -- The SQL statement is executed as many times as the number of parameter
    -- sets provided. To execute a SQL statement with no parameters, use one of
    -- the following options:
    --
    -- -   Specify one or more empty parameter sets.
    --
    -- -   Use the @ExecuteStatement@ operation instead of the
    --     @BatchExecuteStatement@ operation.
    --
    -- Array parameters are not supported.
    BatchExecuteStatement -> Maybe [[SqlParameter]]
parameterSets :: Prelude.Maybe [[SqlParameter]],
    -- | The identifier of a transaction that was started by using the
    -- @BeginTransaction@ operation. Specify the transaction ID of the
    -- transaction that you want to include the SQL statement in.
    --
    -- If the SQL statement is not part of a transaction, don\'t set this
    -- parameter.
    BatchExecuteStatement -> Maybe Text
transactionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the database schema.
    BatchExecuteStatement -> Maybe Text
schema :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
    BatchExecuteStatement -> Text
resourceArn :: Prelude.Text,
    -- | The name or ARN of the secret that enables access to the DB cluster.
    BatchExecuteStatement -> Text
secretArn :: Prelude.Text,
    -- | The SQL statement to run.
    BatchExecuteStatement -> Text
sql :: Prelude.Text
  }
  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)

-- |
-- Create a value of 'BatchExecuteStatement' 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:
--
-- 'database', 'batchExecuteStatement_database' - The name of the database.
--
-- 'parameterSets', 'batchExecuteStatement_parameterSets' - The parameter set for the batch operation.
--
-- The SQL statement is executed as many times as the number of parameter
-- sets provided. To execute a SQL statement with no parameters, use one of
-- the following options:
--
-- -   Specify one or more empty parameter sets.
--
-- -   Use the @ExecuteStatement@ operation instead of the
--     @BatchExecuteStatement@ operation.
--
-- Array parameters are not supported.
--
-- 'transactionId', 'batchExecuteStatement_transactionId' - The identifier of a transaction that was started by using the
-- @BeginTransaction@ operation. Specify the transaction ID of the
-- transaction that you want to include the SQL statement in.
--
-- If the SQL statement is not part of a transaction, don\'t set this
-- parameter.
--
-- 'schema', 'batchExecuteStatement_schema' - The name of the database schema.
--
-- 'resourceArn', 'batchExecuteStatement_resourceArn' - The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
--
-- 'secretArn', 'batchExecuteStatement_secretArn' - The name or ARN of the secret that enables access to the DB cluster.
--
-- 'sql', 'batchExecuteStatement_sql' - The SQL statement to run.
newBatchExecuteStatement ::
  -- | 'resourceArn'
  Prelude.Text ->
  -- | 'secretArn'
  Prelude.Text ->
  -- | 'sql'
  Prelude.Text ->
  BatchExecuteStatement
newBatchExecuteStatement :: Text -> Text -> Text -> BatchExecuteStatement
newBatchExecuteStatement
  Text
pResourceArn_
  Text
pSecretArn_
  Text
pSql_ =
    BatchExecuteStatement' :: Maybe Text
-> Maybe [[SqlParameter]]
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> Text
-> BatchExecuteStatement
BatchExecuteStatement'
      { $sel:database:BatchExecuteStatement' :: Maybe Text
database = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:parameterSets:BatchExecuteStatement' :: Maybe [[SqlParameter]]
parameterSets = Maybe [[SqlParameter]]
forall a. Maybe a
Prelude.Nothing,
        $sel:transactionId:BatchExecuteStatement' :: Maybe Text
transactionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:schema:BatchExecuteStatement' :: Maybe Text
schema = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:resourceArn:BatchExecuteStatement' :: Text
resourceArn = Text
pResourceArn_,
        $sel:secretArn:BatchExecuteStatement' :: Text
secretArn = Text
pSecretArn_,
        $sel:sql:BatchExecuteStatement' :: Text
sql = Text
pSql_
      }

-- | The name of the database.
batchExecuteStatement_database :: Lens.Lens' BatchExecuteStatement (Prelude.Maybe Prelude.Text)
batchExecuteStatement_database :: (Maybe Text -> f (Maybe Text))
-> BatchExecuteStatement -> f BatchExecuteStatement
batchExecuteStatement_database = (BatchExecuteStatement -> Maybe Text)
-> (BatchExecuteStatement -> Maybe Text -> BatchExecuteStatement)
-> Lens
     BatchExecuteStatement
     BatchExecuteStatement
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatement' {Maybe Text
database :: Maybe Text
$sel:database:BatchExecuteStatement' :: BatchExecuteStatement -> Maybe Text
database} -> Maybe Text
database) (\s :: BatchExecuteStatement
s@BatchExecuteStatement' {} Maybe Text
a -> BatchExecuteStatement
s {$sel:database:BatchExecuteStatement' :: Maybe Text
database = Maybe Text
a} :: BatchExecuteStatement)

-- | The parameter set for the batch operation.
--
-- The SQL statement is executed as many times as the number of parameter
-- sets provided. To execute a SQL statement with no parameters, use one of
-- the following options:
--
-- -   Specify one or more empty parameter sets.
--
-- -   Use the @ExecuteStatement@ operation instead of the
--     @BatchExecuteStatement@ operation.
--
-- Array parameters are not supported.
batchExecuteStatement_parameterSets :: Lens.Lens' BatchExecuteStatement (Prelude.Maybe [[SqlParameter]])
batchExecuteStatement_parameterSets :: (Maybe [[SqlParameter]] -> f (Maybe [[SqlParameter]]))
-> BatchExecuteStatement -> f BatchExecuteStatement
batchExecuteStatement_parameterSets = (BatchExecuteStatement -> Maybe [[SqlParameter]])
-> (BatchExecuteStatement
    -> Maybe [[SqlParameter]] -> BatchExecuteStatement)
-> Lens
     BatchExecuteStatement
     BatchExecuteStatement
     (Maybe [[SqlParameter]])
     (Maybe [[SqlParameter]])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatement' {Maybe [[SqlParameter]]
parameterSets :: Maybe [[SqlParameter]]
$sel:parameterSets:BatchExecuteStatement' :: BatchExecuteStatement -> Maybe [[SqlParameter]]
parameterSets} -> Maybe [[SqlParameter]]
parameterSets) (\s :: BatchExecuteStatement
s@BatchExecuteStatement' {} Maybe [[SqlParameter]]
a -> BatchExecuteStatement
s {$sel:parameterSets:BatchExecuteStatement' :: Maybe [[SqlParameter]]
parameterSets = Maybe [[SqlParameter]]
a} :: BatchExecuteStatement) ((Maybe [[SqlParameter]] -> f (Maybe [[SqlParameter]]))
 -> BatchExecuteStatement -> f BatchExecuteStatement)
-> ((Maybe [[SqlParameter]] -> f (Maybe [[SqlParameter]]))
    -> Maybe [[SqlParameter]] -> f (Maybe [[SqlParameter]]))
-> (Maybe [[SqlParameter]] -> f (Maybe [[SqlParameter]]))
-> BatchExecuteStatement
-> f BatchExecuteStatement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [[SqlParameter]] [[SqlParameter]] [[SqlParameter]] [[SqlParameter]]
-> Iso
     (Maybe [[SqlParameter]])
     (Maybe [[SqlParameter]])
     (Maybe [[SqlParameter]])
     (Maybe [[SqlParameter]])
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
  [[SqlParameter]] [[SqlParameter]] [[SqlParameter]] [[SqlParameter]]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The identifier of a transaction that was started by using the
-- @BeginTransaction@ operation. Specify the transaction ID of the
-- transaction that you want to include the SQL statement in.
--
-- If the SQL statement is not part of a transaction, don\'t set this
-- parameter.
batchExecuteStatement_transactionId :: Lens.Lens' BatchExecuteStatement (Prelude.Maybe Prelude.Text)
batchExecuteStatement_transactionId :: (Maybe Text -> f (Maybe Text))
-> BatchExecuteStatement -> f BatchExecuteStatement
batchExecuteStatement_transactionId = (BatchExecuteStatement -> Maybe Text)
-> (BatchExecuteStatement -> Maybe Text -> BatchExecuteStatement)
-> Lens
     BatchExecuteStatement
     BatchExecuteStatement
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatement' {Maybe Text
transactionId :: Maybe Text
$sel:transactionId:BatchExecuteStatement' :: BatchExecuteStatement -> Maybe Text
transactionId} -> Maybe Text
transactionId) (\s :: BatchExecuteStatement
s@BatchExecuteStatement' {} Maybe Text
a -> BatchExecuteStatement
s {$sel:transactionId:BatchExecuteStatement' :: Maybe Text
transactionId = Maybe Text
a} :: BatchExecuteStatement)

-- | The name of the database schema.
batchExecuteStatement_schema :: Lens.Lens' BatchExecuteStatement (Prelude.Maybe Prelude.Text)
batchExecuteStatement_schema :: (Maybe Text -> f (Maybe Text))
-> BatchExecuteStatement -> f BatchExecuteStatement
batchExecuteStatement_schema = (BatchExecuteStatement -> Maybe Text)
-> (BatchExecuteStatement -> Maybe Text -> BatchExecuteStatement)
-> Lens
     BatchExecuteStatement
     BatchExecuteStatement
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatement' {Maybe Text
schema :: Maybe Text
$sel:schema:BatchExecuteStatement' :: BatchExecuteStatement -> Maybe Text
schema} -> Maybe Text
schema) (\s :: BatchExecuteStatement
s@BatchExecuteStatement' {} Maybe Text
a -> BatchExecuteStatement
s {$sel:schema:BatchExecuteStatement' :: Maybe Text
schema = Maybe Text
a} :: BatchExecuteStatement)

-- | The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
batchExecuteStatement_resourceArn :: Lens.Lens' BatchExecuteStatement Prelude.Text
batchExecuteStatement_resourceArn :: (Text -> f Text)
-> BatchExecuteStatement -> f BatchExecuteStatement
batchExecuteStatement_resourceArn = (BatchExecuteStatement -> Text)
-> (BatchExecuteStatement -> Text -> BatchExecuteStatement)
-> Lens BatchExecuteStatement BatchExecuteStatement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatement' {Text
resourceArn :: Text
$sel:resourceArn:BatchExecuteStatement' :: BatchExecuteStatement -> Text
resourceArn} -> Text
resourceArn) (\s :: BatchExecuteStatement
s@BatchExecuteStatement' {} Text
a -> BatchExecuteStatement
s {$sel:resourceArn:BatchExecuteStatement' :: Text
resourceArn = Text
a} :: BatchExecuteStatement)

-- | The name or ARN of the secret that enables access to the DB cluster.
batchExecuteStatement_secretArn :: Lens.Lens' BatchExecuteStatement Prelude.Text
batchExecuteStatement_secretArn :: (Text -> f Text)
-> BatchExecuteStatement -> f BatchExecuteStatement
batchExecuteStatement_secretArn = (BatchExecuteStatement -> Text)
-> (BatchExecuteStatement -> Text -> BatchExecuteStatement)
-> Lens BatchExecuteStatement BatchExecuteStatement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatement' {Text
secretArn :: Text
$sel:secretArn:BatchExecuteStatement' :: BatchExecuteStatement -> Text
secretArn} -> Text
secretArn) (\s :: BatchExecuteStatement
s@BatchExecuteStatement' {} Text
a -> BatchExecuteStatement
s {$sel:secretArn:BatchExecuteStatement' :: Text
secretArn = Text
a} :: BatchExecuteStatement)

-- | The SQL statement to run.
batchExecuteStatement_sql :: Lens.Lens' BatchExecuteStatement Prelude.Text
batchExecuteStatement_sql :: (Text -> f Text)
-> BatchExecuteStatement -> f BatchExecuteStatement
batchExecuteStatement_sql = (BatchExecuteStatement -> Text)
-> (BatchExecuteStatement -> Text -> BatchExecuteStatement)
-> Lens BatchExecuteStatement BatchExecuteStatement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatement' {Text
sql :: Text
$sel:sql:BatchExecuteStatement' :: BatchExecuteStatement -> Text
sql} -> Text
sql) (\s :: BatchExecuteStatement
s@BatchExecuteStatement' {} Text
a -> BatchExecuteStatement
s {$sel:sql:BatchExecuteStatement' :: Text
sql = Text
a} :: BatchExecuteStatement)

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 [UpdateResult] -> Int -> BatchExecuteStatementResponse
BatchExecuteStatementResponse'
            (Maybe [UpdateResult] -> Int -> BatchExecuteStatementResponse)
-> Either String (Maybe [UpdateResult])
-> Either String (Int -> BatchExecuteStatementResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [UpdateResult]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"updateResults" Either String (Maybe (Maybe [UpdateResult]))
-> Maybe [UpdateResult] -> Either String (Maybe [UpdateResult])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [UpdateResult]
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
"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 BatchExecuteStatement where
  toJSON :: BatchExecuteStatement -> Value
toJSON BatchExecuteStatement' {Maybe [[SqlParameter]]
Maybe Text
Text
sql :: Text
secretArn :: Text
resourceArn :: Text
schema :: Maybe Text
transactionId :: Maybe Text
parameterSets :: Maybe [[SqlParameter]]
database :: Maybe Text
$sel:sql:BatchExecuteStatement' :: BatchExecuteStatement -> Text
$sel:secretArn:BatchExecuteStatement' :: BatchExecuteStatement -> Text
$sel:resourceArn:BatchExecuteStatement' :: BatchExecuteStatement -> Text
$sel:schema:BatchExecuteStatement' :: BatchExecuteStatement -> Maybe Text
$sel:transactionId:BatchExecuteStatement' :: BatchExecuteStatement -> Maybe Text
$sel:parameterSets:BatchExecuteStatement' :: BatchExecuteStatement -> Maybe [[SqlParameter]]
$sel:database:BatchExecuteStatement' :: BatchExecuteStatement -> 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
"parameterSets" Text -> [[SqlParameter]] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([[SqlParameter]] -> Pair) -> Maybe [[SqlParameter]] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [[SqlParameter]]
parameterSets,
            (Text
"transactionId" 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
transactionId,
            (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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"sql" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sql)
          ]
      )

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

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

-- | The response elements represent the output of a SQL statement over an
-- array of data.
--
-- /See:/ 'newBatchExecuteStatementResponse' smart constructor.
data BatchExecuteStatementResponse = BatchExecuteStatementResponse'
  { -- | The execution results of each batch entry.
    BatchExecuteStatementResponse -> Maybe [UpdateResult]
updateResults :: Prelude.Maybe [UpdateResult],
    -- | The response's http status code.
    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)

-- |
-- Create a value of 'BatchExecuteStatementResponse' 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:
--
-- 'updateResults', 'batchExecuteStatementResponse_updateResults' - The execution results of each batch entry.
--
-- 'httpStatus', 'batchExecuteStatementResponse_httpStatus' - The response's http status code.
newBatchExecuteStatementResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchExecuteStatementResponse
newBatchExecuteStatementResponse :: Int -> BatchExecuteStatementResponse
newBatchExecuteStatementResponse Int
pHttpStatus_ =
  BatchExecuteStatementResponse' :: Maybe [UpdateResult] -> Int -> BatchExecuteStatementResponse
BatchExecuteStatementResponse'
    { $sel:updateResults:BatchExecuteStatementResponse' :: Maybe [UpdateResult]
updateResults =
        Maybe [UpdateResult]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchExecuteStatementResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The execution results of each batch entry.
batchExecuteStatementResponse_updateResults :: Lens.Lens' BatchExecuteStatementResponse (Prelude.Maybe [UpdateResult])
batchExecuteStatementResponse_updateResults :: (Maybe [UpdateResult] -> f (Maybe [UpdateResult]))
-> BatchExecuteStatementResponse -> f BatchExecuteStatementResponse
batchExecuteStatementResponse_updateResults = (BatchExecuteStatementResponse -> Maybe [UpdateResult])
-> (BatchExecuteStatementResponse
    -> Maybe [UpdateResult] -> BatchExecuteStatementResponse)
-> Lens
     BatchExecuteStatementResponse
     BatchExecuteStatementResponse
     (Maybe [UpdateResult])
     (Maybe [UpdateResult])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchExecuteStatementResponse' {Maybe [UpdateResult]
updateResults :: Maybe [UpdateResult]
$sel:updateResults:BatchExecuteStatementResponse' :: BatchExecuteStatementResponse -> Maybe [UpdateResult]
updateResults} -> Maybe [UpdateResult]
updateResults) (\s :: BatchExecuteStatementResponse
s@BatchExecuteStatementResponse' {} Maybe [UpdateResult]
a -> BatchExecuteStatementResponse
s {$sel:updateResults:BatchExecuteStatementResponse' :: Maybe [UpdateResult]
updateResults = Maybe [UpdateResult]
a} :: BatchExecuteStatementResponse) ((Maybe [UpdateResult] -> f (Maybe [UpdateResult]))
 -> BatchExecuteStatementResponse
 -> f BatchExecuteStatementResponse)
-> ((Maybe [UpdateResult] -> f (Maybe [UpdateResult]))
    -> Maybe [UpdateResult] -> f (Maybe [UpdateResult]))
-> (Maybe [UpdateResult] -> f (Maybe [UpdateResult]))
-> BatchExecuteStatementResponse
-> f BatchExecuteStatementResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [UpdateResult] [UpdateResult] [UpdateResult] [UpdateResult]
-> Iso
     (Maybe [UpdateResult])
     (Maybe [UpdateResult])
     (Maybe [UpdateResult])
     (Maybe [UpdateResult])
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 [UpdateResult] [UpdateResult] [UpdateResult] [UpdateResult]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
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