{-# 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.FilterControl
-- 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.FilterControl 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.FilterDateTimePickerControl
import Amazonka.QuickSight.Types.FilterDropDownControl
import Amazonka.QuickSight.Types.FilterListControl
import Amazonka.QuickSight.Types.FilterRelativeDateTimeControl
import Amazonka.QuickSight.Types.FilterSliderControl
import Amazonka.QuickSight.Types.FilterTextAreaControl
import Amazonka.QuickSight.Types.FilterTextFieldControl

-- | The control of a filter that is used to interact with a dashboard or an
-- analysis.
--
-- This is a union type structure. For this structure to be valid, only one
-- of the attributes can be defined.
--
-- /See:/ 'newFilterControl' smart constructor.
data FilterControl = FilterControl'
  { -- | A control from a date filter that is used to specify date and time.
    FilterControl -> Maybe FilterDateTimePickerControl
dateTimePicker :: Prelude.Maybe FilterDateTimePickerControl,
    -- | A control to display a dropdown list with buttons that are used to
    -- select a single value.
    FilterControl -> Maybe FilterDropDownControl
dropdown :: Prelude.Maybe FilterDropDownControl,
    -- | A control to display a list of buttons or boxes. This is used to select
    -- either a single value or multiple values.
    FilterControl -> Maybe FilterListControl
list :: Prelude.Maybe FilterListControl,
    -- | A control from a date filter that is used to specify the relative date.
    FilterControl -> Maybe FilterRelativeDateTimeControl
relativeDateTime :: Prelude.Maybe FilterRelativeDateTimeControl,
    -- | A control to display a horizontal toggle bar. This is used to change a
    -- value by sliding the toggle.
    FilterControl -> Maybe FilterSliderControl
slider :: Prelude.Maybe FilterSliderControl,
    -- | A control to display a text box that is used to enter multiple entries.
    FilterControl -> Maybe FilterTextAreaControl
textArea :: Prelude.Maybe FilterTextAreaControl,
    -- | A control to display a text box that is used to enter a single entry.
    FilterControl -> Maybe FilterTextFieldControl
textField :: Prelude.Maybe FilterTextFieldControl
  }
  deriving (FilterControl -> FilterControl -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FilterControl -> FilterControl -> Bool
$c/= :: FilterControl -> FilterControl -> Bool
== :: FilterControl -> FilterControl -> Bool
$c== :: FilterControl -> FilterControl -> Bool
Prelude.Eq, ReadPrec [FilterControl]
ReadPrec FilterControl
Int -> ReadS FilterControl
ReadS [FilterControl]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FilterControl]
$creadListPrec :: ReadPrec [FilterControl]
readPrec :: ReadPrec FilterControl
$creadPrec :: ReadPrec FilterControl
readList :: ReadS [FilterControl]
$creadList :: ReadS [FilterControl]
readsPrec :: Int -> ReadS FilterControl
$creadsPrec :: Int -> ReadS FilterControl
Prelude.Read, Int -> FilterControl -> ShowS
[FilterControl] -> ShowS
FilterControl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FilterControl] -> ShowS
$cshowList :: [FilterControl] -> ShowS
show :: FilterControl -> String
$cshow :: FilterControl -> String
showsPrec :: Int -> FilterControl -> ShowS
$cshowsPrec :: Int -> FilterControl -> ShowS
Prelude.Show, forall x. Rep FilterControl x -> FilterControl
forall x. FilterControl -> Rep FilterControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FilterControl x -> FilterControl
$cfrom :: forall x. FilterControl -> Rep FilterControl x
Prelude.Generic)

-- |
-- Create a value of 'FilterControl' 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:
--
-- 'dateTimePicker', 'filterControl_dateTimePicker' - A control from a date filter that is used to specify date and time.
--
-- 'dropdown', 'filterControl_dropdown' - A control to display a dropdown list with buttons that are used to
-- select a single value.
--
-- 'list', 'filterControl_list' - A control to display a list of buttons or boxes. This is used to select
-- either a single value or multiple values.
--
-- 'relativeDateTime', 'filterControl_relativeDateTime' - A control from a date filter that is used to specify the relative date.
--
-- 'slider', 'filterControl_slider' - A control to display a horizontal toggle bar. This is used to change a
-- value by sliding the toggle.
--
-- 'textArea', 'filterControl_textArea' - A control to display a text box that is used to enter multiple entries.
--
-- 'textField', 'filterControl_textField' - A control to display a text box that is used to enter a single entry.
newFilterControl ::
  FilterControl
