{-# 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.TopBottomRankedComputation
-- 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.TopBottomRankedComputation 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.DimensionField
import Amazonka.QuickSight.Types.MeasureField
import Amazonka.QuickSight.Types.TopBottomComputationType

-- | The top ranked and bottom ranked computation configuration.
--
-- /See:/ 'newTopBottomRankedComputation' smart constructor.
data TopBottomRankedComputation = TopBottomRankedComputation'
  { -- | The name of a computation.
    TopBottomRankedComputation -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The result size of a top and bottom ranked computation.
    TopBottomRankedComputation -> Maybe Natural
resultSize :: Prelude.Maybe Prelude.Natural,
    -- | The value field that is used in a computation.
    TopBottomRankedComputation -> Maybe MeasureField
value :: Prelude.Maybe MeasureField,
    -- | The ID for a computation.
    TopBottomRankedComputation -> Text
computationId :: Prelude.Text,
    -- | The category field that is used in a computation.
    TopBottomRankedComputation -> DimensionField
category :: DimensionField,
    -- | The computation type. Choose one of the following options:
    --
    -- -   TOP: A top ranked computation.
    --
    -- -   BOTTOM: A bottom ranked computation.
    TopBottomRankedComputation -> TopBottomComputationType
type' :: TopBottomComputationType
  }
  deriving (TopBottomRankedComputation -> TopBottomRankedComputation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopBottomRankedComputation -> TopBottomRankedComputation -> Bool
$c/= :: TopBottomRankedComputation -> TopBottomRankedComputation -> Bool
== :: TopBottomRankedComputation -> TopBottomRankedComputation -> Bool
$c== :: TopBottomRankedComputation -> TopBottomRankedComputation -> Bool
Prelude.Eq, Int -> TopBottomRankedComputation -> ShowS
[TopBottomRankedComputation] -> ShowS
TopBottomRankedComputation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopBottomRankedComputation] -> ShowS
$cshowList :: [TopBottomRankedComputation] -> ShowS
show :: TopBottomRankedComputation -> String
$cshow :: TopBottomRankedComputation -> String
showsPrec :: Int -> TopBottomRankedComputation -> ShowS
$cshowsPrec :: Int -> TopBottomRankedComputation -> ShowS
Prelude.Show, forall x.
Rep TopBottomRankedComputation x -> TopBottomRankedComputation
forall x.
TopBottomRankedComputation -> Rep TopBottomRankedComputation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TopBottomRankedComputation x -> TopBottomRankedComputation
$cfrom :: forall x.
TopBottomRankedComputation -> Rep TopBottomRankedComputation x
Prelude.Generic)

-- |
-- Create a value of 'TopBottomRankedComputation' 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:
--
-- 'name', 'topBottomRankedComputation_name' - The name of a computation.
--
-- 'resultSize', 'topBottomRankedComputation_resultSize' - The result size of a top and bottom ranked computation.
--
-- 'value', 'topBottomRankedComputation_value' - The value field that is used in a computation.
--
-- 'computationId', 'topBottomRankedComputation_computationId' - The ID for a computation.
--
-- 'category', 'topBottomRankedComputation_category' - The category field that is used in a computation.
--
-- 'type'', 'topBottomRankedComputation_type' - The computation type. Choose one of the following options:
--
-- -   TOP: A top ranked computation.
--
-- -   BOTTOM: A bottom ranked computation.
newTopBottomRankedComputation ::
  -- | 'computationId'
  Prelude.Text ->
  -- | 'category'
  DimensionField ->
  -- | 'type''
  TopBottomComputationType ->
  TopBottomRankedComputation
newTopBottomRankedComputation :: Text
-> DimensionField
-> TopBottomComputationType
-> TopBottomRankedComputation
newTopBottomRankedComputation
  Text
pComputationId_
  DimensionField
pCategory_
  TopBottomComputationType
pType_ =
    TopBottomRankedComputation'
      { $sel:name:TopBottomRankedComputation' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
        $sel:resultSize:TopBottomRankedComputation' :: Maybe Natural
resultSize = forall a. Maybe a
Prelude.Nothing,
        $sel:value:TopBottomRankedComputation' :: Maybe MeasureField
value = forall a. Maybe a
Prelude.Nothing,
        $sel:computationId:TopBottomRankedComputation' :: Text
computationId = Text
pComputationId_,
        $sel:category:TopBottomRankedComputation' :: DimensionField
category = DimensionField
pCategory_,
        $sel:type':TopBottomRankedComputation' :: TopBottomComputationType
type' = TopBottomComputationType
pType_
      }

