{-# 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.CodeStar.Types.Toolchain
-- 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.CodeStar.Types.Toolchain where

import Amazonka.CodeStar.Types.ToolchainSource
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The toolchain template file provided with the project request. AWS
-- CodeStar uses the template to provision the toolchain stack in AWS
-- CloudFormation.
--
-- /See:/ 'newToolchain' smart constructor.
data Toolchain = Toolchain'
  { -- | The list of parameter overrides to be passed into the toolchain template
    -- during stack provisioning, if any.
    Toolchain -> Maybe (HashMap Text (Sensitive Text))
stackParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text (Core.Sensitive Prelude.Text)),
    -- | The service role ARN for AWS CodeStar to use for the toolchain template
    -- during stack provisioning.
    Toolchain -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 location where the toolchain template file provided with
    -- the project request is stored. AWS CodeStar retrieves the file during
    -- project creation.
    Toolchain -> ToolchainSource
source :: ToolchainSource
  }
  deriving (Toolchain -> Toolchain -> Bool
(Toolchain -> Toolchain -> Bool)
-> (Toolchain -> Toolchain -> Bool) -> Eq Toolchain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Toolchain -> Toolchain -> Bool
$c/= :: Toolchain -> Toolchain -> Bool
== :: Toolchain -> Toolchain -> Bool
$c== :: Toolchain -> Toolchain -> Bool
Prelude.Eq, Int -> Toolchain -> ShowS
[Toolchain] -> ShowS
Toolchain -> String
(Int -> Toolchain -> ShowS)
-> (Toolchain -> String)
-> ([Toolchain] -> ShowS)
-> Show Toolchain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Toolchain] -> ShowS
$cshowList :: [Toolchain] -> ShowS
show :: Toolchain -> String
$cshow :: Toolchain -> String
showsPrec :: Int -> Toolchain -> ShowS
$cshowsPrec :: Int -> Toolchain -> ShowS
Prelude.Show, (forall x. Toolchain -> Rep Toolchain x)
-> (forall x. Rep Toolchain x -> Toolchain) -> Generic Toolchain
forall x. Rep Toolchain x -> Toolchain
forall x. Toolchain -> Rep Toolchain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Toolchain x -> Toolchain
$cfrom :: forall x. Toolchain -> Rep Toolchain x
Prelude.Generic)

-- |
-- Create a value of 'Toolchain' 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:
--
-- 'stackParameters', 'toolchain_stackParameters' - The list of parameter overrides to be passed into the toolchain template
-- during stack provisioning, if any.
--
-- 'roleArn', 'toolchain_roleArn' - The service role ARN for AWS CodeStar to use for the toolchain template
-- during stack provisioning.
--
-- 'source', 'toolchain_source' - The Amazon S3 location where the toolchain template file provided with
-- the project request is stored. AWS CodeStar retrieves the file during
-- project creation.
newToolchain ::
  -- | 'source'
  ToolchainSource ->
  Toolchain
newToolchain :: ToolchainSource -> Toolchain
newToolchain ToolchainSource
pSource_ =
  Toolchain' :: Maybe (HashMap Text (Sensitive Text))
-> Maybe Text -> ToolchainSource -> Toolchain
Toolchain'
    { $sel:stackParameters:Toolchain' :: Maybe (HashMap Text (Sensitive Text))
stackParameters = Maybe (HashMap Text (Sensitive Text))
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:Toolchain' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:source:Toolchain' :: ToolchainSource
source = ToolchainSource
pSource_
    }

-- | The list of parameter overrides to be passed into the toolchain template
-- during stack provisioning, if any.
toolchain_stackParameters :: Lens.Lens' Toolchain (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
toolchain_stackParameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Toolchain -> f Toolchain
toolchain_stackParameters = (Toolchain -> Maybe (HashMap Text (Sensitive Text)))
-> (Toolchain
    -> Maybe (HashMap Text (Sensitive Text)) -> Toolchain)
