{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudFormation.Types.Parameter where

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

-- | The Parameter data type.
--
-- /See:/ 'newParameter' smart constructor.
data Parameter = 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\'s specified in your template.
    Parameter -> Maybe Text
parameterKey :: Prelude.Maybe Prelude.Text,
    -- | The input value associated with the parameter.
    Parameter -> Maybe Text
parameterValue :: Prelude.Maybe Prelude.Text,
    -- | Read-only. The value that corresponds to a SSM 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,
    -- | 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
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]
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
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. 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:
--
-- '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\'s specified in your template.
--
-- 'parameterValue', 'parameter_parameterValue' - The input value associated with the parameter.
--
-- 'resolvedValue', 'parameter_resolvedValue' - Read-only. The value that corresponds to a SSM 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.
--
-- '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'
    { $sel:parameterKey:Parameter' :: Maybe Text
parameterKey = forall a. Maybe a
Prelude.Nothing,
      $sel:parameterValue:Parameter' :: Maybe Text
parameterValue = forall a. Maybe a
Prelude.Nothing,
      $sel:resolvedValue:Parameter' :: Maybe Text
resolvedValue = forall a. Maybe a
Prelude.Nothing,
      $sel:usePreviousValue:Parameter' :: Maybe Bool
usePreviousValue = forall a. Maybe a
Prelude.Nothing
    }

-- | 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\'s specified in your template.
parameter_parameterKey :: Lens.Lens' Parameter (Prelude.Maybe Prelude.Text)
parameter_parameterKey :: Lens' Parameter (Maybe Text)
parameter_parameterKey = 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)

-- | The input value associated with the parameter.
parameter_parameterValue :: Lens.Lens' Parameter (Prelude.Maybe Prelude.Text)
parameter_parameterValue :: Lens' Parameter (Maybe Text)
parameter_parameterValue = 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 SSM 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 :: Lens' Parameter (Maybe Text)
parameter_resolvedValue = 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)

-- | 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 :: Lens' Parameter (Maybe Bool)
parameter_usePreviousValue = 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 Data.FromXML Parameter where
  parseXML :: [Node] -> Either String Parameter
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe Text -> Maybe Bool -> Parameter
Parameter'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ParameterKey")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ParameterValue")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ResolvedValue")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"UsePreviousValue")

instance Prelude.Hashable Parameter where
  hashWithSalt :: Int -> Parameter -> Int
hashWithSalt Int
_salt Parameter' {Maybe Bool
Maybe Text
usePreviousValue :: Maybe Bool
resolvedValue :: Maybe Text
parameterValue :: Maybe Text
parameterKey :: Maybe Text
$sel:usePreviousValue:Parameter' :: Parameter -> Maybe Bool
$sel:resolvedValue:Parameter' :: Parameter -> Maybe Text
$sel:parameterValue:Parameter' :: Parameter -> Maybe Text
$sel:parameterKey:Parameter' :: Parameter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parameterKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parameterValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resolvedValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
usePreviousValue

instance Prelude.NFData Parameter where
  rnf :: Parameter -> ()
rnf Parameter' {Maybe Bool
Maybe Text
usePreviousValue :: Maybe Bool
resolvedValue :: Maybe Text
parameterValue :: Maybe Text
parameterKey :: Maybe Text
$sel:usePreviousValue:Parameter' :: Parameter -> Maybe Bool
$sel:resolvedValue:Parameter' :: Parameter -> Maybe Text
$sel:parameterValue:Parameter' :: Parameter -> Maybe Text
$sel:parameterKey:Parameter' :: Parameter -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parameterKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parameterValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resolvedValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
usePreviousValue

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