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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SWF.Types.ChildPolicy
import Amazonka.SWF.Types.WorkflowExecutionTerminatedCause

-- | Provides the details of the @WorkflowExecutionTerminated@ event.
--
-- /See:/ 'newWorkflowExecutionTerminatedEventAttributes' smart constructor.
data WorkflowExecutionTerminatedEventAttributes = WorkflowExecutionTerminatedEventAttributes'
  { -- | If set, indicates that the workflow execution was automatically
    -- terminated, and specifies the cause. This happens if the parent workflow
    -- execution times out or is terminated and the child policy is set to
    -- terminate child executions.
    WorkflowExecutionTerminatedEventAttributes
-> Maybe WorkflowExecutionTerminatedCause
cause :: Prelude.Maybe WorkflowExecutionTerminatedCause,
    -- | The reason provided for the termination.
    WorkflowExecutionTerminatedEventAttributes -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The details provided for the termination.
    WorkflowExecutionTerminatedEventAttributes -> Maybe Text
details :: Prelude.Maybe Prelude.Text,
    -- | The policy used for the child workflow executions of this workflow
    -- execution.
    --
    -- 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.
    WorkflowExecutionTerminatedEventAttributes -> ChildPolicy
childPolicy :: ChildPolicy
  }
  deriving (WorkflowExecutionTerminatedEventAttributes
-> WorkflowExecutionTerminatedEventAttributes -> Bool
(WorkflowExecutionTerminatedEventAttributes
 -> WorkflowExecutionTerminatedEventAttributes -> Bool)
-> (WorkflowExecutionTerminatedEventAttributes
    -> WorkflowExecutionTerminatedEventAttributes -> Bool)
-> Eq WorkflowExecutionTerminatedEventAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkflowExecutionTerminatedEventAttributes
-> WorkflowExecutionTerminatedEventAttributes -> Bool
$c/= :: WorkflowExecutionTerminatedEventAttributes
-> WorkflowExecutionTerminatedEventAttributes -> Bool
== :: WorkflowExecutionTerminatedEventAttributes
-> WorkflowExecutionTerminatedEventAttributes -> Bool
$c== :: WorkflowExecutionTerminatedEventAttributes
-> WorkflowExecutionTerminatedEventAttributes -> Bool
Prelude.Eq, ReadPrec [WorkflowExecutionTerminatedEventAttributes]
ReadPrec WorkflowExecutionTerminatedEventAttributes
Int -> ReadS WorkflowExecutionTerminatedEventAttributes
ReadS [WorkflowExecutionTerminatedEventAttributes]
(Int -> ReadS WorkflowExecutionTerminatedEventAttributes)
-> ReadS [WorkflowExecutionTerminatedEventAttributes]
-> ReadPrec WorkflowExecutionTerminatedEventAttributes
-> ReadPrec [WorkflowExecutionTerminatedEventAttributes]
-> Read WorkflowExecutionTerminatedEventAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkflowExecutionTerminatedEventAttributes]
$creadListPrec :: ReadPrec [WorkflowExecutionTerminatedEventAttributes]
readPrec :: ReadPrec WorkflowExecutionTerminatedEventAttributes
$creadPrec :: ReadPrec WorkflowExecutionTerminatedEventAttributes
readList :: ReadS [WorkflowExecutionTerminatedEventAttributes]
$creadList :: ReadS [WorkflowExecutionTerminatedEventAttributes]
readsPrec :: Int -> ReadS WorkflowExecutionTerminatedEventAttributes
$creadsPrec :: Int -> ReadS WorkflowExecutionTerminatedEventAttributes
Prelude.Read, Int -> WorkflowExecutionTerminatedEventAttributes -> ShowS
[WorkflowExecutionTerminatedEventAttributes] -> ShowS
WorkflowExecutionTerminatedEventAttributes -> String
(Int -> WorkflowExecutionTerminatedEventAttributes -> ShowS)
-> (WorkflowExecutionTerminatedEventAttributes -> String)
-> ([WorkflowExecutionTerminatedEventAttributes] -> ShowS)
-> Show WorkflowExecutionTerminatedEventAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkflowExecutionTerminatedEventAttributes] -> ShowS
$cshowList :: [WorkflowExecutionTerminatedEventAttributes] -> ShowS
show :: WorkflowExecutionTerminatedEventAttributes -> String
$cshow :: WorkflowExecutionTerminatedEventAttributes -> String
showsPrec :: Int -> WorkflowExecutionTerminatedEventAttributes -> ShowS
$cshowsPrec :: Int -> WorkflowExecutionTerminatedEventAttributes -> ShowS
Prelude.Show, (forall x.
 WorkflowExecutionTerminatedEventAttributes
 -> Rep WorkflowExecutionTerminatedEventAttributes x)
