{-# 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.DynamoDB.Types.BatchStatementRequest
-- 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.DynamoDB.Types.BatchStatementRequest where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.AttributeValue
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A PartiQL batch statement request.
--
-- /See:/ 'newBatchStatementRequest' smart constructor.
data BatchStatementRequest = BatchStatementRequest'
  { -- | The read consistency of the PartiQL batch request.
    BatchStatementRequest -> Maybe Bool
consistentRead :: Prelude.Maybe Prelude.Bool,
    -- | The parameters associated with a PartiQL statement in the batch request.
    BatchStatementRequest -> Maybe (NonEmpty AttributeValue)
parameters :: Prelude.Maybe (Prelude.NonEmpty AttributeValue),
    -- | A valid PartiQL statement.
    BatchStatementRequest -> Text
statement :: Prelude.Text
  }
  deriving (BatchStatementRequest -> BatchStatementRequest -> Bool
(BatchStatementRequest -> BatchStatementRequest -> Bool)
-> (BatchStatementRequest -> BatchStatementRequest -> Bool)
-> Eq BatchStatementRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchStatementRequest -> BatchStatementRequest -> Bool
$c/= :: BatchStatementRequest -> BatchStatementRequest -> Bool
== :: BatchStatementRequest -> BatchStatementRequest -> Bool
$c== :: BatchStatementRequest -> BatchStatementRequest -> Bool
Prelude.Eq, ReadPrec [BatchStatementRequest]
ReadPrec BatchStatementRequest
Int -> ReadS BatchStatementRequest
ReadS [BatchStatementRequest]
(Int -> ReadS BatchStatementRequest)
-> ReadS [BatchStatementRequest]
-> ReadPrec BatchStatementRequest
-> ReadPrec [BatchStatementRequest]
-> Read BatchStatementRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchStatementRequest]
$creadListPrec :: ReadPrec [BatchStatementRequest]
readPrec :: ReadPrec BatchStatementRequest
$creadPrec :: ReadPrec BatchStatementRequest
readList :: ReadS [BatchStatementRequest]
$creadList :: ReadS [BatchStatementRequest]
readsPrec :: Int -> ReadS BatchStatementRequest
$creadsPrec :: Int -> ReadS BatchStatementRequest
Prelude.Read, Int -> BatchStatementRequest -> ShowS
[BatchStatementRequest] -> ShowS
BatchStatementRequest -> String
(Int -> BatchStatementRequest -> ShowS)
-> (BatchStatementRequest -> String)
-> ([BatchStatementRequest] -> ShowS)
-> Show BatchStatementRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchStatementRequest] -> ShowS
$cshowList :: [BatchStatementRequest] -> ShowS
show :: BatchStatementRequest -> String
$cshow :: BatchStatementRequest -> String
showsPrec :: Int -> BatchStatementRequest -> ShowS
$cshowsPrec :: Int -> BatchStatementRequest -> ShowS
Prelude.Show, (forall x. BatchStatementRequest -> Rep BatchStatementRequest x)
-> (forall x. Rep BatchStatementRequest x -> BatchStatementRequest)
-> Generic BatchStatementRequest
forall x. Rep BatchStatementRequest x -> BatchStatementRequest
forall x. BatchStatementRequest -> Rep BatchStatementRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchStatementRequest x -> BatchStatementRequest
$cfrom :: forall x. BatchStatementRequest -> Rep BatchStatementRequest x
Prelude.Generic)

-- |
-- Create a value of 'BatchStatementRequest' 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:
--
-- 'consistentRead', 'batchStatementRequest_consistentRead' - The read consistency of the PartiQL batch request.
--
-- 'parameters', 'batchStatementRequest_parameters' - The parameters associated with a PartiQL statement in the batch request.
--
-- 'statement', 'batchStatementRequest_statement' - A valid PartiQL statement.
newBatchStatementRequest ::
  -- | 'statement'
  Prelude.Text ->
  BatchStatementRequest
newBatchStatementRequest :: Text -> BatchStatementRequest
newBatchStatementRequest Text
pStatement_ =
  BatchStatementRequest' :: Maybe Bool
-> Maybe (NonEmpty AttributeValue) -> Text -> BatchStatementRequest
BatchStatementRequest'
    { $sel:consistentRead:BatchStatementRequest' :: Maybe Bool
consistentRead =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:BatchStatementRequest' :: Maybe (NonEmpty AttributeValue)
parameters = Maybe (NonEmpty AttributeValue)
forall a. Maybe a
Prelude.Nothing,
      $sel:statement:BatchStatementRequest' :: Text
statement = Text
pStatement_
    }

