{-# 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.CompleteWorkflowExecutionFailedEventAttributes
-- 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.CompleteWorkflowExecutionFailedEventAttributes 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.CompleteWorkflowExecutionFailedCause

-- | Provides the details of the @CompleteWorkflowExecutionFailed@ event.
--
-- /See:/ 'newCompleteWorkflowExecutionFailedEventAttributes' smart constructor.
data CompleteWorkflowExecutionFailedEventAttributes = CompleteWorkflowExecutionFailedEventAttributes'
  { -- | 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/.
    CompleteWorkflowExecutionFailedEventAttributes
-> CompleteWorkflowExecutionFailedCause
cause :: CompleteWorkflowExecutionFailedCause,
    -- | The ID of the @DecisionTaskCompleted@ event corresponding to the
    -- decision task that resulted in the @CompleteWorkflowExecution@ decision
    -- to complete this execution. This information can be useful for
    -- diagnosing problems by tracing back the chain of events leading up to
    -- this event.
    CompleteWorkflowExecutionFailedEventAttributes -> Integer
decisionTaskCompletedEventId :: Prelude.Integer
  }
  deriving (CompleteWorkflowExecutionFailedEventAttributes
-> CompleteWorkflowExecutionFailedEventAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompleteWorkflowExecutionFailedEventAttributes
-> CompleteWorkflowExecutionFailedEventAttributes -> Bool
$c/= :: CompleteWorkflowExecutionFailedEventAttributes
-> CompleteWorkflowExecutionFailedEventAttributes -> Bool
== :: CompleteWorkflowExecutionFailedEventAttributes
-> CompleteWorkflowExecutionFailedEventAttributes -> Bool
$c== :: CompleteWorkflowExecutionFailedEventAttributes
-> CompleteWorkflowExecutionFailedEventAttributes -> Bool
Prelude.Eq, ReadPrec [CompleteWorkflowExecutionFailedEventAttributes]
ReadPrec CompleteWorkflowExecutionFailedEventAttributes
Int -> ReadS CompleteWorkflowExecutionFailedEventAttributes
ReadS [CompleteWorkflowExecutionFailedEventAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompleteWorkflowExecutionFailedEventAttributes]
$creadListPrec :: ReadPrec [CompleteWorkflowExecutionFailedEventAttributes]
readPrec :: ReadPrec CompleteWorkflowExecutionFailedEventAttributes
$creadPrec :: ReadPrec CompleteWorkflowExecutionFailedEventAttributes
readList :: ReadS [CompleteWorkflowExecutionFailedEventAttributes]
$creadList :: ReadS [CompleteWorkflowExecutionFailedEventAttributes]
readsPrec :: Int -> ReadS CompleteWorkflowExecutionFailedEventAttributes
$creadsPrec :: Int -> ReadS CompleteWorkflowExecutionFailedEventAttributes
Prelude.Read, Int -> CompleteWorkflowExecutionFailedEventAttributes -> ShowS
[CompleteWorkflowExecutionFailedEventAttributes] -> ShowS
CompleteWorkflowExecutionFailedEventAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompleteWorkflowExecutionFailedEventAttributes] -> ShowS
$cshowList :: [CompleteWorkflowExecutionFailedEventAttributes] -> ShowS
show :: CompleteWorkflowExecutionFailedEventAttributes -> String
$cshow :: CompleteWorkflowExecutionFailedEventAttributes -> String
showsPrec :: Int -> CompleteWorkflowExecutionFailedEventAttributes -> ShowS
$cshowsPrec :: Int -> CompleteWorkflowExecutionFailedEventAttributes -> ShowS
Prelude.Show, forall x.
Rep CompleteWorkflowExecutionFailedEventAttributes x
-> CompleteWorkflowExecutionFailedEventAttributes
forall x.
CompleteWorkflowExecutionFailedEventAttributes
-> Rep CompleteWorkflowExecutionFailedEventAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CompleteWorkflowExecutionFailedEventAttributes x
-> CompleteWorkflowExecutionFailedEventAttributes
$cfrom :: forall x.
CompleteWorkflowExecutionFailedEventAttributes
-> Rep CompleteWorkflowExecutionFailedEventAttributes x
Prelude.Generic)

