{-# 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.CodePipeline.Types.StageExecution
-- 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.CodePipeline.Types.StageExecution where

import Amazonka.CodePipeline.Types.StageExecutionStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information about the run of a stage.
--
-- /See:/ 'newStageExecution' smart constructor.
data StageExecution = StageExecution'
  { -- | The ID of the pipeline execution associated with the stage.
    StageExecution -> Text
pipelineExecutionId :: Prelude.Text,
    -- | The status of the stage, or for a completed stage, the last status of
    -- the stage.
    --
    -- A status of cancelled means that the pipeline’s definition was updated
    -- before the stage execution could be completed.
    StageExecution -> StageExecutionStatus
status :: StageExecutionStatus
  }
  deriving (StageExecution -> StageExecution -> Bool
(StageExecution -> StageExecution -> Bool)
-> (StageExecution -> StageExecution -> Bool) -> Eq StageExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StageExecution -> StageExecution -> Bool
$c/= :: StageExecution -> StageExecution -> Bool
== :: StageExecution -> StageExecution -> Bool
$c== :: StageExecution -> StageExecution -> Bool
Prelude.Eq, ReadPrec [StageExecution]
ReadPrec StageExecution
Int -> ReadS StageExecution
ReadS [StageExecution]
(Int -> ReadS StageExecution)
-> ReadS [StageExecution]
-> ReadPrec StageExecution
-> ReadPrec [StageExecution]
-> Read StageExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StageExecution]
$creadListPrec :: ReadPrec [StageExecution]
readPrec :: ReadPrec StageExecution
$creadPrec :: ReadPrec StageExecution
readList :: ReadS [StageExecution]
$creadList :: ReadS [StageExecution]
readsPrec :: Int -> ReadS StageExecution
$creadsPrec :: Int -> ReadS StageExecution
Prelude.Read, Int -> StageExecution -> ShowS
[StageExecution] -> ShowS
StageExecution -> String
(Int -> StageExecution -> ShowS)
-> (StageExecution -> String)
-> ([StageExecution] -> ShowS)
-> Show StageExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StageExecution] -> ShowS
$cshowList :: [StageExecution] -> ShowS
show :: StageExecution -> String
$cshow :: StageExecution -> String
showsPrec :: Int -> StageExecution -> ShowS
$cshowsPrec :: Int -> StageExecution -> ShowS
Prelude.Show, (forall x. StageExecution -> Rep StageExecution x)
-> (forall x. Rep StageExecution x -> StageExecution)
-> Generic StageExecution
forall x. Rep StageExecution x -> StageExecution
forall x. StageExecution -> Rep StageExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StageExecution x -> StageExecution
$cfrom :: forall x. StageExecution -> Rep StageExecution x
Prelude.Generic)

-- |
-- Create a value of 'StageExecution' 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:
--
-- 'pipelineExecutionId', 'stageExecution_pipelineExecutionId' - The ID of the pipeline execution associated with the stage.
--
-- 'status', 'stageExecution_status' - The status of the stage, or for a completed stage, the last status of
-- the stage.
--
-- A status of cancelled means that the pipeline’s definition was updated
-- before the stage execution could be completed.
newStageExecution ::
  -- | 'pipelineExecutionId'
  Prelude.Text ->
  -- | 'status'
  StageExecutionStatus ->
  StageExecution
newStageExecution :: Text -> StageExecutionStatus -> StageExecution
newStageExecution Text
pPipelineExecutionId_ StageExecutionStatus
pStatus_ =
  StageExecution' :: Text -> StageExecutionStatus -> StageExecution
StageExecution'
    { $sel:pipelineExecutionId:StageExecution' :: Text
pipelineExecutionId =
        Text
pPipelineExecutionId_,
      $sel:status:StageExecution' :: StageExecutionStatus
status = StageExecutionStatus
pStatus_
    }

-- | The ID of the pipeline execution associated with the stage.
stageExecution_pipelineExecutionId :: Lens.Lens' StageExecution Prelude.Text
stageExecution_pipelineExecutionId :: (Text -> f Text) -> StageExecution -> f StageExecution
stageExecution_pipelineExecutionId = (StageExecution -> Text)
-> (StageExecution -> Text -> StageExecution)
-> Lens StageExecution StageExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StageExecution' {Text
pipelineExecutionId :: Text
$sel:pipelineExecutionId:StageExecution' :: StageExecution -> Text
pipelineExecutionId} -> Text
pipelineExecutionId) (\s :: StageExecution
s@StageExecution' {} Text
a -> StageExecution
s {$sel:pipelineExecutionId:StageExecution' :: Text
pipelineExecutionId = Text
a} :: StageExecution)

-- | The status of the stage, or for a completed stage, the last status of
-- the stage.
--
-- A status of cancelled means that the pipeline’s definition was updated
-- before the stage execution could be completed.
stageExecution_status :: Lens.Lens' StageExecution StageExecutionStatus
stageExecution_status :: (StageExecutionStatus -> f StageExecutionStatus)
-> StageExecution -> f StageExecution
stageExecution_status = (StageExecution -> StageExecutionStatus)
-> (StageExecution -> StageExecutionStatus -> StageExecution)
-> Lens
     StageExecution
     StageExecution
     StageExecutionStatus
     StageExecutionStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StageExecution' {StageExecutionStatus
status :: StageExecutionStatus
$sel:status:StageExecution' :: StageExecution -> StageExecutionStatus
status} -> StageExecutionStatus
status) (\s :: StageExecution
s@StageExecution' {} StageExecutionStatus
a -> StageExecution
s {$sel:status:StageExecution' :: StageExecutionStatus
status = StageExecutionStatus
a} :: StageExecution)

instance Core.FromJSON StageExecution where
  parseJSON :: Value -> Parser StageExecution
parseJSON =
    String
-> (Object -> Parser StageExecution)
-> Value
-> Parser StageExecution
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StageExecution"
      ( \Object
x ->
          Text -> StageExecutionStatus -> StageExecution
StageExecution'
            (Text -> StageExecutionStatus -> StageExecution)
-> Parser Text -> Parser (StageExecutionStatus -> StageExecution)
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
"pipelineExecutionId")
            Parser (StageExecutionStatus -> StageExecution)
-> Parser StageExecutionStatus -> Parser StageExecution
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser StageExecutionStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"status")
      )

instance Prelude.Hashable StageExecution

instance Prelude.NFData StageExecution