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

import Amazonka.CodePipeline.Types.ArtifactStore
import Amazonka.CodePipeline.Types.StageDeclaration
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 the structure of actions and stages to be performed in the
-- pipeline.
--
-- /See:/ 'newPipelineDeclaration' smart constructor.
data PipelineDeclaration = PipelineDeclaration'
  { -- | Represents information about the S3 bucket where artifacts are stored
    -- for the pipeline.
    --
    -- You must include either @artifactStore@ or @artifactStores@ in your
    -- pipeline, but you cannot use both. If you create a cross-region action
    -- in your pipeline, you must use @artifactStores@.
    PipelineDeclaration -> Maybe ArtifactStore
artifactStore :: Prelude.Maybe ArtifactStore,
    -- | A mapping of @artifactStore@ objects and their corresponding AWS
    -- Regions. There must be an artifact store for the pipeline Region and for
    -- each cross-region action in the pipeline.
    --
    -- You must include either @artifactStore@ or @artifactStores@ in your
    -- pipeline, but you cannot use both. If you create a cross-region action
    -- in your pipeline, you must use @artifactStores@.
    PipelineDeclaration -> Maybe (HashMap Text ArtifactStore)
artifactStores :: Prelude.Maybe (Prelude.HashMap Prelude.Text ArtifactStore),
    -- | The version number of the pipeline. A new pipeline always has a version
    -- number of 1. This number is incremented when a pipeline is updated.
    PipelineDeclaration -> Maybe Natural
version :: Prelude.Maybe Prelude.Natural,
    -- | The name of the pipeline.
    PipelineDeclaration -> Text
name :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) for AWS CodePipeline to use to either
    -- perform actions with no @actionRoleArn@, or to use to assume roles for
    -- actions with an @actionRoleArn@.
    PipelineDeclaration -> Text
roleArn :: Prelude.Text,
    -- | The stage in which to perform the action.
    PipelineDeclaration -> [StageDeclaration]
stages :: [StageDeclaration]
  }
  deriving (PipelineDeclaration -> PipelineDeclaration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PipelineDeclaration -> PipelineDeclaration -> Bool
$c/= :: PipelineDeclaration -> PipelineDeclaration -> Bool
== :: PipelineDeclaration -> PipelineDeclaration -> Bool
$c== :: PipelineDeclaration -> PipelineDeclaration -> Bool
Prelude.Eq, ReadPrec [PipelineDeclaration]
ReadPrec PipelineDeclaration
Int -> ReadS PipelineDeclaration
ReadS [PipelineDeclaration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PipelineDeclaration]
$creadListPrec :: ReadPrec [PipelineDeclaration]
readPrec :: ReadPrec PipelineDeclaration
$creadPrec :: ReadPrec PipelineDeclaration
readList :: ReadS [PipelineDeclaration]
$creadList :: ReadS [PipelineDeclaration]
readsPrec :: Int -> ReadS PipelineDeclaration
$creadsPrec :: Int -> ReadS PipelineDeclaration
Prelude.Read, Int -> PipelineDeclaration -> ShowS
[PipelineDeclaration] -> ShowS
PipelineDeclaration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PipelineDeclaration] -> ShowS
$cshowList :: [PipelineDeclaration] -> ShowS
show :: PipelineDeclaration -> String
$cshow :: PipelineDeclaration -> String
showsPrec :: Int -> PipelineDeclaration -> ShowS
$cshowsPrec :: Int -> PipelineDeclaration -> ShowS
Prelude.Show, forall x. Rep PipelineDeclaration x -> PipelineDeclaration
forall x. PipelineDeclaration -> Rep PipelineDeclaration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PipelineDeclaration x -> PipelineDeclaration
$cfrom :: forall x. PipelineDeclaration -> Rep PipelineDeclaration x
Prelude.Generic)