newFilterControl :: FilterControl
newFilterControl =
  FilterControl'
    { $sel:dateTimePicker:FilterControl' :: Maybe FilterDateTimePickerControl
dateTimePicker = forall a. Maybe a
Prelude.Nothing,
      $sel:dropdown:FilterControl' :: Maybe FilterDropDownControl
dropdown = forall a. Maybe a
Prelude.Nothing,
      $sel:list:FilterControl' :: Maybe FilterListControl
list = forall a. Maybe a
Prelude.Nothing,
      $sel:relativeDateTime:FilterControl' :: Maybe FilterRelativeDateTimeControl
relativeDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:slider:FilterControl' :: Maybe FilterSliderControl
slider = forall a. Maybe a
Prelude.Nothing,
      $sel:textArea:FilterControl' :: Maybe FilterTextAreaControl
textArea = forall a. Maybe a
Prelude.Nothing,
      $sel:textField:FilterControl' :: Maybe FilterTextFieldControl
textField = forall a. Maybe a
Prelude.Nothing
    }

-- | A control from a date filter that is used to specify date and time.
filterControl_dateTimePicker :: Lens.Lens' FilterControl (Prelude.Maybe FilterDateTimePickerControl)
filterControl_dateTimePicker :: Lens' FilterControl (Maybe FilterDateTimePickerControl)
filterControl_dateTimePicker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterControl' {Maybe FilterDateTimePickerControl
dateTimePicker :: Maybe FilterDateTimePickerControl
$sel:dateTimePicker:FilterControl' :: FilterControl -> Maybe FilterDateTimePickerControl
dateTimePicker} -> Maybe FilterDateTimePickerControl
dateTimePicker) (\s :: FilterControl
s@FilterControl' {} Maybe FilterDateTimePickerControl
a -> FilterControl
s {$sel:dateTimePicker:FilterControl' :: Maybe FilterDateTimePickerControl
dateTimePicker = Maybe FilterDateTimePickerControl
a} :: FilterControl)

-- | A control to display a dropdown list with buttons that are used to
-- select a single value.
filterControl_dropdown :: Lens.Lens' FilterControl (Prelude.Maybe FilterDropDownControl)
filterControl_dropdown :: Lens' FilterControl (Maybe FilterDropDownControl)
filterControl_dropdown = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterControl' {Maybe FilterDropDownControl
dropdown :: Maybe FilterDropDownControl
$sel:dropdown:FilterControl' :: FilterControl -> Maybe FilterDropDownControl
dropdown} -> Maybe FilterDropDownControl
dropdown) (\s :: FilterControl
s@FilterControl' {} Maybe FilterDropDownControl
a -> FilterControl
s {$sel:dropdown:FilterControl' :: Maybe FilterDropDownControl
dropdown = Maybe FilterDropDownControl
a} :: FilterControl)

-- | A control to display a list of buttons or boxes. This is used to select
-- either a single value or multiple values.
filterControl_list :: Lens.Lens' FilterControl (Prelude.Maybe FilterListControl)
filterControl_list :: Lens' FilterControl (Maybe FilterListControl)
filterControl_list = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterControl' {Maybe FilterListControl
list :: Maybe FilterListControl
$sel:list:FilterControl' :: FilterControl -> Maybe FilterListControl
list} -> Maybe FilterListControl
list) (\s :: FilterControl
s@FilterControl' {} Maybe FilterListControl
a -> FilterControl
s {$sel:list:FilterControl' :: Maybe FilterListControl
list = Maybe FilterListControl
a} :: FilterControl)

-- | A control from a date filter that is used to specify the relative date.
filterControl_relativeDateTime :: Lens.Lens' FilterControl (Prelude.Maybe FilterRelativeDateTimeControl)
filterControl_relativeDateTime :: Lens' FilterControl (Maybe FilterRelativeDateTimeControl)
filterControl_relativeDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterControl' {Maybe FilterRelativeDateTimeControl
relativeDateTime :: Maybe FilterRelativeDateTimeControl
$sel:relativeDateTime:FilterControl' :: FilterControl -> Maybe FilterRelativeDateTimeControl
relativeDateTime} -> Maybe FilterRelativeDateTimeControl
relativeDateTime) (\s :: FilterControl
s@FilterControl' {} Maybe FilterRelativeDateTimeControl
a -> FilterControl
s {$sel:relativeDateTime:FilterControl' :: Maybe FilterRelativeDateTimeControl
relativeDateTime = Maybe FilterRelativeDateTimeControl
a} :: FilterControl)

