{-# 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.SWF.Types.FailWorkflowExecutionFailedEventAttributes
-- 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.SWF.Types.FailWorkflowExecutionFailedEventAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SWF.Types.FailWorkflowExecutionFailedCause

-- | Provides the details of the @FailWorkflowExecutionFailed@ event.
--
-- /See:/ 'newFailWorkflowExecutionFailedEventAttributes' smart constructor.
data FailWorkflowExecutionFailedEventAttributes = FailWorkflowExecutionFailedEventAttributes'
  { -- | The cause of the failure. This information is generated by the system
    -- and can be useful for diagnostic purposes.
    --
    -- If @cause@ is set to @OPERATION_NOT_PERMITTED@, the decision failed
    -- because it lacked sufficient permissions. For details and example IAM
    -- policies, see
    -- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html Using IAM to Manage Access to Amazon SWF Workflows>
    -- in the /Amazon SWF Developer Guide/.
    FailWorkflowExecutionFailedEventAttributes
-> FailWorkflowExecutionFailedCause
cause :: FailWorkflowExecutionFailedCause,
    -- | The ID of the @DecisionTaskCompleted@ event corresponding to the
    -- decision task that resulted in the @FailWorkflowExecution@ decision to
    -- fail this execution. This information can be useful for diagnosing
    -- problems by tracing back the chain of events leading up to this event.
    FailWorkflowExecutionFailedEventAttributes -> Integer
decisionTaskCompletedEventId :: Prelude.Integer
  }
  deriving (FailWorkflowExecutionFailedEventAttributes
-> FailWorkflowExecutionFailedEventAttributes -> Bool
(FailWorkflowExecutionFailedEventAttributes
 -> FailWorkflowExecutionFailedEventAttributes -> Bool)
-> (FailWorkflowExecutionFailedEventAttributes
    -> FailWorkflowExecutionFailedEventAttributes -> Bool)
-> Eq FailWorkflowExecutionFailedEventAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailWorkflowExecutionFailedEventAttributes
-> FailWorkflowExecutionFailedEventAttributes -> Bool
$c/= :: FailWorkflowExecutionFailedEventAttributes
-> FailWorkflowExecutionFailedEventAttributes -> Bool
== :: FailWorkflowExecutionFailedEventAttributes
-> FailWorkflowExecutionFailedEventAttributes -> Bool
$c== :: FailWorkflowExecutionFailedEventAttributes
-> FailWorkflowExecutionFailedEventAttributes -> Bool
Prelude.Eq, ReadPrec [FailWorkflowExecutionFailedEventAttributes]
ReadPrec FailWorkflowExecutionFailedEventAttributes
Int -> ReadS FailWorkflowExecutionFailedEventAttributes
ReadS [FailWorkflowExecutionFailedEventAttributes]
(Int -> ReadS FailWorkflowExecutionFailedEventAttributes)
-> ReadS [FailWorkflowExecutionFailedEventAttributes]
-> ReadPrec FailWorkflowExecutionFailedEventAttributes
-> ReadPrec [FailWorkflowExecutionFailedEventAttributes]
-> Read FailWorkflowExecutionFailedEventAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailWorkflowExecutionFailedEventAttributes]
$creadListPrec :: ReadPrec [FailWorkflowExecutionFailedEventAttributes]
readPrec :: ReadPrec FailWorkflowExecutionFailedEventAttributes
$creadPrec :: ReadPrec FailWorkflowExecutionFailedEventAttributes
readList :: ReadS [FailWorkflowExecutionFailedEventAttributes]
$creadList :: ReadS [FailWorkflowExecutionFailedEventAttributes]
readsPrec :: Int -> ReadS FailWorkflowExecutionFailedEventAttributes
$creadsPrec :: Int -> ReadS FailWorkflowExecutionFailedEventAttributes
Prelude.Read, Int -> FailWorkflowExecutionFailedEventAttributes -> ShowS
[FailWorkflowExecutionFailedEventAttributes] -> ShowS
FailWorkflowExecutionFailedEventAttributes -> String
(Int -> FailWorkflowExecutionFailedEventAttributes -> ShowS)
-> (FailWorkflowExecutionFailedEventAttributes -> String)
-> ([FailWorkflowExecutionFailedEventAttributes] -> ShowS)
-> Show FailWorkflowExecutionFailedEventAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailWorkflowExecutionFailedEventAttributes] -> ShowS
$cshowList :: [FailWorkflowExecutionFailedEventAttributes] -> ShowS
show :: FailWorkflowExecutionFailedEventAttributes -> String
$cshow :: FailWorkflowExecutionFailedEventAttributes -> String
showsPrec :: Int -> FailWorkflowExecutionFailedEventAttributes -> ShowS
$cshowsPrec :: Int -> FailWorkflowExecutionFailedEventAttributes -> ShowS
Prelude.Show, (forall x.
 FailWorkflowExecutionFailedEventAttributes
 -> Rep FailWorkflowExecutionFailedEventAttributes x)
