{-# 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.DateTimeParameterDeclaration
-- 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.DateTimeParameterDeclaration 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.DateTimeDefaultValues
import Amazonka.QuickSight.Types.DateTimeValueWhenUnsetConfiguration
import Amazonka.QuickSight.Types.TimeGranularity

-- | A parameter declaration for the @DateTime@ data type.
--
-- /See:/ 'newDateTimeParameterDeclaration' smart constructor.
data DateTimeParameterDeclaration = DateTimeParameterDeclaration'
  { -- | The default values of a parameter. If the parameter is a single-value
    -- parameter, a maximum of one default value can be provided.
    DateTimeParameterDeclaration -> Maybe DateTimeDefaultValues
defaultValues :: Prelude.Maybe DateTimeDefaultValues,
    -- | The level of time precision that is used to aggregate @DateTime@ values.
    DateTimeParameterDeclaration -> Maybe TimeGranularity
timeGranularity :: Prelude.Maybe TimeGranularity,
    -- | The configuration that defines the default value of a @DateTime@
    -- parameter when a value has not been set.
    DateTimeParameterDeclaration
-> Maybe DateTimeValueWhenUnsetConfiguration
valueWhenUnset :: Prelude.Maybe DateTimeValueWhenUnsetConfiguration,
    -- | The name of the parameter that is being declared.
    DateTimeParameterDeclaration -> Text
name :: Prelude.Text
  }
  deriving (DateTimeParameterDeclaration
-> DateTimeParameterDeclaration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DateTimeParameterDeclaration
-> DateTimeParameterDeclaration -> Bool
$c/= :: DateTimeParameterDeclaration
-> DateTimeParameterDeclaration -> Bool
== :: DateTimeParameterDeclaration
-> DateTimeParameterDeclaration -> Bool
$c== :: DateTimeParameterDeclaration
-> DateTimeParameterDeclaration -> Bool
Prelude.Eq, Int -> DateTimeParameterDeclaration -> ShowS
[DateTimeParameterDeclaration] -> ShowS
DateTimeParameterDeclaration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DateTimeParameterDeclaration] -> ShowS
$cshowList :: [DateTimeParameterDeclaration] -> ShowS
show :: DateTimeParameterDeclaration -> String
$cshow :: DateTimeParameterDeclaration -> String
showsPrec :: Int -> DateTimeParameterDeclaration -> ShowS
$cshowsPrec :: Int -> DateTimeParameterDeclaration -> ShowS
Prelude.Show, forall x.
Rep DateTimeParameterDeclaration x -> DateTimeParameterDeclaration
forall x.
DateTimeParameterDeclaration -> Rep DateTimeParameterDeclaration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DateTimeParameterDeclaration x -> DateTimeParameterDeclaration
$cfrom :: forall x.
DateTimeParameterDeclaration -> Rep DateTimeParameterDeclaration x
Prelude.Generic)

-- |
-- Create a value of 'DateTimeParameterDeclaration' 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', 'dateTimeParameterDeclaration_defaultValues' - The default values of a parameter. If the parameter is a single-value
-- parameter, a maximum of one default value can be provided.
--
-- 'timeGranularity', 'dateTimeParameterDeclaration_timeGranularity' - The level of time precision that is used to aggregate @DateTime@ values.
--
-- 'valueWhenUnset', 'dateTimeParameterDeclaration_valueWhenUnset' - The configuration that defines the default value of a @DateTime@
-- parameter when a value has not been set.
--
-- 'name', 'dateTimeParameterDeclaration_name' - The name of the parameter that is being declared.
newDateTimeParameterDeclaration ::
  -- | 'name'
  Prelude.Text ->
  DateTimeParameterDeclaration
newDateTimeParameterDeclaration :: Text -> DateTimeParameterDeclaration
newDateTimeParameterDeclaration Text
pName_ =
  DateTimeParameterDeclaration'
    { $sel:defaultValues:DateTimeParameterDeclaration' :: Maybe DateTimeDefaultValues
defaultValues =
        forall a. Maybe a
Prelude.Nothing,
      $sel:timeGranularity:DateTimeParameterDeclaration' :: Maybe TimeGranularity
timeGranularity = forall a. Maybe a
Prelude.Nothing,
      $sel:valueWhenUnset:DateTimeParameterDeclaration' :: Maybe DateTimeValueWhenUnsetConfiguration
valueWhenUnset = forall a. Maybe a
Prelude.Nothing,
      $sel:name:DateTimeParameterDeclaration' :: 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.
dateTimeParameterDeclaration_defaultValues :: Lens.Lens' DateTimeParameterDeclaration (Prelude.Maybe DateTimeDefaultValues)
dateTimeParameterDeclaration_defaultValues :: Lens' DateTimeParameterDeclaration (Maybe DateTimeDefaultValues)
dateTimeParameterDeclaration_defaultValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DateTimeParameterDeclaration' {Maybe DateTimeDefaultValues
defaultValues :: Maybe DateTimeDefaultValues
$sel:defaultValues:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Maybe DateTimeDefaultValues
defaultValues} -> Maybe DateTimeDefaultValues
defaultValues) (\s :: DateTimeParameterDeclaration
s@DateTimeParameterDeclaration' {} Maybe DateTimeDefaultValues
a -> DateTimeParameterDeclaration
s {$sel:defaultValues:DateTimeParameterDeclaration' :: Maybe DateTimeDefaultValues
defaultValues = Maybe DateTimeDefaultValues
a} :: DateTimeParameterDeclaration)