-- |
-- Create a value of 'PipelineDeclaration' 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:
--
-- 'artifactStore', 'pipelineDeclaration_artifactStore' - Represents information about the S3 bucket where artifacts are stored
-- for the pipeline.
--
-- You must include either @artifactStore@ or @artifactStores@ in your
-- pipeline, but you cannot use both. If you create a cross-region action
-- in your pipeline, you must use @artifactStores@.
--
-- 'artifactStores', 'pipelineDeclaration_artifactStores' - A mapping of @artifactStore@ objects and their corresponding AWS
-- Regions. There must be an artifact store for the pipeline Region and for
-- each cross-region action in the pipeline.
--
-- You must include either @artifactStore@ or @artifactStores@ in your
-- pipeline, but you cannot use both. If you create a cross-region action
-- in your pipeline, you must use @artifactStores@.
--
-- 'version', 'pipelineDeclaration_version' - The version number of the pipeline. A new pipeline always has a version
-- number of 1. This number is incremented when a pipeline is updated.
--
-- 'name', 'pipelineDeclaration_name' - The name of the pipeline.
--
-- 'roleArn', 'pipelineDeclaration_roleArn' - The Amazon Resource Name (ARN) for AWS CodePipeline to use to either
-- perform actions with no @actionRoleArn@, or to use to assume roles for
-- actions with an @actionRoleArn@.
--
-- 'stages', 'pipelineDeclaration_stages' - The stage in which to perform the action.
newPipelineDeclaration ::
  -- | 'name'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  PipelineDeclaration
newPipelineDeclaration :: Text -> Text -> PipelineDeclaration
newPipelineDeclaration Text
pName_ Text
pRoleArn_ =
  PipelineDeclaration'
    { $sel:artifactStore:PipelineDeclaration' :: Maybe ArtifactStore
artifactStore =
        forall a. Maybe a
Prelude.Nothing,
      $sel:artifactStores:PipelineDeclaration' :: Maybe (HashMap Text ArtifactStore)
artifactStores = forall a. Maybe a
Prelude.Nothing,
      $sel:version:PipelineDeclaration' :: Maybe Natural
version = forall a. Maybe a
Prelude.Nothing,
      $sel:name:PipelineDeclaration' :: Text
name = Text
pName_,
      $sel:roleArn:PipelineDeclaration' :: Text
roleArn = Text
pRoleArn_,
      $sel:stages:PipelineDeclaration' :: [StageDeclaration]
stages = forall a. Monoid a => a
Prelude.mempty
    }

-- | Represents information about the S3 bucket where artifacts are stored
-- for the pipeline.
--
-- You must include either @artifactStore@ or @artifactStores@ in your
-- pipeline, but you cannot use both. If you create a cross-region action
-- in your pipeline, you must use @artifactStores@.
pipelineDeclaration_artifactStore :: Lens.Lens' PipelineDeclaration (Prelude.Maybe ArtifactStore)
pipelineDeclaration_artifactStore :: Lens' PipelineDeclaration (Maybe ArtifactStore)
pipelineDeclaration_artifactStore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineDeclaration' {Maybe ArtifactStore
artifactStore :: Maybe ArtifactStore
$sel:artifactStore:PipelineDeclaration' :: PipelineDeclaration -> Maybe ArtifactStore
artifactStore} -> Maybe ArtifactStore
artifactStore) (\s :: PipelineDeclaration
s@PipelineDeclaration' {} Maybe ArtifactStore
a -> PipelineDeclaration
s {$sel:artifactStore:PipelineDeclaration' :: Maybe ArtifactStore
artifactStore = Maybe ArtifactStore
a} :: PipelineDeclaration)

