{-# 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.AxisLabelReferenceOptions
-- 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.AxisLabelReferenceOptions 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.ColumnIdentifier

-- | The reference that specifies where the axis label is applied to.
--
-- /See:/ 'newAxisLabelReferenceOptions' smart constructor.
data AxisLabelReferenceOptions = AxisLabelReferenceOptions'
  { -- | The field that the axis label is targeted to.
    AxisLabelReferenceOptions -> Text
fieldId :: Prelude.Text,
    -- | The column that the axis label is targeted to.
    AxisLabelReferenceOptions -> ColumnIdentifier
column :: ColumnIdentifier
  }
  deriving (AxisLabelReferenceOptions -> AxisLabelReferenceOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AxisLabelReferenceOptions -> AxisLabelReferenceOptions -> Bool
$c/= :: AxisLabelReferenceOptions -> AxisLabelReferenceOptions -> Bool
== :: AxisLabelReferenceOptions -> AxisLabelReferenceOptions -> Bool
$c== :: AxisLabelReferenceOptions -> AxisLabelReferenceOptions -> Bool
Prelude.Eq, ReadPrec [AxisLabelReferenceOptions]
ReadPrec AxisLabelReferenceOptions
Int -> ReadS AxisLabelReferenceOptions
ReadS [AxisLabelReferenceOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AxisLabelReferenceOptions]
$creadListPrec :: ReadPrec [AxisLabelReferenceOptions]
readPrec :: ReadPrec AxisLabelReferenceOptions
$creadPrec :: ReadPrec AxisLabelReferenceOptions
readList :: ReadS [AxisLabelReferenceOptions]
$creadList :: ReadS [AxisLabelReferenceOptions]
readsPrec :: Int -> ReadS AxisLabelReferenceOptions
$creadsPrec :: Int -> ReadS AxisLabelReferenceOptions
Prelude.Read, Int -> AxisLabelReferenceOptions -> ShowS
[AxisLabelReferenceOptions] -> ShowS
AxisLabelReferenceOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AxisLabelReferenceOptions] -> ShowS
$cshowList :: [AxisLabelReferenceOptions] -> ShowS
show :: AxisLabelReferenceOptions -> String
$cshow :: AxisLabelReferenceOptions -> String
showsPrec :: Int -> AxisLabelReferenceOptions -> ShowS
$cshowsPrec :: Int -> AxisLabelReferenceOptions -> ShowS
Prelude.Show, forall x.
Rep AxisLabelReferenceOptions x -> AxisLabelReferenceOptions
forall x.
AxisLabelReferenceOptions -> Rep AxisLabelReferenceOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AxisLabelReferenceOptions x -> AxisLabelReferenceOptions
$cfrom :: forall x.
AxisLabelReferenceOptions -> Rep AxisLabelReferenceOptions x
Prelude.Generic)

-- |
-- Create a value of 'AxisLabelReferenceOptions' 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:
--
-- 'fieldId', 'axisLabelReferenceOptions_fieldId' - The field that the axis label is targeted to.
--
-- 'column', 'axisLabelReferenceOptions_column' - The column that the axis label is targeted to.
newAxisLabelReferenceOptions ::
  -- | 'fieldId'
  Prelude.Text ->
  -- | 'column'
  ColumnIdentifier ->
  AxisLabelReferenceOptions
newAxisLabelReferenceOptions :: Text -> ColumnIdentifier -> AxisLabelReferenceOptions
newAxisLabelReferenceOptions Text
pFieldId_ ColumnIdentifier
pColumn_ =
  AxisLabelReferenceOptions'
    { $sel:fieldId:AxisLabelReferenceOptions' :: Text
fieldId = Text
pFieldId_,
      $sel:column:AxisLabelReferenceOptions' :: ColumnIdentifier
column = ColumnIdentifier
pColumn_
    }

-- | The field that the axis label is targeted to.
axisLabelReferenceOptions_fieldId :: Lens.Lens' AxisLabelReferenceOptions Prelude.Text
axisLabelReferenceOptions_fieldId :: Lens' AxisLabelReferenceOptions Text
axisLabelReferenceOptions_fieldId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AxisLabelReferenceOptions' {Text
fieldId :: Text
$sel:fieldId:AxisLabelReferenceOptions' :: AxisLabelReferenceOptions -> Text
fieldId} -> Text
fieldId) (\s :: AxisLabelReferenceOptions
s@AxisLabelReferenceOptions' {} Text
a -> AxisLabelReferenceOptions
s {$sel:fieldId:AxisLabelReferenceOptions' :: Text
fieldId = Text
a} :: AxisLabelReferenceOptions)

-- | The column that the axis label is targeted to.
axisLabelReferenceOptions_column :: Lens.Lens' AxisLabelReferenceOptions ColumnIdentifier
axisLabelReferenceOptions_column :: Lens' AxisLabelReferenceOptions ColumnIdentifier
axisLabelReferenceOptions_column = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AxisLabelReferenceOptions' {ColumnIdentifier
column :: ColumnIdentifier
$sel:column:AxisLabelReferenceOptions' :: AxisLabelReferenceOptions -> ColumnIdentifier
column} -> ColumnIdentifier
column) (\s :: AxisLabelReferenceOptions
s@AxisLabelReferenceOptions' {} ColumnIdentifier
a -> AxisLabelReferenceOptions
s {$sel:column:AxisLabelReferenceOptions' :: ColumnIdentifier
column = ColumnIdentifier
a} :: AxisLabelReferenceOptions)

instance Data.FromJSON AxisLabelReferenceOptions where
  parseJSON :: Value -> Parser AxisLabelReferenceOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AxisLabelReferenceOptions"
      ( \Object
x ->
          Text -> ColumnIdentifier -> AxisLabelReferenceOptions
AxisLabelReferenceOptions'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FieldId")
            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")
      )

instance Prelude.Hashable AxisLabelReferenceOptions where
  hashWithSalt :: Int -> AxisLabelReferenceOptions -> Int
hashWithSalt Int
_salt AxisLabelReferenceOptions' {Text
ColumnIdentifier
column :: ColumnIdentifier
fieldId :: Text
$sel:column:AxisLabelReferenceOptions' :: AxisLabelReferenceOptions -> ColumnIdentifier
$sel:fieldId:AxisLabelReferenceOptions' :: AxisLabelReferenceOptions -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fieldId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ColumnIdentifier
column

instance Prelude.NFData AxisLabelReferenceOptions where
  rnf :: AxisLabelReferenceOptions -> ()
rnf AxisLabelReferenceOptions' {Text
ColumnIdentifier
column :: ColumnIdentifier
fieldId :: Text
$sel:column:AxisLabelReferenceOptions' :: AxisLabelReferenceOptions -> ColumnIdentifier
$sel:fieldId:AxisLabelReferenceOptions' :: AxisLabelReferenceOptions -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
fieldId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ColumnIdentifier
column

instance Data.ToJSON AxisLabelReferenceOptions where
  toJSON :: AxisLabelReferenceOptions -> Value
toJSON AxisLabelReferenceOptions' {Text
ColumnIdentifier
column :: ColumnIdentifier
fieldId :: Text
$sel:column:AxisLabelReferenceOptions' :: AxisLabelReferenceOptions -> ColumnIdentifier
$sel:fieldId:AxisLabelReferenceOptions' :: AxisLabelReferenceOptions -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"FieldId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fieldId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ColumnIdentifier
column)
          ]
      )