{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' StageExecution Text
stageExecution_pipelineExecutionId = 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 :: Lens' StageExecution StageExecutionStatus
stageExecution_status = 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 Data.FromJSON StageExecution where
  parseJSON :: Value -> Parser StageExecution
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StageExecution"
      ( \Object
x ->
          Text -> StageExecutionStatus -> StageExecution
StageExecution'
            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
"pipelineExecutionId")
            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
"status")
      )

instance Prelude.Hashable StageExecution where
  hashWithSalt :: Int -> StageExecution -> Int
hashWithSalt Int
_salt StageExecution' {Text
StageExecutionStatus
status :: StageExecutionStatus
pipelineExecutionId :: Text
$sel:status:StageExecution' :: StageExecution -> StageExecutionStatus
$sel:pipelineExecutionId:StageExecution' :: StageExecution -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
pipelineExecutionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` StageExecutionStatus
status

instance Prelude.NFData StageExecution where
  rnf :: StageExecution -> ()
rnf StageExecution' {Text
StageExecutionStatus
status :: StageExecutionStatus
pipelineExecutionId :: Text
$sel:status:StageExecution' :: StageExecution -> StageExecutionStatus
$sel:pipelineExecutionId:StageExecution' :: StageExecution -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
pipelineExecutionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf StageExecutionStatus
status