{-# 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.SSM.Types.FailureDetails
-- 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.SSM.Types.FailureDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about an Automation failure.
--
-- /See:/ 'newFailureDetails' smart constructor.
data FailureDetails = FailureDetails'
  { -- | The type of Automation failure. Failure types include the following:
    -- Action, Permission, Throttling, Verification, Internal.
    FailureDetails -> Maybe Text
failureType :: Prelude.Maybe Prelude.Text,
    -- | The stage of the Automation execution when the failure occurred. The
    -- stages include the following: InputValidation, PreVerification,
    -- Invocation, PostVerification.
    FailureDetails -> Maybe Text
failureStage :: Prelude.Maybe Prelude.Text,
    -- | Detailed information about the Automation step failure.
    FailureDetails -> Maybe (HashMap Text [Text])
details :: Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text])
  }
  deriving (FailureDetails -> FailureDetails -> Bool
(FailureDetails -> FailureDetails -> Bool)
-> (FailureDetails -> FailureDetails -> Bool) -> Eq FailureDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailureDetails -> FailureDetails -> Bool
$c/= :: FailureDetails -> FailureDetails -> Bool
== :: FailureDetails -> FailureDetails -> Bool
$c== :: FailureDetails -> FailureDetails -> Bool
Prelude.Eq, ReadPrec [FailureDetails]
ReadPrec FailureDetails
Int -> ReadS FailureDetails
ReadS [FailureDetails]
(Int -> ReadS FailureDetails)
-> ReadS [FailureDetails]
-> ReadPrec FailureDetails
-> ReadPrec [FailureDetails]
-> Read FailureDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailureDetails]
$creadListPrec :: ReadPrec [FailureDetails]
readPrec :: ReadPrec FailureDetails
$creadPrec :: ReadPrec FailureDetails
readList :: ReadS [FailureDetails]
$creadList :: ReadS [FailureDetails]
readsPrec :: Int -> ReadS FailureDetails
$creadsPrec :: Int -> ReadS FailureDetails
Prelude.Read, Int -> FailureDetails -> ShowS
[FailureDetails] -> ShowS
FailureDetails -> String
(Int -> FailureDetails -> ShowS)
-> (FailureDetails -> String)
-> ([FailureDetails] -> ShowS)
-> Show FailureDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailureDetails] -> ShowS
$cshowList :: [FailureDetails] -> ShowS
show :: FailureDetails -> String
$cshow :: FailureDetails -> String
showsPrec :: Int -> FailureDetails -> ShowS
$cshowsPrec :: Int -> FailureDetails -> ShowS
Prelude.Show, (forall x. FailureDetails -> Rep FailureDetails x)
-> (forall x. Rep FailureDetails x -> FailureDetails)
-> Generic FailureDetails
forall x. Rep FailureDetails x -> FailureDetails
forall x. FailureDetails -> Rep FailureDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailureDetails x -> FailureDetails
$cfrom :: forall x. FailureDetails -> Rep FailureDetails x
Prelude.Generic)

-- |
-- Create a value of 'FailureDetails' 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:
--
-- 'failureType', 'failureDetails_failureType' - The type of Automation failure. Failure types include the following:
-- Action, Permission, Throttling, Verification, Internal.
--
-- 'failureStage', 'failureDetails_failureStage' - The stage of the Automation execution when the failure occurred. The
-- stages include the following: InputValidation, PreVerification,
-- Invocation, PostVerification.
--
-- 'details', 'failureDetails_details' - Detailed information about the Automation step failure.
newFailureDetails ::
  FailureDetails
newFailureDetails :: FailureDetails
newFailureDetails =
  FailureDetails' :: Maybe Text