-- | The level of time precision that is used to aggregate @DateTime@ values.
dateTimeParameterDeclaration_timeGranularity :: Lens.Lens' DateTimeParameterDeclaration (Prelude.Maybe TimeGranularity)
dateTimeParameterDeclaration_timeGranularity :: Lens' DateTimeParameterDeclaration (Maybe TimeGranularity)
dateTimeParameterDeclaration_timeGranularity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DateTimeParameterDeclaration' {Maybe TimeGranularity
timeGranularity :: Maybe TimeGranularity
$sel:timeGranularity:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Maybe TimeGranularity
timeGranularity} -> Maybe TimeGranularity
timeGranularity) (\s :: DateTimeParameterDeclaration
s@DateTimeParameterDeclaration' {} Maybe TimeGranularity
a -> DateTimeParameterDeclaration
s {$sel:timeGranularity:DateTimeParameterDeclaration' :: Maybe TimeGranularity
timeGranularity = Maybe TimeGranularity
a} :: DateTimeParameterDeclaration)

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

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

instance Data.FromJSON DateTimeParameterDeclaration where
  parseJSON :: Value -> Parser DateTimeParameterDeclaration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DateTimeParameterDeclaration"
      ( \Object
x ->
          Maybe DateTimeDefaultValues
-> Maybe TimeGranularity
-> Maybe DateTimeValueWhenUnsetConfiguration
-> Text
-> DateTimeParameterDeclaration
DateTimeParameterDeclaration'
            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
"TimeGranularity")
            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
"Name")
      )

instance
  Prelude.Hashable
    DateTimeParameterDeclaration
  where
  hashWithSalt :: Int -> DateTimeParameterDeclaration -> Int
hashWithSalt Int
_salt DateTimeParameterDeclaration' {Maybe DateTimeDefaultValues
Maybe TimeGranularity
Maybe DateTimeValueWhenUnsetConfiguration
Text
name :: Text
valueWhenUnset :: Maybe DateTimeValueWhenUnsetConfiguration
timeGranularity :: Maybe TimeGranularity
defaultValues :: Maybe DateTimeDefaultValues
$sel:name:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Text
$sel:valueWhenUnset:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration
-> Maybe DateTimeValueWhenUnsetConfiguration
$sel:timeGranularity:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Maybe TimeGranularity
$sel:defaultValues:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Maybe DateTimeDefaultValues
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DateTimeDefaultValues
defaultValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TimeGranularity
timeGranularity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DateTimeValueWhenUnsetConfiguration
valueWhenUnset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DateTimeParameterDeclaration where
  rnf :: DateTimeParameterDeclaration -> ()
rnf DateTimeParameterDeclaration' {Maybe DateTimeDefaultValues
Maybe TimeGranularity
Maybe DateTimeValueWhenUnsetConfiguration
Text
name :: Text
valueWhenUnset :: Maybe DateTimeValueWhenUnsetConfiguration
timeGranularity :: Maybe TimeGranularity
defaultValues :: Maybe DateTimeDefaultValues
$sel:name:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Text
$sel:valueWhenUnset:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration
-> Maybe DateTimeValueWhenUnsetConfiguration
$sel:timeGranularity:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Maybe TimeGranularity
$sel:defaultValues:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Maybe DateTimeDefaultValues
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DateTimeDefaultValues
defaultValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TimeGranularity
timeGranularity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DateTimeValueWhenUnsetConfiguration
valueWhenUnset
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToJSON DateTimeParameterDeclaration where
  toJSON :: DateTimeParameterDeclaration -> Value
toJSON DateTimeParameterDeclaration' {Maybe DateTimeDefaultValues
Maybe TimeGranularity
Maybe DateTimeValueWhenUnsetConfiguration
Text
name :: Text
valueWhenUnset :: Maybe DateTimeValueWhenUnsetConfiguration
timeGranularity :: Maybe TimeGranularity
defaultValues :: Maybe DateTimeDefaultValues
$sel:name:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Text
$sel:valueWhenUnset:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration
-> Maybe DateTimeValueWhenUnsetConfiguration
$sel:timeGranularity:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Maybe TimeGranularity
$sel:defaultValues:DateTimeParameterDeclaration' :: DateTimeParameterDeclaration -> Maybe DateTimeDefaultValues
..} =
    [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 DateTimeDefaultValues
defaultValues,
            (Key
"TimeGranularity" 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 TimeGranularity
timeGranularity,
            (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 DateTimeValueWhenUnsetConfiguration
valueWhenUnset,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )