{-# 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.Forecast.Types.BaselineMetric
-- 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.Forecast.Types.BaselineMetric 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

-- | An individual metric that you can use for comparison as you evaluate
-- your monitoring results.
--
-- /See:/ 'newBaselineMetric' smart constructor.
data BaselineMetric = BaselineMetric'
  { -- | The name of the metric.
    BaselineMetric -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The value for the metric.
    BaselineMetric -> Maybe Double
value :: Prelude.Maybe Prelude.Double
  }
  deriving (BaselineMetric -> BaselineMetric -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BaselineMetric -> BaselineMetric -> Bool
$c/= :: BaselineMetric -> BaselineMetric -> Bool
== :: BaselineMetric -> BaselineMetric -> Bool
$c== :: BaselineMetric -> BaselineMetric -> Bool
Prelude.Eq, ReadPrec [BaselineMetric]
ReadPrec BaselineMetric
Int -> ReadS BaselineMetric
ReadS [BaselineMetric]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BaselineMetric]
$creadListPrec :: ReadPrec [BaselineMetric]
readPrec :: ReadPrec BaselineMetric
$creadPrec :: ReadPrec BaselineMetric
readList :: ReadS [BaselineMetric]
$creadList :: ReadS [BaselineMetric]
readsPrec :: Int -> ReadS BaselineMetric
$creadsPrec :: Int -> ReadS BaselineMetric
Prelude.Read, Int -> BaselineMetric -> ShowS
[BaselineMetric] -> ShowS
BaselineMetric -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BaselineMetric] -> ShowS
$cshowList :: [BaselineMetric] -> ShowS
show :: BaselineMetric -> String
$cshow :: BaselineMetric -> String
showsPrec :: Int -> BaselineMetric -> ShowS
$cshowsPrec :: Int -> BaselineMetric -> ShowS
Prelude.Show, forall x. Rep BaselineMetric x -> BaselineMetric
forall x. BaselineMetric -> Rep BaselineMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BaselineMetric x -> BaselineMetric
$cfrom :: forall x. BaselineMetric -> Rep BaselineMetric x
Prelude.Generic)

-- |
-- Create a value of 'BaselineMetric' 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', 'baselineMetric_name' - The name of the metric.
--
-- 'value', 'baselineMetric_value' - The value for the metric.
newBaselineMetric ::
  BaselineMetric
newBaselineMetric :: BaselineMetric
newBaselineMetric =
  BaselineMetric'
    { $sel:name:BaselineMetric' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:value:BaselineMetric' :: Maybe Double
value = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The value for the metric.
baselineMetric_value :: Lens.Lens' BaselineMetric (Prelude.Maybe Prelude.Double)
baselineMetric_value :: Lens' BaselineMetric (Maybe Double)
baselineMetric_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BaselineMetric' {Maybe Double
value :: Maybe Double
$sel:value:BaselineMetric' :: BaselineMetric -> Maybe Double
value} -> Maybe Double
value) (\s :: BaselineMetric
s@BaselineMetric' {} Maybe Double
a -> BaselineMetric
s {$sel:value:BaselineMetric' :: Maybe Double
value = Maybe Double
a} :: BaselineMetric)

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

instance Prelude.Hashable BaselineMetric where
  hashWithSalt :: Int -> BaselineMetric -> Int
hashWithSalt Int
_salt BaselineMetric' {Maybe Double
Maybe Text
value :: Maybe Double
name :: Maybe Text
$sel:value:BaselineMetric' :: BaselineMetric -> Maybe Double
$sel:name:BaselineMetric' :: BaselineMetric -> 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 Double
value

instance Prelude.NFData BaselineMetric where
  rnf :: BaselineMetric -> ()
rnf BaselineMetric' {Maybe Double
Maybe Text
value :: Maybe Double
name :: Maybe Text
$sel:value:BaselineMetric' :: BaselineMetric -> Maybe Double
$sel:name:BaselineMetric' :: BaselineMetric -> 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 Double
value