{-# 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.TimeRangeFilterValue
-- 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.TimeRangeFilterValue 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.RollingDateConfiguration

-- | The value of a time range filter.
--
-- This is a union type structure. For this structure to be valid, only one
-- of the attributes can be defined.
--
-- /See:/ 'newTimeRangeFilterValue' smart constructor.
data TimeRangeFilterValue = TimeRangeFilterValue'
  { -- | The parameter type input value.
    TimeRangeFilterValue -> Maybe Text
parameter :: Prelude.Maybe Prelude.Text,
    -- | The rolling date input value.
    TimeRangeFilterValue -> Maybe RollingDateConfiguration
rollingDate :: Prelude.Maybe RollingDateConfiguration,
    -- | The static input value.
    TimeRangeFilterValue -> Maybe POSIX
staticValue :: Prelude.Maybe Data.POSIX
  }
  deriving (TimeRangeFilterValue -> TimeRangeFilterValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeRangeFilterValue -> TimeRangeFilterValue -> Bool
$c/= :: TimeRangeFilterValue -> TimeRangeFilterValue -> Bool
== :: TimeRangeFilterValue -> TimeRangeFilterValue -> Bool
$c== :: TimeRangeFilterValue -> TimeRangeFilterValue -> Bool
Prelude.Eq, Int -> TimeRangeFilterValue -> ShowS
[TimeRangeFilterValue] -> ShowS
TimeRangeFilterValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeRangeFilterValue] -> ShowS
$cshowList :: [TimeRangeFilterValue] -> ShowS
show :: TimeRangeFilterValue -> String
$cshow :: TimeRangeFilterValue -> String
showsPrec :: Int -> TimeRangeFilterValue -> ShowS
$cshowsPrec :: Int -> TimeRangeFilterValue -> ShowS
Prelude.Show, forall x. Rep TimeRangeFilterValue x -> TimeRangeFilterValue
forall x. TimeRangeFilterValue -> Rep TimeRangeFilterValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeRangeFilterValue x -> TimeRangeFilterValue
$cfrom :: forall x. TimeRangeFilterValue -> Rep TimeRangeFilterValue x
Prelude.Generic)

-- |
-- Create a value of 'TimeRangeFilterValue' 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:
--
-- 'parameter', 'timeRangeFilterValue_parameter' - The parameter type input value.
--
-- 'rollingDate', 'timeRangeFilterValue_rollingDate' - The rolling date input value.
--
-- 'staticValue', 'timeRangeFilterValue_staticValue' - The static input value.
newTimeRangeFilterValue ::
  TimeRangeFilterValue
newTimeRangeFilterValue :: TimeRangeFilterValue
newTimeRangeFilterValue =
  TimeRangeFilterValue'
    { $sel:parameter:TimeRangeFilterValue' :: Maybe Text
parameter = forall a. Maybe a
Prelude.Nothing,
      $sel:rollingDate:TimeRangeFilterValue' :: Maybe RollingDateConfiguration
rollingDate = forall a. Maybe a
Prelude.Nothing,
      $sel:staticValue:TimeRangeFilterValue' :: Maybe POSIX
staticValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The parameter type input value.
timeRangeFilterValue_parameter :: Lens.Lens' TimeRangeFilterValue (Prelude.Maybe Prelude.Text)
timeRangeFilterValue_parameter :: Lens' TimeRangeFilterValue (Maybe Text)
timeRangeFilterValue_parameter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeRangeFilterValue' {Maybe Text
parameter :: Maybe Text
$sel:parameter:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe Text
parameter} -> Maybe Text
parameter) (\s :: TimeRangeFilterValue
s@TimeRangeFilterValue' {} Maybe Text
a -> TimeRangeFilterValue
s {$sel:parameter:TimeRangeFilterValue' :: Maybe Text
parameter = Maybe Text
a} :: TimeRangeFilterValue)

