{-# 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.Firehose.Types.FailureDescription
-- 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.Firehose.Types.FailureDescription where

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.DeliveryStreamFailureType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides details in case one of the following operations fails due to an
-- error related to KMS: CreateDeliveryStream, DeleteDeliveryStream,
-- StartDeliveryStreamEncryption, StopDeliveryStreamEncryption.
--
-- /See:/ 'newFailureDescription' smart constructor.
data FailureDescription = FailureDescription'
  { -- | The type of error that caused the failure.
    FailureDescription -> DeliveryStreamFailureType
type' :: DeliveryStreamFailureType,
    -- | A message providing details about the error that caused the failure.
    FailureDescription -> Text
details :: Prelude.Text
  }
  deriving (FailureDescription -> FailureDescription -> Bool
(FailureDescription -> FailureDescription -> Bool)
-> (FailureDescription -> FailureDescription -> Bool)
-> Eq FailureDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailureDescription -> FailureDescription -> Bool
$c/= :: FailureDescription -> FailureDescription -> Bool
== :: FailureDescription -> FailureDescription -> Bool
$c== :: FailureDescription -> FailureDescription -> Bool
Prelude.Eq, ReadPrec [FailureDescription]
ReadPrec FailureDescription
Int -> ReadS FailureDescription
ReadS [FailureDescription]
(Int -> ReadS FailureDescription)
-> ReadS [FailureDescription]
-> ReadPrec FailureDescription
-> ReadPrec [FailureDescription]
-> Read FailureDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailureDescription]
$creadListPrec :: ReadPrec [FailureDescription]
readPrec :: ReadPrec FailureDescription
$creadPrec :: ReadPrec FailureDescription
readList :: ReadS [FailureDescription]
$creadList :: ReadS [FailureDescription]
readsPrec :: Int -> ReadS FailureDescription
$creadsPrec :: Int -> ReadS FailureDescription
Prelude.Read, Int -> FailureDescription -> ShowS
[FailureDescription] -> ShowS
FailureDescription -> String
(Int -> FailureDescription -> ShowS)
-> (FailureDescription -> String)
-> ([FailureDescription] -> ShowS)
-> Show FailureDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailureDescription] -> ShowS
$cshowList :: [FailureDescription] -> ShowS
show :: FailureDescription -> String
$cshow :: FailureDescription -> String
showsPrec :: Int -> FailureDescription -> ShowS
$cshowsPrec :: Int -> FailureDescription -> ShowS
Prelude.Show, (forall x. FailureDescription -> Rep FailureDescription x)
-> (forall x. Rep FailureDescription x -> FailureDescription)
-> Generic FailureDescription
forall x. Rep FailureDescription x -> FailureDescription
forall x. FailureDescription -> Rep FailureDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailureDescription x -> FailureDescription
$cfrom :: forall x. FailureDescription -> Rep FailureDescription x
Prelude.Generic)

-- |
-- Create a value of 'FailureDescription' 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'', 'failureDescription_type' - The type of error that caused the failure.
--
-- 'details', 'failureDescription_details' - A message providing details about the error that caused the failure.
newFailureDescription ::
  -- | 'type''
  DeliveryStreamFailureType ->
  -- | 'details'
  Prelude.Text ->
  FailureDescription
newFailureDescription :: DeliveryStreamFailureType -> Text -> FailureDescription
newFailureDescription DeliveryStreamFailureType
pType_ Text
pDetails_ =
  FailureDescription' :: DeliveryStreamFailureType -> Text -> FailureDescription
FailureDescription'
    { $sel:type':FailureDescription' :: DeliveryStreamFailureType
type' = DeliveryStreamFailureType
pType_,
      $sel:details:FailureDescription' :: Text
details = Text
pDetails_
    }

-- | The type of error that caused the failure.
failureDescription_type :: Lens.Lens' FailureDescription DeliveryStreamFailureType
failureDescription_type :: (DeliveryStreamFailureType -> f DeliveryStreamFailureType)
-> FailureDescription -> f FailureDescription
failureDescription_type = (FailureDescription -> DeliveryStreamFailureType)
-> (FailureDescription
    -> DeliveryStreamFailureType -> FailureDescription)
-> Lens
     FailureDescription
     FailureDescription
     DeliveryStreamFailureType
     DeliveryStreamFailureType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDescription' {DeliveryStreamFailureType
type' :: DeliveryStreamFailureType
$sel:type':FailureDescription' :: FailureDescription -> DeliveryStreamFailureType
type'} -> DeliveryStreamFailureType
type') (\s :: FailureDescription
s@FailureDescription' {} DeliveryStreamFailureType
a -> FailureDescription
s {$sel:type':FailureDescription' :: DeliveryStreamFailureType
type' = DeliveryStreamFailureType
a} :: FailureDescription)

-- | A message providing details about the error that caused the failure.
failureDescription_details :: Lens.Lens' FailureDescription Prelude.Text
failureDescription_details :: (Text -> f Text) -> FailureDescription -> f FailureDescription
failureDescription_details = (FailureDescription -> Text)
-> (FailureDescription -> Text -> FailureDescription)
-> Lens FailureDescription FailureDescription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDescription' {Text
details :: Text
$sel:details:FailureDescription' :: FailureDescription -> Text
details} -> Text
details) (\s :: FailureDescription
s@FailureDescription' {} Text
a -> FailureDescription
s {$sel:details:FailureDescription' :: Text
details = Text
a} :: FailureDescription)

instance Core.FromJSON FailureDescription where
  parseJSON :: Value -> Parser FailureDescription
parseJSON =
    String
-> (Object -> Parser FailureDescription)
-> Value
-> Parser FailureDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FailureDescription"
      ( \Object
x ->
          DeliveryStreamFailureType -> Text -> FailureDescription
FailureDescription'
            (DeliveryStreamFailureType -> Text -> FailureDescription)
-> Parser DeliveryStreamFailureType
-> Parser (Text -> FailureDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser DeliveryStreamFailureType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type") Parser (Text -> FailureDescription)
-> Parser Text -> Parser FailureDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Details")
      )

instance Prelude.Hashable FailureDescription

instance Prelude.NFData FailureDescription