{-# 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.AnchorDateConfiguration
-- 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.AnchorDateConfiguration 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.AnchorOption

-- | The date configuration of the filter.
--
-- /See:/ 'newAnchorDateConfiguration' smart constructor.
data AnchorDateConfiguration = AnchorDateConfiguration'
  { -- | The options for the date configuration. Choose one of the options below:
    --
    -- -   @NOW@
    AnchorDateConfiguration -> Maybe AnchorOption
anchorOption :: Prelude.Maybe AnchorOption,
    -- | The name of the parameter that is used for the anchor date
    -- configuration.
    AnchorDateConfiguration -> Maybe Text
parameterName :: Prelude.Maybe Prelude.Text
  }
  deriving (AnchorDateConfiguration -> AnchorDateConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnchorDateConfiguration -> AnchorDateConfiguration -> Bool
$c/= :: AnchorDateConfiguration -> AnchorDateConfiguration -> Bool
== :: AnchorDateConfiguration -> AnchorDateConfiguration -> Bool
$c== :: AnchorDateConfiguration -> AnchorDateConfiguration -> Bool
Prelude.Eq, ReadPrec [AnchorDateConfiguration]
ReadPrec AnchorDateConfiguration
Int -> ReadS AnchorDateConfiguration
ReadS [AnchorDateConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnchorDateConfiguration]
$creadListPrec :: ReadPrec [AnchorDateConfiguration]
readPrec :: ReadPrec AnchorDateConfiguration
$creadPrec :: ReadPrec AnchorDateConfiguration
readList :: ReadS [AnchorDateConfiguration]
$creadList :: ReadS [AnchorDateConfiguration]
readsPrec :: Int -> ReadS AnchorDateConfiguration
$creadsPrec :: Int -> ReadS AnchorDateConfiguration
Prelude.Read, Int -> AnchorDateConfiguration -> ShowS
[AnchorDateConfiguration] -> ShowS
AnchorDateConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnchorDateConfiguration] -> ShowS
$cshowList :: [AnchorDateConfiguration] -> ShowS
show :: AnchorDateConfiguration -> String
$cshow :: AnchorDateConfiguration -> String
showsPrec :: Int -> AnchorDateConfiguration -> ShowS
$cshowsPrec :: Int -> AnchorDateConfiguration -> ShowS
Prelude.Show, forall x. Rep AnchorDateConfiguration x -> AnchorDateConfiguration
forall x. AnchorDateConfiguration -> Rep AnchorDateConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnchorDateConfiguration x -> AnchorDateConfiguration
$cfrom :: forall x. AnchorDateConfiguration -> Rep AnchorDateConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AnchorDateConfiguration' 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:
--
-- 'anchorOption', 'anchorDateConfiguration_anchorOption' - The options for the date configuration. Choose one of the options below:
--
-- -   @NOW@
--
-- 'parameterName', 'anchorDateConfiguration_parameterName' - The name of the parameter that is used for the anchor date
-- configuration.
newAnchorDateConfiguration ::
  AnchorDateConfiguration
newAnchorDateConfiguration :: AnchorDateConfiguration
newAnchorDateConfiguration =
  AnchorDateConfiguration'
    { $sel:anchorOption:AnchorDateConfiguration' :: Maybe AnchorOption
anchorOption =
        forall a. Maybe a
Prelude.Nothing,
      $sel:parameterName:AnchorDateConfiguration' :: Maybe Text
parameterName = forall a. Maybe a
Prelude.Nothing
    }

-- | The options for the date configuration. Choose one of the options below:
--
-- -   @NOW@
anchorDateConfiguration_anchorOption :: Lens.Lens' AnchorDateConfiguration (Prelude.Maybe AnchorOption)
anchorDateConfiguration_anchorOption :: Lens' AnchorDateConfiguration (Maybe AnchorOption)
anchorDateConfiguration_anchorOption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnchorDateConfiguration' {Maybe AnchorOption
anchorOption :: Maybe AnchorOption
$sel:anchorOption:AnchorDateConfiguration' :: AnchorDateConfiguration -> Maybe AnchorOption
anchorOption} -> Maybe AnchorOption
anchorOption) (\s :: AnchorDateConfiguration
s@AnchorDateConfiguration' {} Maybe AnchorOption
a -> AnchorDateConfiguration
s {$sel:anchorOption:AnchorDateConfiguration' :: Maybe AnchorOption
anchorOption = Maybe AnchorOption
a} :: AnchorDateConfiguration)

-- | The name of the parameter that is used for the anchor date
-- configuration.
anchorDateConfiguration_parameterName :: Lens.Lens' AnchorDateConfiguration (Prelude.Maybe Prelude.Text)
anchorDateConfiguration_parameterName :: Lens' AnchorDateConfiguration (Maybe Text)
anchorDateConfiguration_parameterName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnchorDateConfiguration' {Maybe Text
parameterName :: Maybe Text
$sel:parameterName:AnchorDateConfiguration' :: AnchorDateConfiguration -> Maybe Text
parameterName} -> Maybe Text
parameterName) (\s :: AnchorDateConfiguration
s@AnchorDateConfiguration' {} Maybe Text
a -> AnchorDateConfiguration
s {$sel:parameterName:AnchorDateConfiguration' :: Maybe Text
parameterName = Maybe Text
a} :: AnchorDateConfiguration)

instance Data.FromJSON AnchorDateConfiguration where
  parseJSON :: Value -> Parser AnchorDateConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AnchorDateConfiguration"
      ( \Object
x ->
          Maybe AnchorOption -> Maybe Text -> AnchorDateConfiguration
AnchorDateConfiguration'
            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
"AnchorOption")
            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
"ParameterName")
      )

instance Prelude.Hashable AnchorDateConfiguration where
  hashWithSalt :: Int -> AnchorDateConfiguration -> Int
hashWithSalt Int
_salt AnchorDateConfiguration' {Maybe Text
Maybe AnchorOption
parameterName :: Maybe Text
anchorOption :: Maybe AnchorOption
$sel:parameterName:AnchorDateConfiguration' :: AnchorDateConfiguration -> Maybe Text
$sel:anchorOption:AnchorDateConfiguration' :: AnchorDateConfiguration -> Maybe AnchorOption
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AnchorOption
anchorOption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parameterName

instance Prelude.NFData AnchorDateConfiguration where
  rnf :: AnchorDateConfiguration -> ()
rnf AnchorDateConfiguration' {Maybe Text
Maybe AnchorOption
parameterName :: Maybe Text
anchorOption :: Maybe AnchorOption
$sel:parameterName:AnchorDateConfiguration' :: AnchorDateConfiguration -> Maybe Text
$sel:anchorOption:AnchorDateConfiguration' :: AnchorDateConfiguration -> Maybe AnchorOption
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AnchorOption
anchorOption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parameterName

instance Data.ToJSON AnchorDateConfiguration where
  toJSON :: AnchorDateConfiguration -> Value
toJSON AnchorDateConfiguration' {Maybe Text
Maybe AnchorOption
parameterName :: Maybe Text
anchorOption :: Maybe AnchorOption
$sel:parameterName:AnchorDateConfiguration' :: AnchorDateConfiguration -> Maybe Text
$sel:anchorOption:AnchorDateConfiguration' :: AnchorDateConfiguration -> Maybe AnchorOption
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AnchorOption" 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 AnchorOption
anchorOption,
            (Key
"ParameterName" 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 Text
parameterName
          ]
      )