-> (forall x.
    Rep WorkflowExecutionTerminatedEventAttributes x
    -> WorkflowExecutionTerminatedEventAttributes)
-> Generic WorkflowExecutionTerminatedEventAttributes
forall x.
Rep WorkflowExecutionTerminatedEventAttributes x
-> WorkflowExecutionTerminatedEventAttributes
forall x.
WorkflowExecutionTerminatedEventAttributes
-> Rep WorkflowExecutionTerminatedEventAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep WorkflowExecutionTerminatedEventAttributes x
-> WorkflowExecutionTerminatedEventAttributes
$cfrom :: forall x.
WorkflowExecutionTerminatedEventAttributes
-> Rep WorkflowExecutionTerminatedEventAttributes x
Prelude.Generic)

-- |
-- Create a value of 'WorkflowExecutionTerminatedEventAttributes' 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', 'workflowExecutionTerminatedEventAttributes_cause' - If set, indicates that the workflow execution was automatically
-- terminated, and specifies the cause. This happens if the parent workflow
-- execution times out or is terminated and the child policy is set to
-- terminate child executions.
--
-- 'reason', 'workflowExecutionTerminatedEventAttributes_reason' - The reason provided for the termination.
--
-- 'details', 'workflowExecutionTerminatedEventAttributes_details' - The details provided for the termination.
--
-- 'childPolicy', 'workflowExecutionTerminatedEventAttributes_childPolicy' - The policy used for the child workflow executions of this workflow
-- execution.
--
-- 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.
newWorkflowExecutionTerminatedEventAttributes ::
  -- | 'childPolicy'
  ChildPolicy ->
  WorkflowExecutionTerminatedEventAttributes
newWorkflowExecutionTerminatedEventAttributes :: ChildPolicy -> WorkflowExecutionTerminatedEventAttributes
newWorkflowExecutionTerminatedEventAttributes
  ChildPolicy
pChildPolicy_ =
    WorkflowExecutionTerminatedEventAttributes' :: Maybe WorkflowExecutionTerminatedCause
-> Maybe Text
-> Maybe Text
-> ChildPolicy
-> WorkflowExecutionTerminatedEventAttributes
WorkflowExecutionTerminatedEventAttributes'
      { $sel:cause:WorkflowExecutionTerminatedEventAttributes' :: Maybe WorkflowExecutionTerminatedCause
cause =
          Maybe WorkflowExecutionTerminatedCause
forall a. Maybe a
Prelude.Nothing,
        $sel:reason:WorkflowExecutionTerminatedEventAttributes' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:details:WorkflowExecutionTerminatedEventAttributes' :: Maybe Text
details = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:childPolicy:WorkflowExecutionTerminatedEventAttributes' :: ChildPolicy
childPolicy = ChildPolicy
pChildPolicy_
      }

-- | If set, indicates that the workflow execution was automatically
-- terminated, and specifies the cause. This happens if the parent workflow
-- execution times out or is terminated and the child policy is set to
-- terminate child executions.
workflowExecutionTerminatedEventAttributes_cause :: Lens.Lens' WorkflowExecutionTerminatedEventAttributes (Prelude.Maybe WorkflowExecutionTerminatedCause)
workflowExecutionTerminatedEventAttributes_cause :: (Maybe WorkflowExecutionTerminatedCause
 -> f (Maybe WorkflowExecutionTerminatedCause))
