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

import Amazonka.CodePipeline.Types.ArtifactRevision
import Amazonka.CodePipeline.Types.PipelineExecutionStatus
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 an execution of a pipeline.
--
-- /See:/ 'newPipelineExecution' smart constructor.
data PipelineExecution = PipelineExecution'
  { -- | A list of @ArtifactRevision@ objects included in a pipeline execution.
    PipelineExecution -> Maybe [ArtifactRevision]
artifactRevisions :: Prelude.Maybe [ArtifactRevision],
    -- | The ID of the pipeline execution.
    PipelineExecution -> Maybe Text
pipelineExecutionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the pipeline with the specified pipeline execution.
    PipelineExecution -> Maybe Text
pipelineName :: Prelude.Maybe Prelude.Text,
    -- | The version number of the pipeline with the specified pipeline
    -- execution.
    PipelineExecution -> Maybe Natural
pipelineVersion :: Prelude.Maybe Prelude.Natural,
    -- | The status of the pipeline execution.
    --
    -- -   Cancelled: The pipeline’s definition was updated before the pipeline
    --     execution could be completed.
    --
    -- -   InProgress: The pipeline execution is currently running.
    --
    -- -   Stopped: The pipeline execution was manually stopped. For more
    --     information, see
    --     <https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-executions-stopped Stopped Executions>.
    --
    -- -   Stopping: The pipeline execution received a request to be manually
    --     stopped. Depending on the selected stop mode, the execution is
    --     either completing or abandoning in-progress actions. For more
    --     information, see
    --     <https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-executions-stopped Stopped Executions>.
    --
    -- -   Succeeded: The pipeline execution was completed successfully.
    --
    -- -   Superseded: While this pipeline execution was waiting for the next
    --     stage to be completed, a newer pipeline execution advanced and
    --     continued through the pipeline instead. For more information, see
    --     <https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-superseded Superseded Executions>.
    --
    -- -   Failed: The pipeline execution was not completed successfully.
    PipelineExecution -> Maybe PipelineExecutionStatus
status :: Prelude.Maybe PipelineExecutionStatus,
    -- | A summary that contains a description of the pipeline execution status.
    PipelineExecution -> Maybe Text
statusSummary :: Prelude.Maybe Prelude.Text
  }
  deriving (PipelineExecution -> PipelineExecution -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PipelineExecution -> PipelineExecution -> Bool
$c/= :: PipelineExecution -> PipelineExecution -> Bool
== :: PipelineExecution -> PipelineExecution -> Bool
$c== :: PipelineExecution -> PipelineExecution -> Bool
Prelude.Eq, ReadPrec [PipelineExecution]
ReadPrec PipelineExecution
Int -> ReadS PipelineExecution
ReadS [PipelineExecution]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PipelineExecution]
$creadListPrec :: ReadPrec [PipelineExecution]
readPrec :: ReadPrec PipelineExecution
$creadPrec :: ReadPrec PipelineExecution
readList :: ReadS [PipelineExecution]
$creadList :: ReadS [PipelineExecution]
readsPrec :: Int -> ReadS PipelineExecution
$creadsPrec :: Int -> ReadS PipelineExecution
Prelude.Read, Int -> PipelineExecution -> ShowS
[PipelineExecution] -> ShowS
PipelineExecution -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PipelineExecution] -> ShowS
$cshowList :: [PipelineExecution] -> ShowS
show :: PipelineExecution -> String
$cshow :: PipelineExecution -> String
showsPrec :: Int -> PipelineExecution -> ShowS
$cshowsPrec :: Int -> PipelineExecution -> ShowS
Prelude.Show, forall x. Rep PipelineExecution x -> PipelineExecution
forall x. PipelineExecution -> Rep PipelineExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PipelineExecution x -> PipelineExecution
$cfrom :: forall x. PipelineExecution -> Rep PipelineExecution x
Prelude.Generic)

-- |
-- Create a value of 'PipelineExecution' 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:
--
-- 'artifactRevisions', 'pipelineExecution_artifactRevisions' - A list of @ArtifactRevision@ objects included in a pipeline execution.
--
-- 'pipelineExecutionId', 'pipelineExecution_pipelineExecutionId' - The ID of the pipeline execution.
--
-- 'pipelineName', 'pipelineExecution_pipelineName' - The name of the pipeline with the specified pipeline execution.
--
-- 'pipelineVersion', 'pipelineExecution_pipelineVersion' - The version number of the pipeline with the specified pipeline
-- execution.
--
-- 'status', 'pipelineExecution_status' - The status of the pipeline execution.
--
-- -   Cancelled: The pipeline’s definition was updated before the pipeline
--     execution could be completed.
--
-- -   InProgress: The pipeline execution is currently running.
--
-- -   Stopped: The pipeline execution was manually stopped. For more
--     information, see
--     <https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-executions-stopped Stopped Executions>.
--
-- -   Stopping: The pipeline execution received a request to be manually
--     stopped. Depending on the selected stop mode, the execution is
--     either completing or abandoning in-progress actions. For more
--     information, see
--     <https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-executions-stopped Stopped Executions>.
--
-- -   Succeeded: The pipeline execution was completed successfully.
--
-- -   Superseded: While this pipeline execution was waiting for the next
--     stage to be completed, a newer pipeline execution advanced and
--     continued through the pipeline instead. For more information, see
--     <https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-superseded Superseded Executions>.
--
-- -   Failed: The pipeline execution was not completed successfully.
--
-- 'statusSummary', 'pipelineExecution_statusSummary' - A summary that contains a description of the pipeline execution status.
newPipelineExecution ::
  PipelineExecution
