{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.QLDBSession.Types.ExecuteStatementRequest
-- 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)
module Amazonka.QLDBSession.Types.ExecuteStatementRequest where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QLDBSession.Types.ValueHolder

-- | Specifies a request to execute a statement.
--
-- /See:/ 'newExecuteStatementRequest' smart constructor.
data ExecuteStatementRequest = ExecuteStatementRequest'
  { -- | Specifies the parameters for the parameterized statement in the request.
    ExecuteStatementRequest -> Maybe [ValueHolder]
parameters :: Prelude.Maybe [ValueHolder],
    -- | Specifies the transaction ID of the request.
    ExecuteStatementRequest -> Text
transactionId :: Prelude.Text,
    -- | Specifies the statement of the request.
    ExecuteStatementRequest -> Text
statement :: Prelude.Text
  }
  deriving (ExecuteStatementRequest -> ExecuteStatementRequest -> Bool
(ExecuteStatementRequest -> ExecuteStatementRequest -> Bool)
-> (ExecuteStatementRequest -> ExecuteStatementRequest -> Bool)
-> Eq ExecuteStatementRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteStatementRequest -> ExecuteStatementRequest -> Bool
$c/= :: ExecuteStatementRequest -> ExecuteStatementRequest -> Bool
== :: ExecuteStatementRequest -> ExecuteStatementRequest -> Bool
$c== :: ExecuteStatementRequest -> ExecuteStatementRequest -> Bool
Prelude.Eq, ReadPrec [ExecuteStatementRequest]
ReadPrec ExecuteStatementRequest
Int -> ReadS ExecuteStatementRequest
ReadS [ExecuteStatementRequest]
(Int -> ReadS ExecuteStatementRequest)
-> ReadS [ExecuteStatementRequest]
-> ReadPrec ExecuteStatementRequest
-> ReadPrec [ExecuteStatementRequest]
-> Read ExecuteStatementRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteStatementRequest]
$creadListPrec :: ReadPrec [ExecuteStatementRequest]
readPrec :: ReadPrec ExecuteStatementRequest
$creadPrec :: ReadPrec ExecuteStatementRequest
readList :: ReadS [ExecuteStatementRequest]
$creadList :: ReadS [ExecuteStatementRequest]
readsPrec :: Int -> ReadS ExecuteStatementRequest
$creadsPrec :: Int -> ReadS ExecuteStatementRequest
Prelude.Read, Int -> ExecuteStatementRequest -> ShowS
[ExecuteStatementRequest] -> ShowS
ExecuteStatementRequest -> String
(Int -> ExecuteStatementRequest -> ShowS)
-> (ExecuteStatementRequest -> String)
-> ([ExecuteStatementRequest] -> ShowS)
-> Show ExecuteStatementRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteStatementRequest] -> ShowS
$cshowList :: [ExecuteStatementRequest] -> ShowS
show :: ExecuteStatementRequest -> String
$cshow :: ExecuteStatementRequest -> String
showsPrec :: Int -> ExecuteStatementRequest -> ShowS
$cshowsPrec :: Int -> ExecuteStatementRequest -> ShowS
Prelude.Show, (forall x.
 ExecuteStatementRequest -> Rep ExecuteStatementRequest x)
-> (forall x.
    Rep ExecuteStatementRequest x -> ExecuteStatementRequest)
-> Generic ExecuteStatementRequest
forall x. Rep ExecuteStatementRequest x -> ExecuteStatementRequest
forall x. ExecuteStatementRequest -> Rep ExecuteStatementRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecuteStatementRequest x -> ExecuteStatementRequest
$cfrom :: forall x. ExecuteStatementRequest -> Rep ExecuteStatementRequest x
Prelude.Generic)

-- |
-- Create a value of 'ExecuteStatementRequest' 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:
--
-- 'parameters', 'executeStatementRequest_parameters' - Specifies the parameters for the parameterized statement in the request.
--
-- 'transactionId', 'executeStatementRequest_transactionId' - Specifies the transaction ID of the request.
--
-- 'statement', 'executeStatementRequest_statement' - Specifies the statement of the request.
newExecuteStatementRequest ::
  -- | 'transactionId'
  Prelude.Text ->
  -- | 'statement'
  Prelude.Text ->
  ExecuteStatementRequest
newExecuteStatementRequest :: Text -> Text -> ExecuteStatementRequest
newExecuteStatementRequest
  Text
pTransactionId_
  Text
pStatement_ =
    ExecuteStatementRequest' :: Maybe [ValueHolder] -> Text -> Text -> ExecuteStatementRequest
ExecuteStatementRequest'
      { $sel:parameters:ExecuteStatementRequest' :: Maybe [ValueHolder]
parameters =
          Maybe [ValueHolder]
forall a. Maybe a
Prelude.Nothing,
        $sel:transactionId:ExecuteStatementRequest' :: Text
transactionId = Text
pTransactionId_,
        $sel:statement:ExecuteStatementRequest' :: Text
statement = Text
pStatement_
      }

