{-# 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.TopBottomFilter
-- 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.TopBottomFilter 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.AggregationSortConfiguration
import Amazonka.QuickSight.Types.ColumnIdentifier
import Amazonka.QuickSight.Types.TimeGranularity

-- | A @TopBottomFilter@ filters values that are at the top or the bottom.
--
-- /See:/ 'newTopBottomFilter' smart constructor.
data TopBottomFilter = TopBottomFilter'
  { -- | The number of items to include in the top bottom filter results.
    TopBottomFilter -> Maybe Int
limit :: Prelude.Maybe Prelude.Int,
    -- | The parameter whose value should be used for the filter value.
    TopBottomFilter -> Maybe Text
parameterName :: Prelude.Maybe Prelude.Text,
    -- | The level of time precision that is used to aggregate @DateTime@ values.
    TopBottomFilter -> Maybe TimeGranularity
timeGranularity :: Prelude.Maybe TimeGranularity,
    -- | An identifier that uniquely identifies a filter within a dashboard,
    -- analysis, or template.
    TopBottomFilter -> Text
filterId :: Prelude.Text,
    -- | The column that the filter is applied to.
    TopBottomFilter -> ColumnIdentifier
column :: ColumnIdentifier,
    -- | The aggregation and sort configuration of the top bottom filter.
    TopBottomFilter -> [AggregationSortConfiguration]
aggregationSortConfigurations :: [AggregationSortConfiguration]
  }
  deriving (TopBottomFilter -> TopBottomFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopBottomFilter -> TopBottomFilter -> Bool
$c/= :: TopBottomFilter -> TopBottomFilter -> Bool
== :: TopBottomFilter -> TopBottomFilter -> Bool
$c== :: TopBottomFilter -> TopBottomFilter -> Bool
Prelude.Eq, ReadPrec [TopBottomFilter]
ReadPrec TopBottomFilter
Int -> ReadS TopBottomFilter
ReadS [TopBottomFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TopBottomFilter]
$creadListPrec :: ReadPrec [TopBottomFilter]
readPrec :: ReadPrec TopBottomFilter
$creadPrec :: ReadPrec TopBottomFilter
readList :: ReadS [TopBottomFilter]
$creadList :: ReadS [TopBottomFilter]
readsPrec :: Int -> ReadS TopBottomFilter
$creadsPrec :: Int -> ReadS TopBottomFilter
Prelude.Read, Int -> TopBottomFilter -> ShowS
[TopBottomFilter] -> ShowS
TopBottomFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopBottomFilter] -> ShowS
$cshowList :: [TopBottomFilter] -> ShowS
show :: TopBottomFilter -> String
$cshow :: TopBottomFilter -> String
showsPrec :: Int -> TopBottomFilter -> ShowS
$cshowsPrec :: Int -> TopBottomFilter -> ShowS
Prelude.Show, forall x. Rep TopBottomFilter x -> TopBottomFilter
forall x. TopBottomFilter -> Rep TopBottomFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TopBottomFilter x -> TopBottomFilter
$cfrom :: forall x. TopBottomFilter -> Rep TopBottomFilter x
Prelude.Generic)

-- |
-- Create a value of 'TopBottomFilter' 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:
--
-- 'limit', 'topBottomFilter_limit' - The number of items to include in the top bottom filter results.
--
-- 'parameterName', 'topBottomFilter_parameterName' - The parameter whose value should be used for the filter value.
--
-- 'timeGranularity', 'topBottomFilter_timeGranularity' - The level of time precision that is used to aggregate @DateTime@ values.
--
-- 'filterId', 'topBottomFilter_filterId' - An identifier that uniquely identifies a filter within a dashboard,
-- analysis, or template.
--
-- 'column', 'topBottomFilter_column' - The column that the filter is applied to.
--
-- 'aggregationSortConfigurations', 'topBottomFilter_aggregationSortConfigurations' - The aggregation and sort configuration of the top bottom filter.
newTopBottomFilter ::
  -- | 'filterId'
  Prelude.Text ->
  -- | 'column'
  ColumnIdentifier ->
  TopBottomFilter
newTopBottomFilter :: Text -> ColumnIdentifier -> TopBottomFilter
newTopBottomFilter Text
pFilterId_ ColumnIdentifier
pColumn_ =
  TopBottomFilter'
    { $sel:limit:TopBottomFilter' :: Maybe Int
limit = forall a. Maybe a
Prelude.Nothing,
      $sel:parameterName:TopBottomFilter' :: Maybe Text
parameterName = forall a. Maybe a
Prelude.Nothing,
      $sel:timeGranularity:TopBottomFilter' :: Maybe TimeGranularity
timeGranularity = forall a. Maybe a
Prelude.Nothing,
      $sel:filterId:TopBottomFilter' :: Text
filterId = Text
pFilterId_,
      $sel:column:TopBottomFilter' :: ColumnIdentifier
column = ColumnIdentifier
pColumn_,
      $sel:aggregationSortConfigurations:TopBottomFilter' :: [AggregationSortConfiguration]
aggregationSortConfigurations = forall a. Monoid a => a
Prelude.mempty
    }