-- | A mapping of @artifactStore@ objects and their corresponding AWS
-- Regions. There must be an artifact store for the pipeline Region and for
-- each cross-region action in the pipeline.
--
-- You must include either @artifactStore@ or @artifactStores@ in your
-- pipeline, but you cannot use both. If you create a cross-region action
-- in your pipeline, you must use @artifactStores@.
pipelineDeclaration_artifactStores :: Lens.Lens' PipelineDeclaration (Prelude.Maybe (Prelude.HashMap Prelude.Text ArtifactStore))
pipelineDeclaration_artifactStores :: Lens' PipelineDeclaration (Maybe (HashMap Text ArtifactStore))
pipelineDeclaration_artifactStores = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineDeclaration' {Maybe (HashMap Text ArtifactStore)
artifactStores :: Maybe (HashMap Text ArtifactStore)
$sel:artifactStores:PipelineDeclaration' :: PipelineDeclaration -> Maybe (HashMap Text ArtifactStore)
artifactStores} -> Maybe (HashMap Text ArtifactStore)
artifactStores) (\s :: PipelineDeclaration
s@PipelineDeclaration' {} Maybe (HashMap Text ArtifactStore)
a -> PipelineDeclaration
s {$sel:artifactStores:PipelineDeclaration' :: Maybe (HashMap Text ArtifactStore)
artifactStores = Maybe (HashMap Text ArtifactStore)
a} :: PipelineDeclaration) 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 version number of the pipeline. A new pipeline always has a version
-- number of 1. This number is incremented when a pipeline is updated.
pipelineDeclaration_version :: Lens.Lens' PipelineDeclaration (Prelude.Maybe Prelude.Natural)
pipelineDeclaration_version :: Lens' PipelineDeclaration (Maybe Natural)
pipelineDeclaration_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineDeclaration' {Maybe Natural
version :: Maybe Natural
$sel:version:PipelineDeclaration' :: PipelineDeclaration -> Maybe Natural
version} -> Maybe Natural
version) (\s :: PipelineDeclaration
s@PipelineDeclaration' {} Maybe Natural
a -> PipelineDeclaration
s {$sel:version:PipelineDeclaration' :: Maybe Natural
version = Maybe Natural
a} :: PipelineDeclaration)

-- | The name of the pipeline.
pipelineDeclaration_name :: Lens.Lens' PipelineDeclaration Prelude.Text
pipelineDeclaration_name :: Lens' PipelineDeclaration Text
pipelineDeclaration_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineDeclaration' {Text
name :: Text
$sel:name:PipelineDeclaration' :: PipelineDeclaration -> Text
name} -> Text
name) (\s :: PipelineDeclaration
s@PipelineDeclaration' {} Text
a -> PipelineDeclaration
s {$sel:name:PipelineDeclaration' :: Text
name = Text
a} :: PipelineDeclaration)

-- | The Amazon Resource Name (ARN) for AWS CodePipeline to use to either
-- perform actions with no @actionRoleArn@, or to use to assume roles for
-- actions with an @actionRoleArn@.
pipelineDeclaration_roleArn :: Lens.Lens' PipelineDeclaration Prelude.Text
pipelineDeclaration_roleArn :: Lens' PipelineDeclaration Text
pipelineDeclaration_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineDeclaration' {Text
roleArn :: Text
$sel:roleArn:PipelineDeclaration' :: PipelineDeclaration -> Text
roleArn} -> Text
roleArn) (\s :: PipelineDeclaration
s@PipelineDeclaration' {} Text
a -> PipelineDeclaration
s {$sel:roleArn:PipelineDeclaration' :: Text
roleArn = Text
a} :: PipelineDeclaration)

-- | The stage in which to perform the action.
pipelineDeclaration_stages :: Lens.Lens' PipelineDeclaration [StageDeclaration]
pipelineDeclaration_stages :: Lens' PipelineDeclaration [StageDeclaration]
pipelineDeclaration_stages = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineDeclaration' {[StageDeclaration]
stages :: [StageDeclaration]
$sel:stages:PipelineDeclaration' :: PipelineDeclaration -> [StageDeclaration]
stages} -> [StageDeclaration]
stages) (\s :: PipelineDeclaration
s@PipelineDeclaration' {} [StageDeclaration]
a -> PipelineDeclaration
s {$sel:stages:PipelineDeclaration' :: [StageDeclaration]
stages = [StageDeclaration]
a} :: PipelineDeclaration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON PipelineDeclaration where
  parseJSON :: Value -> Parser PipelineDeclaration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PipelineDeclaration"
      ( \Object
x ->
          Maybe ArtifactStore
-> Maybe (HashMap Text ArtifactStore)
-> Maybe Natural
-> Text
-> Text
-> [StageDeclaration]
-> PipelineDeclaration
PipelineDeclaration'
            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
"artifactStore")
            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
"artifactStores" 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
"version")
            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
"name")
            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
"roleArn")
            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
"stages" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PipelineDeclaration where
  hashWithSalt :: Int -> PipelineDeclaration -> Int
hashWithSalt Int
_salt PipelineDeclaration' {[StageDeclaration]
Maybe Natural
Maybe (HashMap Text ArtifactStore)
Maybe ArtifactStore
Text
stages :: [StageDeclaration]
roleArn :: Text
name :: Text
version :: Maybe Natural
artifactStores :: Maybe (HashMap Text ArtifactStore)
artifactStore :: Maybe ArtifactStore
$sel:stages:PipelineDeclaration' :: PipelineDeclaration -> [StageDeclaration]
$sel:roleArn:PipelineDeclaration' :: PipelineDeclaration -> Text
$sel:name:PipelineDeclaration' :: PipelineDeclaration -> Text
$sel:version:PipelineDeclaration' :: PipelineDeclaration -> Maybe Natural
$sel:artifactStores:PipelineDeclaration' :: PipelineDeclaration -> Maybe (HashMap Text ArtifactStore)
$sel:artifactStore:PipelineDeclaration' :: PipelineDeclaration -> Maybe ArtifactStore
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ArtifactStore
artifactStore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text ArtifactStore)
artifactStores
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
version
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [StageDeclaration]
stages

instance Prelude.NFData PipelineDeclaration where
  rnf :: PipelineDeclaration -> ()
rnf PipelineDeclaration' {[StageDeclaration]
Maybe Natural
Maybe (HashMap Text ArtifactStore)
Maybe ArtifactStore
Text
stages :: [StageDeclaration]
roleArn :: Text
name :: Text
version :: Maybe Natural
artifactStores :: Maybe (HashMap Text ArtifactStore)
artifactStore :: Maybe ArtifactStore
$sel:stages:PipelineDeclaration' :: PipelineDeclaration -> [StageDeclaration]
$sel:roleArn:PipelineDeclaration' :: PipelineDeclaration -> Text
$sel:name:PipelineDeclaration' :: PipelineDeclaration -> Text
$sel:version:PipelineDeclaration' :: PipelineDeclaration -> Maybe Natural
$sel:artifactStores:PipelineDeclaration' :: PipelineDeclaration -> Maybe (HashMap Text ArtifactStore)
$sel:artifactStore:PipelineDeclaration' :: PipelineDeclaration -> Maybe ArtifactStore
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ArtifactStore
artifactStore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text ArtifactStore)
artifactStores
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
version
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [StageDeclaration]
stages

instance Data.ToJSON PipelineDeclaration where
  toJSON :: PipelineDeclaration -> Value
toJSON PipelineDeclaration' {[StageDeclaration]
Maybe Natural
Maybe (HashMap Text ArtifactStore)
Maybe ArtifactStore
Text
stages :: [StageDeclaration]
roleArn :: Text
name :: Text
version :: Maybe Natural
artifactStores :: Maybe (HashMap Text ArtifactStore)
artifactStore :: Maybe ArtifactStore
$sel:stages:PipelineDeclaration' :: PipelineDeclaration -> [StageDeclaration]
$sel:roleArn:PipelineDeclaration' :: PipelineDeclaration -> Text
$sel:name:PipelineDeclaration' :: PipelineDeclaration -> Text
$sel:version:PipelineDeclaration' :: PipelineDeclaration -> Maybe Natural
$sel:artifactStores:PipelineDeclaration' :: PipelineDeclaration -> Maybe (HashMap Text ArtifactStore)
$sel:artifactStore:PipelineDeclaration' :: PipelineDeclaration -> Maybe ArtifactStore
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"artifactStore" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ArtifactStore
artifactStore,
            (Key
"artifactStores" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text ArtifactStore)
artifactStores,
            (Key
"version" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
version,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"roleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"stages" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [StageDeclaration]
stages)
          ]
      )