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

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

-- | The constraints that the administrator has put on the parameter.
--
-- /See:/ 'newParameterConstraints' smart constructor.
data ParameterConstraints = ParameterConstraints'
  { -- | A numeric value that determines the largest numeric value you want to
    -- allow for @Number@ types.
    ParameterConstraints -> Maybe Text
maxValue :: Prelude.Maybe Prelude.Text,
    -- | An integer value that determines the largest number of characters you
    -- want to allow for @String@ types.
    ParameterConstraints -> Maybe Text
maxLength :: Prelude.Maybe Prelude.Text,
    -- | A string that explains a constraint when the constraint is violated. For
    -- example, without a constraint description, a parameter that has an
    -- allowed pattern of @[A-Za-z0-9]+@ displays the following error message
    -- when the user specifies an invalid value:
    --
    -- @Malformed input-Parameter MyParameter must match pattern [A-Za-z0-9]+@
    --
    -- By adding a constraint description, such as must only contain letters
    -- (uppercase and lowercase) and numbers, you can display the following
    -- customized error message:
    --
    -- @Malformed input-Parameter MyParameter must only contain uppercase and lowercase letters and numbers.@
    ParameterConstraints -> Maybe Text
constraintDescription :: Prelude.Maybe Prelude.Text,
    -- | An integer value that determines the smallest number of characters you
    -- want to allow for @String@ types.
    ParameterConstraints -> Maybe Text
minLength :: Prelude.Maybe Prelude.Text,
    -- | A regular expression that represents the patterns that allow for
    -- @String@ types. The pattern must match the entire parameter value
    -- provided.
    ParameterConstraints -> Maybe Text
allowedPattern :: Prelude.Maybe Prelude.Text,
    -- | The values that the administrator has allowed for the parameter.
    ParameterConstraints -> Maybe [Text]
allowedValues :: Prelude.Maybe [Prelude.Text],
    -- | A numeric value that determines the smallest numeric value you want to
    -- allow for @Number@ types.
    ParameterConstraints -> Maybe Text
minValue :: Prelude.Maybe Prelude.Text
  }
  deriving (ParameterConstraints -> ParameterConstraints -> Bool
(ParameterConstraints -> ParameterConstraints -> Bool)
-> (ParameterConstraints -> ParameterConstraints -> Bool)
-> Eq ParameterConstraints
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]
(Int -> ReadS ParameterConstraints)
-> ReadS [ParameterConstraints]
-> ReadPrec ParameterConstraints
-> ReadPrec [ParameterConstraints]
-> Read 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
(Int -> ParameterConstraints -> ShowS)
-> (ParameterConstraints -> String)
-> ([ParameterConstraints] -> ShowS)
-> Show ParameterConstraints
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. ParameterConstraints -> Rep ParameterConstraints x)
-> (forall x. Rep ParameterConstraints x -> ParameterConstraints)
-> Generic ParameterConstraints
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:
--
-- 'maxValue', 'parameterConstraints_maxValue' - A numeric value that determines the largest numeric value you want to
-- allow for @Number@ types.
--
-- 'maxLength', 'parameterConstraints_maxLength' - An integer value that determines the largest number of characters you
-- want to allow for @String@ types.
--
-- 'constraintDescription', 'parameterConstraints_constraintDescription' - A string that explains a constraint when the constraint is violated. For
-- example, without a constraint description, a parameter that has an
-- allowed pattern of @[A-Za-z0-9]+@ displays the following error message
-- when the user specifies an invalid value:
--
-- @Malformed input-Parameter MyParameter must match pattern [A-Za-z0-9]+@
--
-- By adding a constraint description, such as must only contain letters
-- (uppercase and lowercase) and numbers, you can display the following
-- customized error message:
--
-- @Malformed input-Parameter MyParameter must only contain uppercase and lowercase letters and numbers.@
--
-- 'minLength', 'parameterConstraints_minLength' - An integer value that determines the smallest number of characters you
-- want to allow for @String@ types.
--
-- 'allowedPattern', 'parameterConstraints_allowedPattern' - A regular expression that represents the patterns that allow for
-- @String@ types. The pattern must match the entire parameter value
-- provided.
--
-- 'allowedValues', 'parameterConstraints_allowedValues' - The values that the administrator has allowed for the parameter.
--
-- 'minValue', 'parameterConstraints_minValue' - A numeric value that determines the smallest numeric value you want to
-- allow for @Number@ types.
newParameterConstraints ::
  ParameterConstraints
newParameterConstraints :: ParameterConstraints
newParameterConstraints =
  ParameterConstraints' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> ParameterConstraints
