{-# 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.CloudDirectory.Types.BatchReadException
-- 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.CloudDirectory.Types.BatchReadException where

import Amazonka.CloudDirectory.Types.BatchReadExceptionType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The batch read exception structure, which contains the exception type
-- and message.
--
-- /See:/ 'newBatchReadException' smart constructor.
data BatchReadException = BatchReadException'
  { -- | A type of exception, such as @InvalidArnException@.
    BatchReadException -> Maybe BatchReadExceptionType
type' :: Prelude.Maybe BatchReadExceptionType,
    -- | An exception message that is associated with the failure.
    BatchReadException -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (BatchReadException -> BatchReadException -> Bool
(BatchReadException -> BatchReadException -> Bool)
-> (BatchReadException -> BatchReadException -> Bool)
-> Eq BatchReadException
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchReadException -> BatchReadException -> Bool
$c/= :: BatchReadException -> BatchReadException -> Bool
== :: BatchReadException -> BatchReadException -> Bool
$c== :: BatchReadException -> BatchReadException -> Bool
Prelude.Eq, ReadPrec [BatchReadException]
ReadPrec BatchReadException
Int -> ReadS BatchReadException
ReadS [BatchReadException]
(Int -> ReadS BatchReadException)
-> ReadS [BatchReadException]
-> ReadPrec BatchReadException
-> ReadPrec [BatchReadException]
-> Read BatchReadException
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchReadException]
$creadListPrec :: ReadPrec [BatchReadException]
readPrec :: ReadPrec BatchReadException
$creadPrec :: ReadPrec BatchReadException
readList :: ReadS [BatchReadException]
$creadList :: ReadS [BatchReadException]
readsPrec :: Int -> ReadS BatchReadException
$creadsPrec :: Int -> ReadS BatchReadException
Prelude.Read, Int -> BatchReadException -> ShowS
[BatchReadException] -> ShowS
BatchReadException -> String
(Int -> BatchReadException -> ShowS)
-> (BatchReadException -> String)
-> ([BatchReadException] -> ShowS)
-> Show BatchReadException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchReadException] -> ShowS
$cshowList :: [BatchReadException] -> ShowS
show :: BatchReadException -> String
$cshow :: BatchReadException -> String
showsPrec :: Int -> BatchReadException -> ShowS
$cshowsPrec :: Int -> BatchReadException -> ShowS
Prelude.Show, (forall x. BatchReadException -> Rep BatchReadException x)
-> (forall x. Rep BatchReadException x -> BatchReadException)
-> Generic BatchReadException
forall x. Rep BatchReadException x -> BatchReadException
forall x. BatchReadException -> Rep BatchReadException x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchReadException x -> BatchReadException
$cfrom :: forall x. BatchReadException -> Rep BatchReadException x
Prelude.Generic)

-- |
-- Create a value of 'BatchReadException' 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:
--
-- 'type'', 'batchReadException_type' - A type of exception, such as @InvalidArnException@.
--
-- 'message', 'batchReadException_message' - An exception message that is associated with the failure.
newBatchReadException ::
  BatchReadException
newBatchReadException :: BatchReadException
newBatchReadException =
  BatchReadException' :: Maybe BatchReadExceptionType -> Maybe Text -> BatchReadException
BatchReadException'
    { $sel:type':BatchReadException' :: Maybe BatchReadExceptionType
type' = Maybe BatchReadExceptionType
forall a. Maybe a
Prelude.Nothing,
      $sel:message:BatchReadException' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A type of exception, such as @InvalidArnException@.
batchReadException_type :: Lens.Lens' BatchReadException (Prelude.Maybe BatchReadExceptionType)
batchReadException_type :: (Maybe BatchReadExceptionType -> f (Maybe BatchReadExceptionType))
-> BatchReadException -> f BatchReadException
batchReadException_type = (BatchReadException -> Maybe BatchReadExceptionType)
-> (BatchReadException
    -> Maybe BatchReadExceptionType -> BatchReadException)
-> Lens
     BatchReadException
     BatchReadException
     (Maybe BatchReadExceptionType)
     (Maybe BatchReadExceptionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchReadException' {Maybe BatchReadExceptionType
type' :: Maybe BatchReadExceptionType
$sel:type':BatchReadException' :: BatchReadException -> Maybe BatchReadExceptionType
type'} -> Maybe BatchReadExceptionType
type') (\s :: BatchReadException
s@BatchReadException' {} Maybe BatchReadExceptionType
a -> BatchReadException
s {$sel:type':BatchReadException' :: Maybe BatchReadExceptionType
type' = Maybe BatchReadExceptionType
a} :: BatchReadException)

-- | An exception message that is associated with the failure.
batchReadException_message :: Lens.Lens' BatchReadException (Prelude.Maybe Prelude.Text)
batchReadException_message :: (Maybe Text -> f (Maybe Text))
-> BatchReadException -> f BatchReadException
batchReadException_message = (BatchReadException -> Maybe Text)
-> (BatchReadException -> Maybe Text -> BatchReadException)
-> Lens
     BatchReadException BatchReadException (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchReadException' {Maybe Text
message :: Maybe Text
$sel:message:BatchReadException' :: BatchReadException -> Maybe Text
message} -> Maybe Text
message) (\s :: BatchReadException
s@BatchReadException' {} Maybe Text
a -> BatchReadException
s {$sel:message:BatchReadException' :: Maybe Text
message = Maybe Text
a} :: BatchReadException)

instance Core.FromJSON BatchReadException where
  parseJSON :: Value -> Parser BatchReadException
parseJSON =
    String
-> (Object -> Parser BatchReadException)
-> Value
-> Parser BatchReadException
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchReadException"
      ( \Object
x ->
          Maybe BatchReadExceptionType -> Maybe Text -> BatchReadException
BatchReadException'
            (Maybe BatchReadExceptionType -> Maybe Text -> BatchReadException)
-> Parser (Maybe BatchReadExceptionType)
-> Parser (Maybe Text -> BatchReadException)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe BatchReadExceptionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe Text -> BatchReadException)
-> Parser (Maybe Text) -> Parser BatchReadException
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 BatchReadException

instance Prelude.NFData BatchReadException