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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(WorkflowExecution -> WorkflowExecution -> Bool)
-> (WorkflowExecution -> WorkflowExecution -> Bool)
-> Eq WorkflowExecution
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]
(Int -> ReadS WorkflowExecution)
-> ReadS [WorkflowExecution]
-> ReadPrec WorkflowExecution
-> ReadPrec [WorkflowExecution]
-> Read 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
(Int -> WorkflowExecution -> ShowS)
-> (WorkflowExecution -> String)
-> ([WorkflowExecution] -> ShowS)
-> Show WorkflowExecution
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. WorkflowExecution -> Rep WorkflowExecution x)
-> (forall x. Rep WorkflowExecution x -> WorkflowExecution)
-> Generic WorkflowExecution
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' :: Text -> Text -> WorkflowExecution
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 :: (Text -> f Text) -> WorkflowExecution -> f WorkflowExecution
workflowExecution_workflowId = (WorkflowExecution -> Text)
-> (WorkflowExecution -> Text -> WorkflowExecution)
-> Lens WorkflowExecution WorkflowExecution Text Text
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 :: (Text -> f Text) -> WorkflowExecution -> f WorkflowExecution
workflowExecution_runId = (WorkflowExecution -> Text)
-> (WorkflowExecution -> Text -> WorkflowExecution)
-> Lens WorkflowExecution WorkflowExecution Text Text
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 Core.FromJSON WorkflowExecution where
  parseJSON :: Value -> Parser WorkflowExecution
parseJSON =
    String
-> (Object -> Parser WorkflowExecution)
-> Value
-> Parser WorkflowExecution
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorkflowExecution"
      ( \Object
x ->
          Text -> Text -> WorkflowExecution
WorkflowExecution'
            (Text -> Text -> WorkflowExecution)
-> Parser Text -> Parser (Text -> WorkflowExecution)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"workflowId")
            Parser (Text -> WorkflowExecution)
-> Parser Text -> Parser WorkflowExecution
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
"runId")
      )

instance Prelude.Hashable WorkflowExecution

instance Prelude.NFData WorkflowExecution

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"workflowId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workflowId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"runId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
runId)
          ]
      )