-> (forall x.
    Rep FailWorkflowExecutionFailedEventAttributes x
    -> FailWorkflowExecutionFailedEventAttributes)
-> Generic FailWorkflowExecutionFailedEventAttributes
forall x.
Rep FailWorkflowExecutionFailedEventAttributes x
-> FailWorkflowExecutionFailedEventAttributes
forall x.
FailWorkflowExecutionFailedEventAttributes
-> Rep FailWorkflowExecutionFailedEventAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FailWorkflowExecutionFailedEventAttributes x
-> FailWorkflowExecutionFailedEventAttributes
$cfrom :: forall x.
FailWorkflowExecutionFailedEventAttributes
-> Rep FailWorkflowExecutionFailedEventAttributes x
Prelude.Generic)

-- |
-- Create a value of 'FailWorkflowExecutionFailedEventAttributes' 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:
--
-- 'cause', 'failWorkflowExecutionFailedEventAttributes_cause' - The cause of the failure. This information is generated by the system
-- and can be useful for diagnostic purposes.
--
-- If @cause@ is set to @OPERATION_NOT_PERMITTED@, the decision failed
-- because it lacked sufficient permissions. For details and example IAM
-- policies, see
-- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html Using IAM to Manage Access to Amazon SWF Workflows>
-- in the /Amazon SWF Developer Guide/.
--
-- 'decisionTaskCompletedEventId', 'failWorkflowExecutionFailedEventAttributes_decisionTaskCompletedEventId' - The ID of the @DecisionTaskCompleted@ event corresponding to the
-- decision task that resulted in the @FailWorkflowExecution@ decision to
-- fail this execution. This information can be useful for diagnosing
-- problems by tracing back the chain of events leading up to this event.
newFailWorkflowExecutionFailedEventAttributes ::
  -- | 'cause'
  FailWorkflowExecutionFailedCause ->
  -- | 'decisionTaskCompletedEventId'
  Prelude.Integer ->
  FailWorkflowExecutionFailedEventAttributes
newFailWorkflowExecutionFailedEventAttributes :: FailWorkflowExecutionFailedCause
-> Integer -> FailWorkflowExecutionFailedEventAttributes
newFailWorkflowExecutionFailedEventAttributes
  FailWorkflowExecutionFailedCause
pCause_
  Integer
pDecisionTaskCompletedEventId_ =
    FailWorkflowExecutionFailedEventAttributes' :: FailWorkflowExecutionFailedCause
-> Integer -> FailWorkflowExecutionFailedEventAttributes
FailWorkflowExecutionFailedEventAttributes'
      { $sel:cause:FailWorkflowExecutionFailedEventAttributes' :: FailWorkflowExecutionFailedCause
cause =
          FailWorkflowExecutionFailedCause
pCause_,
        $sel:decisionTaskCompletedEventId:FailWorkflowExecutionFailedEventAttributes' :: Integer
decisionTaskCompletedEventId =
          Integer
pDecisionTaskCompletedEventId_
      }

-- | The cause of the failure. This information is generated by the system
-- and can be useful for diagnostic purposes.
--
-- If @cause@ is set to @OPERATION_NOT_PERMITTED@, the decision failed
-- because it lacked sufficient permissions. For details and example IAM
-- policies, see
-- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html Using IAM to Manage Access to Amazon SWF Workflows>
-- in the /Amazon SWF Developer Guide/.
failWorkflowExecutionFailedEventAttributes_cause :: Lens.Lens' FailWorkflowExecutionFailedEventAttributes FailWorkflowExecutionFailedCause
failWorkflowExecutionFailedEventAttributes_cause :: (FailWorkflowExecutionFailedCause
 -> f FailWorkflowExecutionFailedCause)
-> FailWorkflowExecutionFailedEventAttributes
-> f FailWorkflowExecutionFailedEventAttributes
failWorkflowExecutionFailedEventAttributes_cause = (FailWorkflowExecutionFailedEventAttributes
 -> FailWorkflowExecutionFailedCause)