-- |
-- Create a value of 'CompleteWorkflowExecutionFailedEventAttributes' 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', 'completeWorkflowExecutionFailedEventAttributes_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', 'completeWorkflowExecutionFailedEventAttributes_decisionTaskCompletedEventId' - The ID of the @DecisionTaskCompleted@ event corresponding to the
-- decision task that resulted in the @CompleteWorkflowExecution@ decision
-- to complete this execution. This information can be useful for
-- diagnosing problems by tracing back the chain of events leading up to
-- this event.
newCompleteWorkflowExecutionFailedEventAttributes ::
  -- | 'cause'
  CompleteWorkflowExecutionFailedCause ->
  -- | 'decisionTaskCompletedEventId'
  Prelude.Integer ->
  CompleteWorkflowExecutionFailedEventAttributes
newCompleteWorkflowExecutionFailedEventAttributes :: CompleteWorkflowExecutionFailedCause
-> Integer -> CompleteWorkflowExecutionFailedEventAttributes
newCompleteWorkflowExecutionFailedEventAttributes
  CompleteWorkflowExecutionFailedCause
pCause_
  Integer
pDecisionTaskCompletedEventId_ =
    CompleteWorkflowExecutionFailedEventAttributes'
      { $sel:cause:CompleteWorkflowExecutionFailedEventAttributes' :: CompleteWorkflowExecutionFailedCause
cause =
          CompleteWorkflowExecutionFailedCause
pCause_,
        $sel:decisionTaskCompletedEventId:CompleteWorkflowExecutionFailedEventAttributes' :: 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/.
completeWorkflowExecutionFailedEventAttributes_cause :: Lens.Lens' CompleteWorkflowExecutionFailedEventAttributes CompleteWorkflowExecutionFailedCause
completeWorkflowExecutionFailedEventAttributes_cause :: Lens'
  CompleteWorkflowExecutionFailedEventAttributes
  CompleteWorkflowExecutionFailedCause
completeWorkflowExecutionFailedEventAttributes_cause = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompleteWorkflowExecutionFailedEventAttributes' {CompleteWorkflowExecutionFailedCause
cause :: CompleteWorkflowExecutionFailedCause
$sel:cause:CompleteWorkflowExecutionFailedEventAttributes' :: CompleteWorkflowExecutionFailedEventAttributes
-> CompleteWorkflowExecutionFailedCause
cause} -> CompleteWorkflowExecutionFailedCause
cause) (\s :: CompleteWorkflowExecutionFailedEventAttributes
s@CompleteWorkflowExecutionFailedEventAttributes' {} CompleteWorkflowExecutionFailedCause
a -> CompleteWorkflowExecutionFailedEventAttributes
s {$sel:cause:CompleteWorkflowExecutionFailedEventAttributes' :: CompleteWorkflowExecutionFailedCause
cause = CompleteWorkflowExecutionFailedCause
a} :: CompleteWorkflowExecutionFailedEventAttributes)

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

instance
  Data.FromJSON
    CompleteWorkflowExecutionFailedEventAttributes
  where
  parseJSON :: Value -> Parser CompleteWorkflowExecutionFailedEventAttributes
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CompleteWorkflowExecutionFailedEventAttributes"
      ( \Object
x ->
          CompleteWorkflowExecutionFailedCause
-> Integer -> CompleteWorkflowExecutionFailedEventAttributes
CompleteWorkflowExecutionFailedEventAttributes'
            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
    CompleteWorkflowExecutionFailedEventAttributes
  where
  hashWithSalt :: Int -> CompleteWorkflowExecutionFailedEventAttributes -> Int
hashWithSalt
    Int
_salt
    CompleteWorkflowExecutionFailedEventAttributes' {Integer
CompleteWorkflowExecutionFailedCause
decisionTaskCompletedEventId :: Integer
cause :: CompleteWorkflowExecutionFailedCause
$sel:decisionTaskCompletedEventId:CompleteWorkflowExecutionFailedEventAttributes' :: CompleteWorkflowExecutionFailedEventAttributes -> Integer
$sel:cause:CompleteWorkflowExecutionFailedEventAttributes' :: CompleteWorkflowExecutionFailedEventAttributes
-> CompleteWorkflowExecutionFailedCause
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CompleteWorkflowExecutionFailedCause
cause
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
decisionTaskCompletedEventId

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