-- | The read consistency of the PartiQL batch request.
batchStatementRequest_consistentRead :: Lens.Lens' BatchStatementRequest (Prelude.Maybe Prelude.Bool)
batchStatementRequest_consistentRead :: (Maybe Bool -> f (Maybe Bool))
-> BatchStatementRequest -> f BatchStatementRequest
batchStatementRequest_consistentRead = (BatchStatementRequest -> Maybe Bool)
-> (BatchStatementRequest -> Maybe Bool -> BatchStatementRequest)
-> Lens
     BatchStatementRequest
     BatchStatementRequest
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStatementRequest' {Maybe Bool
consistentRead :: Maybe Bool
$sel:consistentRead:BatchStatementRequest' :: BatchStatementRequest -> Maybe Bool
consistentRead} -> Maybe Bool
consistentRead) (\s :: BatchStatementRequest
s@BatchStatementRequest' {} Maybe Bool
a -> BatchStatementRequest
s {$sel:consistentRead:BatchStatementRequest' :: Maybe Bool
consistentRead = Maybe Bool
a} :: BatchStatementRequest)

-- | The parameters associated with a PartiQL statement in the batch request.
batchStatementRequest_parameters :: Lens.Lens' BatchStatementRequest (Prelude.Maybe (Prelude.NonEmpty AttributeValue))
batchStatementRequest_parameters :: (Maybe (NonEmpty AttributeValue)
 -> f (Maybe (NonEmpty AttributeValue)))
-> BatchStatementRequest -> f BatchStatementRequest
batchStatementRequest_parameters = (BatchStatementRequest -> Maybe (NonEmpty AttributeValue))
-> (BatchStatementRequest
    -> Maybe (NonEmpty AttributeValue) -> BatchStatementRequest)
-> Lens
     BatchStatementRequest
     BatchStatementRequest
     (Maybe (NonEmpty AttributeValue))
     (Maybe (NonEmpty AttributeValue))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStatementRequest' {Maybe (NonEmpty AttributeValue)
parameters :: Maybe (NonEmpty AttributeValue)
$sel:parameters:BatchStatementRequest' :: BatchStatementRequest -> Maybe (NonEmpty AttributeValue)
parameters} -> Maybe (NonEmpty AttributeValue)
parameters) (\s :: BatchStatementRequest
s@BatchStatementRequest' {} Maybe (NonEmpty AttributeValue)
a -> BatchStatementRequest
s {$sel:parameters:BatchStatementRequest' :: Maybe (NonEmpty AttributeValue)
parameters = Maybe (NonEmpty AttributeValue)
a} :: BatchStatementRequest) ((Maybe (NonEmpty AttributeValue)
  -> f (Maybe (NonEmpty AttributeValue)))
 -> BatchStatementRequest -> f BatchStatementRequest)
-> ((Maybe (NonEmpty AttributeValue)
     -> f (Maybe (NonEmpty AttributeValue)))
    -> Maybe (NonEmpty AttributeValue)
    -> f (Maybe (NonEmpty AttributeValue)))
-> (Maybe (NonEmpty AttributeValue)
    -> f (Maybe (NonEmpty AttributeValue)))
-> BatchStatementRequest
-> f BatchStatementRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
-> Iso
     (Maybe (NonEmpty AttributeValue))
     (Maybe (NonEmpty AttributeValue))
     (Maybe (NonEmpty AttributeValue))
     (Maybe (NonEmpty AttributeValue))
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 AttributeValue)
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
  (NonEmpty AttributeValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A valid PartiQL statement.
batchStatementRequest_statement :: Lens.Lens' BatchStatementRequest Prelude.Text
batchStatementRequest_statement :: (Text -> f Text)
-> BatchStatementRequest -> f BatchStatementRequest
batchStatementRequest_statement = (BatchStatementRequest -> Text)
-> (BatchStatementRequest -> Text -> BatchStatementRequest)
-> Lens BatchStatementRequest BatchStatementRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStatementRequest' {Text
statement :: Text
$sel:statement:BatchStatementRequest' :: BatchStatementRequest -> Text
statement} -> Text
statement) (\s :: BatchStatementRequest
s@BatchStatementRequest' {} Text
a -> BatchStatementRequest
s {$sel:statement:BatchStatementRequest' :: Text
statement = Text
a} :: BatchStatementRequest)

instance Prelude.Hashable BatchStatementRequest

instance Prelude.NFData BatchStatementRequest

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