{-# 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.QuickSight.Types.StringParameterDeclaration
-- 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.QuickSight.Types.StringParameterDeclaration 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
import Amazonka.QuickSight.Types.ParameterValueType
import Amazonka.QuickSight.Types.StringDefaultValues
import Amazonka.QuickSight.Types.StringValueWhenUnsetConfiguration

-- | A parameter declaration for the @String@ data type.
--
-- /See:/ 'newStringParameterDeclaration' smart constructor.
data StringParameterDeclaration = StringParameterDeclaration'
  { -- | The default values of a parameter. If the parameter is a single-value
    -- parameter, a maximum of one default value can be provided.
    StringParameterDeclaration -> Maybe StringDefaultValues
defaultValues :: Prelude.Maybe StringDefaultValues,
    -- | The configuration that defines the default value of a @String@ parameter
    -- when a value has not been set.
    StringParameterDeclaration
-> Maybe StringValueWhenUnsetConfiguration
valueWhenUnset :: Prelude.Maybe StringValueWhenUnsetConfiguration,
    -- | The value type determines whether the parameter is a single-value or
    -- multi-value parameter.
    StringParameterDeclaration -> ParameterValueType
parameterValueType :: ParameterValueType,
    -- | The name of the parameter that is being declared.
    StringParameterDeclaration -> Text
name :: Prelude.Text
  }
  deriving (StringParameterDeclaration -> StringParameterDeclaration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StringParameterDeclaration -> StringParameterDeclaration -> Bool
$c/= :: StringParameterDeclaration -> StringParameterDeclaration -> Bool
== :: StringParameterDeclaration -> StringParameterDeclaration -> Bool
$c== :: StringParameterDeclaration -> StringParameterDeclaration -> Bool
Prelude.Eq, Int -> StringParameterDeclaration -> ShowS
[StringParameterDeclaration] -> ShowS
StringParameterDeclaration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StringParameterDeclaration] -> ShowS
$cshowList :: [StringParameterDeclaration] -> ShowS
show :: StringParameterDeclaration -> String
$cshow :: StringParameterDeclaration -> String
showsPrec :: Int -> StringParameterDeclaration -> ShowS
$cshowsPrec :: Int -> StringParameterDeclaration -> ShowS
Prelude.Show, forall x.
Rep StringParameterDeclaration x -> StringParameterDeclaration
forall x.
StringParameterDeclaration -> Rep StringParameterDeclaration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StringParameterDeclaration x -> StringParameterDeclaration
$cfrom :: forall x.
StringParameterDeclaration -> Rep StringParameterDeclaration x
Prelude.Generic)

-- |
-- Create a value of 'StringParameterDeclaration' 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:
--
-- 'defaultValues', 'stringParameterDeclaration_defaultValues' - The default values of a parameter. If the parameter is a single-value
-- parameter, a maximum of one default value can be provided.
--
-- 'valueWhenUnset', 'stringParameterDeclaration_valueWhenUnset' - The configuration that defines the default value of a @String@ parameter
-- when a value has not been set.
--
-- 'parameterValueType', 'stringParameterDeclaration_parameterValueType' - The value type determines whether the parameter is a single-value or
-- multi-value parameter.
--
-- 'name', 'stringParameterDeclaration_name' - The name of the parameter that is being declared.
newStringParameterDeclaration ::
  -- | 'parameterValueType'
  ParameterValueType ->
  -- | 'name'
  Prelude.Text ->
  StringParameterDeclaration
newStringParameterDeclaration :: ParameterValueType -> Text -> StringParameterDeclaration
newStringParameterDeclaration
  ParameterValueType
pParameterValueType_
  Text