-- | A control to display a horizontal toggle bar. This is used to change a
-- value by sliding the toggle.
filterControl_slider :: Lens.Lens' FilterControl (Prelude.Maybe FilterSliderControl)
filterControl_slider :: Lens' FilterControl (Maybe FilterSliderControl)
filterControl_slider = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterControl' {Maybe FilterSliderControl
slider :: Maybe FilterSliderControl
$sel:slider:FilterControl' :: FilterControl -> Maybe FilterSliderControl
slider} -> Maybe FilterSliderControl
slider) (\s :: FilterControl
s@FilterControl' {} Maybe FilterSliderControl
a -> FilterControl
s {$sel:slider:FilterControl' :: Maybe FilterSliderControl
slider = Maybe FilterSliderControl
a} :: FilterControl)

-- | A control to display a text box that is used to enter multiple entries.
filterControl_textArea :: Lens.Lens' FilterControl (Prelude.Maybe FilterTextAreaControl)
filterControl_textArea :: Lens' FilterControl (Maybe FilterTextAreaControl)
filterControl_textArea = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterControl' {Maybe FilterTextAreaControl
textArea :: Maybe FilterTextAreaControl
$sel:textArea:FilterControl' :: FilterControl -> Maybe FilterTextAreaControl
textArea} -> Maybe FilterTextAreaControl
textArea) (\s :: FilterControl
s@FilterControl' {} Maybe FilterTextAreaControl
a -> FilterControl
s {$sel:textArea:FilterControl' :: Maybe FilterTextAreaControl
textArea = Maybe FilterTextAreaControl
a} :: FilterControl)

-- | A control to display a text box that is used to enter a single entry.
filterControl_textField :: Lens.Lens' FilterControl (Prelude.Maybe FilterTextFieldControl)
filterControl_textField :: Lens' FilterControl (Maybe FilterTextFieldControl)
filterControl_textField = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterControl' {Maybe FilterTextFieldControl
textField :: Maybe FilterTextFieldControl
$sel:textField:FilterControl' :: FilterControl -> Maybe FilterTextFieldControl
textField} -> Maybe FilterTextFieldControl
textField) (\s :: FilterControl
s@FilterControl' {} Maybe FilterTextFieldControl
a -> FilterControl
s {$sel:textField:FilterControl' :: Maybe FilterTextFieldControl
textField = Maybe FilterTextFieldControl
a} :: FilterControl)

instance Data.FromJSON FilterControl where
  parseJSON :: Value -> Parser FilterControl
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FilterControl"
      ( \Object
x ->
          Maybe FilterDateTimePickerControl
-> Maybe FilterDropDownControl
-> Maybe FilterListControl
-> Maybe FilterRelativeDateTimeControl
-> Maybe FilterSliderControl
-> Maybe FilterTextAreaControl
-> Maybe FilterTextFieldControl
-> FilterControl
FilterControl'
            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
"DateTimePicker")
            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
"Dropdown")
            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
"List")
            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
"RelativeDateTime")
            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
"Slider")
            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
"TextArea")
            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
"TextField")
      )

instance Prelude.Hashable FilterControl where
  hashWithSalt :: Int -> FilterControl -> Int
hashWithSalt Int
_salt FilterControl' {Maybe FilterTextFieldControl
Maybe FilterTextAreaControl
Maybe FilterSliderControl
Maybe FilterRelativeDateTimeControl
Maybe FilterListControl
Maybe FilterDropDownControl
Maybe FilterDateTimePickerControl
textField :: Maybe FilterTextFieldControl
textArea :: Maybe FilterTextAreaControl
slider :: Maybe FilterSliderControl
relativeDateTime :: Maybe FilterRelativeDateTimeControl
list :: Maybe FilterListControl
dropdown :: Maybe FilterDropDownControl
dateTimePicker :: Maybe FilterDateTimePickerControl
$sel:textField:FilterControl' :: FilterControl -> Maybe FilterTextFieldControl
$sel:textArea:FilterControl' :: FilterControl -> Maybe FilterTextAreaControl
$sel:slider:FilterControl' :: FilterControl -> Maybe FilterSliderControl
$sel:relativeDateTime:FilterControl' :: FilterControl -> Maybe FilterRelativeDateTimeControl
$sel:list:FilterControl' :: FilterControl -> Maybe FilterListControl
$sel:dropdown:FilterControl' :: FilterControl -> Maybe FilterDropDownControl
$sel:dateTimePicker:FilterControl' :: FilterControl -> Maybe FilterDateTimePickerControl
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterDateTimePickerControl
dateTimePicker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterDropDownControl
dropdown
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterListControl
list
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterRelativeDateTimeControl
relativeDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterSliderControl
slider
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterTextAreaControl
textArea
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterTextFieldControl
textField

