{-# 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.ScheduleActivityTaskFailedEventAttributes
-- 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.ScheduleActivityTaskFailedEventAttributes 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.ActivityType
import Amazonka.SWF.Types.ScheduleActivityTaskFailedCause

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

-- |
-- Create a value of 'ScheduleActivityTaskFailedEventAttributes' 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:
--
-- 'activityType', 'scheduleActivityTaskFailedEventAttributes_activityType' - The activity type provided in the @ScheduleActivityTask@ decision that
-- failed.
--
-- 'activityId', 'scheduleActivityTaskFailedEventAttributes_activityId' - The activityId provided in the @ScheduleActivityTask@ decision that
-- failed.
--
-- 'cause', 'scheduleActivityTaskFailedEventAttributes_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', 'scheduleActivityTaskFailedEventAttributes_decisionTaskCompletedEventId' - The ID of the @DecisionTaskCompleted@ event corresponding to the
-- decision that resulted in the scheduling of this activity task. This
-- information can be useful for diagnosing problems by tracing back the
-- chain of events leading up to this event.
newScheduleActivityTaskFailedEventAttributes ::
  -- | 'activityType'
  ActivityType ->
  -- | 'activityId'
  Prelude.Text ->
  -- | 'cause'
  ScheduleActivityTaskFailedCause ->
  -- | 'decisionTaskCompletedEventId'
  Prelude.Integer ->
  ScheduleActivityTaskFailedEventAttributes
newScheduleActivityTaskFailedEventAttributes :: ActivityType
-> Text
-> ScheduleActivityTaskFailedCause
-> Integer
-> ScheduleActivityTaskFailedEventAttributes
newScheduleActivityTaskFailedEventAttributes
  ActivityType
pActivityType_
  Text
pActivityId_
  ScheduleActivityTaskFailedCause
pCause_
  Integer
pDecisionTaskCompletedEventId_ =
    ScheduleActivityTaskFailedEventAttributes'
      { $sel:activityType:ScheduleActivityTaskFailedEventAttributes' :: ActivityType
activityType =
          ActivityType
pActivityType_,
        $sel:activityId:ScheduleActivityTaskFailedEventAttributes' :: Text
activityId = Text
pActivityId_,
        $sel:cause:ScheduleActivityTaskFailedEventAttributes' :: ScheduleActivityTaskFailedCause
cause = ScheduleActivityTaskFailedCause
pCause_,
        $sel:decisionTaskCompletedEventId:ScheduleActivityTaskFailedEventAttributes' :: Integer
decisionTaskCompletedEventId =
          Integer
pDecisionTaskCompletedEventId_
      }

-- | The activity type provided in the @ScheduleActivityTask@ decision that
-- failed.
scheduleActivityTaskFailedEventAttributes_activityType :: Lens.Lens' ScheduleActivityTaskFailedEventAttributes ActivityType
scheduleActivityTaskFailedEventAttributes_activityType :: Lens' ScheduleActivityTaskFailedEventAttributes ActivityType
scheduleActivityTaskFailedEventAttributes_activityType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleActivityTaskFailedEventAttributes' {ActivityType
activityType :: ActivityType
$sel:activityType:ScheduleActivityTaskFailedEventAttributes' :: ScheduleActivityTaskFailedEventAttributes -> ActivityType
activityType} -> ActivityType
activityType) (\s :: ScheduleActivityTaskFailedEventAttributes
s@ScheduleActivityTaskFailedEventAttributes' {} ActivityType
a -> ScheduleActivityTaskFailedEventAttributes
s {$sel:activityType:ScheduleActivityTaskFailedEventAttributes' :: ActivityType
activityType = ActivityType
a} :: ScheduleActivityTaskFailedEventAttributes)

-- | The activityId provided in the @ScheduleActivityTask@ decision that
-- failed.
scheduleActivityTaskFailedEventAttributes_activityId :: Lens.Lens' ScheduleActivityTaskFailedEventAttributes Prelude.Text
scheduleActivityTaskFailedEventAttributes_activityId :: Lens' ScheduleActivityTaskFailedEventAttributes Text
scheduleActivityTaskFailedEventAttributes_activityId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleActivityTaskFailedEventAttributes' {Text
activityId :: Text
$sel:activityId:ScheduleActivityTaskFailedEventAttributes' :: ScheduleActivityTaskFailedEventAttributes -> Text
activityId} -> Text
activityId) (\s :: ScheduleActivityTaskFailedEventAttributes
s@ScheduleActivityTaskFailedEventAttributes' {} Text
a -> ScheduleActivityTaskFailedEventAttributes
s {$sel:activityId:ScheduleActivityTaskFailedEventAttributes' :: Text
activityId = Text
a} :: ScheduleActivityTaskFailedEventAttributes)

-- | 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/.
scheduleActivityTaskFailedEventAttributes_cause :: Lens.Lens' ScheduleActivityTaskFailedEventAttributes ScheduleActivityTaskFailedCause
scheduleActivityTaskFailedEventAttributes_cause :: Lens'
  ScheduleActivityTaskFailedEventAttributes
  ScheduleActivityTaskFailedCause
scheduleActivityTaskFailedEventAttributes_cause = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduleActivityTaskFailedEventAttributes' {ScheduleActivityTaskFailedCause
cause :: ScheduleActivityTaskFailedCause
$sel:cause:ScheduleActivityTaskFailedEventAttributes' :: ScheduleActivityTaskFailedEventAttributes
-> ScheduleActivityTaskFailedCause
cause} -> ScheduleActivityTaskFailedCause
cause) (\s :: ScheduleActivityTaskFailedEventAttributes
s@ScheduleActivityTaskFailedEventAttributes' {} ScheduleActivityTaskFailedCause
a -> ScheduleActivityTaskFailedEventAttributes
s {$sel:cause:ScheduleActivityTaskFailedEventAttributes' :: ScheduleActivityTaskFailedCause
cause = ScheduleActivityTaskFailedCause
a} :: ScheduleActivityTaskFailedEventAttributes)

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

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

instance
  Prelude.NFData
    ScheduleActivityTaskFailedEventAttributes
  where
  rnf :: ScheduleActivityTaskFailedEventAttributes -> ()
rnf ScheduleActivityTaskFailedEventAttributes' {Integer
Text
ActivityType
ScheduleActivityTaskFailedCause
decisionTaskCompletedEventId :: Integer
cause :: ScheduleActivityTaskFailedCause
activityId :: Text
activityType :: ActivityType
$sel:decisionTaskCompletedEventId:ScheduleActivityTaskFailedEventAttributes' :: ScheduleActivityTaskFailedEventAttributes -> Integer
$sel:cause:ScheduleActivityTaskFailedEventAttributes' :: ScheduleActivityTaskFailedEventAttributes
-> ScheduleActivityTaskFailedCause
$sel:activityId:ScheduleActivityTaskFailedEventAttributes' :: ScheduleActivityTaskFailedEventAttributes -> Text
$sel:activityType:ScheduleActivityTaskFailedEventAttributes' :: ScheduleActivityTaskFailedEventAttributes -> ActivityType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ActivityType
activityType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
activityId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ScheduleActivityTaskFailedCause
cause
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
decisionTaskCompletedEventId