{-# 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.FilterListControl
-- 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.FilterListControl 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.CascadingControlConfiguration
import Amazonka.QuickSight.Types.FilterSelectableValues
import Amazonka.QuickSight.Types.ListControlDisplayOptions
import Amazonka.QuickSight.Types.SheetControlListType

-- | A control to display a list of buttons or boxes. This is used to select
-- either a single value or multiple values.
--
-- /See:/ 'newFilterListControl' smart constructor.
data FilterListControl = FilterListControl'
  { -- | The values that are displayed in a control can be configured to only
    -- show values that are valid based on what\'s selected in other controls.
    FilterListControl -> Maybe CascadingControlConfiguration
cascadingControlConfiguration :: Prelude.Maybe CascadingControlConfiguration,
    -- | The display options of a control.
    FilterListControl -> Maybe ListControlDisplayOptions
displayOptions :: Prelude.Maybe ListControlDisplayOptions,
    -- | A list of selectable values that are used in a control.
    FilterListControl -> Maybe FilterSelectableValues
selectableValues :: Prelude.Maybe FilterSelectableValues,
    -- | The type of @FilterListControl@. Choose one of the following options:
    --
    -- -   @MULTI_SELECT@: The user can select multiple entries from the list.
    --
    -- -   @SINGLE_SELECT@: The user can select a single entry from the list.
    FilterListControl -> Maybe SheetControlListType
type' :: Prelude.Maybe SheetControlListType,
    -- | The ID of the @FilterListControl@.
    FilterListControl -> Text
filterControlId :: Prelude.Text,
    -- | The title of the @FilterListControl@.
    FilterListControl -> Text
title :: Prelude.Text,
    -- | The source filter ID of the @FilterListControl@.
    FilterListControl -> Text
sourceFilterId :: Prelude.Text
  }
  deriving (FilterListControl -> FilterListControl -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FilterListControl -> FilterListControl -> Bool
$c/= :: FilterListControl -> FilterListControl -> Bool
== :: FilterListControl -> FilterListControl -> Bool
$c== :: FilterListControl -> FilterListControl -> Bool
Prelude.Eq, ReadPrec [FilterListControl]
ReadPrec FilterListControl
Int -> ReadS FilterListControl
ReadS [FilterListControl]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FilterListControl]
$creadListPrec :: ReadPrec [FilterListControl]
readPrec :: ReadPrec FilterListControl
$creadPrec :: ReadPrec FilterListControl
readList :: ReadS [FilterListControl]
$creadList :: ReadS [FilterListControl]
readsPrec :: Int -> ReadS FilterListControl
$creadsPrec :: Int -> ReadS FilterListControl
Prelude.Read, Int -> FilterListControl -> ShowS
[FilterListControl] -> ShowS
FilterListControl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FilterListControl] -> ShowS
$cshowList :: [FilterListControl] -> ShowS
show :: FilterListControl -> String
$cshow :: FilterListControl -> String
showsPrec :: Int -> FilterListControl -> ShowS
$cshowsPrec :: Int -> FilterListControl -> ShowS
Prelude.Show, forall x. Rep FilterListControl x -> FilterListControl
forall x. FilterListControl -> Rep FilterListControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FilterListControl x -> FilterListControl
$cfrom :: forall x. FilterListControl -> Rep FilterListControl x
Prelude.Generic)

-- |
-- Create a value of 'FilterListControl' 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:
--
-- 'cascadingControlConfiguration', 'filterListControl_cascadingControlConfiguration' - The values that are displayed in a control can be configured to only
-- show values that are valid based on what\'s selected in other controls.
--
-- 'displayOptions', 'filterListControl_displayOptions' - The display options of a control.
--
-- 'selectableValues', 'filterListControl_selectableValues' - A list of selectable values that are used in a control.
--
-- 'type'', 'filterListControl_type' - The type of @FilterListControl@. Choose one of the following options:
--
-- -   @MULTI_SELECT@: The user can select multiple entries from the list.
--
-- -   @SINGLE_SELECT@: The user can select a single entry from the list.
--
-- 'filterControlId', 'filterListControl_filterControlId' - The ID of the @FilterListControl@.
--
-- 'title', 'filterListControl_title' - The title of the @FilterListControl@.
--
-- 'sourceFilterId', 'filterListControl_sourceFilterId' - The source filter ID of the @FilterListControl@.
newFilterListControl ::
  -- | 'filterControlId'
  Prelude.Text ->
  -- | 'title'
  Prelude.Text ->
  -- | 'sourceFilterId'
  Prelude.Text ->
  FilterListControl
