{-# 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.StepFunctions.Types.TaskFailedEventDetails
-- 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.StepFunctions.Types.TaskFailedEventDetails where

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

-- | Contains details about a task failure event.
--
-- /See:/ 'newTaskFailedEventDetails' smart constructor.
data TaskFailedEventDetails = TaskFailedEventDetails'
  { -- | The error code of the failure.
    TaskFailedEventDetails -> Maybe (Sensitive Text)
error :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | A more detailed explanation of the cause of the failure.
    TaskFailedEventDetails -> Maybe (Sensitive Text)
cause :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The action of the resource called by a task state.
    TaskFailedEventDetails -> Text
resourceType :: Prelude.Text,
    -- | The service name of the resource in a task state.
    TaskFailedEventDetails -> Text
resource :: Prelude.Text
  }
  deriving (TaskFailedEventDetails -> TaskFailedEventDetails -> Bool
(TaskFailedEventDetails -> TaskFailedEventDetails -> Bool)
-> (TaskFailedEventDetails -> TaskFailedEventDetails -> Bool)
-> Eq TaskFailedEventDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TaskFailedEventDetails -> TaskFailedEventDetails -> Bool
$c/= :: TaskFailedEventDetails -> TaskFailedEventDetails -> Bool
== :: TaskFailedEventDetails -> TaskFailedEventDetails -> Bool
$c== :: TaskFailedEventDetails -> TaskFailedEventDetails -> Bool
Prelude.Eq, Int -> TaskFailedEventDetails -> ShowS
[TaskFailedEventDetails] -> ShowS
TaskFailedEventDetails -> String
(Int -> TaskFailedEventDetails -> ShowS)
-> (TaskFailedEventDetails -> String)
-> ([TaskFailedEventDetails] -> ShowS)
-> Show TaskFailedEventDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TaskFailedEventDetails] -> ShowS
$cshowList :: [TaskFailedEventDetails] -> ShowS
show :: TaskFailedEventDetails -> String
$cshow :: TaskFailedEventDetails -> String
showsPrec :: Int -> TaskFailedEventDetails -> ShowS
$cshowsPrec :: Int -> TaskFailedEventDetails -> ShowS
Prelude.Show, (forall x. TaskFailedEventDetails -> Rep TaskFailedEventDetails x)
-> (forall x.
    Rep TaskFailedEventDetails x -> TaskFailedEventDetails)
-> Generic TaskFailedEventDetails
forall x. Rep TaskFailedEventDetails x -> TaskFailedEventDetails
forall x. TaskFailedEventDetails -> Rep TaskFailedEventDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TaskFailedEventDetails x -> TaskFailedEventDetails
$cfrom :: forall x. TaskFailedEventDetails -> Rep TaskFailedEventDetails x
Prelude.Generic)

-- |
-- Create a value of 'TaskFailedEventDetails' 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:
--
-- 'error', 'taskFailedEventDetails_error' - The error code of the failure.
--
-- 'cause', 'taskFailedEventDetails_cause' - A more detailed explanation of the cause of the failure.
--
-- 'resourceType', 'taskFailedEventDetails_resourceType' - The action of the resource called by a task state.
--
-- 'resource', 'taskFailedEventDetails_resource' - The service name of the resource in a task state.
newTaskFailedEventDetails ::
  -- | 'resourceType'
  Prelude.Text ->
  -- | 'resource'
  Prelude.Text ->
  TaskFailedEventDetails
newTaskFailedEventDetails :: Text -> Text -> TaskFailedEventDetails
newTaskFailedEventDetails Text
pResourceType_ Text
pResource_ =
  TaskFailedEventDetails' :: Maybe (Sensitive Text)
-> Maybe (Sensitive Text) -> Text -> Text -> TaskFailedEventDetails
TaskFailedEventDetails'
    { $sel:error:TaskFailedEventDetails' :: Maybe (Sensitive Text)
error = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:cause:TaskFailedEventDetails' :: Maybe (Sensitive Text)
cause = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:TaskFailedEventDetails' :: Text
resourceType = Text
pResourceType_,
      $sel:resource:TaskFailedEventDetails' :: Text
resource = Text
pResource_
    }

-- | The error code of the failure.
taskFailedEventDetails_error :: Lens.Lens' TaskFailedEventDetails (Prelude.Maybe Prelude.Text)
taskFailedEventDetails_error :: (Maybe Text -> f (Maybe Text))
-> TaskFailedEventDetails -> f TaskFailedEventDetails
taskFailedEventDetails_error = (TaskFailedEventDetails -> Maybe (Sensitive Text))
-> (TaskFailedEventDetails
    -> Maybe (Sensitive Text) -> TaskFailedEventDetails)
