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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ScheduleActivityTaskFailedEventAttributes
 -> ScheduleActivityTaskFailedEventAttributes -> Bool)
-> (ScheduleActivityTaskFailedEventAttributes
    -> ScheduleActivityTaskFailedEventAttributes -> Bool)
-> Eq ScheduleActivityTaskFailedEventAttributes
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]
(Int -> ReadS ScheduleActivityTaskFailedEventAttributes)
-> ReadS [ScheduleActivityTaskFailedEventAttributes]
-> ReadPrec ScheduleActivityTaskFailedEventAttributes
-> ReadPrec [ScheduleActivityTaskFailedEventAttributes]
-> Read 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
(Int -> ScheduleActivityTaskFailedEventAttributes -> ShowS)
-> (ScheduleActivityTaskFailedEventAttributes -> String)
-> ([ScheduleActivityTaskFailedEventAttributes] -> ShowS)
-> Show ScheduleActivityTaskFailedEventAttributes
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.
 ScheduleActivityTaskFailedEventAttributes
 -> Rep ScheduleActivityTaskFailedEventAttributes x)
-> (forall x.
    Rep ScheduleActivityTaskFailedEventAttributes x
    -> ScheduleActivityTaskFailedEventAttributes)
-> Generic ScheduleActivityTaskFailedEventAttributes
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' :: ActivityType
-> Text
-> ScheduleActivityTaskFailedCause
-> Integer
-> ScheduleActivityTaskFailedEventAttributes
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 :: (ActivityType -> f ActivityType)
-> ScheduleActivityTaskFailedEventAttributes
-> f ScheduleActivityTaskFailedEventAttributes
scheduleActivityTaskFailedEventAttributes_activityType = (ScheduleActivityTaskFailedEventAttributes -> ActivityType)
-> (ScheduleActivityTaskFailedEventAttributes
    -> ActivityType -> ScheduleActivityTaskFailedEventAttributes)
-> Lens
     ScheduleActivityTaskFailedEventAttributes
     ScheduleActivityTaskFailedEventAttributes
     ActivityType
     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 :: (Text -> f Text)
-> ScheduleActivityTaskFailedEventAttributes
-> f ScheduleActivityTaskFailedEventAttributes
scheduleActivityTaskFailedEventAttributes_activityId = (ScheduleActivityTaskFailedEventAttributes -> Text)
-> (ScheduleActivityTaskFailedEventAttributes
    -> Text -> ScheduleActivityTaskFailedEventAttributes)
-> Lens
     ScheduleActivityTaskFailedEventAttributes
     ScheduleActivityTaskFailedEventAttributes
     Text
     Text
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 :: (ScheduleActivityTaskFailedCause
 -> f ScheduleActivityTaskFailedCause)
-> ScheduleActivityTaskFailedEventAttributes
-> f ScheduleActivityTaskFailedEventAttributes
scheduleActivityTaskFailedEventAttributes_cause = (ScheduleActivityTaskFailedEventAttributes
 -> ScheduleActivityTaskFailedCause)
-> (ScheduleActivityTaskFailedEventAttributes
    -> ScheduleActivityTaskFailedCause
    -> ScheduleActivityTaskFailedEventAttributes)
-> Lens
     ScheduleActivityTaskFailedEventAttributes
     ScheduleActivityTaskFailedEventAttributes
     ScheduleActivityTaskFailedCause
     ScheduleActivityTaskFailedCause
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 :: (Integer -> f Integer)
-> ScheduleActivityTaskFailedEventAttributes
-> f ScheduleActivityTaskFailedEventAttributes
scheduleActivityTaskFailedEventAttributes_decisionTaskCompletedEventId = (ScheduleActivityTaskFailedEventAttributes -> Integer)
-> (ScheduleActivityTaskFailedEventAttributes
    -> Integer -> ScheduleActivityTaskFailedEventAttributes)
-> Lens
     ScheduleActivityTaskFailedEventAttributes
     ScheduleActivityTaskFailedEventAttributes
     Integer
     Integer
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
  Core.FromJSON
    ScheduleActivityTaskFailedEventAttributes
  where
  parseJSON :: Value -> Parser ScheduleActivityTaskFailedEventAttributes
parseJSON =
    String
-> (Object -> Parser ScheduleActivityTaskFailedEventAttributes)
-> Value
-> Parser ScheduleActivityTaskFailedEventAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ScheduleActivityTaskFailedEventAttributes"
      ( \Object
x ->
          ActivityType
-> Text
-> ScheduleActivityTaskFailedCause
-> Integer
-> ScheduleActivityTaskFailedEventAttributes
ScheduleActivityTaskFailedEventAttributes'
            (ActivityType
 -> Text
 -> ScheduleActivityTaskFailedCause
 -> Integer
 -> ScheduleActivityTaskFailedEventAttributes)
-> Parser ActivityType
-> Parser
     (Text
      -> ScheduleActivityTaskFailedCause
      -> Integer
      -> ScheduleActivityTaskFailedEventAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ActivityType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"activityType")
              Parser
  (Text
   -> ScheduleActivityTaskFailedCause
   -> Integer
   -> ScheduleActivityTaskFailedEventAttributes)
-> Parser Text
-> Parser
     (ScheduleActivityTaskFailedCause
      -> Integer -> ScheduleActivityTaskFailedEventAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"activityId")
              Parser
  (ScheduleActivityTaskFailedCause
   -> Integer -> ScheduleActivityTaskFailedEventAttributes)
-> Parser ScheduleActivityTaskFailedCause
-> Parser (Integer -> ScheduleActivityTaskFailedEventAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ScheduleActivityTaskFailedCause
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"cause")
              Parser (Integer -> ScheduleActivityTaskFailedEventAttributes)
-> Parser Integer
-> Parser ScheduleActivityTaskFailedEventAttributes
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
    ScheduleActivityTaskFailedEventAttributes

instance
  Prelude.NFData
    ScheduleActivityTaskFailedEventAttributes