-- | The name of a computation.
topBottomRankedComputation_name :: Lens.Lens' TopBottomRankedComputation (Prelude.Maybe Prelude.Text)
topBottomRankedComputation_name :: Lens' TopBottomRankedComputation (Maybe Text)
topBottomRankedComputation_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomRankedComputation' {Maybe Text
name :: Maybe Text
$sel:name:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe Text
name} -> Maybe Text
name) (\s :: TopBottomRankedComputation
s@TopBottomRankedComputation' {} Maybe Text
a -> TopBottomRankedComputation
s {$sel:name:TopBottomRankedComputation' :: Maybe Text
name = Maybe Text
a} :: TopBottomRankedComputation)

-- | The result size of a top and bottom ranked computation.
topBottomRankedComputation_resultSize :: Lens.Lens' TopBottomRankedComputation (Prelude.Maybe Prelude.Natural)
topBottomRankedComputation_resultSize :: Lens' TopBottomRankedComputation (Maybe Natural)
topBottomRankedComputation_resultSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomRankedComputation' {Maybe Natural
resultSize :: Maybe Natural
$sel:resultSize:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe Natural
resultSize} -> Maybe Natural
resultSize) (\s :: TopBottomRankedComputation
s@TopBottomRankedComputation' {} Maybe Natural
a -> TopBottomRankedComputation
s {$sel:resultSize:TopBottomRankedComputation' :: Maybe Natural
resultSize = Maybe Natural
a} :: TopBottomRankedComputation)

-- | The value field that is used in a computation.
topBottomRankedComputation_value :: Lens.Lens' TopBottomRankedComputation (Prelude.Maybe MeasureField)
topBottomRankedComputation_value :: Lens' TopBottomRankedComputation (Maybe MeasureField)
topBottomRankedComputation_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomRankedComputation' {Maybe MeasureField
value :: Maybe MeasureField
$sel:value:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe MeasureField
value} -> Maybe MeasureField
value) (\s :: TopBottomRankedComputation
s@TopBottomRankedComputation' {} Maybe MeasureField
a -> TopBottomRankedComputation
s {$sel:value:TopBottomRankedComputation' :: Maybe MeasureField
value = Maybe MeasureField
a} :: TopBottomRankedComputation)

-- | The ID for a computation.
topBottomRankedComputation_computationId :: Lens.Lens' TopBottomRankedComputation Prelude.Text
topBottomRankedComputation_computationId :: Lens' TopBottomRankedComputation Text
topBottomRankedComputation_computationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomRankedComputation' {Text
computationId :: Text
$sel:computationId:TopBottomRankedComputation' :: TopBottomRankedComputation -> Text
computationId} -> Text
computationId) (\s :: TopBottomRankedComputation
s@TopBottomRankedComputation' {} Text
a -> TopBottomRankedComputation
s {$sel:computationId:TopBottomRankedComputation' :: Text
computationId = Text
a} :: TopBottomRankedComputation)

-- | The category field that is used in a computation.
topBottomRankedComputation_category :: Lens.Lens' TopBottomRankedComputation DimensionField
topBottomRankedComputation_category :: Lens' TopBottomRankedComputation DimensionField
topBottomRankedComputation_category = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomRankedComputation' {DimensionField
category :: DimensionField
$sel:category:TopBottomRankedComputation' :: TopBottomRankedComputation -> DimensionField
category} -> DimensionField
category) (\s :: TopBottomRankedComputation
s@TopBottomRankedComputation' {} DimensionField
a -> TopBottomRankedComputation
s {$sel:category:TopBottomRankedComputation' :: DimensionField
category = DimensionField
a} :: TopBottomRankedComputation)