newPipelineExecution :: PipelineExecution
newPipelineExecution =
  PipelineExecution'
    { $sel:artifactRevisions:PipelineExecution' :: Maybe [ArtifactRevision]
artifactRevisions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineExecutionId:PipelineExecution' :: Maybe Text
pipelineExecutionId = forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineName:PipelineExecution' :: Maybe Text
pipelineName = forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineVersion:PipelineExecution' :: Maybe Natural
pipelineVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:status:PipelineExecution' :: Maybe PipelineExecutionStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:statusSummary:PipelineExecution' :: Maybe Text
statusSummary = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of @ArtifactRevision@ objects included in a pipeline execution.
pipelineExecution_artifactRevisions :: Lens.Lens' PipelineExecution (Prelude.Maybe [ArtifactRevision])
pipelineExecution_artifactRevisions :: Lens' PipelineExecution (Maybe [ArtifactRevision])
pipelineExecution_artifactRevisions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineExecution' {Maybe [ArtifactRevision]
artifactRevisions :: Maybe [ArtifactRevision]
$sel:artifactRevisions:PipelineExecution' :: PipelineExecution -> Maybe [ArtifactRevision]
artifactRevisions} -> Maybe [ArtifactRevision]
artifactRevisions) (\s :: PipelineExecution
s@PipelineExecution' {} Maybe [ArtifactRevision]
a -> PipelineExecution
s {$sel:artifactRevisions:PipelineExecution' :: Maybe [ArtifactRevision]
artifactRevisions = Maybe [ArtifactRevision]
a} :: PipelineExecution) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the pipeline execution.
pipelineExecution_pipelineExecutionId :: Lens.Lens' PipelineExecution (Prelude.Maybe Prelude.Text)
pipelineExecution_pipelineExecutionId :: Lens' PipelineExecution (Maybe Text)
pipelineExecution_pipelineExecutionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineExecution' {Maybe Text
pipelineExecutionId :: Maybe Text
$sel:pipelineExecutionId:PipelineExecution' :: PipelineExecution -> Maybe Text
pipelineExecutionId} -> Maybe Text
pipelineExecutionId) (\s :: PipelineExecution
s@PipelineExecution' {} Maybe Text
a -> PipelineExecution
s {$sel:pipelineExecutionId:PipelineExecution' :: Maybe Text
pipelineExecutionId = Maybe Text
a} :: PipelineExecution)

-- | The name of the pipeline with the specified pipeline execution.
pipelineExecution_pipelineName :: Lens.Lens' PipelineExecution (Prelude.Maybe Prelude.Text)
pipelineExecution_pipelineName :: Lens' PipelineExecution (Maybe Text)
pipelineExecution_pipelineName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineExecution' {Maybe Text
pipelineName :: Maybe Text
$sel:pipelineName:PipelineExecution' :: PipelineExecution -> Maybe Text
pipelineName} -> Maybe Text
pipelineName) (\s :: PipelineExecution
s@PipelineExecution' {} Maybe Text
a -> PipelineExecution
s {$sel:pipelineName:PipelineExecution' :: Maybe Text
pipelineName = Maybe Text
a} :: PipelineExecution)

-- | The version number of the pipeline with the specified pipeline
-- execution.
pipelineExecution_pipelineVersion :: Lens.Lens' PipelineExecution (Prelude.Maybe Prelude.Natural)
pipelineExecution_pipelineVersion :: Lens' PipelineExecution (Maybe Natural)
pipelineExecution_pipelineVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineExecution' {Maybe Natural
pipelineVersion :: Maybe Natural
$sel:pipelineVersion:PipelineExecution' :: PipelineExecution -> Maybe Natural
pipelineVersion} -> Maybe Natural
pipelineVersion) (\s :: PipelineExecution
s@PipelineExecution' {} Maybe Natural
a -> PipelineExecution
s {$sel:pipelineVersion:PipelineExecution' :: Maybe Natural
pipelineVersion = Maybe Natural
a} :: PipelineExecution)