instance Prelude.NFData FilterControl where
  rnf :: FilterControl -> ()
rnf FilterControl' {Maybe FilterTextFieldControl
Maybe FilterTextAreaControl
Maybe FilterSliderControl
Maybe FilterRelativeDateTimeControl
Maybe FilterListControl
Maybe FilterDropDownControl
Maybe FilterDateTimePickerControl
textField :: Maybe FilterTextFieldControl
textArea :: Maybe FilterTextAreaControl
slider :: Maybe FilterSliderControl
relativeDateTime :: Maybe FilterRelativeDateTimeControl
list :: Maybe FilterListControl
dropdown :: Maybe FilterDropDownControl
dateTimePicker :: Maybe FilterDateTimePickerControl
$sel:textField:FilterControl' :: FilterControl -> Maybe FilterTextFieldControl
$sel:textArea:FilterControl' :: FilterControl -> Maybe FilterTextAreaControl
$sel:slider:FilterControl' :: FilterControl -> Maybe FilterSliderControl
$sel:relativeDateTime:FilterControl' :: FilterControl -> Maybe FilterRelativeDateTimeControl
$sel:list:FilterControl' :: FilterControl -> Maybe FilterListControl
$sel:dropdown:FilterControl' :: FilterControl -> Maybe FilterDropDownControl
$sel:dateTimePicker:FilterControl' :: FilterControl -> Maybe FilterDateTimePickerControl
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FilterDateTimePickerControl
dateTimePicker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FilterDropDownControl
dropdown
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FilterListControl
list
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FilterRelativeDateTimeControl
relativeDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FilterSliderControl
slider
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FilterTextAreaControl
textArea
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FilterTextFieldControl
textField

instance Data.ToJSON FilterControl where
  toJSON :: FilterControl -> Value
toJSON FilterControl' {Maybe FilterTextFieldControl
Maybe FilterTextAreaControl
Maybe FilterSliderControl
Maybe FilterRelativeDateTimeControl
Maybe FilterListControl
Maybe FilterDropDownControl
Maybe FilterDateTimePickerControl
textField :: Maybe FilterTextFieldControl
textArea :: Maybe FilterTextAreaControl
slider :: Maybe FilterSliderControl
relativeDateTime :: Maybe FilterRelativeDateTimeControl
list :: Maybe FilterListControl
dropdown :: Maybe FilterDropDownControl
dateTimePicker :: Maybe FilterDateTimePickerControl
$sel:textField:FilterControl' :: FilterControl -> Maybe FilterTextFieldControl
$sel:textArea:FilterControl' :: FilterControl -> Maybe FilterTextAreaControl
$sel:slider:FilterControl' :: FilterControl -> Maybe FilterSliderControl
$sel:relativeDateTime:FilterControl' :: FilterControl -> Maybe FilterRelativeDateTimeControl
$sel:list:FilterControl' :: FilterControl -> Maybe FilterListControl
$sel:dropdown:FilterControl' :: FilterControl -> Maybe FilterDropDownControl
$sel:dateTimePicker:FilterControl' :: FilterControl -> Maybe FilterDateTimePickerControl
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DateTimePicker" 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 FilterDateTimePickerControl
dateTimePicker,
            (Key
"Dropdown" 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 FilterDropDownControl
dropdown,
            (Key
"List" 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 FilterListControl
list,
            (Key
"RelativeDateTime" 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 FilterRelativeDateTimeControl
relativeDateTime,
            (Key
"Slider" 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 FilterSliderControl
slider,
            (Key
"TextArea" 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 FilterTextAreaControl
textArea,
            (Key
"TextField" 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 FilterTextFieldControl
textField
          ]
      )