{-# 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-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.WorkflowExecutionTerminatedEventAttributes 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.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 details provided for the termination.
    WorkflowExecutionTerminatedEventAttributes -> Maybe Text
details :: Prelude.Maybe Prelude.Text,
    -- | The reason provided for the termination.
    WorkflowExecutionTerminatedEventAttributes -> Maybe Text
reason :: 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
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]
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
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.
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.
--
-- 'details', 'workflowExecutionTerminatedEventAttributes_details' - The details provided for the termination.
--
-- 'reason', 'workflowExecutionTerminatedEventAttributes_reason' - The reason 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'
      { $sel:cause:WorkflowExecutionTerminatedEventAttributes' :: Maybe WorkflowExecutionTerminatedCause
cause =
          forall a. Maybe a
Prelude.Nothing,
        $sel:details:WorkflowExecutionTerminatedEventAttributes' :: Maybe Text
details = forall a. Maybe a
Prelude.Nothing,
        $sel:reason:WorkflowExecutionTerminatedEventAttributes' :: Maybe Text
reason = 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 :: Lens'
  WorkflowExecutionTerminatedEventAttributes
  (Maybe WorkflowExecutionTerminatedCause)
workflowExecutionTerminatedEventAttributes_cause = 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 details provided for the termination.
workflowExecutionTerminatedEventAttributes_details :: Lens.Lens' WorkflowExecutionTerminatedEventAttributes (Prelude.Maybe Prelude.Text)
workflowExecutionTerminatedEventAttributes_details :: Lens' WorkflowExecutionTerminatedEventAttributes (Maybe Text)
workflowExecutionTerminatedEventAttributes_details = 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 reason provided for the termination.
workflowExecutionTerminatedEventAttributes_reason :: Lens.Lens' WorkflowExecutionTerminatedEventAttributes (Prelude.Maybe Prelude.Text)
workflowExecutionTerminatedEventAttributes_reason :: Lens' WorkflowExecutionTerminatedEventAttributes (Maybe Text)
workflowExecutionTerminatedEventAttributes_reason = 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 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 :: Lens' WorkflowExecutionTerminatedEventAttributes ChildPolicy
workflowExecutionTerminatedEventAttributes_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
  Data.FromJSON
    WorkflowExecutionTerminatedEventAttributes
  where
  parseJSON :: Value -> Parser WorkflowExecutionTerminatedEventAttributes
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorkflowExecutionTerminatedEventAttributes"
      ( \Object
x ->
          Maybe WorkflowExecutionTerminatedCause
-> Maybe Text
-> Maybe Text
-> ChildPolicy
-> WorkflowExecutionTerminatedEventAttributes
WorkflowExecutionTerminatedEventAttributes'
            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
"cause")
            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
"details")
            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
"reason")
            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
    WorkflowExecutionTerminatedEventAttributes
  where
  hashWithSalt :: Int -> WorkflowExecutionTerminatedEventAttributes -> Int
hashWithSalt
    Int
_salt
    WorkflowExecutionTerminatedEventAttributes' {Maybe Text
Maybe WorkflowExecutionTerminatedCause
ChildPolicy
childPolicy :: ChildPolicy
reason :: Maybe Text
details :: Maybe Text
cause :: Maybe WorkflowExecutionTerminatedCause
$sel:childPolicy:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes -> ChildPolicy
$sel:reason:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes -> Maybe Text
$sel:details:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes -> Maybe Text
$sel:cause:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes
-> Maybe WorkflowExecutionTerminatedCause
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WorkflowExecutionTerminatedCause
cause
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
details
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reason
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ChildPolicy
childPolicy

instance
  Prelude.NFData
    WorkflowExecutionTerminatedEventAttributes
  where
  rnf :: WorkflowExecutionTerminatedEventAttributes -> ()
rnf WorkflowExecutionTerminatedEventAttributes' {Maybe Text
Maybe WorkflowExecutionTerminatedCause
ChildPolicy
childPolicy :: ChildPolicy
reason :: Maybe Text
details :: Maybe Text
cause :: Maybe WorkflowExecutionTerminatedCause
$sel:childPolicy:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes -> ChildPolicy
$sel:reason:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes -> Maybe Text
$sel:details:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes -> Maybe Text
$sel:cause:WorkflowExecutionTerminatedEventAttributes' :: WorkflowExecutionTerminatedEventAttributes
-> Maybe WorkflowExecutionTerminatedCause
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe WorkflowExecutionTerminatedCause
cause
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
details
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ChildPolicy
childPolicy