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

import Amazonka.CodePipeline.Types.ActionContext
import Amazonka.CodePipeline.Types.StageContext
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 stage of the pipeline.
    PipelineContext -> Maybe StageContext
stage :: Prelude.Maybe StageContext,
    -- | 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 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
  }
  deriving (PipelineContext -> PipelineContext -> Bool
(PipelineContext -> PipelineContext -> Bool)
-> (PipelineContext -> PipelineContext -> Bool)
-> Eq PipelineContext
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]
(Int -> ReadS PipelineContext)
-> ReadS [PipelineContext]
-> ReadPrec PipelineContext
-> ReadPrec [PipelineContext]
-> Read 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
(Int -> PipelineContext -> ShowS)
-> (PipelineContext -> String)
-> ([PipelineContext] -> ShowS)
-> Show PipelineContext
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. PipelineContext -> Rep PipelineContext x)
-> (forall x. Rep PipelineContext x -> PipelineContext)
-> Generic PipelineContext
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:
--
-- 'stage', 'pipelineContext_stage' - The stage 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.
--
-- '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.
newPipelineContext ::
  PipelineContext
newPipelineContext :: PipelineContext
newPipelineContext =
  PipelineContext' :: Maybe StageContext
-> Maybe Text
-> Maybe ActionContext
-> Maybe Text
-> Maybe Text
-> PipelineContext
PipelineContext'
    { $sel:stage:PipelineContext' :: Maybe StageContext
stage = Maybe StageContext
forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineName:PipelineContext' :: Maybe Text
pipelineName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:action:PipelineContext' :: Maybe ActionContext
action = Maybe ActionContext
forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineArn:PipelineContext' :: Maybe Text
pipelineArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineExecutionId:PipelineContext' :: Maybe Text
pipelineExecutionId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The stage of the pipeline.
pipelineContext_stage :: Lens.Lens' PipelineContext (Prelude.Maybe StageContext)
pipelineContext_stage :: (Maybe StageContext -> f (Maybe StageContext))
-> PipelineContext -> f PipelineContext
pipelineContext_stage = (PipelineContext -> Maybe StageContext)
-> (PipelineContext -> Maybe StageContext -> PipelineContext)
-> Lens
     PipelineContext
     PipelineContext
     (Maybe StageContext)
     (Maybe StageContext)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> PipelineContext -> f PipelineContext
pipelineContext_pipelineName = (PipelineContext -> Maybe Text)
-> (PipelineContext -> Maybe Text -> PipelineContext)
-> Lens PipelineContext PipelineContext (Maybe Text) (Maybe Text)
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 context of an action to a job worker in the stage of a pipeline.
pipelineContext_action :: Lens.Lens' PipelineContext (Prelude.Maybe ActionContext)
pipelineContext_action :: (Maybe ActionContext -> f (Maybe ActionContext))
-> PipelineContext -> f PipelineContext
pipelineContext_action = (PipelineContext -> Maybe ActionContext)
-> (PipelineContext -> Maybe ActionContext -> PipelineContext)
-> Lens
     PipelineContext
     PipelineContext
     (Maybe ActionContext)
     (Maybe ActionContext)
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 :: (Maybe Text -> f (Maybe Text))
-> PipelineContext -> f PipelineContext
pipelineContext_pipelineArn = (PipelineContext -> Maybe Text)
-> (PipelineContext -> Maybe Text -> PipelineContext)
-> Lens PipelineContext PipelineContext (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> PipelineContext -> f PipelineContext
pipelineContext_pipelineExecutionId = (PipelineContext -> Maybe Text)
-> (PipelineContext -> Maybe Text -> PipelineContext)
-> Lens PipelineContext PipelineContext (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON PipelineContext where
  parseJSON :: Value -> Parser PipelineContext
parseJSON =
    String
-> (Object -> Parser PipelineContext)
-> Value
-> Parser PipelineContext
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PipelineContext"
      ( \Object
x ->
          Maybe StageContext
-> Maybe Text
-> Maybe ActionContext
-> Maybe Text
-> Maybe Text
-> PipelineContext
PipelineContext'
            (Maybe StageContext
 -> Maybe Text
 -> Maybe ActionContext
 -> Maybe Text
 -> Maybe Text
 -> PipelineContext)
-> Parser (Maybe StageContext)
-> Parser
     (Maybe Text
      -> Maybe ActionContext
      -> Maybe Text
      -> Maybe Text
      -> PipelineContext)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe StageContext)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"stage")
            Parser
  (Maybe Text
   -> Maybe ActionContext
   -> Maybe Text
   -> Maybe Text
   -> PipelineContext)
-> Parser (Maybe Text)
-> Parser
     (Maybe ActionContext
      -> Maybe Text -> Maybe Text -> PipelineContext)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"pipelineName")
            Parser
  (Maybe ActionContext
   -> Maybe Text -> Maybe Text -> PipelineContext)
-> Parser (Maybe ActionContext)
-> Parser (Maybe Text -> Maybe Text -> PipelineContext)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ActionContext)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"action")
            Parser (Maybe Text -> Maybe Text -> PipelineContext)
-> Parser (Maybe Text) -> Parser (Maybe Text -> PipelineContext)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"pipelineArn")
            Parser (Maybe Text -> PipelineContext)
-> Parser (Maybe Text) -> Parser PipelineContext
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"pipelineExecutionId")
      )

instance Prelude.Hashable PipelineContext

instance Prelude.NFData PipelineContext