{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SWF.Types.FailWorkflowExecutionFailedEventAttributes 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
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
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]
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
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.
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'
      { $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 :: Lens'
  FailWorkflowExecutionFailedEventAttributes
  FailWorkflowExecutionFailedCause
failWorkflowExecutionFailedEventAttributes_cause = 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 :: Lens' FailWorkflowExecutionFailedEventAttributes Integer
failWorkflowExecutionFailedEventAttributes_decisionTaskCompletedEventId = 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
  Data.FromJSON
    FailWorkflowExecutionFailedEventAttributes
  where
  parseJSON :: Value -> Parser FailWorkflowExecutionFailedEventAttributes
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FailWorkflowExecutionFailedEventAttributes"
      ( \Object
x ->
          FailWorkflowExecutionFailedCause
-> Integer -> FailWorkflowExecutionFailedEventAttributes
FailWorkflowExecutionFailedEventAttributes'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"cause")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"decisionTaskCompletedEventId")
      )

instance
  Prelude.Hashable
    FailWorkflowExecutionFailedEventAttributes
  where
  hashWithSalt :: Int -> FailWorkflowExecutionFailedEventAttributes -> Int
hashWithSalt
    Int
_salt
    FailWorkflowExecutionFailedEventAttributes' {Integer
FailWorkflowExecutionFailedCause
decisionTaskCompletedEventId :: Integer
cause :: FailWorkflowExecutionFailedCause
$sel:decisionTaskCompletedEventId:FailWorkflowExecutionFailedEventAttributes' :: FailWorkflowExecutionFailedEventAttributes -> Integer
$sel:cause:FailWorkflowExecutionFailedEventAttributes' :: FailWorkflowExecutionFailedEventAttributes
-> FailWorkflowExecutionFailedCause
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FailWorkflowExecutionFailedCause
cause
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
decisionTaskCompletedEventId

instance
  Prelude.NFData
    FailWorkflowExecutionFailedEventAttributes
  where
  rnf :: FailWorkflowExecutionFailedEventAttributes -> ()
rnf FailWorkflowExecutionFailedEventAttributes' {Integer
FailWorkflowExecutionFailedCause
decisionTaskCompletedEventId :: Integer
cause :: FailWorkflowExecutionFailedCause
$sel:decisionTaskCompletedEventId:FailWorkflowExecutionFailedEventAttributes' :: FailWorkflowExecutionFailedEventAttributes -> Integer
$sel:cause:FailWorkflowExecutionFailedEventAttributes' :: FailWorkflowExecutionFailedEventAttributes
-> FailWorkflowExecutionFailedCause
..} =
    forall a. NFData a => a -> ()
Prelude.rnf FailWorkflowExecutionFailedCause
cause
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
decisionTaskCompletedEventId