{-# 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.FilterRelativeDateTimeControl
-- 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.FilterRelativeDateTimeControl 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.RelativeDateTimeControlDisplayOptions

-- | A control from a date filter that is used to specify the relative date.
--
-- /See:/ 'newFilterRelativeDateTimeControl' smart constructor.
data FilterRelativeDateTimeControl = FilterRelativeDateTimeControl'
  { -- | The display options of a control.
    FilterRelativeDateTimeControl
-> Maybe RelativeDateTimeControlDisplayOptions
displayOptions :: Prelude.Maybe RelativeDateTimeControlDisplayOptions,
    -- | The ID of the @FilterTextAreaControl@.
    FilterRelativeDateTimeControl -> Text
filterControlId :: Prelude.Text,
    -- | The title of the @FilterTextAreaControl@.
    FilterRelativeDateTimeControl -> Text
title :: Prelude.Text,
    -- | The source filter ID of the @FilterTextAreaControl@.
    FilterRelativeDateTimeControl -> Text
sourceFilterId :: Prelude.Text
  }
  deriving (FilterRelativeDateTimeControl
-> FilterRelativeDateTimeControl -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FilterRelativeDateTimeControl
-> FilterRelativeDateTimeControl -> Bool
$c/= :: FilterRelativeDateTimeControl
-> FilterRelativeDateTimeControl -> Bool
== :: FilterRelativeDateTimeControl
-> FilterRelativeDateTimeControl -> Bool
$c== :: FilterRelativeDateTimeControl
-> FilterRelativeDateTimeControl -> Bool
Prelude.Eq, ReadPrec [FilterRelativeDateTimeControl]
ReadPrec FilterRelativeDateTimeControl
Int -> ReadS FilterRelativeDateTimeControl
ReadS [FilterRelativeDateTimeControl]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FilterRelativeDateTimeControl]
$creadListPrec :: ReadPrec [FilterRelativeDateTimeControl]
readPrec :: ReadPrec FilterRelativeDateTimeControl
$creadPrec :: ReadPrec FilterRelativeDateTimeControl
readList :: ReadS [FilterRelativeDateTimeControl]
$creadList :: ReadS [FilterRelativeDateTimeControl]
readsPrec :: Int -> ReadS FilterRelativeDateTimeControl
$creadsPrec :: Int -> ReadS FilterRelativeDateTimeControl
Prelude.Read, Int -> FilterRelativeDateTimeControl -> ShowS
[FilterRelativeDateTimeControl] -> ShowS
FilterRelativeDateTimeControl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FilterRelativeDateTimeControl] -> ShowS
$cshowList :: [FilterRelativeDateTimeControl] -> ShowS
show :: FilterRelativeDateTimeControl -> String
$cshow :: FilterRelativeDateTimeControl -> String
showsPrec :: Int -> FilterRelativeDateTimeControl -> ShowS
$cshowsPrec :: Int -> FilterRelativeDateTimeControl -> ShowS
Prelude.Show, forall x.
Rep FilterRelativeDateTimeControl x
-> FilterRelativeDateTimeControl
forall x.
FilterRelativeDateTimeControl
-> Rep FilterRelativeDateTimeControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FilterRelativeDateTimeControl x
-> FilterRelativeDateTimeControl
$cfrom :: forall x.
FilterRelativeDateTimeControl
-> Rep FilterRelativeDateTimeControl x
Prelude.Generic)

-- |
-- Create a value of 'FilterRelativeDateTimeControl' 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:
--
-- 'displayOptions', 'filterRelativeDateTimeControl_displayOptions' - The display options of a control.
--
-- 'filterControlId', 'filterRelativeDateTimeControl_filterControlId' - The ID of the @FilterTextAreaControl@.
--
-- 'title', 'filterRelativeDateTimeControl_title' - The title of the @FilterTextAreaControl@.
--
-- 'sourceFilterId', 'filterRelativeDateTimeControl_sourceFilterId' - The source filter ID of the @FilterTextAreaControl@.
newFilterRelativeDateTimeControl ::
  -- | 'filterControlId'
  Prelude.Text ->
  -- | 'title'
  Prelude.Text ->
  -- | 'sourceFilterId'
  Prelude.Text ->
  FilterRelativeDateTimeControl
newFilterRelativeDateTimeControl :: Text -> Text -> Text -> FilterRelativeDateTimeControl
newFilterRelativeDateTimeControl
  Text
pFilterControlId_
  Text
pTitle_
  Text
pSourceFilterId_ =
    FilterRelativeDateTimeControl'
      { $sel:displayOptions:FilterRelativeDateTimeControl' :: Maybe RelativeDateTimeControlDisplayOptions
displayOptions =
          forall a. Maybe a
Prelude.Nothing,
        $sel:filterControlId:FilterRelativeDateTimeControl' :: Text
filterControlId = Text
pFilterControlId_,
        $sel:title:FilterRelativeDateTimeControl' :: Text
title = Text
pTitle_,
        $sel:sourceFilterId:FilterRelativeDateTimeControl' :: Text
sourceFilterId = Text
pSourceFilterId_
      }

-- | The display options of a control.
filterRelativeDateTimeControl_displayOptions :: Lens.Lens' FilterRelativeDateTimeControl (Prelude.Maybe RelativeDateTimeControlDisplayOptions)
filterRelativeDateTimeControl_displayOptions :: Lens'
  FilterRelativeDateTimeControl
  (Maybe RelativeDateTimeControlDisplayOptions)
