{-# 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.CloudFormation.Types.Parameter
-- 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.CloudFormation.Types.Parameter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The Parameter data type.
--
-- /See:/ 'newParameter' smart constructor.
data Parameter = Parameter'
  { -- | The input value associated with the parameter.
    Parameter -> Maybe Text
parameterValue :: Prelude.Maybe Prelude.Text,
    -- | Read-only. The value that corresponds to a Systems Manager parameter
    -- key. This field is returned only for
    -- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#aws-ssm-parameter-types SSM parameter types>
    -- in the template.
    Parameter -> Maybe Text
resolvedValue :: Prelude.Maybe Prelude.Text,
    -- | The key associated with the parameter. If you don\'t specify a key and
    -- value for a particular parameter, CloudFormation uses the default value
    -- that is specified in your template.
    Parameter -> Maybe Text
parameterKey :: Prelude.Maybe Prelude.Text,
    -- | During a stack update, use the existing parameter value that the stack
    -- is using for a given parameter key. If you specify @true@, do not
    -- specify a parameter value.
    Parameter -> Maybe Bool
usePreviousValue :: Prelude.Maybe Prelude.Bool
  }
  deriving (Parameter -> Parameter -> Bool
(Parameter -> Parameter -> Bool)
-> (Parameter -> Parameter -> Bool) -> Eq Parameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Parameter -> Parameter -> Bool
$c/= :: Parameter -> Parameter -> Bool
== :: Parameter -> Parameter -> Bool
$c== :: Parameter -> Parameter -> Bool
Prelude.Eq, ReadPrec [Parameter]
ReadPrec Parameter
Int -> ReadS Parameter
ReadS [Parameter]
(Int -> ReadS Parameter)
-> ReadS [Parameter]
-> ReadPrec Parameter
-> ReadPrec [Parameter]
-> Read Parameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Parameter]
$creadListPrec :: ReadPrec [Parameter]
readPrec :: ReadPrec Parameter
$creadPrec :: ReadPrec Parameter
readList :: ReadS [Parameter]
$creadList :: ReadS [Parameter]
readsPrec :: Int -> ReadS Parameter
$creadsPrec :: Int -> ReadS Parameter
Prelude.Read, Int -> Parameter -> ShowS
[Parameter] -> ShowS
Parameter -> String
(Int -> Parameter -> ShowS)
-> (Parameter -> String)
-> ([Parameter] -> ShowS)
-> Show Parameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Parameter] -> ShowS
$cshowList :: [Parameter] -> ShowS
show :: Parameter -> String
$cshow :: Parameter -> String
showsPrec :: Int -> Parameter -> ShowS
$cshowsPrec :: Int -> Parameter -> ShowS
Prelude.Show, (forall x. Parameter -> Rep Parameter x)
-> (forall x. Rep Parameter x -> Parameter) -> Generic Parameter
forall x. Rep Parameter x -> Parameter
forall x. Parameter -> Rep Parameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Parameter x -> Parameter
$cfrom :: forall x. Parameter -> Rep Parameter x
Prelude.Generic)

-- |
-- Create a value of 'Parameter' 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:
--
-- 'parameterValue', 'parameter_parameterValue' - The input value associated with the parameter.
--
-- 'resolvedValue', 'parameter_resolvedValue' - Read-only. The value that corresponds to a Systems Manager parameter
-- key. This field is returned only for
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#aws-ssm-parameter-types SSM parameter types>
-- in the template.
--
-- 'parameterKey', 'parameter_parameterKey' - The key associated with the parameter. If you don\'t specify a key and
-- value for a particular parameter, CloudFormation uses the default value
-- that is specified in your template.
--
-- 'usePreviousValue', 'parameter_usePreviousValue' - During a stack update, use the existing parameter value that the stack
-- is using for a given parameter key. If you specify @true@, do not
-- specify a parameter value.
newParameter ::
  Parameter
newParameter :: Parameter
newParameter =
  Parameter' :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Bool -> Parameter
Parameter'
    { $sel:parameterValue:Parameter' :: Maybe Text
parameterValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resolvedValue:Parameter' :: Maybe Text
resolvedValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parameterKey:Parameter' :: Maybe Text
parameterKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:usePreviousValue:Parameter' :: Maybe Bool
usePreviousValue = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The input value associated with the parameter.
parameter_parameterValue :: Lens.Lens' Parameter (Prelude.Maybe Prelude.Text)
parameter_parameterValue :: (Maybe Text -> f (Maybe Text)) -> Parameter -> f Parameter
parameter_parameterValue = (Parameter -> Maybe Text)
-> (Parameter -> Maybe Text -> Parameter)
-> Lens Parameter Parameter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Parameter' {Maybe Text
parameterValue :: Maybe Text
$sel:parameterValue:Parameter' :: Parameter -> Maybe Text
parameterValue} -> Maybe Text
parameterValue) (\s :: Parameter
s@Parameter' {} Maybe Text
a -> Parameter
s {$sel:parameterValue:Parameter' :: Maybe Text
parameterValue = Maybe Text
a} :: Parameter)