-> (FailWorkflowExecutionFailedEventAttributes
    -> FailWorkflowExecutionFailedCause
    -> FailWorkflowExecutionFailedEventAttributes)
-> Lens
     FailWorkflowExecutionFailedEventAttributes
     FailWorkflowExecutionFailedEventAttributes
     FailWorkflowExecutionFailedCause
     FailWorkflowExecutionFailedCause
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailWorkflowExecutionFailedEventAttributes' {FailWorkflowExecutionFailedCause
cause :: FailWorkflowExecutionFailedCause
$sel:cause:FailWorkflowExecutionFailedEventAttributes' :: FailWorkflowExecutionFailedEventAttributes
-> FailWorkflowExecutionFailedCause
cause} -> FailWorkflowExecutionFailedCause
cause) (\s :: FailWorkflowExecutionFailedEventAttributes
s@FailWorkflowExecutionFailedEventAttributes' {} FailWorkflowExecutionFailedCause
a -> FailWorkflowExecutionFailedEventAttributes
s {$sel:cause:FailWorkflowExecutionFailedEventAttributes' :: FailWorkflowExecutionFailedCause
cause = FailWorkflowExecutionFailedCause
a} :: FailWorkflowExecutionFailedEventAttributes)

-- | The ID of the @DecisionTaskCompleted@ event corresponding to the
-- decision task that resulted in the @FailWorkflowExecution@ decision to
-- fail this execution. This information can be useful for diagnosing
-- problems by tracing back the chain of events leading up to this event.
failWorkflowExecutionFailedEventAttributes_decisionTaskCompletedEventId :: Lens.Lens' FailWorkflowExecutionFailedEventAttributes Prelude.Integer
failWorkflowExecutionFailedEventAttributes_decisionTaskCompletedEventId :: (Integer -> f Integer)
-> FailWorkflowExecutionFailedEventAttributes
-> f FailWorkflowExecutionFailedEventAttributes
failWorkflowExecutionFailedEventAttributes_decisionTaskCompletedEventId = (FailWorkflowExecutionFailedEventAttributes -> Integer)
-> (FailWorkflowExecutionFailedEventAttributes
    -> Integer -> FailWorkflowExecutionFailedEventAttributes)
-> Lens
     FailWorkflowExecutionFailedEventAttributes
     FailWorkflowExecutionFailedEventAttributes
     Integer
     Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailWorkflowExecutionFailedEventAttributes' {Integer
decisionTaskCompletedEventId :: Integer
$sel:decisionTaskCompletedEventId:FailWorkflowExecutionFailedEventAttributes' :: FailWorkflowExecutionFailedEventAttributes -> Integer
decisionTaskCompletedEventId} -> Integer
decisionTaskCompletedEventId) (\s :: FailWorkflowExecutionFailedEventAttributes
s@FailWorkflowExecutionFailedEventAttributes' {} Integer
a -> FailWorkflowExecutionFailedEventAttributes
s {$sel:decisionTaskCompletedEventId:FailWorkflowExecutionFailedEventAttributes' :: Integer
decisionTaskCompletedEventId = Integer
a} :: FailWorkflowExecutionFailedEventAttributes)

instance
  Core.FromJSON
    FailWorkflowExecutionFailedEventAttributes
  where
  parseJSON :: Value -> Parser FailWorkflowExecutionFailedEventAttributes
parseJSON =
    String
-> (Object -> Parser FailWorkflowExecutionFailedEventAttributes)
-> Value
-> Parser FailWorkflowExecutionFailedEventAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FailWorkflowExecutionFailedEventAttributes"
      ( \Object
x ->
          FailWorkflowExecutionFailedCause
-> Integer -> FailWorkflowExecutionFailedEventAttributes
FailWorkflowExecutionFailedEventAttributes'
            (FailWorkflowExecutionFailedCause
 -> Integer -> FailWorkflowExecutionFailedEventAttributes)
-> Parser FailWorkflowExecutionFailedCause
-> Parser (Integer -> FailWorkflowExecutionFailedEventAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser FailWorkflowExecutionFailedCause
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"cause")
              Parser (Integer -> FailWorkflowExecutionFailedEventAttributes)
-> Parser Integer
-> Parser FailWorkflowExecutionFailedEventAttributes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Integer
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"decisionTaskCompletedEventId")
      )

instance
  Prelude.Hashable
    FailWorkflowExecutionFailedEventAttributes

instance
  Prelude.NFData
    FailWorkflowExecutionFailedEventAttributes