{-# 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.AxisLabelOptions
-- 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.AxisLabelOptions 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.AxisLabelReferenceOptions
import Amazonka.QuickSight.Types.FontConfiguration

-- | The label options for a chart axis. You must specify the field that the
-- label is targeted to.
--
-- /See:/ 'newAxisLabelOptions' smart constructor.
data AxisLabelOptions = AxisLabelOptions'
  { -- | The options that indicate which field the label belongs to.
    AxisLabelOptions -> Maybe AxisLabelReferenceOptions
applyTo :: Prelude.Maybe AxisLabelReferenceOptions,
    -- | The text for the axis label.
    AxisLabelOptions -> Maybe Text
customLabel :: Prelude.Maybe Prelude.Text,
    -- | The font configuration of the axis label.
    AxisLabelOptions -> Maybe FontConfiguration
fontConfiguration :: Prelude.Maybe FontConfiguration
  }
  deriving (AxisLabelOptions -> AxisLabelOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AxisLabelOptions -> AxisLabelOptions -> Bool
$c/= :: AxisLabelOptions -> AxisLabelOptions -> Bool
== :: AxisLabelOptions -> AxisLabelOptions -> Bool
$c== :: AxisLabelOptions -> AxisLabelOptions -> Bool
Prelude.Eq, ReadPrec [AxisLabelOptions]
ReadPrec AxisLabelOptions
Int -> ReadS AxisLabelOptions
ReadS [AxisLabelOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AxisLabelOptions]
$creadListPrec :: ReadPrec [AxisLabelOptions]
readPrec :: ReadPrec AxisLabelOptions
$creadPrec :: ReadPrec AxisLabelOptions
readList :: ReadS [AxisLabelOptions]
$creadList :: ReadS [AxisLabelOptions]
readsPrec :: Int -> ReadS AxisLabelOptions
$creadsPrec :: Int -> ReadS AxisLabelOptions
Prelude.Read, Int -> AxisLabelOptions -> ShowS
[AxisLabelOptions] -> ShowS
AxisLabelOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AxisLabelOptions] -> ShowS
$cshowList :: [AxisLabelOptions] -> ShowS
show :: AxisLabelOptions -> String
$cshow :: AxisLabelOptions -> String
showsPrec :: Int -> AxisLabelOptions -> ShowS
$cshowsPrec :: Int -> AxisLabelOptions -> ShowS
Prelude.Show, forall x. Rep AxisLabelOptions x -> AxisLabelOptions
forall x. AxisLabelOptions -> Rep AxisLabelOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AxisLabelOptions x -> AxisLabelOptions
$cfrom :: forall x. AxisLabelOptions -> Rep AxisLabelOptions x
Prelude.Generic)

-- |
-- Create a value of 'AxisLabelOptions' 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:
--
-- 'applyTo', 'axisLabelOptions_applyTo' - The options that indicate which field the label belongs to.
--
-- 'customLabel', 'axisLabelOptions_customLabel' - The text for the axis label.
--
-- 'fontConfiguration', 'axisLabelOptions_fontConfiguration' - The font configuration of the axis label.
newAxisLabelOptions ::
  AxisLabelOptions
newAxisLabelOptions :: AxisLabelOptions
newAxisLabelOptions =
  AxisLabelOptions'
    { $sel:applyTo:AxisLabelOptions' :: Maybe AxisLabelReferenceOptions
applyTo = forall a. Maybe a
Prelude.Nothing,
      $sel:customLabel:AxisLabelOptions' :: Maybe Text
customLabel = forall a. Maybe a
Prelude.Nothing,
      $sel:fontConfiguration:AxisLabelOptions' :: Maybe FontConfiguration
fontConfiguration = forall a. Maybe a
Prelude.Nothing
    }

-- | The options that indicate which field the label belongs to.
axisLabelOptions_applyTo :: Lens.Lens' AxisLabelOptions (Prelude.Maybe AxisLabelReferenceOptions)
axisLabelOptions_applyTo :: Lens' AxisLabelOptions (Maybe AxisLabelReferenceOptions)
axisLabelOptions_applyTo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AxisLabelOptions' {Maybe AxisLabelReferenceOptions
applyTo :: Maybe AxisLabelReferenceOptions
$sel:applyTo:AxisLabelOptions' :: AxisLabelOptions -> Maybe AxisLabelReferenceOptions
applyTo} -> Maybe AxisLabelReferenceOptions
applyTo) (\s :: AxisLabelOptions
s@AxisLabelOptions' {} Maybe AxisLabelReferenceOptions
a -> AxisLabelOptions
s {$sel:applyTo:AxisLabelOptions' :: Maybe AxisLabelReferenceOptions
applyTo = Maybe AxisLabelReferenceOptions
a} :: AxisLabelOptions)

