{-# 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.GrowthRateComputation
-- 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.GrowthRateComputation 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

-- | The growth rate computation configuration.
--
-- /See:/ 'newGrowthRateComputation' smart constructor.
data GrowthRateComputation = GrowthRateComputation'
  { -- | The name of a computation.
    GrowthRateComputation -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The period size setup of a growth rate computation.
    GrowthRateComputation -> Maybe Natural
periodSize :: Prelude.Maybe Prelude.Natural,
    -- | The value field that is used in a computation.
    GrowthRateComputation -> Maybe MeasureField
value :: Prelude.Maybe MeasureField,
    -- | The ID for a computation.
    GrowthRateComputation -> Text
computationId :: Prelude.Text,
    -- | The time field that is used in a computation.
    GrowthRateComputation -> DimensionField
time :: DimensionField
  }
  deriving (GrowthRateComputation -> GrowthRateComputation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrowthRateComputation -> GrowthRateComputation -> Bool
$c/= :: GrowthRateComputation -> GrowthRateComputation -> Bool
== :: GrowthRateComputation -> GrowthRateComputation -> Bool
$c== :: GrowthRateComputation -> GrowthRateComputation -> Bool
Prelude.Eq, Int -> GrowthRateComputation -> ShowS
[GrowthRateComputation] -> ShowS
GrowthRateComputation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrowthRateComputation] -> ShowS
$cshowList :: [GrowthRateComputation] -> ShowS
show :: GrowthRateComputation -> String
$cshow :: GrowthRateComputation -> String
showsPrec :: Int -> GrowthRateComputation -> ShowS
$cshowsPrec :: Int -> GrowthRateComputation -> ShowS
Prelude.Show, forall x. Rep GrowthRateComputation x -> GrowthRateComputation
forall x. GrowthRateComputation -> Rep GrowthRateComputation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GrowthRateComputation x -> GrowthRateComputation
$cfrom :: forall x. GrowthRateComputation -> Rep GrowthRateComputation x
Prelude.Generic)

-- |
-- Create a value of 'GrowthRateComputation' 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', 'growthRateComputation_name' - The name of a computation.
--
-- 'periodSize', 'growthRateComputation_periodSize' - The period size setup of a growth rate computation.
--
-- 'value', 'growthRateComputation_value' - The value field that is used in a computation.
--
-- 'computationId', 'growthRateComputation_computationId' - The ID for a computation.
--
-- 'time', 'growthRateComputation_time' - The time field that is used in a computation.
newGrowthRateComputation ::
  -- | 'computationId'
  Prelude.Text ->
  -- | 'time'
  DimensionField ->
  GrowthRateComputation
newGrowthRateComputation :: Text -> DimensionField -> GrowthRateComputation
newGrowthRateComputation Text
pComputationId_ DimensionField
pTime_ =
  GrowthRateComputation'
    { $sel:name:GrowthRateComputation' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:periodSize:GrowthRateComputation' :: Maybe Natural
periodSize = forall a. Maybe a
Prelude.Nothing,
      $sel:value:GrowthRateComputation' :: Maybe MeasureField
value = forall a. Maybe a
Prelude.Nothing,
      $sel:computationId:GrowthRateComputation' :: Text
computationId = Text
pComputationId_,
      $sel:time:GrowthRateComputation' :: DimensionField
time = DimensionField
pTime_
    }

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

-- | The period size setup of a growth rate computation.
growthRateComputation_periodSize :: Lens.Lens' GrowthRateComputation (Prelude.Maybe Prelude.Natural)
growthRateComputation_periodSize :: Lens' GrowthRateComputation (Maybe Natural)
growthRateComputation_periodSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrowthRateComputation' {Maybe Natural
periodSize :: Maybe Natural
$sel:periodSize:GrowthRateComputation' :: GrowthRateComputation -> Maybe Natural
periodSize} -> Maybe Natural
periodSize) (\s :: GrowthRateComputation
s@GrowthRateComputation' {} Maybe Natural
a -> GrowthRateComputation
s {$sel:periodSize:GrowthRateComputation' :: Maybe Natural
periodSize = Maybe Natural
a} :: GrowthRateComputation)

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

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

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

instance Data.FromJSON GrowthRateComputation where
  parseJSON :: Value -> Parser GrowthRateComputation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GrowthRateComputation"
      ( \Object
x ->
          Maybe Text
-> Maybe Natural
-> Maybe MeasureField
-> Text
-> DimensionField
-> GrowthRateComputation
GrowthRateComputation'
            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
"PeriodSize")
            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
"Time")
      )

instance Prelude.Hashable GrowthRateComputation where
  hashWithSalt :: Int -> GrowthRateComputation -> Int
hashWithSalt Int
_salt GrowthRateComputation' {Maybe Natural
Maybe Text
Maybe MeasureField
Text
DimensionField
time :: DimensionField
computationId :: Text
value :: Maybe MeasureField
periodSize :: Maybe Natural
name :: Maybe Text
$sel:time:GrowthRateComputation' :: GrowthRateComputation -> DimensionField
$sel:computationId:GrowthRateComputation' :: GrowthRateComputation -> Text
$sel:value:GrowthRateComputation' :: GrowthRateComputation -> Maybe MeasureField
$sel:periodSize:GrowthRateComputation' :: GrowthRateComputation -> Maybe Natural
$sel:name:GrowthRateComputation' :: GrowthRateComputation -> 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
periodSize
      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
time

instance Prelude.NFData GrowthRateComputation where
  rnf :: GrowthRateComputation -> ()
rnf GrowthRateComputation' {Maybe Natural
Maybe Text
Maybe MeasureField
Text
DimensionField
time :: DimensionField
computationId :: Text
value :: Maybe MeasureField
periodSize :: Maybe Natural
name :: Maybe Text
$sel:time:GrowthRateComputation' :: GrowthRateComputation -> DimensionField
$sel:computationId:GrowthRateComputation' :: GrowthRateComputation -> Text
$sel:value:GrowthRateComputation' :: GrowthRateComputation -> Maybe MeasureField
$sel:periodSize:GrowthRateComputation' :: GrowthRateComputation -> Maybe Natural
$sel:name:GrowthRateComputation' :: GrowthRateComputation -> 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
periodSize
      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
time

instance Data.ToJSON GrowthRateComputation where
  toJSON :: GrowthRateComputation -> Value
toJSON GrowthRateComputation' {Maybe Natural
Maybe Text
Maybe MeasureField
Text
DimensionField
time :: DimensionField
computationId :: Text
value :: Maybe MeasureField
periodSize :: Maybe Natural
name :: Maybe Text
$sel:time:GrowthRateComputation' :: GrowthRateComputation -> DimensionField
$sel:computationId:GrowthRateComputation' :: GrowthRateComputation -> Text
$sel:value:GrowthRateComputation' :: GrowthRateComputation -> Maybe MeasureField
$sel:periodSize:GrowthRateComputation' :: GrowthRateComputation -> Maybe Natural
$sel:name:GrowthRateComputation' :: GrowthRateComputation -> 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
"PeriodSize" 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
periodSize,
            (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
"Time" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DimensionField
time)
          ]
      )