{-# 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-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.Location.Types.BatchItemError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(BatchItemError -> BatchItemError -> Bool)
-> (BatchItemError -> BatchItemError -> Bool) -> Eq BatchItemError
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]
(Int -> ReadS BatchItemError)
-> ReadS [BatchItemError]
-> ReadPrec BatchItemError
-> ReadPrec [BatchItemError]
-> Read 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
(Int -> BatchItemError -> ShowS)
-> (BatchItemError -> String)
-> ([BatchItemError] -> ShowS)
-> Show BatchItemError
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. BatchItemError -> Rep BatchItemError x)
-> (forall x. Rep BatchItemError x -> BatchItemError)
-> Generic BatchItemError
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' :: Maybe BatchItemErrorCode -> Maybe Text -> BatchItemError
BatchItemError'
    { $sel:code:BatchItemError' :: Maybe BatchItemErrorCode
code = Maybe BatchItemErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:BatchItemError' :: Maybe Text
message = Maybe Text
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 :: (Maybe BatchItemErrorCode -> f (Maybe BatchItemErrorCode))
-> BatchItemError -> f BatchItemError
batchItemError_code = (BatchItemError -> Maybe BatchItemErrorCode)
-> (BatchItemError -> Maybe BatchItemErrorCode -> BatchItemError)
-> Lens
     BatchItemError
     BatchItemError
     (Maybe BatchItemErrorCode)
     (Maybe BatchItemErrorCode)
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 :: (Maybe Text -> f (Maybe Text))
-> BatchItemError -> f BatchItemError
batchItemError_message = (BatchItemError -> Maybe Text)
-> (BatchItemError -> Maybe Text -> BatchItemError)
-> Lens BatchItemError BatchItemError (Maybe Text) (Maybe Text)
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 Core.FromJSON BatchItemError where
  parseJSON :: Value -> Parser BatchItemError
parseJSON =
    String
-> (Object -> Parser BatchItemError)
-> Value
-> Parser BatchItemError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchItemError"
      ( \Object
x ->
          Maybe BatchItemErrorCode -> Maybe Text -> BatchItemError
BatchItemError'
            (Maybe BatchItemErrorCode -> Maybe Text -> BatchItemError)
-> Parser (Maybe BatchItemErrorCode)
-> Parser (Maybe Text -> BatchItemError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe BatchItemErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Code")
            Parser (Maybe Text -> BatchItemError)
-> Parser (Maybe Text) -> Parser BatchItemError
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 BatchItemError

instance Prelude.NFData BatchItemError