{-# 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.WorkflowExecution
-- 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.WorkflowExecution 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

-- | Represents a workflow execution.
--
-- /See:/ 'newWorkflowExecution' smart constructor.
data WorkflowExecution = WorkflowExecution'
  { -- | The user defined identifier associated with the workflow execution.
    WorkflowExecution -> Text
workflowId :: Prelude.Text,
    -- | A system-generated unique identifier for the workflow execution.
    WorkflowExecution -> Text
runId :: Prelude.Text
  }
  deriving (WorkflowExecution -> WorkflowExecution -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkflowExecution -> WorkflowExecution -> Bool
$c/= :: WorkflowExecution -> WorkflowExecution -> Bool
== :: WorkflowExecution -> WorkflowExecution -> Bool
$c== :: WorkflowExecution -> WorkflowExecution -> Bool
Prelude.Eq, ReadPrec [WorkflowExecution]
ReadPrec WorkflowExecution
Int -> ReadS WorkflowExecution
ReadS [WorkflowExecution]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkflowExecution]
$creadListPrec :: ReadPrec [WorkflowExecution]
readPrec :: ReadPrec WorkflowExecution
$creadPrec :: ReadPrec WorkflowExecution
readList :: ReadS [WorkflowExecution]
$creadList :: ReadS [WorkflowExecution]
readsPrec :: Int -> ReadS WorkflowExecution
$creadsPrec :: Int -> ReadS WorkflowExecution
Prelude.Read, Int -> WorkflowExecution -> ShowS
[WorkflowExecution] -> ShowS
WorkflowExecution -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkflowExecution] -> ShowS
$cshowList :: [WorkflowExecution] -> ShowS
show :: WorkflowExecution -> String
$cshow :: WorkflowExecution -> String
showsPrec :: Int -> WorkflowExecution -> ShowS
$cshowsPrec :: Int -> WorkflowExecution -> ShowS
Prelude.Show, forall x. Rep WorkflowExecution x -> WorkflowExecution
forall x. WorkflowExecution -> Rep WorkflowExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkflowExecution x -> WorkflowExecution
$cfrom :: forall x. WorkflowExecution -> Rep WorkflowExecution x
Prelude.Generic)

-- |
-- Create a value of 'WorkflowExecution' 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:
--
-- 'workflowId', 'workflowExecution_workflowId' - The user defined identifier associated with the workflow execution.
--
-- 'runId', 'workflowExecution_runId' - A system-generated unique identifier for the workflow execution.
newWorkflowExecution ::
  -- | 'workflowId'
  Prelude.Text ->
  -- | 'runId'
  Prelude.Text ->
  WorkflowExecution
newWorkflowExecution :: Text -> Text -> WorkflowExecution
newWorkflowExecution Text
pWorkflowId_ Text
pRunId_ =
  WorkflowExecution'
    { $sel:workflowId:WorkflowExecution' :: Text
workflowId = Text
pWorkflowId_,
      $sel:runId:WorkflowExecution' :: Text
runId = Text
pRunId_
    }

-- | The user defined identifier associated with the workflow execution.
workflowExecution_workflowId :: Lens.Lens' WorkflowExecution Prelude.Text
workflowExecution_workflowId :: Lens' WorkflowExecution Text
workflowExecution_workflowId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecution' {Text
workflowId :: Text
$sel:workflowId:WorkflowExecution' :: WorkflowExecution -> Text
workflowId} -> Text
workflowId) (\s :: WorkflowExecution
s@WorkflowExecution' {} Text
a -> WorkflowExecution
s {$sel:workflowId:WorkflowExecution' :: Text
workflowId = Text
a} :: WorkflowExecution)

-- | A system-generated unique identifier for the workflow execution.
workflowExecution_runId :: Lens.Lens' WorkflowExecution Prelude.Text
workflowExecution_runId :: Lens' WorkflowExecution Text
workflowExecution_runId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowExecution' {Text
runId :: Text
$sel:runId:WorkflowExecution' :: WorkflowExecution -> Text
runId} -> Text
runId) (\s :: WorkflowExecution
s@WorkflowExecution' {} Text
a -> WorkflowExecution
s {$sel:runId:WorkflowExecution' :: Text
runId = Text
a} :: WorkflowExecution)

instance Data.FromJSON WorkflowExecution where
  parseJSON :: Value -> Parser WorkflowExecution
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorkflowExecution"
      ( \Object
x ->
          Text -> Text -> WorkflowExecution
WorkflowExecution'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"workflowId")
            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
"runId")
      )

instance Prelude.Hashable WorkflowExecution where
  hashWithSalt :: Int -> WorkflowExecution -> Int
hashWithSalt Int
_salt WorkflowExecution' {Text
runId :: Text
workflowId :: Text
$sel:runId:WorkflowExecution' :: WorkflowExecution -> Text
$sel:workflowId:WorkflowExecution' :: WorkflowExecution -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
workflowId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
runId

instance Prelude.NFData WorkflowExecution where
  rnf :: WorkflowExecution -> ()
rnf WorkflowExecution' {Text
runId :: Text
workflowId :: Text
$sel:runId:WorkflowExecution' :: WorkflowExecution -> Text
$sel:workflowId:WorkflowExecution' :: WorkflowExecution -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
workflowId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
runId

instance Data.ToJSON WorkflowExecution where
  toJSON :: WorkflowExecution -> Value
toJSON WorkflowExecution' {Text
runId :: Text
workflowId :: Text
$sel:runId:WorkflowExecution' :: WorkflowExecution -> Text
$sel:workflowId:WorkflowExecution' :: WorkflowExecution -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"workflowId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
workflowId),
            forall a. a -> Maybe a
Prelude.Just (Key
"runId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
runId)
          ]
      )