-- | The number of items to include in the top bottom filter results.
topBottomFilter_limit :: Lens.Lens' TopBottomFilter (Prelude.Maybe Prelude.Int)
topBottomFilter_limit :: Lens' TopBottomFilter (Maybe Int)
topBottomFilter_limit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomFilter' {Maybe Int
limit :: Maybe Int
$sel:limit:TopBottomFilter' :: TopBottomFilter -> Maybe Int
limit} -> Maybe Int
limit) (\s :: TopBottomFilter
s@TopBottomFilter' {} Maybe Int
a -> TopBottomFilter
s {$sel:limit:TopBottomFilter' :: Maybe Int
limit = Maybe Int
a} :: TopBottomFilter)

-- | The parameter whose value should be used for the filter value.
topBottomFilter_parameterName :: Lens.Lens' TopBottomFilter (Prelude.Maybe Prelude.Text)
topBottomFilter_parameterName :: Lens' TopBottomFilter (Maybe Text)
topBottomFilter_parameterName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomFilter' {Maybe Text
parameterName :: Maybe Text
$sel:parameterName:TopBottomFilter' :: TopBottomFilter -> Maybe Text
parameterName} -> Maybe Text
parameterName) (\s :: TopBottomFilter
s@TopBottomFilter' {} Maybe Text
a -> TopBottomFilter
s {$sel:parameterName:TopBottomFilter' :: Maybe Text
parameterName = Maybe Text
a} :: TopBottomFilter)

-- | The level of time precision that is used to aggregate @DateTime@ values.
topBottomFilter_timeGranularity :: Lens.Lens' TopBottomFilter (Prelude.Maybe TimeGranularity)
topBottomFilter_timeGranularity :: Lens' TopBottomFilter (Maybe TimeGranularity)
topBottomFilter_timeGranularity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomFilter' {Maybe TimeGranularity
timeGranularity :: Maybe TimeGranularity
$sel:timeGranularity:TopBottomFilter' :: TopBottomFilter -> Maybe TimeGranularity
timeGranularity} -> Maybe TimeGranularity
timeGranularity) (\s :: TopBottomFilter
s@TopBottomFilter' {} Maybe TimeGranularity
a -> TopBottomFilter
s {$sel:timeGranularity:TopBottomFilter' :: Maybe TimeGranularity
timeGranularity = Maybe TimeGranularity
a} :: TopBottomFilter)

-- | An identifier that uniquely identifies a filter within a dashboard,
-- analysis, or template.
topBottomFilter_filterId :: Lens.Lens' TopBottomFilter Prelude.Text
topBottomFilter_filterId :: Lens' TopBottomFilter Text
topBottomFilter_filterId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomFilter' {Text
filterId :: Text
$sel:filterId:TopBottomFilter' :: TopBottomFilter -> Text
filterId} -> Text
filterId) (\s :: TopBottomFilter
s@TopBottomFilter' {} Text
a -> TopBottomFilter
s {$sel:filterId:TopBottomFilter' :: Text
filterId = Text
a} :: TopBottomFilter)

-- | The column that the filter is applied to.
topBottomFilter_column :: Lens.Lens' TopBottomFilter ColumnIdentifier
topBottomFilter_column :: Lens' TopBottomFilter ColumnIdentifier
topBottomFilter_column = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomFilter' {ColumnIdentifier
column :: ColumnIdentifier
$sel:column:TopBottomFilter' :: TopBottomFilter -> ColumnIdentifier
column} -> ColumnIdentifier
column) (\s :: TopBottomFilter
s@TopBottomFilter' {} ColumnIdentifier
a -> TopBottomFilter
s {$sel:column:TopBottomFilter' :: ColumnIdentifier
column = ColumnIdentifier
a} :: TopBottomFilter)

-- | The aggregation and sort configuration of the top bottom filter.
topBottomFilter_aggregationSortConfigurations :: Lens.Lens' TopBottomFilter [AggregationSortConfiguration]
topBottomFilter_aggregationSortConfigurations :: Lens' TopBottomFilter [AggregationSortConfiguration]
topBottomFilter_aggregationSortConfigurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomFilter' {[AggregationSortConfiguration]
aggregationSortConfigurations :: [AggregationSortConfiguration]
$sel:aggregationSortConfigurations:TopBottomFilter' :: TopBottomFilter -> [AggregationSortConfiguration]
aggregationSortConfigurations} -> [AggregationSortConfiguration]
aggregationSortConfigurations) (\s :: TopBottomFilter
s@TopBottomFilter' {} [AggregationSortConfiguration]
a -> TopBottomFilter
s {$sel:aggregationSortConfigurations:TopBottomFilter' :: [AggregationSortConfiguration]
aggregationSortConfigurations = [AggregationSortConfiguration]
a} :: TopBottomFilter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON TopBottomFilter where
  parseJSON :: Value -> Parser TopBottomFilter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TopBottomFilter"
      ( \Object
x ->
          Maybe Int
-> Maybe Text
-> Maybe TimeGranularity
-> Text
-> ColumnIdentifier
-> [AggregationSortConfiguration]
-> TopBottomFilter
TopBottomFilter'
            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
"Limit")
            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
"ParameterName")
            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
