{-# 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.MetricResult
-- 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.MetricResult 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 Forecast calculated when monitoring predictor
-- usage. You can compare the value for this metric to the metric\'s value
-- in the Baseline to see how your predictor\'s performance is changing.
--
-- For more information about metrics generated by Forecast see
-- <https://docs.aws.amazon.com/forecast/latest/dg/metrics.html Evaluating Predictor Accuracy>
--
-- /See:/ 'newMetricResult' smart constructor.
data MetricResult = MetricResult'
  { -- | The name of the metric.
    MetricResult -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The value for the metric.
    MetricResult -> Maybe Double
metricValue :: Prelude.Maybe Prelude.Double
  }
  deriving (MetricResult -> MetricResult -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricResult -> MetricResult -> Bool
$c/= :: MetricResult -> MetricResult -> Bool
== :: MetricResult -> MetricResult -> Bool
$c== :: MetricResult -> MetricResult -> Bool
Prelude.Eq, ReadPrec [MetricResult]
ReadPrec MetricResult
Int -> ReadS MetricResult
ReadS [MetricResult]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricResult]
$creadListPrec :: ReadPrec [MetricResult]
readPrec :: ReadPrec MetricResult
$creadPrec :: ReadPrec MetricResult
readList :: ReadS [MetricResult]
$creadList :: ReadS [MetricResult]
readsPrec :: Int -> ReadS MetricResult
$creadsPrec :: Int -> ReadS MetricResult
Prelude.Read, Int -> MetricResult -> ShowS
[MetricResult] -> ShowS
MetricResult -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricResult] -> ShowS
$cshowList :: [MetricResult] -> ShowS
show :: MetricResult -> String
$cshow :: MetricResult -> String
showsPrec :: Int -> MetricResult -> ShowS
$cshowsPrec :: Int -> MetricResult -> ShowS
Prelude.Show, forall x. Rep MetricResult x -> MetricResult
forall x. MetricResult -> Rep MetricResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricResult x -> MetricResult
$cfrom :: forall x. MetricResult -> Rep MetricResult x
Prelude.Generic)

-- |
-- Create a value of 'MetricResult' 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:
--
-- 'metricName', 'metricResult_metricName' - The name of the metric.
--
-- 'metricValue', 'metricResult_metricValue' - The value for the metric.
newMetricResult ::
  MetricResult
newMetricResult :: MetricResult
newMetricResult =
  MetricResult'
    { $sel:metricName:MetricResult' :: Maybe Text
metricName = forall a. Maybe a
Prelude.Nothing,
      $sel:metricValue:MetricResult' :: Maybe Double
metricValue = forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.Hashable MetricResult where
  hashWithSalt :: Int -> MetricResult -> Int
hashWithSalt Int
_salt MetricResult' {Maybe Double
Maybe Text
metricValue :: Maybe Double
metricName :: Maybe Text
$sel:metricValue:MetricResult' :: MetricResult -> Maybe Double
$sel:metricName:MetricResult' :: MetricResult -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
metricName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
metricValue

instance Prelude.NFData MetricResult where
  rnf :: MetricResult -> ()
rnf MetricResult' {Maybe Double
Maybe Text
metricValue :: Maybe Double
metricName :: Maybe Text
$sel:metricValue:MetricResult' :: MetricResult -> Maybe Double
$sel:metricName:MetricResult' :: MetricResult -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
metricName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
metricValue