ParameterConstraints'
    { $sel:maxValue:ParameterConstraints' :: Maybe Text
maxValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxLength:ParameterConstraints' :: Maybe Text
maxLength = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:constraintDescription:ParameterConstraints' :: Maybe Text
constraintDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:minLength:ParameterConstraints' :: Maybe Text
minLength = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:allowedPattern:ParameterConstraints' :: Maybe Text
allowedPattern = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:allowedValues:ParameterConstraints' :: Maybe [Text]
allowedValues = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:minValue:ParameterConstraints' :: Maybe Text
minValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A numeric value that determines the largest numeric value you want to
-- allow for @Number@ types.
parameterConstraints_maxValue :: Lens.Lens' ParameterConstraints (Prelude.Maybe Prelude.Text)
parameterConstraints_maxValue :: (Maybe Text -> f (Maybe Text))
-> ParameterConstraints -> f ParameterConstraints
parameterConstraints_maxValue = (ParameterConstraints -> Maybe Text)
-> (ParameterConstraints -> Maybe Text -> ParameterConstraints)
-> Lens
     ParameterConstraints ParameterConstraints (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterConstraints' {Maybe Text
maxValue :: Maybe Text
$sel:maxValue:ParameterConstraints' :: ParameterConstraints -> Maybe Text
maxValue} -> Maybe Text
maxValue) (\s :: ParameterConstraints
s@ParameterConstraints' {} Maybe Text
a -> ParameterConstraints
s {$sel:maxValue:ParameterConstraints' :: Maybe Text
maxValue = Maybe Text
a} :: ParameterConstraints)

-- | An integer value that determines the largest number of characters you
-- want to allow for @String@ types.
parameterConstraints_maxLength :: Lens.Lens' ParameterConstraints (Prelude.Maybe Prelude.Text)
parameterConstraints_maxLength :: (Maybe Text -> f (Maybe Text))
-> ParameterConstraints -> f ParameterConstraints
parameterConstraints_maxLength = (ParameterConstraints -> Maybe Text)
-> (ParameterConstraints -> Maybe Text -> ParameterConstraints)
-> Lens
     ParameterConstraints ParameterConstraints (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterConstraints' {Maybe Text
maxLength :: Maybe Text
$sel:maxLength:ParameterConstraints' :: ParameterConstraints -> Maybe Text
maxLength} -> Maybe Text
maxLength) (\s :: ParameterConstraints
s@ParameterConstraints' {} Maybe Text
a -> ParameterConstraints
s {$sel:maxLength:ParameterConstraints' :: Maybe Text
maxLength = Maybe Text
a} :: ParameterConstraints)

-- | A string that explains a constraint when the constraint is violated. For
-- example, without a constraint description, a parameter that has an
-- allowed pattern of @[A-Za-z0-9]+@ displays the following error message
-- when the user specifies an invalid value:
--
-- @Malformed input-Parameter MyParameter must match pattern [A-Za-z0-9]+@
--
-- By adding a constraint description, such as must only contain letters
-- (uppercase and lowercase) and numbers, you can display the following
-- customized error message:
--
-- @Malformed input-Parameter MyParameter must only contain uppercase and lowercase letters and numbers.@
parameterConstraints_constraintDescription :: Lens.Lens' ParameterConstraints (Prelude.Maybe Prelude.Text)
parameterConstraints_constraintDescription :: (Maybe Text -> f (Maybe Text))
-> ParameterConstraints -> f ParameterConstraints
parameterConstraints_constraintDescription = (ParameterConstraints -> Maybe Text)
-> (ParameterConstraints -> Maybe Text -> ParameterConstraints)
-> Lens
     ParameterConstraints ParameterConstraints (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterConstraints' {Maybe Text
constraintDescription :: Maybe Text
$sel:constraintDescription:ParameterConstraints' :: ParameterConstraints -> Maybe Text
constraintDescription} -> Maybe Text
constraintDescription) (\s :: ParameterConstraints
s@ParameterConstraints' {} Maybe Text
a -> ParameterConstraints
s {$sel:constraintDescription:ParameterConstraints' :: Maybe Text
constraintDescription = Maybe Text
a} :: ParameterConstraints)