"TimeGranularity")
            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
"FilterId")
            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
"Column")
            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
"AggregationSortConfigurations"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable TopBottomFilter where
  hashWithSalt :: Int -> TopBottomFilter -> Int
hashWithSalt Int
_salt TopBottomFilter' {[AggregationSortConfiguration]
Maybe Int
Maybe Text
Maybe TimeGranularity
Text
ColumnIdentifier
aggregationSortConfigurations :: [AggregationSortConfiguration]
column :: ColumnIdentifier
filterId :: Text
timeGranularity :: Maybe TimeGranularity
parameterName :: Maybe Text
limit :: Maybe Int
$sel:aggregationSortConfigurations:TopBottomFilter' :: TopBottomFilter -> [AggregationSortConfiguration]
$sel:column:TopBottomFilter' :: TopBottomFilter -> ColumnIdentifier
$sel:filterId:TopBottomFilter' :: TopBottomFilter -> Text
$sel:timeGranularity:TopBottomFilter' :: TopBottomFilter -> Maybe TimeGranularity
$sel:parameterName:TopBottomFilter' :: TopBottomFilter -> Maybe Text
$sel:limit:TopBottomFilter' :: TopBottomFilter -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
limit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parameterName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TimeGranularity
timeGranularity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
filterId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ColumnIdentifier
column
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AggregationSortConfiguration]
aggregationSortConfigurations

instance Prelude.NFData TopBottomFilter where
  rnf :: TopBottomFilter -> ()
rnf TopBottomFilter' {[AggregationSortConfiguration]
Maybe Int
Maybe Text
Maybe TimeGranularity
Text
ColumnIdentifier
aggregationSortConfigurations :: [AggregationSortConfiguration]
column :: ColumnIdentifier
filterId :: Text
timeGranularity :: Maybe TimeGranularity
parameterName :: Maybe Text
limit :: Maybe Int
$sel:aggregationSortConfigurations:TopBottomFilter' :: TopBottomFilter -> [AggregationSortConfiguration]
$sel:column:TopBottomFilter' :: TopBottomFilter -> ColumnIdentifier
$sel:filterId:TopBottomFilter' :: TopBottomFilter -> Text
$sel:timeGranularity:TopBottomFilter' :: TopBottomFilter -> Maybe TimeGranularity
$sel:parameterName:TopBottomFilter' :: TopBottomFilter -> Maybe Text
$sel:limit:TopBottomFilter' :: TopBottomFilter -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
limit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parameterName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TimeGranularity
timeGranularity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
filterId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ColumnIdentifier
column
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AggregationSortConfiguration]
aggregationSortConfigurations

instance Data.ToJSON TopBottomFilter where
  toJSON :: TopBottomFilter -> Value
toJSON TopBottomFilter' {[AggregationSortConfiguration]
Maybe Int
Maybe Text
Maybe TimeGranularity
Text
ColumnIdentifier
aggregationSortConfigurations :: [AggregationSortConfiguration]
column :: ColumnIdentifier
filterId :: Text
timeGranularity :: Maybe TimeGranularity
parameterName :: Maybe Text
limit :: Maybe Int
$sel:aggregationSortConfigurations:TopBottomFilter' :: TopBottomFilter -> [AggregationSortConfiguration]
$sel:column:TopBottomFilter' :: TopBottomFilter -> ColumnIdentifier
$sel:filterId:TopBottomFilter' :: TopBottomFilter -> Text
$sel:timeGranularity:TopBottomFilter' :: TopBottomFilter -> Maybe TimeGranularity
$sel:parameterName:TopBottomFilter' :: TopBottomFilter -> Maybe Text
$sel:limit:TopBottomFilter' :: TopBottomFilter -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Limit" 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 Int
limit,
            (Key
"ParameterName" 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
parameterName,
            (Key
"TimeGranularity" 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 TimeGranularity
timeGranularity,
            forall a. a -> Maybe a
Prelude.Just (Key
"FilterId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
filterId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ColumnIdentifier
column),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"AggregationSortConfigurations"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AggregationSortConfiguration]
aggregationSortConfigurations
              )
          ]
      )