-- | The status of the pipeline execution.
--
-- -   Cancelled: The pipeline’s definition was updated before the pipeline
--     execution could be completed.
--
-- -   InProgress: The pipeline execution is currently running.
--
-- -   Stopped: The pipeline execution was manually stopped. For more
--     information, see
--     <https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-executions-stopped Stopped Executions>.
--
-- -   Stopping: The pipeline execution received a request to be manually
--     stopped. Depending on the selected stop mode, the execution is
--     either completing or abandoning in-progress actions. For more
--     information, see
--     <https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-executions-stopped Stopped Executions>.
--
-- -   Succeeded: The pipeline execution was completed successfully.
--
-- -   Superseded: While this pipeline execution was waiting for the next
--     stage to be completed, a newer pipeline execution advanced and
--     continued through the pipeline instead. For more information, see
--     <https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html#concepts-superseded Superseded Executions>.
--
-- -   Failed: The pipeline execution was not completed successfully.
pipelineExecution_status :: Lens.Lens' PipelineExecution (Prelude.Maybe PipelineExecutionStatus)
pipelineExecution_status :: Lens' PipelineExecution (Maybe PipelineExecutionStatus)
pipelineExecution_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineExecution' {Maybe PipelineExecutionStatus
status :: Maybe PipelineExecutionStatus
$sel:status:PipelineExecution' :: PipelineExecution -> Maybe PipelineExecutionStatus
status} -> Maybe PipelineExecutionStatus
status) (\s :: PipelineExecution
s@PipelineExecution' {} Maybe PipelineExecutionStatus
a -> PipelineExecution
s {$sel:status:PipelineExecution' :: Maybe PipelineExecutionStatus
status = Maybe PipelineExecutionStatus
a} :: PipelineExecution)

-- | A summary that contains a description of the pipeline execution status.
pipelineExecution_statusSummary :: Lens.Lens' PipelineExecution (Prelude.Maybe Prelude.Text)
pipelineExecution_statusSummary :: Lens' PipelineExecution (Maybe Text)
pipelineExecution_statusSummary = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineExecution' {Maybe Text
statusSummary :: Maybe Text
$sel:statusSummary:PipelineExecution' :: PipelineExecution -> Maybe Text
statusSummary} -> Maybe Text
statusSummary) (\s :: PipelineExecution
s@PipelineExecution' {} Maybe Text
a -> PipelineExecution
s {$sel:statusSummary:PipelineExecution' :: Maybe Text
statusSummary = Maybe Text
a} :: PipelineExecution)

instance Data.FromJSON PipelineExecution where
  parseJSON :: Value -> Parser PipelineExecution
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PipelineExecution"
      ( \Object
x ->
          Maybe [ArtifactRevision]
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe PipelineExecutionStatus
-> Maybe Text
-> PipelineExecution
PipelineExecution'
            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
"artifactRevisions"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"pipelineExecutionId")
            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
"pipelineName")
            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
"pipelineVersion")
            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
"status")
            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
"statusSummary")
      )

instance Prelude.Hashable PipelineExecution where
  hashWithSalt :: Int -> PipelineExecution -> Int
hashWithSalt Int
_salt PipelineExecution' {Maybe Natural
Maybe [ArtifactRevision]
Maybe Text
Maybe PipelineExecutionStatus
statusSummary :: Maybe Text
status :: Maybe PipelineExecutionStatus
pipelineVersion :: Maybe Natural
pipelineName :: Maybe Text
pipelineExecutionId :: Maybe Text
artifactRevisions :: Maybe [ArtifactRevision]
$sel:statusSummary:PipelineExecution' :: PipelineExecution -> Maybe Text
$sel:status:PipelineExecution' :: PipelineExecution -> Maybe PipelineExecutionStatus
$sel:pipelineVersion:PipelineExecution' :: PipelineExecution -> Maybe Natural
$sel:pipelineName:PipelineExecution' :: PipelineExecution -> Maybe Text
$sel:pipelineExecutionId:PipelineExecution' :: PipelineExecution -> Maybe Text
$sel:artifactRevisions:PipelineExecution' :: PipelineExecution -> Maybe [ArtifactRevision]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ArtifactRevision]
artifactRevisions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pipelineExecutionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pipelineName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
pipelineVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PipelineExecutionStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statusSummary

instance Prelude.NFData PipelineExecution where
  rnf :: PipelineExecution -> ()
rnf PipelineExecution' {Maybe Natural
Maybe [ArtifactRevision]
Maybe Text
Maybe PipelineExecutionStatus
statusSummary :: Maybe Text
status :: Maybe PipelineExecutionStatus
pipelineVersion :: Maybe Natural
pipelineName :: Maybe Text
pipelineExecutionId :: Maybe Text
artifactRevisions :: Maybe [ArtifactRevision]
$sel:statusSummary:PipelineExecution' :: PipelineExecution -> Maybe Text
$sel:status:PipelineExecution' :: PipelineExecution -> Maybe PipelineExecutionStatus
$sel:pipelineVersion:PipelineExecution' :: PipelineExecution -> Maybe Natural
$sel:pipelineName:PipelineExecution' :: PipelineExecution -> Maybe Text
$sel:pipelineExecutionId:PipelineExecution' :: PipelineExecution -> Maybe Text
$sel:artifactRevisions:PipelineExecution' :: PipelineExecution -> Maybe [ArtifactRevision]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ArtifactRevision]
artifactRevisions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pipelineExecutionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pipelineName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
pipelineVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PipelineExecutionStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statusSummary