-- | The text for the axis label.
axisLabelOptions_customLabel :: Lens.Lens' AxisLabelOptions (Prelude.Maybe Prelude.Text)
axisLabelOptions_customLabel :: Lens' AxisLabelOptions (Maybe Text)
axisLabelOptions_customLabel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AxisLabelOptions' {Maybe Text
customLabel :: Maybe Text
$sel:customLabel:AxisLabelOptions' :: AxisLabelOptions -> Maybe Text
customLabel} -> Maybe Text
customLabel) (\s :: AxisLabelOptions
s@AxisLabelOptions' {} Maybe Text
a -> AxisLabelOptions
s {$sel:customLabel:AxisLabelOptions' :: Maybe Text
customLabel = Maybe Text
a} :: AxisLabelOptions)

-- | The font configuration of the axis label.
axisLabelOptions_fontConfiguration :: Lens.Lens' AxisLabelOptions (Prelude.Maybe FontConfiguration)
axisLabelOptions_fontConfiguration :: Lens' AxisLabelOptions (Maybe FontConfiguration)
axisLabelOptions_fontConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AxisLabelOptions' {Maybe FontConfiguration
fontConfiguration :: Maybe FontConfiguration
$sel:fontConfiguration:AxisLabelOptions' :: AxisLabelOptions -> Maybe FontConfiguration
fontConfiguration} -> Maybe FontConfiguration
fontConfiguration) (\s :: AxisLabelOptions
s@AxisLabelOptions' {} Maybe FontConfiguration
a -> AxisLabelOptions
s {$sel:fontConfiguration:AxisLabelOptions' :: Maybe FontConfiguration
fontConfiguration = Maybe FontConfiguration
a} :: AxisLabelOptions)

instance Data.FromJSON AxisLabelOptions where
  parseJSON :: Value -> Parser AxisLabelOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AxisLabelOptions"
      ( \Object
x ->
          Maybe AxisLabelReferenceOptions
-> Maybe Text -> Maybe FontConfiguration -> AxisLabelOptions
AxisLabelOptions'
            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
"ApplyTo")
            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
"CustomLabel")
            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
"FontConfiguration")
      )

instance Prelude.Hashable AxisLabelOptions where
  hashWithSalt :: Int -> AxisLabelOptions -> Int
hashWithSalt Int
_salt AxisLabelOptions' {Maybe Text
Maybe AxisLabelReferenceOptions
Maybe FontConfiguration
fontConfiguration :: Maybe FontConfiguration
customLabel :: Maybe Text
applyTo :: Maybe AxisLabelReferenceOptions
$sel:fontConfiguration:AxisLabelOptions' :: AxisLabelOptions -> Maybe FontConfiguration
$sel:customLabel:AxisLabelOptions' :: AxisLabelOptions -> Maybe Text
$sel:applyTo:AxisLabelOptions' :: AxisLabelOptions -> Maybe AxisLabelReferenceOptions
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AxisLabelReferenceOptions
applyTo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
customLabel
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FontConfiguration
fontConfiguration

instance Prelude.NFData AxisLabelOptions where
  rnf :: AxisLabelOptions -> ()
rnf AxisLabelOptions' {Maybe Text
Maybe AxisLabelReferenceOptions
Maybe FontConfiguration
fontConfiguration :: Maybe FontConfiguration
customLabel :: Maybe Text
applyTo :: Maybe AxisLabelReferenceOptions
$sel:fontConfiguration:AxisLabelOptions' :: AxisLabelOptions -> Maybe FontConfiguration
$sel:customLabel:AxisLabelOptions' :: AxisLabelOptions -> Maybe Text
$sel:applyTo:AxisLabelOptions' :: AxisLabelOptions -> Maybe AxisLabelReferenceOptions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AxisLabelReferenceOptions
applyTo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
customLabel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FontConfiguration
fontConfiguration

instance Data.ToJSON AxisLabelOptions where
  toJSON :: AxisLabelOptions -> Value
toJSON AxisLabelOptions' {Maybe Text
Maybe AxisLabelReferenceOptions
Maybe FontConfiguration
fontConfiguration :: Maybe FontConfiguration
customLabel :: Maybe Text
applyTo :: Maybe AxisLabelReferenceOptions
$sel:fontConfiguration:AxisLabelOptions' :: AxisLabelOptions -> Maybe FontConfiguration
$sel:customLabel:AxisLabelOptions' :: AxisLabelOptions -> Maybe Text
$sel:applyTo:AxisLabelOptions' :: AxisLabelOptions -> Maybe AxisLabelReferenceOptions
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ApplyTo" 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 AxisLabelReferenceOptions
applyTo,
            (Key
"CustomLabel" 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
customLabel,
            (Key
"FontConfiguration" 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 FontConfiguration
fontConfiguration
          ]
      )