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

import Amazonka.CodePipeline.Types.ActionContext
import Amazonka.CodePipeline.Types.StageContext
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 a pipeline to a job worker.
--
-- PipelineContext contains @pipelineArn@ and @pipelineExecutionId@ for
-- custom action jobs. The @pipelineArn@ and @pipelineExecutionId@ fields
-- are not populated for ThirdParty action jobs.
--
-- /See:/ 'newPipelineContext' smart constructor.
data PipelineContext = PipelineContext'
  { -- | The context of an action to a job worker in the stage of a pipeline.
    PipelineContext -> Maybe ActionContext
action :: Prelude.Maybe ActionContext,
    -- | The Amazon Resource Name (ARN) of the pipeline.
    PipelineContext -> Maybe Text
pipelineArn :: Prelude.Maybe Prelude.Text,
    -- | The execution ID of the pipeline.
    PipelineContext -> Maybe Text
pipelineExecutionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the pipeline. This is a user-specified value. Pipeline names
    -- must be unique across all pipeline names under an Amazon Web Services
    -- account.
    PipelineContext -> Maybe Text
pipelineName :: Prelude.Maybe Prelude.Text,
    -- | The stage of the pipeline.
    PipelineContext -> Maybe StageContext
stage :: Prelude.Maybe StageContext
  }
  deriving (PipelineContext -> PipelineContext -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PipelineContext -> PipelineContext -> Bool
$c/= :: PipelineContext -> PipelineContext -> Bool
== :: PipelineContext -> PipelineContext -> Bool
$c== :: PipelineContext -> PipelineContext -> Bool
Prelude.Eq, ReadPrec [PipelineContext]
ReadPrec PipelineContext
Int -> ReadS PipelineContext
ReadS [PipelineContext]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PipelineContext]
$creadListPrec :: ReadPrec [PipelineContext]
readPrec :: ReadPrec PipelineContext
$creadPrec :: ReadPrec PipelineContext
readList :: ReadS [PipelineContext]
$creadList :: ReadS [PipelineContext]
readsPrec :: Int -> ReadS PipelineContext
$creadsPrec :: Int -> ReadS PipelineContext
Prelude.Read, Int -> PipelineContext -> ShowS
[PipelineContext] -> ShowS
PipelineContext -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PipelineContext] -> ShowS
$cshowList :: [PipelineContext] -> ShowS
show :: PipelineContext -> String
$cshow :: PipelineContext -> String
showsPrec :: Int -> PipelineContext -> ShowS
$cshowsPrec :: Int -> PipelineContext -> ShowS
Prelude.Show, forall x. Rep PipelineContext x -> PipelineContext
forall x. PipelineContext -> Rep PipelineContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PipelineContext x -> PipelineContext
$cfrom :: forall x. PipelineContext -> Rep PipelineContext x
Prelude.Generic)

-- |
-- Create a value of 'PipelineContext' 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:
--
-- 'action', 'pipelineContext_action' - The context of an action to a job worker in the stage of a pipeline.
--
-- 'pipelineArn', 'pipelineContext_pipelineArn' - The Amazon Resource Name (ARN) of the pipeline.
--
-- 'pipelineExecutionId', 'pipelineContext_pipelineExecutionId' - The execution ID of the pipeline.
--
-- 'pipelineName', 'pipelineContext_pipelineName' - The name of the pipeline. This is a user-specified value. Pipeline names
-- must be unique across all pipeline names under an Amazon Web Services
-- account.
--
-- 'stage', 'pipelineContext_stage' - The stage of the pipeline.
newPipelineContext ::
  PipelineContext
newPipelineContext :: PipelineContext
newPipelineContext =
  PipelineContext'
    { $sel:action:PipelineContext' :: Maybe ActionContext
action = forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineArn:PipelineContext' :: Maybe Text
pipelineArn = forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineExecutionId:PipelineContext' :: Maybe Text
pipelineExecutionId = forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineName:PipelineContext' :: Maybe Text
pipelineName = forall a. Maybe a
Prelude.Nothing,
      $sel:stage:PipelineContext' :: Maybe StageContext
stage = forall a. Maybe a
Prelude.Nothing
    }

-- | The context of an action to a job worker in the stage of a pipeline.
pipelineContext_action :: Lens.Lens' PipelineContext (Prelude.Maybe ActionContext)
pipelineContext_action :: Lens' PipelineContext (Maybe ActionContext)
pipelineContext_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineContext' {Maybe ActionContext
action :: Maybe ActionContext
$sel:action:PipelineContext' :: PipelineContext -> Maybe ActionContext
action} -> Maybe ActionContext
action) (\s :: PipelineContext
s@PipelineContext' {} Maybe ActionContext
a -> PipelineContext
s {$sel:action:PipelineContext' :: Maybe ActionContext
action = Maybe ActionContext
a} :: PipelineContext)

-- | The Amazon Resource Name (ARN) of the pipeline.
pipelineContext_pipelineArn :: Lens.Lens' PipelineContext (Prelude.Maybe Prelude.Text)
pipelineContext_pipelineArn :: Lens' PipelineContext (Maybe Text)
pipelineContext_pipelineArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineContext' {Maybe Text
pipelineArn :: Maybe Text
$sel:pipelineArn:PipelineContext' :: PipelineContext -> Maybe Text
pipelineArn} -> Maybe Text
pipelineArn) (\s :: PipelineContext
s@PipelineContext' {} Maybe Text
a -> PipelineContext
s {$sel:pipelineArn:PipelineContext' :: Maybe Text
pipelineArn = Maybe Text
a} :: PipelineContext)

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

-- | The name of the pipeline. This is a user-specified value. Pipeline names
-- must be unique across all pipeline names under an Amazon Web Services
-- account.
pipelineContext_pipelineName :: Lens.Lens' PipelineContext (Prelude.Maybe Prelude.Text)
pipelineContext_pipelineName :: Lens' PipelineContext (Maybe Text)
pipelineContext_pipelineName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineContext' {Maybe Text
pipelineName :: Maybe Text
$sel:pipelineName:PipelineContext' :: PipelineContext -> Maybe Text
pipelineName} -> Maybe Text
pipelineName) (\s :: PipelineContext
s@PipelineContext' {} Maybe Text
a -> PipelineContext
s {$sel:pipelineName:PipelineContext' :: Maybe Text
pipelineName = Maybe Text
a} :: PipelineContext)

-- | The stage of the pipeline.
pipelineContext_stage :: Lens.Lens' PipelineContext (Prelude.Maybe StageContext)
pipelineContext_stage :: Lens' PipelineContext (Maybe StageContext)
pipelineContext_stage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineContext' {Maybe StageContext
stage :: Maybe StageContext
$sel:stage:PipelineContext' :: PipelineContext -> Maybe StageContext
stage} -> Maybe StageContext
stage) (\s :: PipelineContext
s@PipelineContext' {} Maybe StageContext
a -> PipelineContext
s {$sel:stage:PipelineContext' :: Maybe StageContext
stage = Maybe StageContext
a} :: PipelineContext)

instance Data.FromJSON PipelineContext where
  parseJSON :: Value -> Parser PipelineContext
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PipelineContext"
      ( \Object
x ->
          Maybe ActionContext
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe StageContext
-> PipelineContext
PipelineContext'
            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
"action")
            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
"pipelineArn")
            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
"stage")
      )

instance Prelude.Hashable PipelineContext where
  hashWithSalt :: Int -> PipelineContext -> Int
hashWithSalt Int
_salt PipelineContext' {Maybe Text
Maybe ActionContext
Maybe StageContext
stage :: Maybe StageContext
pipelineName :: Maybe Text
pipelineExecutionId :: Maybe Text
pipelineArn :: Maybe Text
action :: Maybe ActionContext
$sel:stage:PipelineContext' :: PipelineContext -> Maybe StageContext
$sel:pipelineName:PipelineContext' :: PipelineContext -> Maybe Text
$sel:pipelineExecutionId:PipelineContext' :: PipelineContext -> Maybe Text
$sel:pipelineArn:PipelineContext' :: PipelineContext -> Maybe Text
$sel:action:PipelineContext' :: PipelineContext -> Maybe ActionContext
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ActionContext
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pipelineArn
      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 StageContext
stage

instance Prelude.NFData PipelineContext where
  rnf :: PipelineContext -> ()
rnf PipelineContext' {Maybe Text
Maybe ActionContext
Maybe StageContext
stage :: Maybe StageContext
pipelineName :: Maybe Text
pipelineExecutionId :: Maybe Text
pipelineArn :: Maybe Text
action :: Maybe ActionContext
$sel:stage:PipelineContext' :: PipelineContext -> Maybe StageContext
$sel:pipelineName:PipelineContext' :: PipelineContext -> Maybe Text
$sel:pipelineExecutionId:PipelineContext' :: PipelineContext -> Maybe Text
$sel:pipelineArn:PipelineContext' :: PipelineContext -> Maybe Text
$sel:action:PipelineContext' :: PipelineContext -> Maybe ActionContext
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ActionContext
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pipelineArn
      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 StageContext
stage