newFilterListControl :: Text -> Text -> Text -> FilterListControl
newFilterListControl
  Text
pFilterControlId_
  Text
pTitle_
  Text
pSourceFilterId_ =
    FilterListControl'
      { $sel:cascadingControlConfiguration:FilterListControl' :: Maybe CascadingControlConfiguration
cascadingControlConfiguration =
          forall a. Maybe a
Prelude.Nothing,
        $sel:displayOptions:FilterListControl' :: Maybe ListControlDisplayOptions
displayOptions = forall a. Maybe a
Prelude.Nothing,
        $sel:selectableValues:FilterListControl' :: Maybe FilterSelectableValues
selectableValues = forall a. Maybe a
Prelude.Nothing,
        $sel:type':FilterListControl' :: Maybe SheetControlListType
type' = forall a. Maybe a
Prelude.Nothing,
        $sel:filterControlId:FilterListControl' :: Text
filterControlId = Text
pFilterControlId_,
        $sel:title:FilterListControl' :: Text
title = Text
pTitle_,
        $sel:sourceFilterId:FilterListControl' :: Text
sourceFilterId = Text
pSourceFilterId_
      }

-- | The values that are displayed in a control can be configured to only
-- show values that are valid based on what\'s selected in other controls.
filterListControl_cascadingControlConfiguration :: Lens.Lens' FilterListControl (Prelude.Maybe CascadingControlConfiguration)
filterListControl_cascadingControlConfiguration :: Lens' FilterListControl (Maybe CascadingControlConfiguration)
filterListControl_cascadingControlConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterListControl' {Maybe CascadingControlConfiguration
cascadingControlConfiguration :: Maybe CascadingControlConfiguration
$sel:cascadingControlConfiguration:FilterListControl' :: FilterListControl -> Maybe CascadingControlConfiguration
cascadingControlConfiguration} -> Maybe CascadingControlConfiguration
cascadingControlConfiguration) (\s :: FilterListControl
s@FilterListControl' {} Maybe CascadingControlConfiguration
a -> FilterListControl
s {$sel:cascadingControlConfiguration:FilterListControl' :: Maybe CascadingControlConfiguration
cascadingControlConfiguration = Maybe CascadingControlConfiguration
a} :: FilterListControl)

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

-- | A list of selectable values that are used in a control.
filterListControl_selectableValues :: Lens.Lens' FilterListControl (Prelude.Maybe FilterSelectableValues)
filterListControl_selectableValues :: Lens' FilterListControl (Maybe FilterSelectableValues)
filterListControl_selectableValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterListControl' {Maybe FilterSelectableValues
selectableValues :: Maybe FilterSelectableValues
$sel:selectableValues:FilterListControl' :: FilterListControl -> Maybe FilterSelectableValues
selectableValues} -> Maybe FilterSelectableValues
selectableValues) (\s :: FilterListControl
s@FilterListControl' {} Maybe FilterSelectableValues
a -> FilterListControl
s {$sel:selectableValues:FilterListControl' :: Maybe FilterSelectableValues
selectableValues = Maybe FilterSelectableValues
a} :: FilterListControl)

-- | The type of @FilterListControl@. Choose one of the following options:
--
-- -   @MULTI_SELECT@: The user can select multiple entries from the list.
--
-- -   @SINGLE_SELECT@: The user can select a single entry from the list.
filterListControl_type :: Lens.Lens' FilterListControl (Prelude.Maybe SheetControlListType)
filterListControl_type :: Lens' FilterListControl (Maybe SheetControlListType)
filterListControl_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterListControl' {Maybe SheetControlListType
type' :: Maybe SheetControlListType
$sel:type':FilterListControl' :: FilterListControl -> Maybe SheetControlListType
type'} -> Maybe SheetControlListType
type') (\s :: FilterListControl
s@FilterListControl' {} Maybe SheetControlListType
a -> FilterListControl
s {$sel:type':FilterListControl' :: Maybe SheetControlListType
type' = Maybe SheetControlListType
a} :: FilterListControl)

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

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

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

instance Data.FromJSON FilterListControl where
  parseJSON :: Value -> Parser FilterListControl
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FilterListControl"
      ( \Object
x ->
          Maybe CascadingControlConfiguration
-> Maybe ListControlDisplayOptions
-> Maybe FilterSelectableValues
-> Maybe SheetControlListType
-> Text
-> Text
-> Text
-> FilterListControl
FilterListControl'
            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
"CascadingControlConfiguration")
            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
