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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(CompleteWorkflowExecutionFailedEventAttributes
 -> CompleteWorkflowExecutionFailedEventAttributes -> Bool)
-> (CompleteWorkflowExecutionFailedEventAttributes
    -> CompleteWorkflowExecutionFailedEventAttributes -> Bool)
-> Eq CompleteWorkflowExecutionFailedEventAttributes
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]
(Int -> ReadS CompleteWorkflowExecutionFailedEventAttributes)
-> ReadS [CompleteWorkflowExecutionFailedEventAttributes]
-> ReadPrec CompleteWorkflowExecutionFailedEventAttributes
-> ReadPrec [CompleteWorkflowExecutionFailedEventAttributes]
-> Read 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
(Int -> CompleteWorkflowExecutionFailedEventAttributes -> ShowS)
-> (CompleteWorkflowExecutionFailedEventAttributes -> String)
-> ([CompleteWorkflowExecutionFailedEventAttributes] -> ShowS)
-> Show CompleteWorkflowExecutionFailedEventAttributes
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.
 CompleteWorkflowExecutionFailedEventAttributes
 -> Rep CompleteWorkflowExecutionFailedEventAttributes x)
-> (forall x.
    Rep CompleteWorkflowExecutionFailedEventAttributes x
    -> CompleteWorkflowExecutionFailedEventAttributes)
-> Generic CompleteWorkflowExecutionFailedEventAttributes
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' :: CompleteWorkflowExecutionFailedCause
-> Integer -> CompleteWorkflowExecutionFailedEventAttributes
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 :: (CompleteWorkflowExecutionFailedCause
 -> f CompleteWorkflowExecutionFailedCause)
-> CompleteWorkflowExecutionFailedEventAttributes
-> f CompleteWorkflowExecutionFailedEventAttributes
completeWorkflowExecutionFailedEventAttributes_cause = (CompleteWorkflowExecutionFailedEventAttributes
 -> CompleteWorkflowExecutionFailedCause)
-> (CompleteWorkflowExecutionFailedEventAttributes
    -> CompleteWorkflowExecutionFailedCause
    -> CompleteWorkflowExecutionFailedEventAttributes)
-> Lens
     CompleteWorkflowExecutionFailedEventAttributes
     CompleteWorkflowExecutionFailedEventAttributes
     CompleteWorkflowExecutionFailedCause
     CompleteWorkflowExecutionFailedCause
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 :: (Integer -> f Integer)
-> CompleteWorkflowExecutionFailedEventAttributes
-> f CompleteWorkflowExecutionFailedEventAttributes
completeWorkflowExecutionFailedEventAttributes_decisionTaskCompletedEventId = (CompleteWorkflowExecutionFailedEventAttributes -> Integer)
-> (CompleteWorkflowExecutionFailedEventAttributes
    -> Integer -> CompleteWorkflowExecutionFailedEventAttributes)
-> Lens
     CompleteWorkflowExecutionFailedEventAttributes
     CompleteWorkflowExecutionFailedEventAttributes
     Integer
     Integer
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
  Core.FromJSON
    CompleteWorkflowExecutionFailedEventAttributes
  where
  parseJSON :: Value -> Parser CompleteWorkflowExecutionFailedEventAttributes
parseJSON =
    String
-> (Object
    -> Parser CompleteWorkflowExecutionFailedEventAttributes)
-> Value
-> Parser CompleteWorkflowExecutionFailedEventAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CompleteWorkflowExecutionFailedEventAttributes"
      ( \Object
x ->
          CompleteWorkflowExecutionFailedCause
-> Integer -> CompleteWorkflowExecutionFailedEventAttributes
CompleteWorkflowExecutionFailedEventAttributes'
            (CompleteWorkflowExecutionFailedCause
 -> Integer -> CompleteWorkflowExecutionFailedEventAttributes)
-> Parser CompleteWorkflowExecutionFailedCause
-> Parser
     (Integer -> CompleteWorkflowExecutionFailedEventAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser CompleteWorkflowExecutionFailedCause
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"cause")
              Parser (Integer -> CompleteWorkflowExecutionFailedEventAttributes)
-> Parser Integer
-> Parser CompleteWorkflowExecutionFailedEventAttributes
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
    CompleteWorkflowExecutionFailedEventAttributes

instance
  Prelude.NFData
    CompleteWorkflowExecutionFailedEventAttributes