{-# 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.WorkflowExecutionConfiguration
-- 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.WorkflowExecutionConfiguration 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.ChildPolicy
import Amazonka.SWF.Types.TaskList

-- | The configuration settings for a workflow execution including timeout
-- values, tasklist etc. These configuration settings are determined from
-- the defaults specified when registering the workflow type and those
-- specified when starting the workflow execution.
--
-- /See:/ 'newWorkflowExecutionConfiguration' smart constructor.
data WorkflowExecutionConfiguration = WorkflowExecutionConfiguration'
  { -- | The IAM role attached to the child workflow execution.
    WorkflowExecutionConfiguration -> Maybe Text
lambdaRole :: Prelude.Maybe Prelude.Text,
    -- | The priority assigned to decision tasks for this workflow execution.
    -- Valid values are integers that range from Java\'s @Integer.MIN_VALUE@
    -- (-2147483648) to @Integer.MAX_VALUE@ (2147483647). Higher numbers
    -- indicate higher priority.
    --
    -- For more information about setting task priority, see
    -- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/programming-priority.html Setting Task Priority>
    -- in the /Amazon SWF Developer Guide/.
    WorkflowExecutionConfiguration -> Maybe Text
taskPriority :: Prelude.Maybe Prelude.Text,
    -- | The maximum duration allowed for decision tasks for this workflow
    -- execution.
    --
    -- The duration is specified in seconds, an integer greater than or equal
    -- to @0@. You can use @NONE@ to specify unlimited duration.
    WorkflowExecutionConfiguration -> Text
taskStartToCloseTimeout :: Prelude.Text,
    -- | The total duration for this workflow execution.
    --
    -- The duration is specified in seconds, an integer greater than or equal
    -- to @0@. You can use @NONE@ to specify unlimited duration.
    WorkflowExecutionConfiguration -> Text
executionStartToCloseTimeout :: Prelude.Text,
    -- | The task list used for the decision tasks generated for this workflow
    -- execution.
    WorkflowExecutionConfiguration -> TaskList
taskList :: TaskList,
    -- | The policy to use for the child workflow executions if this workflow
    -- execution is terminated, by calling the TerminateWorkflowExecution
    -- action explicitly or due to an expired timeout.
    --
    -- The supported child policies are:
    --
    -- -   @TERMINATE@ – The child executions are terminated.
    --
    -- -   @REQUEST_CANCEL@ – A request to cancel is attempted for each child
    --     execution by recording a @WorkflowExecutionCancelRequested@ event in
    --     its history. It is up to the decider to take appropriate actions
    --     when it receives an execution history with this event.
    --
    -- -   @ABANDON@ – No action is taken. The child executions continue to
    --     run.
    WorkflowExecutionConfiguration -> ChildPolicy
childPolicy :: ChildPolicy
  }
  deriving (WorkflowExecutionConfiguration
-> WorkflowExecutionConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkflowExecutionConfiguration
-> WorkflowExecutionConfiguration -> Bool
$c/= :: WorkflowExecutionConfiguration
-> WorkflowExecutionConfiguration -> Bool
== :: WorkflowExecutionConfiguration
-> WorkflowExecutionConfiguration -> Bool
$c== :: WorkflowExecutionConfiguration
-> WorkflowExecutionConfiguration -> Bool
Prelude.Eq, ReadPrec [WorkflowExecutionConfiguration]
ReadPrec WorkflowExecutionConfiguration
Int -> ReadS WorkflowExecutionConfiguration
ReadS [WorkflowExecutionConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkflowExecutionConfiguration]
$creadListPrec :: ReadPrec [WorkflowExecutionConfiguration]
readPrec :: ReadPrec WorkflowExecutionConfiguration
$creadPrec :: ReadPrec WorkflowExecutionConfiguration
readList :: ReadS [WorkflowExecutionConfiguration]
$creadList :: ReadS [WorkflowExecutionConfiguration]
readsPrec :: Int -> ReadS WorkflowExecutionConfiguration
$creadsPrec :: Int -> ReadS WorkflowExecutionConfiguration
Prelude.Read, Int -> WorkflowExecutionConfiguration -> ShowS
[WorkflowExecutionConfiguration] -> ShowS
WorkflowExecutionConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkflowExecutionConfiguration] -> ShowS
$cshowList :: [WorkflowExecutionConfiguration] -> ShowS
show :: WorkflowExecutionConfiguration -> String
$cshow :: WorkflowExecutionConfiguration -> String
showsPrec :: Int -> WorkflowExecutionConfiguration -> ShowS
$cshowsPrec :: Int -> WorkflowExecutionConfiguration -> ShowS
Prelude.Show, forall x.
Rep WorkflowExecutionConfiguration x
-> WorkflowExecutionConfiguration
forall x.
WorkflowExecutionConfiguration
-> Rep WorkflowExecutionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep WorkflowExecutionConfiguration x
-> WorkflowExecutionConfiguration
$cfrom :: forall x.
WorkflowExecutionConfiguration
-> Rep WorkflowExecutionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'WorkflowExecutionConfiguration' 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:
--
-- 'lambdaRole', 'workflowExecutionConfiguration_lambdaRole' - The IAM role attached to the child workflow execution.
--
-- 'taskPriority', 'workflowExecutionConfiguration_taskPriority' - The priority assigned to decision tasks for this workflow execution.
-- Valid values are integers that range from Java\'s @Integer.MIN_VALUE@
-- (-2147483648) to @Integer.MAX_VALUE@ (2147483647). Higher numbers
-- indicate higher priority.
--
-- For more information about setting task priority, see
-- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/programming-priority.html Setting Task Priority>
-- in the /Amazon SWF Developer Guide/.
--
-- 'taskStartToCloseTimeout', 'workflowExecutionConfiguration_taskStartToCloseTimeout' - The maximum duration allowed for decision tasks for this workflow
-- execution.
--
-- The duration is specified in seconds, an integer greater than or equal
-- to @0@. You can use @NONE@ to specify unlimited duration.
--
-- 'executionStartToCloseTimeout', 'workflowExecutionConfiguration_executionStartToCloseTimeout' - The total duration for this workflow execution.
--
-- The duration is specified in seconds, an integer greater than or equal
-- to @0@. You can use @NONE@ to specify unlimited duration.
--
-- 'taskList', 'workflowExecutionConfiguration_taskList' - The task list used for the decision tasks generated for this workflow
-- execution.
--
-- 'childPolicy', 'workflowExecutionConfiguration_childPolicy' - The policy to use for the child workflow executions if this workflow
-- execution is terminated, by calling the TerminateWorkflowExecution
-- action explicitly or due to an expired timeout.
--
-- The supported child policies are:
--
-- -   @TERMINATE@ – The child executions are terminated.
--
-- -   @REQUEST_CANCEL@ – A request to cancel is attempted for each child
--     execution by recording a @WorkflowExecutionCancelRequested@ event in
--     its history. It is up to the decider to take appropriate actions
--     when it receives an execution history with this event.
--
-- -   @ABANDON@ – No action is taken. The child executions continue to
--     run.
newWorkflowExecutionConfiguration ::
  -- | 'taskStartToCloseTimeout'
  Prelude.Text ->
  -- | 'executionStartToCloseTimeout'
  Prelude.Text ->
  -- | 'taskList'
  TaskList ->
  -- | 'childPolicy'
  ChildPolicy ->
  WorkflowExecutionConfiguration
newWorkflowExecutionConfiguration :: Text
-> Text
-> TaskList
-> ChildPolicy
-> WorkflowExecutionConfiguration
newWorkflowExecutionConfiguration
  Text
pTaskStartToCloseTimeout_
  Text
pExecutionStartToCloseTimeout_
  TaskList
pTaskList_
  ChildPolicy
pChildPolicy_ =
    WorkflowExecutionConfiguration'
      { $sel:lambdaRole:WorkflowExecutionConfiguration' :: Maybe Text
lambdaRole =
          forall a. Maybe a
Prelude.Nothing,
        $sel:taskPriority:WorkflowExecutionConfiguration' :: Maybe Text
taskPriority = forall a. Maybe a
Prelude.Nothing,
        $sel:taskStartToCloseTimeout:WorkflowExecutionConfiguration' :: Text
taskStartToCloseTimeout =
          Text
pTaskStartToCloseTimeout_,
        $sel:executionStartToCloseTimeout:WorkflowExecutionConfiguration' :: Text
executionStartToCloseTimeout =
          Text
pExecutionStartToCloseTimeout_,
        $sel:taskList:WorkflowExecutionConfiguration' :: TaskList
taskList = TaskList
pTaskList_,
        $sel:childPolicy:WorkflowExecutionConfiguration' :: ChildPolicy
childPolicy = ChildPolicy
pChildPolicy_
      }

-- | The IAM role attached to the child workflow execution.
workflowExecutionConfiguration_lambdaRole :: Lens.Lens' WorkflowExecutionConfiguration (Prelude.Maybe Prelude.Text)
workflowExecutionConfiguration_lambdaRole :: Lens' WorkflowExecutionConfiguration (Maybe Text)
workflowExecutionConfiguration_lambdaRole = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionConfiguration' {Maybe Text
lambdaRole :: Maybe Text
$sel:lambdaRole:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Maybe Text
lambdaRole} -> Maybe Text
lambdaRole) (\s :: WorkflowExecutionConfiguration
s@WorkflowExecutionConfiguration' {} Maybe Text
a -> WorkflowExecutionConfiguration
s {$sel:lambdaRole:WorkflowExecutionConfiguration' :: Maybe Text
lambdaRole = Maybe Text
a} :: WorkflowExecutionConfiguration)

