{-# 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.FieldBasedTooltip
-- 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.FieldBasedTooltip 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.TooltipItem
import Amazonka.QuickSight.Types.TooltipTitleType
import Amazonka.QuickSight.Types.Visibility

-- | The setup for the detailed tooltip.
--
-- /See:/ 'newFieldBasedTooltip' smart constructor.
data FieldBasedTooltip = FieldBasedTooltip'
  { -- | The visibility of @Show aggregations@.
    FieldBasedTooltip -> Maybe Visibility
aggregationVisibility :: Prelude.Maybe Visibility,
    -- | The fields configuration in the tooltip.
    FieldBasedTooltip -> Maybe [TooltipItem]
tooltipFields :: Prelude.Maybe [TooltipItem],
    -- | The type for the >tooltip title. Choose one of the following options:
    --
    -- -   @NONE@: Doesn\'t use the primary value as the title.
    --
    -- -   @PRIMARY_VALUE@: Uses primary value as the title.
    FieldBasedTooltip -> Maybe TooltipTitleType
tooltipTitleType :: Prelude.Maybe TooltipTitleType
  }
  deriving (FieldBasedTooltip -> FieldBasedTooltip -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldBasedTooltip -> FieldBasedTooltip -> Bool
$c/= :: FieldBasedTooltip -> FieldBasedTooltip -> Bool
== :: FieldBasedTooltip -> FieldBasedTooltip -> Bool
$c== :: FieldBasedTooltip -> FieldBasedTooltip -> Bool
Prelude.Eq, ReadPrec [FieldBasedTooltip]
ReadPrec FieldBasedTooltip
Int -> ReadS FieldBasedTooltip
ReadS [FieldBasedTooltip]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FieldBasedTooltip]
$creadListPrec :: ReadPrec [FieldBasedTooltip]
readPrec :: ReadPrec FieldBasedTooltip
$creadPrec :: ReadPrec FieldBasedTooltip
readList :: ReadS [FieldBasedTooltip]
$creadList :: ReadS [FieldBasedTooltip]
readsPrec :: Int -> ReadS FieldBasedTooltip
$creadsPrec :: Int -> ReadS FieldBasedTooltip
Prelude.Read, Int -> FieldBasedTooltip -> ShowS
[FieldBasedTooltip] -> ShowS
FieldBasedTooltip -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldBasedTooltip] -> ShowS
$cshowList :: [FieldBasedTooltip] -> ShowS
show :: FieldBasedTooltip -> String
$cshow :: FieldBasedTooltip -> String
showsPrec :: Int -> FieldBasedTooltip -> ShowS
$cshowsPrec :: Int -> FieldBasedTooltip -> ShowS
Prelude.Show, forall x. Rep FieldBasedTooltip x -> FieldBasedTooltip
forall x. FieldBasedTooltip -> Rep FieldBasedTooltip x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FieldBasedTooltip x -> FieldBasedTooltip
$cfrom :: forall x. FieldBasedTooltip -> Rep FieldBasedTooltip x
Prelude.Generic)

-- |
-- Create a value of 'FieldBasedTooltip' 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:
--
-- 'aggregationVisibility', 'fieldBasedTooltip_aggregationVisibility' - The visibility of @Show aggregations@.
--
-- 'tooltipFields', 'fieldBasedTooltip_tooltipFields' - The fields configuration in the tooltip.
--
-- 'tooltipTitleType', 'fieldBasedTooltip_tooltipTitleType' - The type for the >tooltip title. Choose one of the following options:
--
-- -   @NONE@: Doesn\'t use the primary value as the title.
--
-- -   @PRIMARY_VALUE@: Uses primary value as the title.
newFieldBasedTooltip ::
  FieldBasedTooltip
newFieldBasedTooltip :: FieldBasedTooltip
newFieldBasedTooltip =
  FieldBasedTooltip'
    { $sel:aggregationVisibility:FieldBasedTooltip' :: Maybe Visibility
aggregationVisibility =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tooltipFields:FieldBasedTooltip' :: Maybe [TooltipItem]
tooltipFields = forall a. Maybe a
Prelude.Nothing,
      $sel:tooltipTitleType:FieldBasedTooltip' :: Maybe TooltipTitleType
tooltipTitleType = forall a. Maybe a
Prelude.Nothing
    }

-- | The visibility of @Show aggregations@.
fieldBasedTooltip_aggregationVisibility :: Lens.Lens' FieldBasedTooltip (Prelude.Maybe Visibility)
fieldBasedTooltip_aggregationVisibility :: Lens' FieldBasedTooltip (Maybe Visibility)
fieldBasedTooltip_aggregationVisibility = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldBasedTooltip' {Maybe Visibility
aggregationVisibility :: Maybe Visibility
$sel:aggregationVisibility:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe Visibility
aggregationVisibility} -> Maybe Visibility
aggregationVisibility) (\s :: FieldBasedTooltip
s@FieldBasedTooltip' {} Maybe Visibility
a -> FieldBasedTooltip
s {$sel:aggregationVisibility:FieldBasedTooltip' :: Maybe Visibility
aggregationVisibility = Maybe Visibility
a} :: FieldBasedTooltip)

