{-# 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.DecimalParameterDeclaration
-- 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.DecimalParameterDeclaration 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.DecimalDefaultValues
import Amazonka.QuickSight.Types.DecimalValueWhenUnsetConfiguration
import Amazonka.QuickSight.Types.ParameterValueType

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

-- |
-- Create a value of 'DecimalParameterDeclaration' 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', 'decimalParameterDeclaration_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', 'decimalParameterDeclaration_valueWhenUnset' - The configuration that defines the default value of a @Decimal@
-- parameter when a value has not been set.
--
-- 'parameterValueType', 'decimalParameterDeclaration_parameterValueType' - The value type determines whether the parameter is a single-value or
-- multi-value parameter.
--
-- 'name', 'decimalParameterDeclaration_name' - The name of the parameter that is being declared.
newDecimalParameterDeclaration ::
  -- | 'parameterValueType'
  ParameterValueType ->
  -- | 'name'
  Prelude.Text ->
  DecimalParameterDeclaration
newDecimalParameterDeclaration :: ParameterValueType -> Text -> DecimalParameterDeclaration
newDecimalParameterDeclaration
  ParameterValueType
pParameterValueType_
  Text
pName_ =
    DecimalParameterDeclaration'
      { $sel:defaultValues:DecimalParameterDeclaration' :: Maybe DecimalDefaultValues
defaultValues =
          forall a. Maybe a
Prelude.Nothing,
        $sel:valueWhenUnset:DecimalParameterDeclaration' :: Maybe DecimalValueWhenUnsetConfiguration
valueWhenUnset = forall a. Maybe a
Prelude.Nothing,
        $sel:parameterValueType:DecimalParameterDeclaration' :: ParameterValueType
parameterValueType = ParameterValueType
pParameterValueType_,
        $sel:name:DecimalParameterDeclaration' :: 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.
decimalParameterDeclaration_defaultValues :: Lens.Lens' DecimalParameterDeclaration (Prelude.Maybe DecimalDefaultValues)
decimalParameterDeclaration_defaultValues :: Lens' DecimalParameterDeclaration (Maybe DecimalDefaultValues)
decimalParameterDeclaration_defaultValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DecimalParameterDeclaration' {Maybe DecimalDefaultValues
defaultValues :: Maybe DecimalDefaultValues
$sel:defaultValues:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> Maybe DecimalDefaultValues
defaultValues} -> Maybe DecimalDefaultValues
defaultValues) (\s :: DecimalParameterDeclaration
s@DecimalParameterDeclaration' {} Maybe DecimalDefaultValues
a -> DecimalParameterDeclaration
s {$sel:defaultValues:DecimalParameterDeclaration' :: Maybe DecimalDefaultValues
defaultValues = Maybe DecimalDefaultValues
a} :: DecimalParameterDeclaration)

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

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

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

instance Data.FromJSON DecimalParameterDeclaration where
  parseJSON :: Value -> Parser DecimalParameterDeclaration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DecimalParameterDeclaration"
      ( \Object
x ->
          Maybe DecimalDefaultValues
-> Maybe DecimalValueWhenUnsetConfiguration
-> ParameterValueType
-> Text
-> DecimalParameterDeclaration
DecimalParameterDeclaration'
            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 DecimalParameterDeclaration where
  hashWithSalt :: Int -> DecimalParameterDeclaration -> Int
hashWithSalt Int
_salt DecimalParameterDeclaration' {Maybe DecimalDefaultValues
Maybe DecimalValueWhenUnsetConfiguration
Text
ParameterValueType
name :: Text
parameterValueType :: ParameterValueType
valueWhenUnset :: Maybe DecimalValueWhenUnsetConfiguration
defaultValues :: Maybe DecimalDefaultValues
$sel:name:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> Text
$sel:parameterValueType:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> ParameterValueType
$sel:valueWhenUnset:DecimalParameterDeclaration' :: DecimalParameterDeclaration
-> Maybe DecimalValueWhenUnsetConfiguration
$sel:defaultValues:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> Maybe DecimalDefaultValues
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DecimalDefaultValues
defaultValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DecimalValueWhenUnsetConfiguration
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 DecimalParameterDeclaration where
  rnf :: DecimalParameterDeclaration -> ()
rnf DecimalParameterDeclaration' {Maybe DecimalDefaultValues
Maybe DecimalValueWhenUnsetConfiguration
Text
ParameterValueType
name :: Text
parameterValueType :: ParameterValueType
valueWhenUnset :: Maybe DecimalValueWhenUnsetConfiguration
defaultValues :: Maybe DecimalDefaultValues
$sel:name:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> Text
$sel:parameterValueType:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> ParameterValueType
$sel:valueWhenUnset:DecimalParameterDeclaration' :: DecimalParameterDeclaration
-> Maybe DecimalValueWhenUnsetConfiguration
$sel:defaultValues:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> Maybe DecimalDefaultValues
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DecimalDefaultValues
defaultValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DecimalValueWhenUnsetConfiguration
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 DecimalParameterDeclaration where
  toJSON :: DecimalParameterDeclaration -> Value
toJSON DecimalParameterDeclaration' {Maybe DecimalDefaultValues
Maybe DecimalValueWhenUnsetConfiguration
Text
ParameterValueType
name :: Text
parameterValueType :: ParameterValueType
valueWhenUnset :: Maybe DecimalValueWhenUnsetConfiguration
defaultValues :: Maybe DecimalDefaultValues
$sel:name:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> Text
$sel:parameterValueType:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> ParameterValueType
$sel:valueWhenUnset:DecimalParameterDeclaration' :: DecimalParameterDeclaration
-> Maybe DecimalValueWhenUnsetConfiguration
$sel:defaultValues:DecimalParameterDeclaration' :: DecimalParameterDeclaration -> Maybe DecimalDefaultValues
..} =
    [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 DecimalDefaultValues
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 DecimalValueWhenUnsetConfiguration
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)
          ]
      )