-- | The priority assigned to decision tasks for this workflow execution.
-- Valid values are integers that range from Java\'s @Integer.MIN_VALUE@
-- (-2147483648) to @Integer.MAX_VALUE@ (2147483647). Higher numbers
-- indicate higher priority.
--
-- For more information about setting task priority, see
-- <https://docs.aws.amazon.com/amazonswf/latest/developerguide/programming-priority.html Setting Task Priority>
-- in the /Amazon SWF Developer Guide/.
workflowExecutionConfiguration_taskPriority :: Lens.Lens' WorkflowExecutionConfiguration (Prelude.Maybe Prelude.Text)
workflowExecutionConfiguration_taskPriority :: Lens' WorkflowExecutionConfiguration (Maybe Text)
workflowExecutionConfiguration_taskPriority = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionConfiguration' {Maybe Text
taskPriority :: Maybe Text
$sel:taskPriority:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Maybe Text
taskPriority} -> Maybe Text
taskPriority) (\s :: WorkflowExecutionConfiguration
s@WorkflowExecutionConfiguration' {} Maybe Text
a -> WorkflowExecutionConfiguration
s {$sel:taskPriority:WorkflowExecutionConfiguration' :: Maybe Text
taskPriority = Maybe Text
a} :: WorkflowExecutionConfiguration)