"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
"SelectableValues")
            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 FilterListControl where
  hashWithSalt :: Int -> FilterListControl -> Int
hashWithSalt Int
_salt FilterListControl' {Maybe CascadingControlConfiguration
Maybe FilterSelectableValues
Maybe SheetControlListType
Maybe ListControlDisplayOptions
Text
sourceFilterId :: Text
title :: Text
filterControlId :: Text
type' :: Maybe SheetControlListType
selectableValues :: Maybe FilterSelectableValues
displayOptions :: Maybe ListControlDisplayOptions
cascadingControlConfiguration :: Maybe CascadingControlConfiguration
$sel:sourceFilterId:FilterListControl' :: FilterListControl -> Text
$sel:title:FilterListControl' :: FilterListControl -> Text
$sel:filterControlId:FilterListControl' :: FilterListControl -> Text
$sel:type':FilterListControl' :: FilterListControl -> Maybe SheetControlListType
$sel:selectableValues:FilterListControl' :: FilterListControl -> Maybe FilterSelectableValues
$sel:displayOptions:FilterListControl' :: FilterListControl -> Maybe ListControlDisplayOptions
$sel:cascadingControlConfiguration:FilterListControl' :: FilterListControl -> Maybe CascadingControlConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CascadingControlConfiguration
cascadingControlConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ListControlDisplayOptions
displayOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FilterSelectableValues
selectableValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SheetControlListType
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 FilterListControl where
  rnf :: FilterListControl -> ()
rnf FilterListControl' {Maybe CascadingControlConfiguration
Maybe FilterSelectableValues
Maybe SheetControlListType
Maybe ListControlDisplayOptions
Text
sourceFilterId :: Text
title :: Text
filterControlId :: Text
type' :: Maybe SheetControlListType
selectableValues :: Maybe FilterSelectableValues
displayOptions :: Maybe ListControlDisplayOptions
cascadingControlConfiguration :: Maybe CascadingControlConfiguration
$sel:sourceFilterId:FilterListControl' :: FilterListControl -> Text
$sel:title:FilterListControl' :: FilterListControl -> Text
$sel:filterControlId:FilterListControl' :: FilterListControl -> Text
$sel:type':FilterListControl' :: FilterListControl -> Maybe SheetControlListType
$sel:selectableValues:FilterListControl' :: FilterListControl -> Maybe FilterSelectableValues
$sel:displayOptions:FilterListControl' :: FilterListControl -> Maybe ListControlDisplayOptions
$sel:cascadingControlConfiguration:FilterListControl' :: FilterListControl -> Maybe CascadingControlConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CascadingControlConfiguration
cascadingControlConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ListControlDisplayOptions
displayOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FilterSelectableValues
selectableValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SheetControlListType
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 FilterListControl where
  toJSON :: FilterListControl -> Value
toJSON FilterListControl' {Maybe CascadingControlConfiguration
Maybe FilterSelectableValues
Maybe SheetControlListType
Maybe ListControlDisplayOptions
Text
sourceFilterId :: Text
title :: Text
filterControlId :: Text
type' :: Maybe SheetControlListType
selectableValues :: Maybe FilterSelectableValues
displayOptions :: Maybe ListControlDisplayOptions
cascadingControlConfiguration :: Maybe CascadingControlConfiguration
$sel:sourceFilterId:FilterListControl' :: FilterListControl -> Text
$sel:title:FilterListControl' :: FilterListControl -> Text
$sel:filterControlId:FilterListControl' :: FilterListControl -> Text
$sel:type':FilterListControl' :: FilterListControl -> Maybe SheetControlListType
$sel:selectableValues:FilterListControl' :: FilterListControl -> Maybe FilterSelectableValues
$sel:displayOptions:FilterListControl' :: FilterListControl -> Maybe ListControlDisplayOptions
$sel:cascadingControlConfiguration:FilterListControl' :: FilterListControl -> Maybe CascadingControlConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CascadingControlConfiguration" 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 CascadingControlConfiguration
cascadingControlConfiguration,
            (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 ListControlDisplayOptions
displayOptions,
            (Key
"SelectableValues" 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 FilterSelectableValues
selectableValues,
            (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 SheetControlListType
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)
          ]
      )