-- | Specifies the parameters for the parameterized statement in the request.
executeStatementRequest_parameters :: Lens.Lens' ExecuteStatementRequest (Prelude.Maybe [ValueHolder])
executeStatementRequest_parameters :: (Maybe [ValueHolder] -> f (Maybe [ValueHolder]))
-> ExecuteStatementRequest -> f ExecuteStatementRequest
executeStatementRequest_parameters = (ExecuteStatementRequest -> Maybe [ValueHolder])
-> (ExecuteStatementRequest
    -> Maybe [ValueHolder] -> ExecuteStatementRequest)
-> Lens
     ExecuteStatementRequest
     ExecuteStatementRequest
     (Maybe [ValueHolder])
     (Maybe [ValueHolder])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatementRequest' {Maybe [ValueHolder]
parameters :: Maybe [ValueHolder]
$sel:parameters:ExecuteStatementRequest' :: ExecuteStatementRequest -> Maybe [ValueHolder]
parameters} -> Maybe [ValueHolder]
parameters) (\s :: ExecuteStatementRequest
s@ExecuteStatementRequest' {} Maybe [ValueHolder]
a -> ExecuteStatementRequest
s {$sel:parameters:ExecuteStatementRequest' :: Maybe [ValueHolder]
parameters = Maybe [ValueHolder]
a} :: ExecuteStatementRequest) ((Maybe [ValueHolder] -> f (Maybe [ValueHolder]))
 -> ExecuteStatementRequest -> f ExecuteStatementRequest)
-> ((Maybe [ValueHolder] -> f (Maybe [ValueHolder]))
    -> Maybe [ValueHolder] -> f (Maybe [ValueHolder]))
-> (Maybe [ValueHolder] -> f (Maybe [ValueHolder]))
-> ExecuteStatementRequest
-> f ExecuteStatementRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ValueHolder] [ValueHolder] [ValueHolder] [ValueHolder]
-> Iso
     (Maybe [ValueHolder])
     (Maybe [ValueHolder])
     (Maybe [ValueHolder])
     (Maybe [ValueHolder])
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 [ValueHolder] [ValueHolder] [ValueHolder] [ValueHolder]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the transaction ID of the request.
executeStatementRequest_transactionId :: Lens.Lens' ExecuteStatementRequest Prelude.Text
executeStatementRequest_transactionId :: (Text -> f Text)
-> ExecuteStatementRequest -> f ExecuteStatementRequest
executeStatementRequest_transactionId = (ExecuteStatementRequest -> Text)
-> (ExecuteStatementRequest -> Text -> ExecuteStatementRequest)
-> Lens ExecuteStatementRequest ExecuteStatementRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatementRequest' {Text
transactionId :: Text
$sel:transactionId:ExecuteStatementRequest' :: ExecuteStatementRequest -> Text
transactionId} -> Text
transactionId) (\s :: ExecuteStatementRequest
s@ExecuteStatementRequest' {} Text
a -> ExecuteStatementRequest
s {$sel:transactionId:ExecuteStatementRequest' :: Text
transactionId = Text
a} :: ExecuteStatementRequest)

-- | Specifies the statement of the request.
executeStatementRequest_statement :: Lens.Lens' ExecuteStatementRequest Prelude.Text
executeStatementRequest_statement :: (Text -> f Text)
-> ExecuteStatementRequest -> f ExecuteStatementRequest
executeStatementRequest_statement = (ExecuteStatementRequest -> Text)
-> (ExecuteStatementRequest -> Text -> ExecuteStatementRequest)
-> Lens ExecuteStatementRequest ExecuteStatementRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteStatementRequest' {Text
statement :: Text
$sel:statement:ExecuteStatementRequest' :: ExecuteStatementRequest -> Text
statement} -> Text
statement) (\s :: ExecuteStatementRequest
s@ExecuteStatementRequest' {} Text
a -> ExecuteStatementRequest
s {$sel:statement:ExecuteStatementRequest' :: Text
statement = Text
a} :: ExecuteStatementRequest)

instance Prelude.Hashable ExecuteStatementRequest

instance Prelude.NFData ExecuteStatementRequest

instance Core.ToJSON ExecuteStatementRequest where
  toJSON :: ExecuteStatementRequest -> Value
toJSON ExecuteStatementRequest' {Maybe [ValueHolder]
Text
statement :: Text
transactionId :: Text
parameters :: Maybe [ValueHolder]
$sel:statement:ExecuteStatementRequest' :: ExecuteStatementRequest -> Text
$sel:transactionId:ExecuteStatementRequest' :: ExecuteStatementRequest -> Text
$sel:parameters:ExecuteStatementRequest' :: ExecuteStatementRequest -> Maybe [ValueHolder]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Parameters" Text -> [ValueHolder] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ValueHolder] -> Pair) -> Maybe [ValueHolder] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ValueHolder]
parameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TransactionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
transactionId),
            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)
          ]
      )