-- | The fields configuration in the tooltip.
fieldBasedTooltip_tooltipFields :: Lens.Lens' FieldBasedTooltip (Prelude.Maybe [TooltipItem])
fieldBasedTooltip_tooltipFields :: Lens' FieldBasedTooltip (Maybe [TooltipItem])
fieldBasedTooltip_tooltipFields = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldBasedTooltip' {Maybe [TooltipItem]
tooltipFields :: Maybe [TooltipItem]
$sel:tooltipFields:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe [TooltipItem]
tooltipFields} -> Maybe [TooltipItem]
tooltipFields) (\s :: FieldBasedTooltip
s@FieldBasedTooltip' {} Maybe [TooltipItem]
a -> FieldBasedTooltip
s {$sel:tooltipFields:FieldBasedTooltip' :: Maybe [TooltipItem]
tooltipFields = Maybe [TooltipItem]
a} :: FieldBasedTooltip) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type for the >tooltip title. Choose one of the following options:
--
-- -   @NONE@: Doesn\'t use the primary value as the title.
--
-- -   @PRIMARY_VALUE@: Uses primary value as the title.
fieldBasedTooltip_tooltipTitleType :: Lens.Lens' FieldBasedTooltip (Prelude.Maybe TooltipTitleType)
fieldBasedTooltip_tooltipTitleType :: Lens' FieldBasedTooltip (Maybe TooltipTitleType)
fieldBasedTooltip_tooltipTitleType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldBasedTooltip' {Maybe TooltipTitleType
tooltipTitleType :: Maybe TooltipTitleType
$sel:tooltipTitleType:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe TooltipTitleType
tooltipTitleType} -> Maybe TooltipTitleType
tooltipTitleType) (\s :: FieldBasedTooltip
s@FieldBasedTooltip' {} Maybe TooltipTitleType
a -> FieldBasedTooltip
s {$sel:tooltipTitleType:FieldBasedTooltip' :: Maybe TooltipTitleType
tooltipTitleType = Maybe TooltipTitleType
a} :: FieldBasedTooltip)

instance Data.FromJSON FieldBasedTooltip where
  parseJSON :: Value -> Parser FieldBasedTooltip
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FieldBasedTooltip"
      ( \Object
x ->
          Maybe Visibility
-> Maybe [TooltipItem]
-> Maybe TooltipTitleType
-> FieldBasedTooltip
FieldBasedTooltip'
            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
"AggregationVisibility")
            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
"TooltipFields" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"TooltipTitleType")
      )

instance Prelude.Hashable FieldBasedTooltip where
  hashWithSalt :: Int -> FieldBasedTooltip -> Int
hashWithSalt Int
_salt FieldBasedTooltip' {Maybe [TooltipItem]
Maybe TooltipTitleType
Maybe Visibility
tooltipTitleType :: Maybe TooltipTitleType
tooltipFields :: Maybe [TooltipItem]
aggregationVisibility :: Maybe Visibility
$sel:tooltipTitleType:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe TooltipTitleType
$sel:tooltipFields:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe [TooltipItem]
$sel:aggregationVisibility:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe Visibility
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Visibility
aggregationVisibility
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TooltipItem]
tooltipFields
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TooltipTitleType
tooltipTitleType

instance Prelude.NFData FieldBasedTooltip where
  rnf :: FieldBasedTooltip -> ()
rnf FieldBasedTooltip' {Maybe [TooltipItem]
Maybe TooltipTitleType
Maybe Visibility
tooltipTitleType :: Maybe TooltipTitleType
tooltipFields :: Maybe [TooltipItem]
aggregationVisibility :: Maybe Visibility
$sel:tooltipTitleType:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe TooltipTitleType
$sel:tooltipFields:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe [TooltipItem]
$sel:aggregationVisibility:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe Visibility
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Visibility
aggregationVisibility
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [TooltipItem]
tooltipFields
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TooltipTitleType
tooltipTitleType

instance Data.ToJSON FieldBasedTooltip where
  toJSON :: FieldBasedTooltip -> Value
toJSON FieldBasedTooltip' {Maybe [TooltipItem]
Maybe TooltipTitleType
Maybe Visibility
tooltipTitleType :: Maybe TooltipTitleType
tooltipFields :: Maybe [TooltipItem]
aggregationVisibility :: Maybe Visibility
$sel:tooltipTitleType:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe TooltipTitleType
$sel:tooltipFields:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe [TooltipItem]
$sel:aggregationVisibility:FieldBasedTooltip' :: FieldBasedTooltip -> Maybe Visibility
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AggregationVisibility" 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 Visibility
aggregationVisibility,
            (Key
"TooltipFields" 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 [TooltipItem]
tooltipFields,
            (Key
"TooltipTitleType" 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 TooltipTitleType
tooltipTitleType
          ]
      )