pName_ =
    StringParameterDeclaration'
      { $sel:defaultValues:StringParameterDeclaration' :: Maybe StringDefaultValues
defaultValues =
          forall a. Maybe a
Prelude.Nothing,
        $sel:valueWhenUnset:StringParameterDeclaration' :: Maybe StringValueWhenUnsetConfiguration
valueWhenUnset = forall a. Maybe a
Prelude.Nothing,
        $sel:parameterValueType:StringParameterDeclaration' :: ParameterValueType
parameterValueType = ParameterValueType
pParameterValueType_,
        $sel:name:StringParameterDeclaration' :: Text
name = Text
pName_
      }

-- | The default values of a parameter. If the parameter is a single-value
-- parameter, a maximum of one default value can be provided.
stringParameterDeclaration_defaultValues :: Lens.Lens' StringParameterDeclaration (Prelude.Maybe StringDefaultValues)
stringParameterDeclaration_defaultValues :: Lens' StringParameterDeclaration (Maybe StringDefaultValues)
stringParameterDeclaration_defaultValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringParameterDeclaration' {Maybe StringDefaultValues
defaultValues :: Maybe StringDefaultValues
$sel:defaultValues:StringParameterDeclaration' :: StringParameterDeclaration -> Maybe StringDefaultValues
defaultValues} -> Maybe StringDefaultValues
defaultValues) (\s :: StringParameterDeclaration
s@StringParameterDeclaration' {} Maybe StringDefaultValues
a -> StringParameterDeclaration
s {$sel:defaultValues:StringParameterDeclaration' :: Maybe StringDefaultValues
defaultValues = Maybe StringDefaultValues
a} :: StringParameterDeclaration)

-- | The configuration that defines the default value of a @String@ parameter
-- when a value has not been set.
stringParameterDeclaration_valueWhenUnset :: Lens.Lens' StringParameterDeclaration (Prelude.Maybe StringValueWhenUnsetConfiguration)
stringParameterDeclaration_valueWhenUnset :: Lens'
  StringParameterDeclaration
  (Maybe StringValueWhenUnsetConfiguration)
stringParameterDeclaration_valueWhenUnset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringParameterDeclaration' {Maybe StringValueWhenUnsetConfiguration
valueWhenUnset :: Maybe StringValueWhenUnsetConfiguration
$sel:valueWhenUnset:StringParameterDeclaration' :: StringParameterDeclaration
-> Maybe StringValueWhenUnsetConfiguration
valueWhenUnset} -> Maybe StringValueWhenUnsetConfiguration
valueWhenUnset) (\s :: StringParameterDeclaration
s@StringParameterDeclaration' {} Maybe StringValueWhenUnsetConfiguration
a -> StringParameterDeclaration
s {$sel:valueWhenUnset:StringParameterDeclaration' :: Maybe StringValueWhenUnsetConfiguration
valueWhenUnset = Maybe StringValueWhenUnsetConfiguration
a} :: StringParameterDeclaration)

-- | The value type determines whether the parameter is a single-value or
-- multi-value parameter.
stringParameterDeclaration_parameterValueType :: Lens.Lens' StringParameterDeclaration ParameterValueType
stringParameterDeclaration_parameterValueType :: Lens' StringParameterDeclaration ParameterValueType
stringParameterDeclaration_parameterValueType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringParameterDeclaration' {ParameterValueType
parameterValueType :: ParameterValueType
$sel:parameterValueType:StringParameterDeclaration' :: StringParameterDeclaration -> ParameterValueType
parameterValueType} -> ParameterValueType
parameterValueType) (\s :: StringParameterDeclaration
s@StringParameterDeclaration' {} ParameterValueType
a -> StringParameterDeclaration
s {$sel:parameterValueType:StringParameterDeclaration' :: ParameterValueType
parameterValueType = ParameterValueType
a} :: StringParameterDeclaration)

-- | The name of the parameter that is being declared.
stringParameterDeclaration_name :: Lens.Lens' StringParameterDeclaration Prelude.Text
stringParameterDeclaration_name :: Lens' StringParameterDeclaration Text
stringParameterDeclaration_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringParameterDeclaration' {Text
name :: Text
$sel:name:StringParameterDeclaration' :: StringParameterDeclaration -> Text
name} -> Text
name) (\s :: StringParameterDeclaration
s@StringParameterDeclaration' {} Text
a -> StringParameterDeclaration
s {$sel:name:StringParameterDeclaration' :: Text
name = Text
a} :: StringParameterDeclaration)