-> WorkflowExecutionTerminatedEventAttributes
-> f WorkflowExecutionTerminatedEventAttributes
workflowExecutionTerminatedEventAttributes_cause = (WorkflowExecutionTerminatedEventAttributes
 -> Maybe WorkflowExecutionTerminatedCause)
-> (WorkflowExecutionTerminatedEventAttributes
    -> Maybe WorkflowExecutionTerminatedCause
    -> WorkflowExecutionTerminatedEventAttributes)
-> Lens
     WorkflowExecutionTerminatedEventAttributes
     WorkflowExecutionTerminatedEventAttributes
     (Maybe WorkflowExecutionTerminatedCause)
     (Maybe WorkflowExecutionTerminatedCause)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionTerminatedEventAttributes' {Maybe WorkflowExecutionTerminatedCause
cause :: Maybe WorkflowExecutionTerminatedCause
$sel:cause:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes
-> Maybe WorkflowExecutionTerminatedCause
cause} -> Maybe WorkflowExecutionTerminatedCause
cause) (\s :: WorkflowExecutionTerminatedEventAttributes
s@WorkflowExecutionTerminatedEventAttributes' {} Maybe WorkflowExecutionTerminatedCause
a -> WorkflowExecutionTerminatedEventAttributes
s {$sel:cause:WorkflowExecutionTerminatedEventAttributes' :: Maybe WorkflowExecutionTerminatedCause
cause = Maybe WorkflowExecutionTerminatedCause
a} :: WorkflowExecutionTerminatedEventAttributes)

-- | The reason provided for the termination.
workflowExecutionTerminatedEventAttributes_reason :: Lens.Lens' WorkflowExecutionTerminatedEventAttributes (Prelude.Maybe Prelude.Text)
workflowExecutionTerminatedEventAttributes_reason :: (Maybe Text -> f (Maybe Text))
-> WorkflowExecutionTerminatedEventAttributes
-> f WorkflowExecutionTerminatedEventAttributes
workflowExecutionTerminatedEventAttributes_reason = (WorkflowExecutionTerminatedEventAttributes -> Maybe Text)
-> (WorkflowExecutionTerminatedEventAttributes
    -> Maybe Text -> WorkflowExecutionTerminatedEventAttributes)
-> Lens
     WorkflowExecutionTerminatedEventAttributes
     WorkflowExecutionTerminatedEventAttributes
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionTerminatedEventAttributes' {Maybe Text
reason :: Maybe Text
$sel:reason:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes -> Maybe Text
reason} -> Maybe Text
reason) (\s :: WorkflowExecutionTerminatedEventAttributes
s@WorkflowExecutionTerminatedEventAttributes' {} Maybe Text
a -> WorkflowExecutionTerminatedEventAttributes
s {$sel:reason:WorkflowExecutionTerminatedEventAttributes' :: Maybe Text
reason = Maybe Text
a} :: WorkflowExecutionTerminatedEventAttributes)

-- | The details provided for the termination.
workflowExecutionTerminatedEventAttributes_details :: Lens.Lens' WorkflowExecutionTerminatedEventAttributes (Prelude.Maybe Prelude.Text)
workflowExecutionTerminatedEventAttributes_details :: (Maybe Text -> f (Maybe Text))
-> WorkflowExecutionTerminatedEventAttributes
-> f WorkflowExecutionTerminatedEventAttributes
workflowExecutionTerminatedEventAttributes_details = (WorkflowExecutionTerminatedEventAttributes -> Maybe Text)
-> (WorkflowExecutionTerminatedEventAttributes
    -> Maybe Text -> WorkflowExecutionTerminatedEventAttributes)
