{-# 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.BatchStatementError
-- 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.BatchStatementError where

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

-- | An error associated with a statement in a PartiQL batch that was run.
--
-- /See:/ 'newBatchStatementError' smart constructor.
data BatchStatementError = BatchStatementError'
  { -- | The error code associated with the failed PartiQL batch statement.
    BatchStatementError -> Maybe BatchStatementErrorCodeEnum
code :: Prelude.Maybe BatchStatementErrorCodeEnum,
    -- | The error message associated with the PartiQL batch resposne.
    BatchStatementError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (BatchStatementError -> BatchStatementError -> Bool
(BatchStatementError -> BatchStatementError -> Bool)
-> (BatchStatementError -> BatchStatementError -> Bool)
-> Eq BatchStatementError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchStatementError -> BatchStatementError -> Bool
$c/= :: BatchStatementError -> BatchStatementError -> Bool
== :: BatchStatementError -> BatchStatementError -> Bool
$c== :: BatchStatementError -> BatchStatementError -> Bool
Prelude.Eq, ReadPrec [BatchStatementError]
ReadPrec BatchStatementError
Int -> ReadS BatchStatementError
ReadS [BatchStatementError]
(Int -> ReadS BatchStatementError)
-> ReadS [BatchStatementError]
-> ReadPrec BatchStatementError
-> ReadPrec [BatchStatementError]
-> Read BatchStatementError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchStatementError]
$creadListPrec :: ReadPrec [BatchStatementError]
readPrec :: ReadPrec BatchStatementError
$creadPrec :: ReadPrec BatchStatementError
readList :: ReadS [BatchStatementError]
$creadList :: ReadS [BatchStatementError]
readsPrec :: Int -> ReadS BatchStatementError
$creadsPrec :: Int -> ReadS BatchStatementError
Prelude.Read, Int -> BatchStatementError -> ShowS
[BatchStatementError] -> ShowS
BatchStatementError -> String
(Int -> BatchStatementError -> ShowS)
-> (BatchStatementError -> String)
-> ([BatchStatementError] -> ShowS)
-> Show BatchStatementError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchStatementError] -> ShowS
$cshowList :: [BatchStatementError] -> ShowS
show :: BatchStatementError -> String
$cshow :: BatchStatementError -> String
showsPrec :: Int -> BatchStatementError -> ShowS
$cshowsPrec :: Int -> BatchStatementError -> ShowS
Prelude.Show, (forall x. BatchStatementError -> Rep BatchStatementError x)
-> (forall x. Rep BatchStatementError x -> BatchStatementError)
-> Generic BatchStatementError
forall x. Rep BatchStatementError x -> BatchStatementError
forall x. BatchStatementError -> Rep BatchStatementError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchStatementError x -> BatchStatementError
$cfrom :: forall x. BatchStatementError -> Rep BatchStatementError x
Prelude.Generic)

-- |
-- Create a value of 'BatchStatementError' 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:
--
-- 'code', 'batchStatementError_code' - The error code associated with the failed PartiQL batch statement.
--
-- 'message', 'batchStatementError_message' - The error message associated with the PartiQL batch resposne.
newBatchStatementError ::
  BatchStatementError
newBatchStatementError :: BatchStatementError
newBatchStatementError =
  BatchStatementError' :: Maybe BatchStatementErrorCodeEnum
-> Maybe Text -> BatchStatementError
BatchStatementError'
    { $sel:code:BatchStatementError' :: Maybe BatchStatementErrorCodeEnum
code = Maybe BatchStatementErrorCodeEnum
forall a. Maybe a
Prelude.Nothing,
      $sel:message:BatchStatementError' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The error code associated with the failed PartiQL batch statement.
batchStatementError_code :: Lens.Lens' BatchStatementError (Prelude.Maybe BatchStatementErrorCodeEnum)
batchStatementError_code :: (Maybe BatchStatementErrorCodeEnum
 -> f (Maybe BatchStatementErrorCodeEnum))
-> BatchStatementError -> f BatchStatementError
batchStatementError_code = (BatchStatementError -> Maybe BatchStatementErrorCodeEnum)
-> (BatchStatementError
    -> Maybe BatchStatementErrorCodeEnum -> BatchStatementError)
-> Lens
     BatchStatementError
     BatchStatementError
     (Maybe BatchStatementErrorCodeEnum)
     (Maybe BatchStatementErrorCodeEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStatementError' {Maybe BatchStatementErrorCodeEnum
code :: Maybe BatchStatementErrorCodeEnum
$sel:code:BatchStatementError' :: BatchStatementError -> Maybe BatchStatementErrorCodeEnum
code} -> Maybe BatchStatementErrorCodeEnum
code) (\s :: BatchStatementError
s@BatchStatementError' {} Maybe BatchStatementErrorCodeEnum
a -> BatchStatementError
s {$sel:code:BatchStatementError' :: Maybe BatchStatementErrorCodeEnum
code = Maybe BatchStatementErrorCodeEnum
a} :: BatchStatementError)

-- | The error message associated with the PartiQL batch resposne.
batchStatementError_message :: Lens.Lens' BatchStatementError (Prelude.Maybe Prelude.Text)
batchStatementError_message :: (Maybe Text -> f (Maybe Text))
-> BatchStatementError -> f BatchStatementError
batchStatementError_message = (BatchStatementError -> Maybe Text)
-> (BatchStatementError -> Maybe Text -> BatchStatementError)
-> Lens
     BatchStatementError BatchStatementError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStatementError' {Maybe Text
message :: Maybe Text
$sel:message:BatchStatementError' :: BatchStatementError -> Maybe Text
message} -> Maybe Text
message) (\s :: BatchStatementError
s@BatchStatementError' {} Maybe Text
a -> BatchStatementError
s {$sel:message:BatchStatementError' :: Maybe Text
message = Maybe Text
a} :: BatchStatementError)

instance Core.FromJSON BatchStatementError where
  parseJSON :: Value -> Parser BatchStatementError
parseJSON =
    String
-> (Object -> Parser BatchStatementError)
-> Value
-> Parser BatchStatementError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchStatementError"
      ( \Object
x ->
          Maybe BatchStatementErrorCodeEnum
-> Maybe Text -> BatchStatementError
BatchStatementError'
            (Maybe BatchStatementErrorCodeEnum
 -> Maybe Text -> BatchStatementError)
-> Parser (Maybe BatchStatementErrorCodeEnum)
-> Parser (Maybe Text -> BatchStatementError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe BatchStatementErrorCodeEnum)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Code")
            Parser (Maybe Text -> BatchStatementError)
-> Parser (Maybe Text) -> Parser BatchStatementError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Message")
      )

instance Prelude.Hashable BatchStatementError

instance Prelude.NFData BatchStatementError