{-# 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.ParameterConstraints
-- 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.ParameterConstraints 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

-- | A set of criteria that CloudFormation uses to validate parameter values.
-- Although other constraints might be defined in the stack template,
-- CloudFormation returns only the @AllowedValues@ property.
--
-- /See:/ 'newParameterConstraints' smart constructor.
data ParameterConstraints = ParameterConstraints'
  { -- | A list of values that are permitted for a parameter.
    ParameterConstraints -> Maybe [Text]
allowedValues :: Prelude.Maybe [Prelude.Text]
  }
  deriving (ParameterConstraints -> ParameterConstraints -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterConstraints -> ParameterConstraints -> Bool
$c/= :: ParameterConstraints -> ParameterConstraints -> Bool
== :: ParameterConstraints -> ParameterConstraints -> Bool
$c== :: ParameterConstraints -> ParameterConstraints -> Bool
Prelude.Eq, ReadPrec [ParameterConstraints]
ReadPrec ParameterConstraints
Int -> ReadS ParameterConstraints
ReadS [ParameterConstraints]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParameterConstraints]
$creadListPrec :: ReadPrec [ParameterConstraints]
readPrec :: ReadPrec ParameterConstraints
$creadPrec :: ReadPrec ParameterConstraints
readList :: ReadS [ParameterConstraints]
$creadList :: ReadS [ParameterConstraints]
readsPrec :: Int -> ReadS ParameterConstraints
$creadsPrec :: Int -> ReadS ParameterConstraints
Prelude.Read, Int -> ParameterConstraints -> ShowS
[ParameterConstraints] -> ShowS
ParameterConstraints -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterConstraints] -> ShowS
$cshowList :: [ParameterConstraints] -> ShowS
show :: ParameterConstraints -> String
$cshow :: ParameterConstraints -> String
showsPrec :: Int -> ParameterConstraints -> ShowS
$cshowsPrec :: Int -> ParameterConstraints -> ShowS
Prelude.Show, forall x. Rep ParameterConstraints x -> ParameterConstraints
forall x. ParameterConstraints -> Rep ParameterConstraints x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParameterConstraints x -> ParameterConstraints
$cfrom :: forall x. ParameterConstraints -> Rep ParameterConstraints x
Prelude.Generic)

-- |
-- Create a value of 'ParameterConstraints' 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:
--
-- 'allowedValues', 'parameterConstraints_allowedValues' - A list of values that are permitted for a parameter.
newParameterConstraints ::
  ParameterConstraints
newParameterConstraints :: ParameterConstraints
newParameterConstraints =
  ParameterConstraints'
    { $sel:allowedValues:ParameterConstraints' :: Maybe [Text]
allowedValues =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A list of values that are permitted for a parameter.
parameterConstraints_allowedValues :: Lens.Lens' ParameterConstraints (Prelude.Maybe [Prelude.Text])
parameterConstraints_allowedValues :: Lens' ParameterConstraints (Maybe [Text])
parameterConstraints_allowedValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterConstraints' {Maybe [Text]
allowedValues :: Maybe [Text]
$sel:allowedValues:ParameterConstraints' :: ParameterConstraints -> Maybe [Text]
allowedValues} -> Maybe [Text]
allowedValues) (\s :: ParameterConstraints
s@ParameterConstraints' {} Maybe [Text]
a -> ParameterConstraints
s {$sel:allowedValues:ParameterConstraints' :: Maybe [Text]
allowedValues = Maybe [Text]
a} :: ParameterConstraints) 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

instance Data.FromXML ParameterConstraints where
  parseXML :: [Node] -> Either String ParameterConstraints
parseXML [Node]
x =
    Maybe [Text] -> ParameterConstraints
ParameterConstraints'
      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
"AllowedValues"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                  )

instance Prelude.Hashable ParameterConstraints where
  hashWithSalt :: Int -> ParameterConstraints -> Int
hashWithSalt Int
_salt ParameterConstraints' {Maybe [Text]
allowedValues :: Maybe [Text]
$sel:allowedValues:ParameterConstraints' :: ParameterConstraints -> Maybe [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
allowedValues

instance Prelude.NFData ParameterConstraints where
  rnf :: ParameterConstraints -> ()
rnf ParameterConstraints' {Maybe [Text]
allowedValues :: Maybe [Text]
$sel:allowedValues:ParameterConstraints' :: ParameterConstraints -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
allowedValues