{-# 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.Location.Types.BatchItemError
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Location.Types.BatchItemError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Location.Types.BatchItemErrorCode
import qualified Amazonka.Prelude as Prelude

-- | Contains the batch request error details associated with the request.
--
-- /See:/ 'newBatchItemError' smart constructor.
data BatchItemError = BatchItemError'
  { -- | The error code associated with the batch request error.
    BatchItemError -> Maybe BatchItemErrorCode
code :: Prelude.Maybe BatchItemErrorCode,
    -- | A message with the reason for the batch request error.
    BatchItemError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (BatchItemError -> BatchItemError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchItemError -> BatchItemError -> Bool
$c/= :: BatchItemError -> BatchItemError -> Bool
== :: BatchItemError -> BatchItemError -> Bool
$c== :: BatchItemError -> BatchItemError -> Bool
Prelude.Eq, ReadPrec [BatchItemError]
ReadPrec BatchItemError
Int -> ReadS BatchItemError
ReadS [BatchItemError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchItemError]
$creadListPrec :: ReadPrec [BatchItemError]
readPrec :: ReadPrec BatchItemError
$creadPrec :: ReadPrec BatchItemError
readList :: ReadS [BatchItemError]
$creadList :: ReadS [BatchItemError]
readsPrec :: Int -> ReadS BatchItemError
$creadsPrec :: Int -> ReadS BatchItemError
Prelude.Read, Int -> BatchItemError -> ShowS
[BatchItemError] -> ShowS
BatchItemError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchItemError] -> ShowS
$cshowList :: [BatchItemError] -> ShowS
show :: BatchItemError -> String
$cshow :: BatchItemError -> String
showsPrec :: Int -> BatchItemError -> ShowS
$cshowsPrec :: Int -> BatchItemError -> ShowS
Prelude.Show, forall x. Rep BatchItemError x -> BatchItemError
forall x. BatchItemError -> Rep BatchItemError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchItemError x -> BatchItemError
$cfrom :: forall x. BatchItemError -> Rep BatchItemError x
Prelude.Generic)

-- |
-- Create a value of 'BatchItemError' 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', 'batchItemError_code' - The error code associated with the batch request error.
--
-- 'message', 'batchItemError_message' - A message with the reason for the batch request error.
newBatchItemError ::
  BatchItemError
newBatchItemError :: BatchItemError
newBatchItemError =
  BatchItemError'
    { $sel:code:BatchItemError' :: Maybe BatchItemErrorCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:BatchItemError' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code associated with the batch request error.
batchItemError_code :: Lens.Lens' BatchItemError (Prelude.Maybe BatchItemErrorCode)
batchItemError_code :: Lens' BatchItemError (Maybe BatchItemErrorCode)
batchItemError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchItemError' {Maybe BatchItemErrorCode
code :: Maybe BatchItemErrorCode
$sel:code:BatchItemError' :: BatchItemError -> Maybe BatchItemErrorCode
code} -> Maybe BatchItemErrorCode
code) (\s :: BatchItemError
s@BatchItemError' {} Maybe BatchItemErrorCode
a -> BatchItemError
s {$sel:code:BatchItemError' :: Maybe BatchItemErrorCode
code = Maybe BatchItemErrorCode
a} :: BatchItemError)

-- | A message with the reason for the batch request error.
batchItemError_message :: Lens.Lens' BatchItemError (Prelude.Maybe Prelude.Text)
batchItemError_message :: Lens' BatchItemError (Maybe Text)
batchItemError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchItemError' {Maybe Text
message :: Maybe Text
$sel:message:BatchItemError' :: BatchItemError -> Maybe Text
message} -> Maybe Text
message) (\s :: BatchItemError
s@BatchItemError' {} Maybe Text
a -> BatchItemError
s {$sel:message:BatchItemError' :: Maybe Text
message = Maybe Text
a} :: BatchItemError)

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

instance Prelude.Hashable BatchItemError where
  hashWithSalt :: Int -> BatchItemError -> Int
hashWithSalt Int
_salt BatchItemError' {Maybe Text
Maybe BatchItemErrorCode
message :: Maybe Text
code :: Maybe BatchItemErrorCode
$sel:message:BatchItemError' :: BatchItemError -> Maybe Text
$sel:code:BatchItemError' :: BatchItemError -> Maybe BatchItemErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BatchItemErrorCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData BatchItemError where
  rnf :: BatchItemError -> ()
rnf BatchItemError' {Maybe Text
Maybe BatchItemErrorCode
message :: Maybe Text
code :: Maybe BatchItemErrorCode
$sel:message:BatchItemError' :: BatchItemError -> Maybe Text
$sel:code:BatchItemError' :: BatchItemError -> Maybe BatchItemErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BatchItemErrorCode
code seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message