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

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

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

-- | Detailed information about the Automation step failure.
failureDetails_details :: Lens.Lens' FailureDetails (Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]))
failureDetails_details :: Lens' FailureDetails (Maybe (HashMap Text [Text]))
failureDetails_details = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' FailureDetails (Maybe Text)
failureDetails_failureStage = 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)

-- | 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 :: Lens' FailureDetails (Maybe Text)
failureDetails_failureType = 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)

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

instance Prelude.Hashable FailureDetails where
  hashWithSalt :: Int -> FailureDetails -> Int
hashWithSalt Int
_salt FailureDetails' {Maybe Text
Maybe (HashMap Text [Text])
failureType :: Maybe Text
failureStage :: Maybe Text
details :: Maybe (HashMap Text [Text])
$sel:failureType:FailureDetails' :: FailureDetails -> Maybe Text
$sel:failureStage:FailureDetails' :: FailureDetails -> Maybe Text
$sel:details:FailureDetails' :: FailureDetails -> Maybe (HashMap Text [Text])
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text [Text])
details
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
failureStage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
failureType

instance Prelude.NFData FailureDetails where
  rnf :: FailureDetails -> ()
rnf FailureDetails' {Maybe Text
Maybe (HashMap Text [Text])
failureType :: Maybe Text
failureStage :: Maybe Text
details :: Maybe (HashMap Text [Text])
$sel:failureType:FailureDetails' :: FailureDetails -> Maybe Text
$sel:failureStage:FailureDetails' :: FailureDetails -> Maybe Text
$sel:details:FailureDetails' :: FailureDetails -> Maybe (HashMap Text [Text])
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text [Text])
details
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
failureStage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
failureType