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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides the details of the @TimerStarted@ event.
--
-- /See:/ 'newTimerStartedEventAttributes' smart constructor.
data TimerStartedEventAttributes = TimerStartedEventAttributes'
  { -- | Data attached to the event that can be used by the decider in subsequent
    -- workflow tasks.
    TimerStartedEventAttributes -> Maybe Text
control :: Prelude.Maybe Prelude.Text,
    -- | The unique ID of the timer that was started.
    TimerStartedEventAttributes -> Text
timerId :: Prelude.Text,
    -- | The duration of time after which the timer fires.
    --
    -- The duration is specified in seconds, an integer greater than or equal
    -- to @0@.
    TimerStartedEventAttributes -> Text
startToFireTimeout :: Prelude.Text,
    -- | The ID of the @DecisionTaskCompleted@ event corresponding to the
    -- decision task that resulted in the @StartTimer@ decision for this
    -- activity task. This information can be useful for diagnosing problems by
    -- tracing back the chain of events leading up to this event.
    TimerStartedEventAttributes -> Integer
decisionTaskCompletedEventId :: Prelude.Integer
  }
  deriving (TimerStartedEventAttributes -> TimerStartedEventAttributes -> Bool
(TimerStartedEventAttributes
 -> TimerStartedEventAttributes -> Bool)
-> (TimerStartedEventAttributes
    -> TimerStartedEventAttributes -> Bool)
-> Eq TimerStartedEventAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimerStartedEventAttributes -> TimerStartedEventAttributes -> Bool
$c/= :: TimerStartedEventAttributes -> TimerStartedEventAttributes -> Bool
== :: TimerStartedEventAttributes -> TimerStartedEventAttributes -> Bool
$c== :: TimerStartedEventAttributes -> TimerStartedEventAttributes -> Bool
Prelude.Eq, ReadPrec [TimerStartedEventAttributes]
ReadPrec TimerStartedEventAttributes
Int -> ReadS TimerStartedEventAttributes
ReadS [TimerStartedEventAttributes]
(Int -> ReadS TimerStartedEventAttributes)
-> ReadS [TimerStartedEventAttributes]
-> ReadPrec TimerStartedEventAttributes
-> ReadPrec [TimerStartedEventAttributes]
-> Read TimerStartedEventAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimerStartedEventAttributes]
$creadListPrec :: ReadPrec [TimerStartedEventAttributes]
readPrec :: ReadPrec TimerStartedEventAttributes
$creadPrec :: ReadPrec TimerStartedEventAttributes
readList :: ReadS [TimerStartedEventAttributes]
$creadList :: ReadS [TimerStartedEventAttributes]
readsPrec :: Int -> ReadS TimerStartedEventAttributes
$creadsPrec :: Int -> ReadS TimerStartedEventAttributes
Prelude.Read, Int -> TimerStartedEventAttributes -> ShowS
[TimerStartedEventAttributes] -> ShowS
TimerStartedEventAttributes -> String
(Int -> TimerStartedEventAttributes -> ShowS)
-> (TimerStartedEventAttributes -> String)
-> ([TimerStartedEventAttributes] -> ShowS)
-> Show TimerStartedEventAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimerStartedEventAttributes] -> ShowS
$cshowList :: [TimerStartedEventAttributes] -> ShowS
show :: TimerStartedEventAttributes -> String
$cshow :: TimerStartedEventAttributes -> String
showsPrec :: Int -> TimerStartedEventAttributes -> ShowS
$cshowsPrec :: Int -> TimerStartedEventAttributes -> ShowS
Prelude.Show, (forall x.
 TimerStartedEventAttributes -> Rep TimerStartedEventAttributes x)
-> (forall x.
    Rep TimerStartedEventAttributes x -> TimerStartedEventAttributes)
-> Generic TimerStartedEventAttributes
forall x.
Rep TimerStartedEventAttributes x -> TimerStartedEventAttributes
forall x.
TimerStartedEventAttributes -> Rep TimerStartedEventAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TimerStartedEventAttributes x -> TimerStartedEventAttributes
$cfrom :: forall x.
TimerStartedEventAttributes -> Rep TimerStartedEventAttributes x
Prelude.Generic)

-- |
-- Create a value of 'TimerStartedEventAttributes' 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:
--
-- 'control', 'timerStartedEventAttributes_control' - Data attached to the event that can be used by the decider in subsequent
-- workflow tasks.
--
-- 'timerId', 'timerStartedEventAttributes_timerId' - The unique ID of the timer that was started.
--
-- 'startToFireTimeout', 'timerStartedEventAttributes_startToFireTimeout' - The duration of time after which the timer fires.
--
-- The duration is specified in seconds, an integer greater than or equal
-- to @0@.
--
-- 'decisionTaskCompletedEventId', 'timerStartedEventAttributes_decisionTaskCompletedEventId' - The ID of the @DecisionTaskCompleted@ event corresponding to the
-- decision task that resulted in the @StartTimer@ decision for this
-- activity task. This information can be useful for diagnosing problems by
-- tracing back the chain of events leading up to this event.
newTimerStartedEventAttributes ::
  -- | 'timerId'
  Prelude.Text ->
  -- | 'startToFireTimeout'
  Prelude.Text ->
  -- | 'decisionTaskCompletedEventId'
  Prelude.Integer ->
  TimerStartedEventAttributes
newTimerStartedEventAttributes :: Text -> Text -> Integer -> TimerStartedEventAttributes
newTimerStartedEventAttributes
  Text
