{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.MetricData where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 value of the metric.
    MetricData -> Maybe Double
value :: Prelude.Maybe Prelude.Double,
    -- | The date and time that the algorithm emitted the metric.
    MetricData -> Maybe POSIX
timestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (MetricData -> MetricData -> Bool
(MetricData -> MetricData -> Bool)
-> (MetricData -> MetricData -> Bool) -> Eq MetricData
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]
(Int -> ReadS MetricData)
-> ReadS [MetricData]
-> ReadPrec MetricData
-> ReadPrec [MetricData]
-> Read 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
(Int -> MetricData -> ShowS)
-> (MetricData -> String)
-> ([MetricData] -> ShowS)
-> Show MetricData
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. MetricData -> Rep MetricData x)
-> (forall x. Rep MetricData x -> MetricData) -> Generic MetricData
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.
--
-- 'value', 'metricData_value' - The value of the metric.
--
-- 'timestamp', 'metricData_timestamp' - The date and time that the algorithm emitted the metric.
newMetricData ::
  MetricData
newMetricData :: MetricData
newMetricData =
  MetricData' :: Maybe Text -> Maybe Double -> Maybe POSIX -> MetricData
MetricData'
    { $sel:metricName:MetricData' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:value:MetricData' :: Maybe Double
value = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:MetricData' :: Maybe POSIX
timestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the metric.
metricData_metricName :: Lens.Lens' MetricData (Prelude.Maybe Prelude.Text)
metricData_metricName :: (Maybe Text -> f (Maybe Text)) -> MetricData -> f MetricData
metricData_metricName = (MetricData -> Maybe Text)
-> (MetricData -> Maybe Text -> MetricData)
-> Lens MetricData MetricData (Maybe Text) (Maybe Text)
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 value of the metric.
metricData_value :: Lens.Lens' MetricData (Prelude.Maybe Prelude.Double)
metricData_value :: (Maybe Double -> f (Maybe Double)) -> MetricData -> f MetricData
metricData_value = (MetricData -> Maybe Double)
-> (MetricData -> Maybe Double -> MetricData)
-> Lens MetricData MetricData (Maybe Double) (Maybe Double)
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)

-- | The date and time that the algorithm emitted the metric.
metricData_timestamp :: Lens.Lens' MetricData (Prelude.Maybe Prelude.UTCTime)
metricData_timestamp :: (Maybe UTCTime -> f (Maybe UTCTime)) -> MetricData -> f MetricData
metricData_timestamp = (MetricData -> Maybe POSIX)
-> (MetricData -> Maybe POSIX -> MetricData)
-> Lens MetricData MetricData (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> MetricData -> f MetricData)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> MetricData
-> f MetricData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON MetricData where
  parseJSON :: Value -> Parser MetricData
parseJSON =
    String
-> (Object -> Parser MetricData) -> Value -> Parser MetricData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricData"
      ( \Object
x ->
          Maybe Text -> Maybe Double -> Maybe POSIX -> MetricData
MetricData'
            (Maybe Text -> Maybe Double -> Maybe POSIX -> MetricData)
-> Parser (Maybe Text)
-> Parser (Maybe Double -> Maybe POSIX -> MetricData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricName")
            Parser (Maybe Double -> Maybe POSIX -> MetricData)
-> Parser (Maybe Double) -> Parser (Maybe POSIX -> MetricData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value")
            Parser (Maybe POSIX -> MetricData)
-> Parser (Maybe POSIX) -> Parser MetricData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Timestamp")
      )

instance Prelude.Hashable MetricData

instance Prelude.NFData MetricData