instance Data.FromJSON StringParameterDeclaration where
  parseJSON :: Value -> Parser StringParameterDeclaration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StringParameterDeclaration"
      ( \Object
x ->
          Maybe StringDefaultValues
-> Maybe StringValueWhenUnsetConfiguration
-> ParameterValueType
-> Text
-> StringParameterDeclaration
StringParameterDeclaration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DefaultValues")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ValueWhenUnset")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ParameterValueType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
      )

instance Prelude.Hashable StringParameterDeclaration where
  hashWithSalt :: Int -> StringParameterDeclaration -> Int
hashWithSalt Int
_salt StringParameterDeclaration' {Maybe StringDefaultValues
Maybe StringValueWhenUnsetConfiguration
Text
ParameterValueType
name :: Text
parameterValueType :: ParameterValueType
valueWhenUnset :: Maybe StringValueWhenUnsetConfiguration
defaultValues :: Maybe StringDefaultValues
$sel:name:StringParameterDeclaration' :: StringParameterDeclaration -> Text
$sel:parameterValueType:StringParameterDeclaration' :: StringParameterDeclaration -> ParameterValueType
$sel:valueWhenUnset:StringParameterDeclaration' :: StringParameterDeclaration
-> Maybe StringValueWhenUnsetConfiguration
$sel:defaultValues:StringParameterDeclaration' :: StringParameterDeclaration -> Maybe StringDefaultValues
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StringDefaultValues
defaultValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StringValueWhenUnsetConfiguration
valueWhenUnset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ParameterValueType
parameterValueType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData StringParameterDeclaration where
  rnf :: StringParameterDeclaration -> ()
rnf StringParameterDeclaration' {Maybe StringDefaultValues
Maybe StringValueWhenUnsetConfiguration
Text
ParameterValueType
name :: Text
parameterValueType :: ParameterValueType
valueWhenUnset :: Maybe StringValueWhenUnsetConfiguration
defaultValues :: Maybe StringDefaultValues
$sel:name:StringParameterDeclaration' :: StringParameterDeclaration -> Text
$sel:parameterValueType:StringParameterDeclaration' :: StringParameterDeclaration -> ParameterValueType
$sel:valueWhenUnset:StringParameterDeclaration' :: StringParameterDeclaration
-> Maybe StringValueWhenUnsetConfiguration
$sel:defaultValues:StringParameterDeclaration' :: StringParameterDeclaration -> Maybe StringDefaultValues
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StringDefaultValues
defaultValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StringValueWhenUnsetConfiguration
valueWhenUnset
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ParameterValueType
parameterValueType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToJSON StringParameterDeclaration where
  toJSON :: StringParameterDeclaration -> Value
toJSON StringParameterDeclaration' {Maybe StringDefaultValues
Maybe StringValueWhenUnsetConfiguration
Text
ParameterValueType
name :: Text
parameterValueType :: ParameterValueType
valueWhenUnset :: Maybe StringValueWhenUnsetConfiguration
defaultValues :: Maybe StringDefaultValues
$sel:name:StringParameterDeclaration' :: StringParameterDeclaration -> Text
$sel:parameterValueType:StringParameterDeclaration' :: StringParameterDeclaration -> ParameterValueType
$sel:valueWhenUnset:StringParameterDeclaration' :: StringParameterDeclaration
-> Maybe StringValueWhenUnsetConfiguration
$sel:defaultValues:StringParameterDeclaration' :: StringParameterDeclaration -> Maybe StringDefaultValues
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DefaultValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StringDefaultValues
defaultValues,
            (Key
"ValueWhenUnset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StringValueWhenUnsetConfiguration
valueWhenUnset,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ParameterValueType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ParameterValueType
parameterValueType),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )