{-# 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.FilterDateTimePickerControl
-- 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.FilterDateTimePickerControl 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.DateTimePickerControlDisplayOptions
import Amazonka.QuickSight.Types.SheetControlDateTimePickerType

-- | A control from a date filter that is used to specify date and time.
--
-- /See:/ 'newFilterDateTimePickerControl' smart constructor.
data FilterDateTimePickerControl = FilterDateTimePickerControl'
  { -- | The display options of a control.
    FilterDateTimePickerControl
-> Maybe DateTimePickerControlDisplayOptions
displayOptions :: Prelude.Maybe DateTimePickerControlDisplayOptions,
    -- | The date time picker type of a @FilterDateTimePickerControl@. Choose one
    -- of the following options:
    --
    -- -   @SINGLE_VALUED@: The filter condition is a fixed date.
    --
    -- -   @DATE_RANGE@: The filter condition is a date time range.
    FilterDateTimePickerControl -> Maybe SheetControlDateTimePickerType
type' :: Prelude.Maybe SheetControlDateTimePickerType,
    -- | The ID of the @FilterDateTimePickerControl@.
    FilterDateTimePickerControl -> Text
filterControlId :: Prelude.Text,
    -- | The title of the @FilterDateTimePickerControl@.
    FilterDateTimePickerControl -> Text
title :: Prelude.Text,
    -- | The source filter ID of the @FilterDateTimePickerControl@.
    FilterDateTimePickerControl -> Text
sourceFilterId :: Prelude.Text
  }
  deriving (FilterDateTimePickerControl -> FilterDateTimePickerControl -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FilterDateTimePickerControl -> FilterDateTimePickerControl -> Bool
$c/= :: FilterDateTimePickerControl -> FilterDateTimePickerControl -> Bool
== :: FilterDateTimePickerControl -> FilterDateTimePickerControl -> Bool
$c== :: FilterDateTimePickerControl -> FilterDateTimePickerControl -> Bool
Prelude.Eq, ReadPrec [FilterDateTimePickerControl]
ReadPrec FilterDateTimePickerControl
Int -> ReadS FilterDateTimePickerControl
ReadS [FilterDateTimePickerControl]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FilterDateTimePickerControl]
$creadListPrec :: ReadPrec [FilterDateTimePickerControl]
readPrec :: ReadPrec FilterDateTimePickerControl
$creadPrec :: ReadPrec FilterDateTimePickerControl
readList :: ReadS [FilterDateTimePickerControl]
$creadList :: ReadS [FilterDateTimePickerControl]
readsPrec :: Int -> ReadS FilterDateTimePickerControl
$creadsPrec :: Int -> ReadS FilterDateTimePickerControl
Prelude.Read, Int -> FilterDateTimePickerControl -> ShowS
[FilterDateTimePickerControl] -> ShowS
FilterDateTimePickerControl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FilterDateTimePickerControl] -> ShowS
$cshowList :: [FilterDateTimePickerControl] -> ShowS
show :: FilterDateTimePickerControl -> String
$cshow :: FilterDateTimePickerControl -> String
showsPrec :: Int -> FilterDateTimePickerControl -> ShowS
$cshowsPrec :: Int -> FilterDateTimePickerControl -> ShowS
Prelude.Show, forall x.
Rep FilterDateTimePickerControl x -> FilterDateTimePickerControl
forall x.
FilterDateTimePickerControl -> Rep FilterDateTimePickerControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FilterDateTimePickerControl x -> FilterDateTimePickerControl
$cfrom :: forall x.
FilterDateTimePickerControl -> Rep FilterDateTimePickerControl x
Prelude.Generic)

-- |
-- Create a value of 'FilterDateTimePickerControl' 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', 'filterDateTimePickerControl_displayOptions' - The display options of a control.
--
-- 'type'', 'filterDateTimePickerControl_type' - The date time picker type of a @FilterDateTimePickerControl@. Choose one
-- of the following options:
--
-- -   @SINGLE_VALUED@: The filter condition is a fixed date.
--
-- -   @DATE_RANGE@: The filter condition is a date time range.
--
-- 'filterControlId', 'filterDateTimePickerControl_filterControlId' - The ID of the @FilterDateTimePickerControl@.
--
-- 'title', 'filterDateTimePickerControl_title' - The title of the @FilterDateTimePickerControl@.
--
-- 'sourceFilterId', 'filterDateTimePickerControl_sourceFilterId' - The source filter ID of the @FilterDateTimePickerControl@.
newFilterDateTimePickerControl ::
  -- | 'filterControlId'
  Prelude.Text ->
  -- | 'title'
  Prelude.Text ->
  -- | 'sourceFilterId'
  Prelude.Text ->
  FilterDateTimePickerControl
newFilterDateTimePickerControl :: Text -> Text -> Text -> FilterDateTimePickerControl
newFilterDateTimePickerControl
  Text
pFilterControlId_
  Text
pTitle_
  Text
pSourceFilterId_ =
    FilterDateTimePickerControl'
      { $sel:displayOptions:FilterDateTimePickerControl' :: Maybe DateTimePickerControlDisplayOptions
displayOptions =
          forall a. Maybe a
Prelude.Nothing,
        $sel:type':FilterDateTimePickerControl' :: Maybe SheetControlDateTimePickerType
type' = forall a. Maybe a
Prelude.Nothing,
        $sel:filterControlId:FilterDateTimePickerControl' :: Text
filterControlId = Text
pFilterControlId_,
        $sel:title:FilterDateTimePickerControl' :: Text
title = Text
pTitle_,
        $sel:sourceFilterId:FilterDateTimePickerControl' :: Text
sourceFilterId = Text
pSourceFilterId_
      }

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

-- | The date time picker type of a @FilterDateTimePickerControl@. Choose one
-- of the following options:
--
-- -   @SINGLE_VALUED@: The filter condition is a fixed date.
--
-- -   @DATE_RANGE@: The filter condition is a date time range.
filterDateTimePickerControl_type :: Lens.Lens' FilterDateTimePickerControl (Prelude.Maybe SheetControlDateTimePickerType)
filterDateTimePickerControl_type :: Lens'
  FilterDateTimePickerControl (Maybe SheetControlDateTimePickerType)
filterDateTimePickerControl_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterDateTimePickerControl' {Maybe SheetControlDateTimePickerType
type' :: Maybe SheetControlDateTimePickerType
$sel:type':FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Maybe SheetControlDateTimePickerType
type'} -> Maybe SheetControlDateTimePickerType
type') (\s :: FilterDateTimePickerControl
s@FilterDateTimePickerControl' {} Maybe SheetControlDateTimePickerType
a -> FilterDateTimePickerControl
s {$sel:type':FilterDateTimePickerControl' :: Maybe SheetControlDateTimePickerType
type' = Maybe SheetControlDateTimePickerType
a} :: FilterDateTimePickerControl)

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

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

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

instance Data.FromJSON FilterDateTimePickerControl where
  parseJSON :: Value -> Parser FilterDateTimePickerControl
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FilterDateTimePickerControl"
      ( \Object
x ->
          Maybe DateTimePickerControlDisplayOptions
-> Maybe SheetControlDateTimePickerType
-> Text
-> Text
-> Text
-> FilterDateTimePickerControl
FilterDateTimePickerControl'
            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 (Maybe a)
Data..:? Key
"Type")
            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 FilterDateTimePickerControl where
  hashWithSalt :: Int -> FilterDateTimePickerControl -> Int
hashWithSalt Int
_salt FilterDateTimePickerControl' {Maybe SheetControlDateTimePickerType
Maybe DateTimePickerControlDisplayOptions
Text
sourceFilterId :: Text
title :: Text
filterControlId :: Text
type' :: Maybe SheetControlDateTimePickerType
displayOptions :: Maybe DateTimePickerControlDisplayOptions
$sel:sourceFilterId:FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Text
$sel:title:FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Text
$sel:filterControlId:FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Text
$sel:type':FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Maybe SheetControlDateTimePickerType
$sel:displayOptions:FilterDateTimePickerControl' :: FilterDateTimePickerControl
-> Maybe DateTimePickerControlDisplayOptions
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DateTimePickerControlDisplayOptions
displayOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SheetControlDateTimePickerType
type'
      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 FilterDateTimePickerControl where
  rnf :: FilterDateTimePickerControl -> ()
rnf FilterDateTimePickerControl' {Maybe SheetControlDateTimePickerType
Maybe DateTimePickerControlDisplayOptions
Text
sourceFilterId :: Text
title :: Text
filterControlId :: Text
type' :: Maybe SheetControlDateTimePickerType
displayOptions :: Maybe DateTimePickerControlDisplayOptions
$sel:sourceFilterId:FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Text
$sel:title:FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Text
$sel:filterControlId:FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Text
$sel:type':FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Maybe SheetControlDateTimePickerType
$sel:displayOptions:FilterDateTimePickerControl' :: FilterDateTimePickerControl
-> Maybe DateTimePickerControlDisplayOptions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DateTimePickerControlDisplayOptions
displayOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SheetControlDateTimePickerType
type'
      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 FilterDateTimePickerControl where
  toJSON :: FilterDateTimePickerControl -> Value
toJSON FilterDateTimePickerControl' {Maybe SheetControlDateTimePickerType
Maybe DateTimePickerControlDisplayOptions
Text
sourceFilterId :: Text
title :: Text
filterControlId :: Text
type' :: Maybe SheetControlDateTimePickerType
displayOptions :: Maybe DateTimePickerControlDisplayOptions
$sel:sourceFilterId:FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Text
$sel:title:FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Text
$sel:filterControlId:FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Text
$sel:type':FilterDateTimePickerControl' :: FilterDateTimePickerControl -> Maybe SheetControlDateTimePickerType
$sel:displayOptions:FilterDateTimePickerControl' :: FilterDateTimePickerControl
-> Maybe DateTimePickerControlDisplayOptions
..} =
    [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 DateTimePickerControlDisplayOptions
displayOptions,
            (Key
"Type" 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 SheetControlDateTimePickerType
type',
            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)
          ]
      )