-- | The maximum duration allowed for decision tasks for this workflow
-- execution.
--
-- The duration is specified in seconds, an integer greater than or equal
-- to @0@. You can use @NONE@ to specify unlimited duration.
workflowExecutionConfiguration_taskStartToCloseTimeout :: Lens.Lens' WorkflowExecutionConfiguration Prelude.Text
workflowExecutionConfiguration_taskStartToCloseTimeout :: Lens' WorkflowExecutionConfiguration Text
workflowExecutionConfiguration_taskStartToCloseTimeout = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionConfiguration' {Text
taskStartToCloseTimeout :: Text
$sel:taskStartToCloseTimeout:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Text
taskStartToCloseTimeout} -> Text
taskStartToCloseTimeout) (\s :: WorkflowExecutionConfiguration
s@WorkflowExecutionConfiguration' {} Text
a -> WorkflowExecutionConfiguration
s {$sel:taskStartToCloseTimeout:WorkflowExecutionConfiguration' :: Text
taskStartToCloseTimeout = Text
a} :: WorkflowExecutionConfiguration)

-- | The total duration for this workflow execution.
--
-- The duration is specified in seconds, an integer greater than or equal
-- to @0@. You can use @NONE@ to specify unlimited duration.
workflowExecutionConfiguration_executionStartToCloseTimeout :: Lens.Lens' WorkflowExecutionConfiguration Prelude.Text
workflowExecutionConfiguration_executionStartToCloseTimeout :: Lens' WorkflowExecutionConfiguration Text
workflowExecutionConfiguration_executionStartToCloseTimeout = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionConfiguration' {Text
executionStartToCloseTimeout :: Text
$sel:executionStartToCloseTimeout:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Text
executionStartToCloseTimeout} -> Text
executionStartToCloseTimeout) (\s :: WorkflowExecutionConfiguration
s@WorkflowExecutionConfiguration' {} Text
a -> WorkflowExecutionConfiguration
s {$sel:executionStartToCloseTimeout:WorkflowExecutionConfiguration' :: Text
executionStartToCloseTimeout = Text
a} :: WorkflowExecutionConfiguration)

