{-# 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.IntegerParameterDeclaration
-- 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.IntegerParameterDeclaration 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.IntegerDefaultValues
import Amazonka.QuickSight.Types.IntegerValueWhenUnsetConfiguration
import Amazonka.QuickSight.Types.ParameterValueType

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

-- |
-- Create a value of 'IntegerParameterDeclaration' 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', 'integerParameterDeclaration_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', 'integerParameterDeclaration_valueWhenUnset' - A parameter declaration for the @Integer@ data type.
--
-- 'parameterValueType', 'integerParameterDeclaration_parameterValueType' - The value type determines whether the parameter is a single-value or
-- multi-value parameter.
--
-- 'name', 'integerParameterDeclaration_name' - The name of the parameter that is being declared.
newIntegerParameterDeclaration ::
  -- | 'parameterValueType'
  ParameterValueType ->
  -- | 'name'
  Prelude.Text ->
  IntegerParameterDeclaration
newIntegerParameterDeclaration :: ParameterValueType -> Text -> IntegerParameterDeclaration
newIntegerParameterDeclaration
  ParameterValueType
pParameterValueType_
  Text
pName_ =
    IntegerParameterDeclaration'
      { $sel:defaultValues:IntegerParameterDeclaration' :: Maybe IntegerDefaultValues
defaultValues =
          forall a. Maybe a
Prelude.Nothing,
        $sel:valueWhenUnset:IntegerParameterDeclaration' :: Maybe IntegerValueWhenUnsetConfiguration
valueWhenUnset = forall a. Maybe a
Prelude.Nothing,
        $sel:parameterValueType:IntegerParameterDeclaration' :: ParameterValueType
parameterValueType = ParameterValueType
pParameterValueType_,
        $sel:name:IntegerParameterDeclaration' :: 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.
integerParameterDeclaration_defaultValues :: Lens.Lens' IntegerParameterDeclaration (Prelude.Maybe IntegerDefaultValues)
integerParameterDeclaration_defaultValues :: Lens' IntegerParameterDeclaration (Maybe IntegerDefaultValues)
integerParameterDeclaration_defaultValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntegerParameterDeclaration' {Maybe IntegerDefaultValues
defaultValues :: Maybe IntegerDefaultValues
$sel:defaultValues:IntegerParameterDeclaration' :: IntegerParameterDeclaration -> Maybe IntegerDefaultValues
defaultValues} -> Maybe IntegerDefaultValues
defaultValues) (\s :: IntegerParameterDeclaration
s@IntegerParameterDeclaration' {} Maybe IntegerDefaultValues
a -> IntegerParameterDeclaration
s {$sel:defaultValues:IntegerParameterDeclaration' :: Maybe IntegerDefaultValues
defaultValues = Maybe IntegerDefaultValues
a} :: IntegerParameterDeclaration)

-- | A parameter declaration for the @Integer@ data type.
integerParameterDeclaration_valueWhenUnset :: Lens.Lens' IntegerParameterDeclaration (Prelude.Maybe IntegerValueWhenUnsetConfiguration)
integerParameterDeclaration_valueWhenUnset :: Lens'
  IntegerParameterDeclaration
  (Maybe IntegerValueWhenUnsetConfiguration)
integerParameterDeclaration_valueWhenUnset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntegerParameterDeclaration' {Maybe IntegerValueWhenUnsetConfiguration
valueWhenUnset :: Maybe IntegerValueWhenUnsetConfiguration
$sel:valueWhenUnset:IntegerParameterDeclaration' :: IntegerParameterDeclaration
-> Maybe IntegerValueWhenUnsetConfiguration
valueWhenUnset} -> Maybe IntegerValueWhenUnsetConfiguration
valueWhenUnset) (\s :: IntegerParameterDeclaration
s@IntegerParameterDeclaration' {} Maybe IntegerValueWhenUnsetConfiguration
a -> IntegerParameterDeclaration
s {$sel:valueWhenUnset:IntegerParameterDeclaration' :: Maybe IntegerValueWhenUnsetConfiguration
valueWhenUnset = Maybe IntegerValueWhenUnsetConfiguration
a} :: IntegerParameterDeclaration)

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

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

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