-> Lens
     Toolchain
     Toolchain
     (Maybe (HashMap Text (Sensitive Text)))
     (Maybe (HashMap Text (Sensitive Text)))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Toolchain' {Maybe (HashMap Text (Sensitive Text))
stackParameters :: Maybe (HashMap Text (Sensitive Text))
$sel:stackParameters:Toolchain' :: Toolchain -> Maybe (HashMap Text (Sensitive Text))
stackParameters} -> Maybe (HashMap Text (Sensitive Text))
stackParameters) (\s :: Toolchain
s@Toolchain' {} Maybe (HashMap Text (Sensitive Text))
a -> Toolchain
s {$sel:stackParameters:Toolchain' :: Maybe (HashMap Text (Sensitive Text))
stackParameters = Maybe (HashMap Text (Sensitive Text))
a} :: Toolchain) ((Maybe (HashMap Text (Sensitive Text))
  -> f (Maybe (HashMap Text (Sensitive Text))))
 -> Toolchain -> f Toolchain)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text (Sensitive Text))
    -> f (Maybe (HashMap Text (Sensitive Text))))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Toolchain
-> f Toolchain
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text (Sensitive Text))
  (HashMap Text (Sensitive Text))
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text (Sensitive Text)))
     (Maybe (HashMap Text (Sensitive Text)))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text (Sensitive Text))
  (HashMap Text (Sensitive Text))
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The service role ARN for AWS CodeStar to use for the toolchain template
-- during stack provisioning.
toolchain_roleArn :: Lens.Lens' Toolchain (Prelude.Maybe Prelude.Text)
toolchain_roleArn :: (Maybe Text -> f (Maybe Text)) -> Toolchain -> f Toolchain
toolchain_roleArn = (Toolchain -> Maybe Text)
-> (Toolchain -> Maybe Text -> Toolchain)
-> Lens Toolchain Toolchain (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Toolchain' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:Toolchain' :: Toolchain -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: Toolchain
s@Toolchain' {} Maybe Text
a -> Toolchain
s {$sel:roleArn:Toolchain' :: Maybe Text
roleArn = Maybe Text
a} :: Toolchain)

-- | The Amazon S3 location where the toolchain template file provided with
-- the project request is stored. AWS CodeStar retrieves the file during
-- project creation.
toolchain_source :: Lens.Lens' Toolchain ToolchainSource
toolchain_source :: (ToolchainSource -> f ToolchainSource) -> Toolchain -> f Toolchain
toolchain_source = (Toolchain -> ToolchainSource)
-> (Toolchain -> ToolchainSource -> Toolchain)
-> Lens Toolchain Toolchain ToolchainSource ToolchainSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Toolchain' {ToolchainSource
source :: ToolchainSource
$sel:source:Toolchain' :: Toolchain -> ToolchainSource
source} -> ToolchainSource
source) (\s :: Toolchain
s@Toolchain' {} ToolchainSource
a -> Toolchain
s {$sel:source:Toolchain' :: ToolchainSource
source = ToolchainSource
a} :: Toolchain)

instance Prelude.Hashable Toolchain

instance Prelude.NFData Toolchain

instance Core.ToJSON Toolchain where
  toJSON :: Toolchain -> Value
toJSON Toolchain' {Maybe Text
Maybe (HashMap Text (Sensitive Text))
ToolchainSource
source :: ToolchainSource
roleArn :: Maybe Text
stackParameters :: Maybe (HashMap Text (Sensitive Text))
$sel:source:Toolchain' :: Toolchain -> ToolchainSource
$sel:roleArn:Toolchain' :: Toolchain -> Maybe Text
$sel:stackParameters:Toolchain' :: Toolchain -> Maybe (HashMap Text (Sensitive Text))
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"stackParameters" Text -> HashMap Text (Sensitive Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text (Sensitive Text) -> Pair)
-> Maybe (HashMap Text (Sensitive Text)) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text (Sensitive Text))
stackParameters,
            (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"source" Text -> ToolchainSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ToolchainSource
source)
          ]
      )