-> Lens
     WorkflowExecutionTerminatedEventAttributes
     WorkflowExecutionTerminatedEventAttributes
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionTerminatedEventAttributes' {Maybe Text
details :: Maybe Text
$sel:details:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes -> Maybe Text
details} -> Maybe Text
details) (\s :: WorkflowExecutionTerminatedEventAttributes
s@WorkflowExecutionTerminatedEventAttributes' {} Maybe Text
a -> WorkflowExecutionTerminatedEventAttributes
s {$sel:details:WorkflowExecutionTerminatedEventAttributes' :: Maybe Text
details = Maybe Text
a} :: WorkflowExecutionTerminatedEventAttributes)

-- | The policy used for the child workflow executions of this workflow
-- execution.
--
-- 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.
workflowExecutionTerminatedEventAttributes_childPolicy :: Lens.Lens' WorkflowExecutionTerminatedEventAttributes ChildPolicy
workflowExecutionTerminatedEventAttributes_childPolicy :: (ChildPolicy -> f ChildPolicy)
-> WorkflowExecutionTerminatedEventAttributes
-> f WorkflowExecutionTerminatedEventAttributes
workflowExecutionTerminatedEventAttributes_childPolicy = (WorkflowExecutionTerminatedEventAttributes -> ChildPolicy)
-> (WorkflowExecutionTerminatedEventAttributes
    -> ChildPolicy -> WorkflowExecutionTerminatedEventAttributes)
-> Lens
     WorkflowExecutionTerminatedEventAttributes
     WorkflowExecutionTerminatedEventAttributes
     ChildPolicy
     ChildPolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecutionTerminatedEventAttributes' {ChildPolicy
childPolicy :: ChildPolicy
$sel:childPolicy:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes -> ChildPolicy
childPolicy} -> ChildPolicy
childPolicy) (\s :: WorkflowExecutionTerminatedEventAttributes
s@WorkflowExecutionTerminatedEventAttributes' {} ChildPolicy
a -> WorkflowExecutionTerminatedEventAttributes
s {$sel:childPolicy:WorkflowExecutionTerminatedEventAttributes' :: ChildPolicy
childPolicy = ChildPolicy
a} :: WorkflowExecutionTerminatedEventAttributes)

instance
  Core.FromJSON
    WorkflowExecutionTerminatedEventAttributes
  where
  parseJSON :: Value -> Parser WorkflowExecutionTerminatedEventAttributes
parseJSON =
    String
-> (Object -> Parser WorkflowExecutionTerminatedEventAttributes)
-> Value
-> Parser WorkflowExecutionTerminatedEventAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorkflowExecutionTerminatedEventAttributes"
      ( \Object
x ->
          Maybe WorkflowExecutionTerminatedCause
-> Maybe Text
-> Maybe Text
-> ChildPolicy
-> WorkflowExecutionTerminatedEventAttributes
WorkflowExecutionTerminatedEventAttributes'
            (Maybe WorkflowExecutionTerminatedCause
 -> Maybe Text
 -> Maybe Text
 -> ChildPolicy
 -> WorkflowExecutionTerminatedEventAttributes)
-> Parser (Maybe WorkflowExecutionTerminatedCause)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> ChildPolicy
      -> WorkflowExecutionTerminatedEventAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe WorkflowExecutionTerminatedCause)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cause")
              Parser
  (Maybe Text
   -> Maybe Text
   -> ChildPolicy
   -> WorkflowExecutionTerminatedEventAttributes)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> ChildPolicy -> WorkflowExecutionTerminatedEventAttributes)
forall (f :: * -> *) a b. Applicative f => 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
"reason")
              Parser
  (Maybe Text
   -> ChildPolicy -> WorkflowExecutionTerminatedEventAttributes)
-> Parser (Maybe Text)
-> Parser
     (ChildPolicy -> WorkflowExecutionTerminatedEventAttributes)
forall (f :: * -> *) a b. Applicative f => 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
"details")
              Parser (ChildPolicy -> WorkflowExecutionTerminatedEventAttributes)
-> Parser ChildPolicy
-> Parser WorkflowExecutionTerminatedEventAttributes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ChildPolicy
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"childPolicy")
      )

instance
  Prelude.Hashable
    WorkflowExecutionTerminatedEventAttributes

instance
  Prelude.NFData
    WorkflowExecutionTerminatedEventAttributes