{-# 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.NumericAxisOptions
-- 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.NumericAxisOptions 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.AxisDisplayRange
import Amazonka.QuickSight.Types.AxisScale

-- | The options for an axis with a numeric field.
--
-- /See:/ 'newNumericAxisOptions' smart constructor.
data NumericAxisOptions = NumericAxisOptions'
  { -- | The range setup of a numeric axis.
    NumericAxisOptions -> Maybe AxisDisplayRange
range :: Prelude.Maybe AxisDisplayRange,
    -- | The scale setup of a numeric axis.
    NumericAxisOptions -> Maybe AxisScale
scale :: Prelude.Maybe AxisScale
  }
  deriving (NumericAxisOptions -> NumericAxisOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NumericAxisOptions -> NumericAxisOptions -> Bool
$c/= :: NumericAxisOptions -> NumericAxisOptions -> Bool
== :: NumericAxisOptions -> NumericAxisOptions -> Bool
$c== :: NumericAxisOptions -> NumericAxisOptions -> Bool
Prelude.Eq, ReadPrec [NumericAxisOptions]
ReadPrec NumericAxisOptions
Int -> ReadS NumericAxisOptions
ReadS [NumericAxisOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NumericAxisOptions]
$creadListPrec :: ReadPrec [NumericAxisOptions]
readPrec :: ReadPrec NumericAxisOptions
$creadPrec :: ReadPrec NumericAxisOptions
readList :: ReadS [NumericAxisOptions]
$creadList :: ReadS [NumericAxisOptions]
readsPrec :: Int -> ReadS NumericAxisOptions
$creadsPrec :: Int -> ReadS NumericAxisOptions
Prelude.Read, Int -> NumericAxisOptions -> ShowS
[NumericAxisOptions] -> ShowS
NumericAxisOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NumericAxisOptions] -> ShowS
$cshowList :: [NumericAxisOptions] -> ShowS
show :: NumericAxisOptions -> String
$cshow :: NumericAxisOptions -> String
showsPrec :: Int -> NumericAxisOptions -> ShowS
$cshowsPrec :: Int -> NumericAxisOptions -> ShowS
Prelude.Show, forall x. Rep NumericAxisOptions x -> NumericAxisOptions
forall x. NumericAxisOptions -> Rep NumericAxisOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NumericAxisOptions x -> NumericAxisOptions
$cfrom :: forall x. NumericAxisOptions -> Rep NumericAxisOptions x
Prelude.Generic)

-- |
-- Create a value of 'NumericAxisOptions' 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:
--
-- 'range', 'numericAxisOptions_range' - The range setup of a numeric axis.
--
-- 'scale', 'numericAxisOptions_scale' - The scale setup of a numeric axis.
newNumericAxisOptions ::
  NumericAxisOptions
newNumericAxisOptions :: NumericAxisOptions
newNumericAxisOptions =
  NumericAxisOptions'
    { $sel:range:NumericAxisOptions' :: Maybe AxisDisplayRange
range = forall a. Maybe a
Prelude.Nothing,
      $sel:scale:NumericAxisOptions' :: Maybe AxisScale
scale = forall a. Maybe a
Prelude.Nothing
    }

-- | The range setup of a numeric axis.
numericAxisOptions_range :: Lens.Lens' NumericAxisOptions (Prelude.Maybe AxisDisplayRange)
numericAxisOptions_range :: Lens' NumericAxisOptions (Maybe AxisDisplayRange)
numericAxisOptions_range = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NumericAxisOptions' {Maybe AxisDisplayRange
range :: Maybe AxisDisplayRange
$sel:range:NumericAxisOptions' :: NumericAxisOptions -> Maybe AxisDisplayRange
range} -> Maybe AxisDisplayRange
range) (\s :: NumericAxisOptions
s@NumericAxisOptions' {} Maybe AxisDisplayRange
a -> NumericAxisOptions
s {$sel:range:NumericAxisOptions' :: Maybe AxisDisplayRange
range = Maybe AxisDisplayRange
a} :: NumericAxisOptions)

-- | The scale setup of a numeric axis.
numericAxisOptions_scale :: Lens.Lens' NumericAxisOptions (Prelude.Maybe AxisScale)
numericAxisOptions_scale :: Lens' NumericAxisOptions (Maybe AxisScale)
numericAxisOptions_scale = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NumericAxisOptions' {Maybe AxisScale
scale :: Maybe AxisScale
$sel:scale:NumericAxisOptions' :: NumericAxisOptions -> Maybe AxisScale
scale} -> Maybe AxisScale
scale) (\s :: NumericAxisOptions
s@NumericAxisOptions' {} Maybe AxisScale
a -> NumericAxisOptions
s {$sel:scale:NumericAxisOptions' :: Maybe AxisScale
scale = Maybe AxisScale
a} :: NumericAxisOptions)

instance Data.FromJSON NumericAxisOptions where
  parseJSON :: Value -> Parser NumericAxisOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NumericAxisOptions"
      ( \Object
x ->
          Maybe AxisDisplayRange -> Maybe AxisScale -> NumericAxisOptions
NumericAxisOptions'
            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
"Range")
            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
"Scale")
      )

instance Prelude.Hashable NumericAxisOptions where
  hashWithSalt :: Int -> NumericAxisOptions -> Int
hashWithSalt Int
_salt NumericAxisOptions' {Maybe AxisDisplayRange
Maybe AxisScale
scale :: Maybe AxisScale
range :: Maybe AxisDisplayRange
$sel:scale:NumericAxisOptions' :: NumericAxisOptions -> Maybe AxisScale
$sel:range:NumericAxisOptions' :: NumericAxisOptions -> Maybe AxisDisplayRange
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AxisDisplayRange
range
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AxisScale
scale

instance Prelude.NFData NumericAxisOptions where
  rnf :: NumericAxisOptions -> ()
rnf NumericAxisOptions' {Maybe AxisDisplayRange
Maybe AxisScale
scale :: Maybe AxisScale
range :: Maybe AxisDisplayRange
$sel:scale:NumericAxisOptions' :: NumericAxisOptions -> Maybe AxisScale
$sel:range:NumericAxisOptions' :: NumericAxisOptions -> Maybe AxisDisplayRange
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AxisDisplayRange
range seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AxisScale
scale

instance Data.ToJSON NumericAxisOptions where
  toJSON :: NumericAxisOptions -> Value
toJSON NumericAxisOptions' {Maybe AxisDisplayRange
Maybe AxisScale
scale :: Maybe AxisScale
range :: Maybe AxisDisplayRange
$sel:scale:NumericAxisOptions' :: NumericAxisOptions -> Maybe AxisScale
$sel:range:NumericAxisOptions' :: NumericAxisOptions -> Maybe AxisDisplayRange
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Range" 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 AxisDisplayRange
range,
            (Key
"Scale" 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 AxisScale
scale
          ]
      )