pTimerId_
  Text
pStartToFireTimeout_
  Integer
pDecisionTaskCompletedEventId_ =
    TimerStartedEventAttributes' :: Maybe Text
-> Text -> Text -> Integer -> TimerStartedEventAttributes
TimerStartedEventAttributes'
      { $sel:control:TimerStartedEventAttributes' :: Maybe Text
control =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:timerId:TimerStartedEventAttributes' :: Text
timerId = Text
pTimerId_,
        $sel:startToFireTimeout:TimerStartedEventAttributes' :: Text
startToFireTimeout = Text
pStartToFireTimeout_,
        $sel:decisionTaskCompletedEventId:TimerStartedEventAttributes' :: Integer
decisionTaskCompletedEventId =
          Integer
pDecisionTaskCompletedEventId_
      }

-- | Data attached to the event that can be used by the decider in subsequent
-- workflow tasks.
timerStartedEventAttributes_control :: Lens.Lens' TimerStartedEventAttributes (Prelude.Maybe Prelude.Text)
timerStartedEventAttributes_control :: (Maybe Text -> f (Maybe Text))
-> TimerStartedEventAttributes -> f TimerStartedEventAttributes
timerStartedEventAttributes_control = (TimerStartedEventAttributes -> Maybe Text)
-> (TimerStartedEventAttributes
    -> Maybe Text -> TimerStartedEventAttributes)
-> Lens
     TimerStartedEventAttributes
     TimerStartedEventAttributes
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimerStartedEventAttributes' {Maybe Text
control :: Maybe Text
$sel:control:TimerStartedEventAttributes' :: TimerStartedEventAttributes -> Maybe Text
control} -> Maybe Text
control) (\s :: TimerStartedEventAttributes
s@TimerStartedEventAttributes' {} Maybe Text
a -> TimerStartedEventAttributes
s {$sel:control:TimerStartedEventAttributes' :: Maybe Text
control = Maybe Text
a} :: TimerStartedEventAttributes)

-- | The unique ID of the timer that was started.
timerStartedEventAttributes_timerId :: Lens.Lens' TimerStartedEventAttributes Prelude.Text
timerStartedEventAttributes_timerId :: (Text -> f Text)
-> TimerStartedEventAttributes -> f TimerStartedEventAttributes
timerStartedEventAttributes_timerId = (TimerStartedEventAttributes -> Text)
-> (TimerStartedEventAttributes
    -> Text -> TimerStartedEventAttributes)
-> Lens
     TimerStartedEventAttributes TimerStartedEventAttributes Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimerStartedEventAttributes' {Text
timerId :: Text
$sel:timerId:TimerStartedEventAttributes' :: TimerStartedEventAttributes -> Text
timerId} -> Text
timerId) (\s :: TimerStartedEventAttributes
s@TimerStartedEventAttributes' {} Text
a -> TimerStartedEventAttributes
s {$sel:timerId:TimerStartedEventAttributes' :: Text
timerId = Text
a} :: TimerStartedEventAttributes)

-- | The duration of time after which the timer fires.
--
-- The duration is specified in seconds, an integer greater than or equal
-- to @0@.
timerStartedEventAttributes_startToFireTimeout :: Lens.Lens' TimerStartedEventAttributes Prelude.Text
timerStartedEventAttributes_startToFireTimeout :: (Text -> f Text)
-> TimerStartedEventAttributes -> f TimerStartedEventAttributes
timerStartedEventAttributes_startToFireTimeout = (TimerStartedEventAttributes -> Text)
-> (TimerStartedEventAttributes
    -> Text -> TimerStartedEventAttributes)
-> Lens
     TimerStartedEventAttributes TimerStartedEventAttributes Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimerStartedEventAttributes' {Text
startToFireTimeout :: Text
$sel:startToFireTimeout:TimerStartedEventAttributes' :: TimerStartedEventAttributes -> Text
startToFireTimeout} -> Text
startToFireTimeout) (\s :: TimerStartedEventAttributes
s@TimerStartedEventAttributes' {} Text
a -> TimerStartedEventAttributes
s {$sel:startToFireTimeout:TimerStartedEventAttributes' :: Text
startToFireTimeout = Text
a} :: TimerStartedEventAttributes)

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

instance Core.FromJSON TimerStartedEventAttributes where
  parseJSON :: Value -> Parser TimerStartedEventAttributes
parseJSON =
    String
-> (Object -> Parser TimerStartedEventAttributes)
-> Value
-> Parser TimerStartedEventAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TimerStartedEventAttributes"
      ( \Object
x ->
          Maybe Text
-> Text -> Text -> Integer -> TimerStartedEventAttributes
TimerStartedEventAttributes'
            (Maybe Text
 -> Text -> Text -> Integer -> TimerStartedEventAttributes)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> Integer -> TimerStartedEventAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"control")
            Parser (Text -> Text -> Integer -> TimerStartedEventAttributes)
-> Parser Text
-> Parser (Text -> Integer -> TimerStartedEventAttributes)
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
"timerId")
            Parser (Text -> Integer -> TimerStartedEventAttributes)
-> Parser Text -> Parser (Integer -> TimerStartedEventAttributes)
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
"startToFireTimeout")
            Parser (Integer -> TimerStartedEventAttributes)
-> Parser Integer -> Parser TimerStartedEventAttributes
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 TimerStartedEventAttributes

instance Prelude.NFData TimerStartedEventAttributes