{-# 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.SageMaker.Types.MetricData
-- 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.SageMaker.Types.MetricData 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

-- | The name, value, and date and time of a metric that was emitted to
-- Amazon CloudWatch.
--
-- /See:/ 'newMetricData' smart constructor.
data MetricData = MetricData'
  { -- | The name of the metric.
    MetricData -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the algorithm emitted the metric.
    MetricData -> Maybe POSIX
timestamp :: Prelude.Maybe Data.POSIX,
    -- | The value of the metric.
    MetricData -> Maybe Double
value :: Prelude.Maybe Prelude.Double
  }
  deriving (MetricData -> MetricData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricData -> MetricData -> Bool
$c/= :: MetricData -> MetricData -> Bool
== :: MetricData -> MetricData -> Bool
$c== :: MetricData -> MetricData -> Bool
Prelude.Eq, ReadPrec [MetricData]
ReadPrec MetricData
Int -> ReadS MetricData
ReadS [MetricData]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricData]
$creadListPrec :: ReadPrec [MetricData]
readPrec :: ReadPrec MetricData
$creadPrec :: ReadPrec MetricData
readList :: ReadS [MetricData]
$creadList :: ReadS [MetricData]
readsPrec :: Int -> ReadS MetricData
$creadsPrec :: Int -> ReadS MetricData
Prelude.Read, Int -> MetricData -> ShowS
[MetricData] -> ShowS
MetricData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricData] -> ShowS
$cshowList :: [MetricData] -> ShowS
show :: MetricData -> String
$cshow :: MetricData -> String
showsPrec :: Int -> MetricData -> ShowS
$cshowsPrec :: Int -> MetricData -> ShowS
Prelude.Show, forall x. Rep MetricData x -> MetricData
forall x. MetricData -> Rep MetricData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricData x -> MetricData
$cfrom :: forall x. MetricData -> Rep MetricData x
Prelude.Generic)

-- |
-- Create a value of 'MetricData' 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', 'metricData_metricName' - The name of the metric.
--
-- 'timestamp', 'metricData_timestamp' - The date and time that the algorithm emitted the metric.
--
-- 'value', 'metricData_value' - The value of the metric.
newMetricData ::
  MetricData
newMetricData :: MetricData
newMetricData =
  MetricData'
    { $sel:metricName:MetricData' :: Maybe Text
metricName = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:MetricData' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:value:MetricData' :: Maybe Double
value = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The date and time that the algorithm emitted the metric.
metricData_timestamp :: Lens.Lens' MetricData (Prelude.Maybe Prelude.UTCTime)
metricData_timestamp :: Lens' MetricData (Maybe UTCTime)
metricData_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricData' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:MetricData' :: MetricData -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: MetricData
s@MetricData' {} Maybe POSIX
a -> MetricData
s {$sel:timestamp:MetricData' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: MetricData) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

instance Data.FromJSON MetricData where
  parseJSON :: Value -> Parser MetricData
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MetricData"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> Maybe Double -> MetricData
MetricData'
            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
"Timestamp")
            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 MetricData where
  hashWithSalt :: Int -> MetricData -> Int
hashWithSalt Int
_salt MetricData' {Maybe Double
Maybe Text
Maybe POSIX
value :: Maybe Double
timestamp :: Maybe POSIX
metricName :: Maybe Text
$sel:value:MetricData' :: MetricData -> Maybe Double
$sel:timestamp:MetricData' :: MetricData -> Maybe POSIX
$sel:metricName:MetricData' :: MetricData -> 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 POSIX
timestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
value

instance Prelude.NFData MetricData where
  rnf :: MetricData -> ()
rnf MetricData' {Maybe Double
Maybe Text
Maybe POSIX
value :: Maybe Double
timestamp :: Maybe POSIX
metricName :: Maybe Text
$sel:value:MetricData' :: MetricData -> Maybe Double
$sel:timestamp:MetricData' :: MetricData -> Maybe POSIX
$sel:metricName:MetricData' :: MetricData -> 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 POSIX
timestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
value