-- | Read-only. The value that corresponds to a Systems Manager parameter
-- key. This field is returned only for
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#aws-ssm-parameter-types SSM parameter types>
-- in the template.
parameter_resolvedValue :: Lens.Lens' Parameter (Prelude.Maybe Prelude.Text)
parameter_resolvedValue :: (Maybe Text -> f (Maybe Text)) -> Parameter -> f Parameter
parameter_resolvedValue = (Parameter -> Maybe Text)
-> (Parameter -> Maybe Text -> Parameter)
-> Lens Parameter Parameter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Parameter' {Maybe Text
resolvedValue :: Maybe Text
$sel:resolvedValue:Parameter' :: Parameter -> Maybe Text
resolvedValue} -> Maybe Text
resolvedValue) (\s :: Parameter
s@Parameter' {} Maybe Text
a -> Parameter
s {$sel:resolvedValue:Parameter' :: Maybe Text
resolvedValue = Maybe Text
a} :: Parameter)

-- | The key associated with the parameter. If you don\'t specify a key and
-- value for a particular parameter, CloudFormation uses the default value
-- that is specified in your template.
parameter_parameterKey :: Lens.Lens' Parameter (Prelude.Maybe Prelude.Text)
parameter_parameterKey :: (Maybe Text -> f (Maybe Text)) -> Parameter -> f Parameter
parameter_parameterKey = (Parameter -> Maybe Text)
-> (Parameter -> Maybe Text -> Parameter)
-> Lens Parameter Parameter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Parameter' {Maybe Text
parameterKey :: Maybe Text
$sel:parameterKey:Parameter' :: Parameter -> Maybe Text
parameterKey} -> Maybe Text
parameterKey) (\s :: Parameter
s@Parameter' {} Maybe Text
a -> Parameter
s {$sel:parameterKey:Parameter' :: Maybe Text
parameterKey = Maybe Text
a} :: Parameter)

-- | During a stack update, use the existing parameter value that the stack
-- is using for a given parameter key. If you specify @true@, do not
-- specify a parameter value.
parameter_usePreviousValue :: Lens.Lens' Parameter (Prelude.Maybe Prelude.Bool)
parameter_usePreviousValue :: (Maybe Bool -> f (Maybe Bool)) -> Parameter -> f Parameter
parameter_usePreviousValue = (Parameter -> Maybe Bool)
-> (Parameter -> Maybe Bool -> Parameter)
-> Lens Parameter Parameter (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Parameter' {Maybe Bool
usePreviousValue :: Maybe Bool
$sel:usePreviousValue:Parameter' :: Parameter -> Maybe Bool
usePreviousValue} -> Maybe Bool
usePreviousValue) (\s :: Parameter
s@Parameter' {} Maybe Bool
a -> Parameter
s {$sel:usePreviousValue:Parameter' :: Maybe Bool
usePreviousValue = Maybe Bool
a} :: Parameter)

instance Core.FromXML Parameter where
  parseXML :: [Node] -> Either String Parameter
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe Text -> Maybe Bool -> Parameter
Parameter'
      (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Bool -> Parameter)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> Maybe Bool -> Parameter)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ParameterValue")
      Either String (Maybe Text -> Maybe Text -> Maybe Bool -> Parameter)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Bool -> Parameter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ResolvedValue")
      Either String (Maybe Text -> Maybe Bool -> Parameter)
-> Either String (Maybe Text)
-> Either String (Maybe Bool -> Parameter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ParameterKey")
      Either String (Maybe Bool -> Parameter)
-> Either String (Maybe Bool) -> Either String Parameter
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"UsePreviousValue")

instance Prelude.Hashable Parameter

instance Prelude.NFData Parameter

instance Core.ToQuery Parameter where
  toQuery :: Parameter -> QueryString
toQuery Parameter' {Maybe Bool
Maybe Text
usePreviousValue :: Maybe Bool
parameterKey :: Maybe Text
resolvedValue :: Maybe Text
parameterValue :: Maybe Text
$sel:usePreviousValue:Parameter' :: Parameter -> Maybe Bool
$sel:parameterKey:Parameter' :: Parameter -> Maybe Text
$sel:resolvedValue:Parameter' :: Parameter -> Maybe Text
$sel:parameterValue:Parameter' :: Parameter -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"ParameterValue" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
parameterValue,
        ByteString
"ResolvedValue" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
resolvedValue,
        ByteString
"ParameterKey" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
parameterKey,
        ByteString
"UsePreviousValue" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
usePreviousValue
      ]