-- | An integer value that determines the smallest number of characters you
-- want to allow for @String@ types.
parameterConstraints_minLength :: Lens.Lens' ParameterConstraints (Prelude.Maybe Prelude.Text)
parameterConstraints_minLength :: (Maybe Text -> f (Maybe Text))
-> ParameterConstraints -> f ParameterConstraints
parameterConstraints_minLength = (ParameterConstraints -> Maybe Text)
-> (ParameterConstraints -> Maybe Text -> ParameterConstraints)
-> Lens
     ParameterConstraints ParameterConstraints (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterConstraints' {Maybe Text
minLength :: Maybe Text
$sel:minLength:ParameterConstraints' :: ParameterConstraints -> Maybe Text
minLength} -> Maybe Text
minLength) (\s :: ParameterConstraints
s@ParameterConstraints' {} Maybe Text
a -> ParameterConstraints
s {$sel:minLength:ParameterConstraints' :: Maybe Text
minLength = Maybe Text
a} :: ParameterConstraints)

-- | A regular expression that represents the patterns that allow for
-- @String@ types. The pattern must match the entire parameter value
-- provided.
parameterConstraints_allowedPattern :: Lens.Lens' ParameterConstraints (Prelude.Maybe Prelude.Text)
parameterConstraints_allowedPattern :: (Maybe Text -> f (Maybe Text))
-> ParameterConstraints -> f ParameterConstraints
parameterConstraints_allowedPattern = (ParameterConstraints -> Maybe Text)
-> (ParameterConstraints -> Maybe Text -> ParameterConstraints)
-> Lens
     ParameterConstraints ParameterConstraints (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterConstraints' {Maybe Text
allowedPattern :: Maybe Text
$sel:allowedPattern:ParameterConstraints' :: ParameterConstraints -> Maybe Text
allowedPattern} -> Maybe Text
allowedPattern) (\s :: ParameterConstraints
s@ParameterConstraints' {} Maybe Text
a -> ParameterConstraints
s {$sel:allowedPattern:ParameterConstraints' :: Maybe Text
allowedPattern = Maybe Text
a} :: ParameterConstraints)

-- | The values that the administrator has allowed for the parameter.
parameterConstraints_allowedValues :: Lens.Lens' ParameterConstraints (Prelude.Maybe [Prelude.Text])
parameterConstraints_allowedValues :: (Maybe [Text] -> f (Maybe [Text]))
-> ParameterConstraints -> f ParameterConstraints
parameterConstraints_allowedValues = (ParameterConstraints -> Maybe [Text])
-> (ParameterConstraints -> Maybe [Text] -> ParameterConstraints)
-> Lens
     ParameterConstraints
     ParameterConstraints
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ParameterConstraints -> f ParameterConstraints)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ParameterConstraints
-> f ParameterConstraints
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A numeric value that determines the smallest numeric value you want to
-- allow for @Number@ types.
parameterConstraints_minValue :: Lens.Lens' ParameterConstraints (Prelude.Maybe Prelude.Text)
parameterConstraints_minValue :: (Maybe Text -> f (Maybe Text))
-> ParameterConstraints -> f ParameterConstraints
parameterConstraints_minValue = (ParameterConstraints -> Maybe Text)
-> (ParameterConstraints -> Maybe Text -> ParameterConstraints)
-> Lens
     ParameterConstraints ParameterConstraints (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterConstraints' {Maybe Text
minValue :: Maybe Text
$sel:minValue:ParameterConstraints' :: ParameterConstraints -> Maybe Text
minValue} -> Maybe Text
minValue) (\s :: ParameterConstraints
s@ParameterConstraints' {} Maybe Text
a -> ParameterConstraints
s {$sel:minValue:ParameterConstraints' :: Maybe Text
minValue = Maybe Text
a} :: ParameterConstraints)

instance Core.FromJSON ParameterConstraints where
  parseJSON :: Value -> Parser ParameterConstraints
parseJSON =
    String
-> (Object -> Parser ParameterConstraints)
-> Value
-> Parser ParameterConstraints
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ParameterConstraints"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> ParameterConstraints
ParameterConstraints'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe [Text]
 -> Maybe Text
 -> ParameterConstraints)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe Text
      -> ParameterConstraints)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxValue")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe Text
   -> ParameterConstraints)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe Text
      -> ParameterConstraints)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxLength")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe Text
   -> ParameterConstraints)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe Text
      -> ParameterConstraints)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConstraintDescription")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe Text
   -> ParameterConstraints)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe [Text] -> Maybe Text -> ParameterConstraints)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MinLength")
            Parser
  (Maybe Text -> Maybe [Text] -> Maybe Text -> ParameterConstraints)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> Maybe Text -> ParameterConstraints)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowedPattern")
            Parser (Maybe [Text] -> Maybe Text -> ParameterConstraints)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> ParameterConstraints)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowedValues" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> ParameterConstraints)
-> Parser (Maybe Text) -> Parser ParameterConstraints
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MinValue")
      )

instance Prelude.Hashable ParameterConstraints

instance Prelude.NFData ParameterConstraints