-> Lens
     TaskFailedEventDetails
     TaskFailedEventDetails
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskFailedEventDetails' {Maybe (Sensitive Text)
error :: Maybe (Sensitive Text)
$sel:error:TaskFailedEventDetails' :: TaskFailedEventDetails -> Maybe (Sensitive Text)
error} -> Maybe (Sensitive Text)
error) (\s :: TaskFailedEventDetails
s@TaskFailedEventDetails' {} Maybe (Sensitive Text)
a -> TaskFailedEventDetails
s {$sel:error:TaskFailedEventDetails' :: Maybe (Sensitive Text)
error = Maybe (Sensitive Text)
a} :: TaskFailedEventDetails) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> TaskFailedEventDetails -> f TaskFailedEventDetails)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> TaskFailedEventDetails
-> f TaskFailedEventDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | A more detailed explanation of the cause of the failure.
taskFailedEventDetails_cause :: Lens.Lens' TaskFailedEventDetails (Prelude.Maybe Prelude.Text)
taskFailedEventDetails_cause :: (Maybe Text -> f (Maybe Text))
-> TaskFailedEventDetails -> f TaskFailedEventDetails
taskFailedEventDetails_cause = (TaskFailedEventDetails -> Maybe (Sensitive Text))
-> (TaskFailedEventDetails
    -> Maybe (Sensitive Text) -> TaskFailedEventDetails)
-> Lens
     TaskFailedEventDetails
     TaskFailedEventDetails
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskFailedEventDetails' {Maybe (Sensitive Text)
cause :: Maybe (Sensitive Text)
$sel:cause:TaskFailedEventDetails' :: TaskFailedEventDetails -> Maybe (Sensitive Text)
cause} -> Maybe (Sensitive Text)
cause) (\s :: TaskFailedEventDetails
s@TaskFailedEventDetails' {} Maybe (Sensitive Text)
a -> TaskFailedEventDetails
s {$sel:cause:TaskFailedEventDetails' :: Maybe (Sensitive Text)
cause = Maybe (Sensitive Text)
a} :: TaskFailedEventDetails) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> TaskFailedEventDetails -> f TaskFailedEventDetails)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> TaskFailedEventDetails
-> f TaskFailedEventDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The action of the resource called by a task state.
taskFailedEventDetails_resourceType :: Lens.Lens' TaskFailedEventDetails Prelude.Text
taskFailedEventDetails_resourceType :: (Text -> f Text)
-> TaskFailedEventDetails -> f TaskFailedEventDetails
taskFailedEventDetails_resourceType = (TaskFailedEventDetails -> Text)
-> (TaskFailedEventDetails -> Text -> TaskFailedEventDetails)
-> Lens TaskFailedEventDetails TaskFailedEventDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskFailedEventDetails' {Text
resourceType :: Text
$sel:resourceType:TaskFailedEventDetails' :: TaskFailedEventDetails -> Text
resourceType} -> Text
resourceType) (\s :: TaskFailedEventDetails
s@TaskFailedEventDetails' {} Text
a -> TaskFailedEventDetails
s {$sel:resourceType:TaskFailedEventDetails' :: Text
resourceType = Text
a} :: TaskFailedEventDetails)

-- | The service name of the resource in a task state.
taskFailedEventDetails_resource :: Lens.Lens' TaskFailedEventDetails Prelude.Text
taskFailedEventDetails_resource :: (Text -> f Text)
-> TaskFailedEventDetails -> f TaskFailedEventDetails
taskFailedEventDetails_resource = (TaskFailedEventDetails -> Text)
-> (TaskFailedEventDetails -> Text -> TaskFailedEventDetails)
-> Lens TaskFailedEventDetails TaskFailedEventDetails Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TaskFailedEventDetails' {Text
resource :: Text
$sel:resource:TaskFailedEventDetails' :: TaskFailedEventDetails -> Text
resource} -> Text
resource) (\s :: TaskFailedEventDetails
s@TaskFailedEventDetails' {} Text
a -> TaskFailedEventDetails
s {$sel:resource:TaskFailedEventDetails' :: Text
resource = Text
a} :: TaskFailedEventDetails)

instance Core.FromJSON TaskFailedEventDetails where
  parseJSON :: Value -> Parser TaskFailedEventDetails
parseJSON =
    String
-> (Object -> Parser TaskFailedEventDetails)
-> Value
-> Parser TaskFailedEventDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TaskFailedEventDetails"
      ( \Object
x ->
          Maybe (Sensitive Text)
-> Maybe (Sensitive Text) -> Text -> Text -> TaskFailedEventDetails
TaskFailedEventDetails'
            (Maybe (Sensitive Text)
 -> Maybe (Sensitive Text)
 -> Text
 -> Text
 -> TaskFailedEventDetails)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe (Sensitive Text) -> Text -> Text -> TaskFailedEventDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"error")
            Parser
  (Maybe (Sensitive Text) -> Text -> Text -> TaskFailedEventDetails)
-> Parser (Maybe (Sensitive Text))
-> Parser (Text -> Text -> TaskFailedEventDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cause")
            Parser (Text -> Text -> TaskFailedEventDetails)
-> Parser Text -> Parser (Text -> TaskFailedEventDetails)
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
"resourceType")
            Parser (Text -> TaskFailedEventDetails)
-> Parser Text -> Parser TaskFailedEventDetails
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
"resource")
      )

instance Prelude.Hashable TaskFailedEventDetails

instance Prelude.NFData TaskFailedEventDetails