-- | The task list used for the decision tasks generated for this workflow
-- execution.
workflowExecutionConfiguration_taskList :: Lens.Lens' WorkflowExecutionConfiguration TaskList
workflowExecutionConfiguration_taskList :: Lens' WorkflowExecutionConfiguration TaskList
workflowExecutionConfiguration_taskList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionConfiguration' {TaskList
taskList :: TaskList
$sel:taskList:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> TaskList
taskList} -> TaskList
taskList) (\s :: WorkflowExecutionConfiguration
s@WorkflowExecutionConfiguration' {} TaskList
a -> WorkflowExecutionConfiguration
s {$sel:taskList:WorkflowExecutionConfiguration' :: TaskList
taskList = TaskList
a} :: WorkflowExecutionConfiguration)

-- | The policy to use for the child workflow executions if this workflow
-- execution is terminated, by calling the TerminateWorkflowExecution
-- action explicitly or due to an expired timeout.
--
-- The supported child policies are:
--
-- -   @TERMINATE@ – The child executions are terminated.
--
-- -   @REQUEST_CANCEL@ – A request to cancel is attempted for each child
--     execution by recording a @WorkflowExecutionCancelRequested@ event in
--     its history. It is up to the decider to take appropriate actions
--     when it receives an execution history with this event.
--
-- -   @ABANDON@ – No action is taken. The child executions continue to
--     run.
workflowExecutionConfiguration_childPolicy :: Lens.Lens' WorkflowExecutionConfiguration ChildPolicy
workflowExecutionConfiguration_childPolicy :: Lens' WorkflowExecutionConfiguration ChildPolicy
workflowExecutionConfiguration_childPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionConfiguration' {ChildPolicy
childPolicy :: ChildPolicy
$sel:childPolicy:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> ChildPolicy
childPolicy} -> ChildPolicy
childPolicy) (\s :: WorkflowExecutionConfiguration
s@WorkflowExecutionConfiguration' {} ChildPolicy
a -> WorkflowExecutionConfiguration
s {$sel:childPolicy:WorkflowExecutionConfiguration' :: ChildPolicy
childPolicy = ChildPolicy
a} :: WorkflowExecutionConfiguration)

instance Data.FromJSON WorkflowExecutionConfiguration where
  parseJSON :: Value -> Parser WorkflowExecutionConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorkflowExecutionConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Text
-> Text
-> TaskList
-> ChildPolicy
-> WorkflowExecutionConfiguration
WorkflowExecutionConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"lambdaRole")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"taskPriority")
            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
"taskStartToCloseTimeout")
            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
"executionStartToCloseTimeout")
            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
"taskList")
            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
"childPolicy")
      )

instance
  Prelude.Hashable
    WorkflowExecutionConfiguration
  where
  hashWithSalt :: Int -> WorkflowExecutionConfiguration -> Int
hashWithSalt
    Int
_salt
    WorkflowExecutionConfiguration' {Maybe Text
Text
ChildPolicy
TaskList
childPolicy :: ChildPolicy
taskList :: TaskList
executionStartToCloseTimeout :: Text
taskStartToCloseTimeout :: Text
taskPriority :: Maybe Text
lambdaRole :: Maybe Text
$sel:childPolicy:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> ChildPolicy
$sel:taskList:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> TaskList
$sel:executionStartToCloseTimeout:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Text
$sel:taskStartToCloseTimeout:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Text
$sel:taskPriority:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Maybe Text
$sel:lambdaRole:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
lambdaRole
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
taskPriority
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
taskStartToCloseTimeout
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
executionStartToCloseTimeout
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TaskList
taskList
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ChildPolicy
childPolicy

instance
  Prelude.NFData
    WorkflowExecutionConfiguration
  where
  rnf :: WorkflowExecutionConfiguration -> ()
rnf WorkflowExecutionConfiguration' {Maybe Text
Text
ChildPolicy
TaskList
childPolicy :: ChildPolicy
taskList :: TaskList
executionStartToCloseTimeout :: Text
taskStartToCloseTimeout :: Text
taskPriority :: Maybe Text
lambdaRole :: Maybe Text
$sel:childPolicy:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> ChildPolicy
$sel:taskList:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> TaskList
$sel:executionStartToCloseTimeout:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Text
$sel:taskStartToCloseTimeout:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Text
$sel:taskPriority:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Maybe Text
$sel:lambdaRole:WorkflowExecutionConfiguration' :: WorkflowExecutionConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
lambdaRole
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
taskPriority
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
taskStartToCloseTimeout
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
executionStartToCloseTimeout
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TaskList
taskList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ChildPolicy
childPolicy