-- | The rolling date input value.
timeRangeFilterValue_rollingDate :: Lens.Lens' TimeRangeFilterValue (Prelude.Maybe RollingDateConfiguration)
timeRangeFilterValue_rollingDate :: Lens' TimeRangeFilterValue (Maybe RollingDateConfiguration)
timeRangeFilterValue_rollingDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeRangeFilterValue' {Maybe RollingDateConfiguration
rollingDate :: Maybe RollingDateConfiguration
$sel:rollingDate:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe RollingDateConfiguration
rollingDate} -> Maybe RollingDateConfiguration
rollingDate) (\s :: TimeRangeFilterValue
s@TimeRangeFilterValue' {} Maybe RollingDateConfiguration
a -> TimeRangeFilterValue
s {$sel:rollingDate:TimeRangeFilterValue' :: Maybe RollingDateConfiguration
rollingDate = Maybe RollingDateConfiguration
a} :: TimeRangeFilterValue)

-- | The static input value.
timeRangeFilterValue_staticValue :: Lens.Lens' TimeRangeFilterValue (Prelude.Maybe Prelude.UTCTime)
timeRangeFilterValue_staticValue :: Lens' TimeRangeFilterValue (Maybe UTCTime)
timeRangeFilterValue_staticValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeRangeFilterValue' {Maybe POSIX
staticValue :: Maybe POSIX
$sel:staticValue:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe POSIX
staticValue} -> Maybe POSIX
staticValue) (\s :: TimeRangeFilterValue
s@TimeRangeFilterValue' {} Maybe POSIX
a -> TimeRangeFilterValue
s {$sel:staticValue:TimeRangeFilterValue' :: Maybe POSIX
staticValue = Maybe POSIX
a} :: TimeRangeFilterValue) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON TimeRangeFilterValue where
  parseJSON :: Value -> Parser TimeRangeFilterValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TimeRangeFilterValue"
      ( \Object
x ->
          Maybe Text
-> Maybe RollingDateConfiguration
-> Maybe POSIX
-> TimeRangeFilterValue
TimeRangeFilterValue'
            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
"Parameter")
            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
"RollingDate")
            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
"StaticValue")
      )

instance Prelude.Hashable TimeRangeFilterValue where
  hashWithSalt :: Int -> TimeRangeFilterValue -> Int
hashWithSalt Int
_salt TimeRangeFilterValue' {Maybe Text
Maybe POSIX
Maybe RollingDateConfiguration
staticValue :: Maybe POSIX
rollingDate :: Maybe RollingDateConfiguration
parameter :: Maybe Text
$sel:staticValue:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe POSIX
$sel:rollingDate:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe RollingDateConfiguration
$sel:parameter:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parameter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RollingDateConfiguration
rollingDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
staticValue

instance Prelude.NFData TimeRangeFilterValue where
  rnf :: TimeRangeFilterValue -> ()
rnf TimeRangeFilterValue' {Maybe Text
Maybe POSIX
Maybe RollingDateConfiguration
staticValue :: Maybe POSIX
rollingDate :: Maybe RollingDateConfiguration
parameter :: Maybe Text
$sel:staticValue:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe POSIX
$sel:rollingDate:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe RollingDateConfiguration
$sel:parameter:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parameter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RollingDateConfiguration
rollingDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
staticValue

instance Data.ToJSON TimeRangeFilterValue where
  toJSON :: TimeRangeFilterValue -> Value
toJSON TimeRangeFilterValue' {Maybe Text
Maybe POSIX
Maybe RollingDateConfiguration
staticValue :: Maybe POSIX
rollingDate :: Maybe RollingDateConfiguration
parameter :: Maybe Text
$sel:staticValue:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe POSIX
$sel:rollingDate:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe RollingDateConfiguration
$sel:parameter:TimeRangeFilterValue' :: TimeRangeFilterValue -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Parameter" 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
parameter,
            (Key
"RollingDate" 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 RollingDateConfiguration
rollingDate,
            (Key
"StaticValue" 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 POSIX
staticValue
          ]
      )