-- | The computation type. Choose one of the following options:
--
-- -   TOP: A top ranked computation.
--
-- -   BOTTOM: A bottom ranked computation.
topBottomRankedComputation_type :: Lens.Lens' TopBottomRankedComputation TopBottomComputationType
topBottomRankedComputation_type :: Lens' TopBottomRankedComputation TopBottomComputationType
topBottomRankedComputation_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopBottomRankedComputation' {TopBottomComputationType
type' :: TopBottomComputationType
$sel:type':TopBottomRankedComputation' :: TopBottomRankedComputation -> TopBottomComputationType
type'} -> TopBottomComputationType
type') (\s :: TopBottomRankedComputation
s@TopBottomRankedComputation' {} TopBottomComputationType
a -> TopBottomRankedComputation
s {$sel:type':TopBottomRankedComputation' :: TopBottomComputationType
type' = TopBottomComputationType
a} :: TopBottomRankedComputation)

instance Data.FromJSON TopBottomRankedComputation where
  parseJSON :: Value -> Parser TopBottomRankedComputation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TopBottomRankedComputation"
      ( \Object
x ->
          Maybe Text
-> Maybe Natural
-> Maybe MeasureField
-> Text
-> DimensionField
-> TopBottomComputationType
-> TopBottomRankedComputation
TopBottomRankedComputation'
            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
"Name")
            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
"ResultSize")
            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
"Value")
            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
"ComputationId")
            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
"Category")
            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
"Type")
      )

instance Prelude.Hashable TopBottomRankedComputation where
  hashWithSalt :: Int -> TopBottomRankedComputation -> Int
hashWithSalt Int
_salt TopBottomRankedComputation' {Maybe Natural
Maybe Text
Maybe MeasureField
Text
TopBottomComputationType
DimensionField
type' :: TopBottomComputationType
category :: DimensionField
computationId :: Text
value :: Maybe MeasureField
resultSize :: Maybe Natural
name :: Maybe Text
$sel:type':TopBottomRankedComputation' :: TopBottomRankedComputation -> TopBottomComputationType
$sel:category:TopBottomRankedComputation' :: TopBottomRankedComputation -> DimensionField
$sel:computationId:TopBottomRankedComputation' :: TopBottomRankedComputation -> Text
$sel:value:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe MeasureField
$sel:resultSize:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe Natural
$sel:name:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
resultSize
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MeasureField
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
computationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DimensionField
category
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TopBottomComputationType
type'

instance Prelude.NFData TopBottomRankedComputation where
  rnf :: TopBottomRankedComputation -> ()
rnf TopBottomRankedComputation' {Maybe Natural
Maybe Text
Maybe MeasureField
Text
TopBottomComputationType
DimensionField
type' :: TopBottomComputationType
category :: DimensionField
computationId :: Text
value :: Maybe MeasureField
resultSize :: Maybe Natural
name :: Maybe Text
$sel:type':TopBottomRankedComputation' :: TopBottomRankedComputation -> TopBottomComputationType
$sel:category:TopBottomRankedComputation' :: TopBottomRankedComputation -> DimensionField
$sel:computationId:TopBottomRankedComputation' :: TopBottomRankedComputation -> Text
$sel:value:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe MeasureField
$sel:resultSize:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe Natural
$sel:name:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
resultSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MeasureField
value
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
computationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DimensionField
category
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TopBottomComputationType
type'

instance Data.ToJSON TopBottomRankedComputation where
  toJSON :: TopBottomRankedComputation -> Value
toJSON TopBottomRankedComputation' {Maybe Natural
Maybe Text
Maybe MeasureField
Text
TopBottomComputationType
DimensionField
type' :: TopBottomComputationType
category :: DimensionField
computationId :: Text
value :: Maybe MeasureField
resultSize :: Maybe Natural
name :: Maybe Text
$sel:type':TopBottomRankedComputation' :: TopBottomRankedComputation -> TopBottomComputationType
$sel:category:TopBottomRankedComputation' :: TopBottomRankedComputation -> DimensionField
$sel:computationId:TopBottomRankedComputation' :: TopBottomRankedComputation -> Text
$sel:value:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe MeasureField
$sel:resultSize:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe Natural
$sel:name:TopBottomRankedComputation' :: TopBottomRankedComputation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Name" 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
name,
            (Key
"ResultSize" 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 Natural
resultSize,
            (Key
"Value" 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 MeasureField
value,
            forall a. a -> Maybe a
Prelude.Just (Key
"ComputationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
computationId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Category" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DimensionField
category),
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TopBottomComputationType
type')
          ]
      )