{-# 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.CancelWorkflowExecutionFailedEventAttributes
-- 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.CancelWorkflowExecutionFailedEventAttributes 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.CancelWorkflowExecutionFailedCause

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

-- |
-- Create a value of 'CancelWorkflowExecutionFailedEventAttributes' 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', 'cancelWorkflowExecutionFailedEventAttributes_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', 'cancelWorkflowExecutionFailedEventAttributes_decisionTaskCompletedEventId' - The ID of the @DecisionTaskCompleted@ event corresponding to the
-- decision task that resulted in the @CancelWorkflowExecution@ decision
-- for this cancellation request. This information can be useful for
-- diagnosing problems by tracing back the chain of events leading up to
-- this event.
newCancelWorkflowExecutionFailedEventAttributes ::
  -- | 'cause'
  CancelWorkflowExecutionFailedCause ->
  -- | 'decisionTaskCompletedEventId'
  Prelude.Integer ->
  CancelWorkflowExecutionFailedEventAttributes
newCancelWorkflowExecutionFailedEventAttributes :: CancelWorkflowExecutionFailedCause
-> Integer -> CancelWorkflowExecutionFailedEventAttributes
newCancelWorkflowExecutionFailedEventAttributes
  CancelWorkflowExecutionFailedCause
pCause_
  Integer
pDecisionTaskCompletedEventId_ =
    CancelWorkflowExecutionFailedEventAttributes'
      { $sel:cause:CancelWorkflowExecutionFailedEventAttributes' :: CancelWorkflowExecutionFailedCause
cause =
          CancelWorkflowExecutionFailedCause
pCause_,
        $sel:decisionTaskCompletedEventId:CancelWorkflowExecutionFailedEventAttributes' :: 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/.
cancelWorkflowExecutionFailedEventAttributes_cause :: Lens.Lens' CancelWorkflowExecutionFailedEventAttributes CancelWorkflowExecutionFailedCause
cancelWorkflowExecutionFailedEventAttributes_cause :: Lens'
  CancelWorkflowExecutionFailedEventAttributes
  CancelWorkflowExecutionFailedCause
cancelWorkflowExecutionFailedEventAttributes_cause = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelWorkflowExecutionFailedEventAttributes' {CancelWorkflowExecutionFailedCause
cause :: CancelWorkflowExecutionFailedCause
$sel:cause:CancelWorkflowExecutionFailedEventAttributes' :: CancelWorkflowExecutionFailedEventAttributes
-> CancelWorkflowExecutionFailedCause
cause} -> CancelWorkflowExecutionFailedCause
cause) (\s :: CancelWorkflowExecutionFailedEventAttributes
s@CancelWorkflowExecutionFailedEventAttributes' {} CancelWorkflowExecutionFailedCause
a -> CancelWorkflowExecutionFailedEventAttributes
s {$sel:cause:CancelWorkflowExecutionFailedEventAttributes' :: CancelWorkflowExecutionFailedCause
cause = CancelWorkflowExecutionFailedCause
a} :: CancelWorkflowExecutionFailedEventAttributes)

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

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

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