filterRelativeDateTimeControl_displayOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterRelativeDateTimeControl' {Maybe RelativeDateTimeControlDisplayOptions
displayOptions :: Maybe RelativeDateTimeControlDisplayOptions
$sel:displayOptions:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl
-> Maybe RelativeDateTimeControlDisplayOptions
displayOptions} -> Maybe RelativeDateTimeControlDisplayOptions
displayOptions) (\s :: FilterRelativeDateTimeControl
s@FilterRelativeDateTimeControl' {} Maybe RelativeDateTimeControlDisplayOptions
a -> FilterRelativeDateTimeControl
s {$sel:displayOptions:FilterRelativeDateTimeControl' :: Maybe RelativeDateTimeControlDisplayOptions
displayOptions = Maybe RelativeDateTimeControlDisplayOptions
a} :: FilterRelativeDateTimeControl)

-- | The ID of the @FilterTextAreaControl@.
filterRelativeDateTimeControl_filterControlId :: Lens.Lens' FilterRelativeDateTimeControl Prelude.Text
filterRelativeDateTimeControl_filterControlId :: Lens' FilterRelativeDateTimeControl Text
filterRelativeDateTimeControl_filterControlId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterRelativeDateTimeControl' {Text
filterControlId :: Text
$sel:filterControlId:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
filterControlId} -> Text
filterControlId) (\s :: FilterRelativeDateTimeControl
s@FilterRelativeDateTimeControl' {} Text
a -> FilterRelativeDateTimeControl
s {$sel:filterControlId:FilterRelativeDateTimeControl' :: Text
filterControlId = Text
a} :: FilterRelativeDateTimeControl)

-- | The title of the @FilterTextAreaControl@.
filterRelativeDateTimeControl_title :: Lens.Lens' FilterRelativeDateTimeControl Prelude.Text
filterRelativeDateTimeControl_title :: Lens' FilterRelativeDateTimeControl Text
filterRelativeDateTimeControl_title = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterRelativeDateTimeControl' {Text
title :: Text
$sel:title:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
title} -> Text
title) (\s :: FilterRelativeDateTimeControl
s@FilterRelativeDateTimeControl' {} Text
a -> FilterRelativeDateTimeControl
s {$sel:title:FilterRelativeDateTimeControl' :: Text
title = Text
a} :: FilterRelativeDateTimeControl)

-- | The source filter ID of the @FilterTextAreaControl@.
filterRelativeDateTimeControl_sourceFilterId :: Lens.Lens' FilterRelativeDateTimeControl Prelude.Text
filterRelativeDateTimeControl_sourceFilterId :: Lens' FilterRelativeDateTimeControl Text
filterRelativeDateTimeControl_sourceFilterId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterRelativeDateTimeControl' {Text
sourceFilterId :: Text
$sel:sourceFilterId:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
sourceFilterId} -> Text
sourceFilterId) (\s :: FilterRelativeDateTimeControl
s@FilterRelativeDateTimeControl' {} Text
a -> FilterRelativeDateTimeControl
s {$sel:sourceFilterId:FilterRelativeDateTimeControl' :: Text
sourceFilterId = Text
a} :: FilterRelativeDateTimeControl)

instance Data.FromJSON FilterRelativeDateTimeControl where
  parseJSON :: Value -> Parser FilterRelativeDateTimeControl
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FilterRelativeDateTimeControl"
      ( \Object
x ->
          Maybe RelativeDateTimeControlDisplayOptions
-> Text -> Text -> Text -> FilterRelativeDateTimeControl
FilterRelativeDateTimeControl'
            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
"DisplayOptions")
            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
"FilterControlId")
            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
"Title")
            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
"SourceFilterId")
      )

instance
  Prelude.Hashable
    FilterRelativeDateTimeControl
  where
  hashWithSalt :: Int -> FilterRelativeDateTimeControl -> Int
hashWithSalt Int
_salt FilterRelativeDateTimeControl' {Maybe RelativeDateTimeControlDisplayOptions
Text
sourceFilterId :: Text
title :: Text
filterControlId :: Text
displayOptions :: Maybe RelativeDateTimeControlDisplayOptions
$sel:sourceFilterId:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
$sel:title:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
$sel:filterControlId:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
$sel:displayOptions:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl
-> Maybe RelativeDateTimeControlDisplayOptions
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RelativeDateTimeControlDisplayOptions
displayOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
filterControlId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
title
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceFilterId

instance Prelude.NFData FilterRelativeDateTimeControl where
  rnf :: FilterRelativeDateTimeControl -> ()
rnf FilterRelativeDateTimeControl' {Maybe RelativeDateTimeControlDisplayOptions
Text
sourceFilterId :: Text
title :: Text
filterControlId :: Text
displayOptions :: Maybe RelativeDateTimeControlDisplayOptions
$sel:sourceFilterId:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
$sel:title:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
$sel:filterControlId:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
$sel:displayOptions:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl
-> Maybe RelativeDateTimeControlDisplayOptions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RelativeDateTimeControlDisplayOptions
displayOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
filterControlId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
title
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sourceFilterId

instance Data.ToJSON FilterRelativeDateTimeControl where
  toJSON :: FilterRelativeDateTimeControl -> Value
toJSON FilterRelativeDateTimeControl' {Maybe RelativeDateTimeControlDisplayOptions
Text
sourceFilterId :: Text
title :: Text
filterControlId :: Text
displayOptions :: Maybe RelativeDateTimeControlDisplayOptions
$sel:sourceFilterId:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
$sel:title:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
$sel:filterControlId:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl -> Text
$sel:displayOptions:FilterRelativeDateTimeControl' :: FilterRelativeDateTimeControl
-> Maybe RelativeDateTimeControlDisplayOptions
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DisplayOptions" 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 RelativeDateTimeControlDisplayOptions
displayOptions,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"FilterControlId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
filterControlId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Title" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
title),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"SourceFilterId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sourceFilterId)
          ]
      )