-> Maybe Text -> Maybe (HashMap Text [Text]) -> FailureDetails
FailureDetails'
    { $sel:failureType:FailureDetails' :: Maybe Text
failureType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:failureStage:FailureDetails' :: Maybe Text
failureStage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:details:FailureDetails' :: Maybe (HashMap Text [Text])
details = Maybe (HashMap Text [Text])
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of Automation failure. Failure types include the following:
-- Action, Permission, Throttling, Verification, Internal.
failureDetails_failureType :: Lens.Lens' FailureDetails (Prelude.Maybe Prelude.Text)
failureDetails_failureType :: (Maybe Text -> f (Maybe Text))
-> FailureDetails -> f FailureDetails
failureDetails_failureType = (FailureDetails -> Maybe Text)
-> (FailureDetails -> Maybe Text -> FailureDetails)
-> Lens FailureDetails FailureDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Maybe Text
failureType :: Maybe Text
$sel:failureType:FailureDetails' :: FailureDetails -> Maybe Text
failureType} -> Maybe Text
failureType) (\s :: FailureDetails
s@FailureDetails' {} Maybe Text
a -> FailureDetails
s {$sel:failureType:FailureDetails' :: Maybe Text
failureType = Maybe Text
a} :: FailureDetails)

-- | The stage of the Automation execution when the failure occurred. The
-- stages include the following: InputValidation, PreVerification,
-- Invocation, PostVerification.
failureDetails_failureStage :: Lens.Lens' FailureDetails (Prelude.Maybe Prelude.Text)
failureDetails_failureStage :: (Maybe Text -> f (Maybe Text))
-> FailureDetails -> f FailureDetails
failureDetails_failureStage = (FailureDetails -> Maybe Text)
-> (FailureDetails -> Maybe Text -> FailureDetails)
-> Lens FailureDetails FailureDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Maybe Text
failureStage :: Maybe Text
$sel:failureStage:FailureDetails' :: FailureDetails -> Maybe Text
failureStage} -> Maybe Text
failureStage) (\s :: FailureDetails
s@FailureDetails' {} Maybe Text
a -> FailureDetails
s {$sel:failureStage:FailureDetails' :: Maybe Text
failureStage = Maybe Text
a} :: FailureDetails)

-- | Detailed information about the Automation step failure.
failureDetails_details :: Lens.Lens' FailureDetails (Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]))
failureDetails_details :: (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> FailureDetails -> f FailureDetails
failureDetails_details = (FailureDetails -> Maybe (HashMap Text [Text]))
-> (FailureDetails
    -> Maybe (HashMap Text [Text]) -> FailureDetails)
-> Lens
     FailureDetails
     FailureDetails
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureDetails' {Maybe (HashMap Text [Text])
details :: Maybe (HashMap Text [Text])
$sel:details:FailureDetails' :: FailureDetails -> Maybe (HashMap Text [Text])
details} -> Maybe (HashMap Text [Text])
details) (\s :: FailureDetails
s@FailureDetails' {} Maybe (HashMap Text [Text])
a -> FailureDetails
s {$sel:details:FailureDetails' :: Maybe (HashMap Text [Text])
details = Maybe (HashMap Text [Text])
a} :: FailureDetails) ((Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
 -> FailureDetails -> f FailureDetails)
-> ((Maybe (HashMap Text [Text])
     -> f (Maybe (HashMap Text [Text])))
    -> Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> FailureDetails
-> f FailureDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
-> Iso
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON FailureDetails where
  parseJSON :: Value -> Parser FailureDetails
parseJSON =
    String
-> (Object -> Parser FailureDetails)
-> Value
-> Parser FailureDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FailureDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe (HashMap Text [Text]) -> FailureDetails
FailureDetails'
            (Maybe Text
 -> Maybe Text -> Maybe (HashMap Text [Text]) -> FailureDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe (HashMap Text [Text]) -> FailureDetails)
forall (f :: * -> *) a b. Functor 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
"FailureType")
            Parser
  (Maybe Text -> Maybe (HashMap Text [Text]) -> FailureDetails)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text [Text]) -> FailureDetails)
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
"FailureStage")
            Parser (Maybe (HashMap Text [Text]) -> FailureDetails)
-> Parser (Maybe (HashMap Text [Text])) -> Parser FailureDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text [Text])))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Details" Parser (Maybe (Maybe (HashMap Text [Text])))
-> Maybe (HashMap Text [Text])
-> Parser (Maybe (HashMap Text [Text]))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text [Text])
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable FailureDetails

instance Prelude.NFData FailureDetails