{-# 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.SageMakerMetrics.Types.RawMetricData
-- 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.SageMakerMetrics.Types.RawMetricData 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 raw metric data to associate with the resource.
--
-- /See:/ 'newRawMetricData' smart constructor.
data RawMetricData = RawMetricData'
  { -- | The metric step (epoch).
    RawMetricData -> Maybe Natural
step :: Prelude.Maybe Prelude.Natural,
    -- | The name of the metric.
    RawMetricData -> Text
metricName :: Prelude.Text,
    -- | The time that the metric was recorded.
    RawMetricData -> POSIX
timestamp :: Data.POSIX,
    -- | The metric value.
    RawMetricData -> Double
value :: Prelude.Double
  }
  deriving (RawMetricData -> RawMetricData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RawMetricData -> RawMetricData -> Bool
$c/= :: RawMetricData -> RawMetricData -> Bool
== :: RawMetricData -> RawMetricData -> Bool
$c== :: RawMetricData -> RawMetricData -> Bool
Prelude.Eq, ReadPrec [RawMetricData]
ReadPrec RawMetricData
Int -> ReadS RawMetricData
ReadS [RawMetricData]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RawMetricData]
$creadListPrec :: ReadPrec [RawMetricData]
readPrec :: ReadPrec RawMetricData
$creadPrec :: ReadPrec RawMetricData
readList :: ReadS [RawMetricData]
$creadList :: ReadS [RawMetricData]
readsPrec :: Int -> ReadS RawMetricData
$creadsPrec :: Int -> ReadS RawMetricData
Prelude.Read, Int -> RawMetricData -> ShowS
[RawMetricData] -> ShowS
RawMetricData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RawMetricData] -> ShowS
$cshowList :: [RawMetricData] -> ShowS
show :: RawMetricData -> String
$cshow :: RawMetricData -> String
showsPrec :: Int -> RawMetricData -> ShowS
$cshowsPrec :: Int -> RawMetricData -> ShowS
Prelude.Show, forall x. Rep RawMetricData x -> RawMetricData
forall x. RawMetricData -> Rep RawMetricData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RawMetricData x -> RawMetricData
$cfrom :: forall x. RawMetricData -> Rep RawMetricData x
Prelude.Generic)

-- |
-- Create a value of 'RawMetricData' 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:
--
-- 'step', 'rawMetricData_step' - The metric step (epoch).
--
-- 'metricName', 'rawMetricData_metricName' - The name of the metric.
--
-- 'timestamp', 'rawMetricData_timestamp' - The time that the metric was recorded.
--
-- 'value', 'rawMetricData_value' - The metric value.
newRawMetricData ::
  -- | 'metricName'
  Prelude.Text ->
  -- | 'timestamp'
  Prelude.UTCTime ->
  -- | 'value'
  Prelude.Double ->
  RawMetricData
newRawMetricData :: Text -> UTCTime -> Double -> RawMetricData
newRawMetricData Text
pMetricName_ UTCTime
pTimestamp_ Double
pValue_ =
  RawMetricData'
    { $sel:step:RawMetricData' :: Maybe Natural
step = forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:RawMetricData' :: Text
metricName = Text
pMetricName_,
      $sel:timestamp:RawMetricData' :: POSIX
timestamp = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pTimestamp_,
      $sel:value:RawMetricData' :: Double
value = Double
pValue_
    }

-- | The metric step (epoch).
rawMetricData_step :: Lens.Lens' RawMetricData (Prelude.Maybe Prelude.Natural)
rawMetricData_step :: Lens' RawMetricData (Maybe Natural)
rawMetricData_step = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RawMetricData' {Maybe Natural
step :: Maybe Natural
$sel:step:RawMetricData' :: RawMetricData -> Maybe Natural
step} -> Maybe Natural
step) (\s :: RawMetricData
s@RawMetricData' {} Maybe Natural
a -> RawMetricData
s {$sel:step:RawMetricData' :: Maybe Natural
step = Maybe Natural
a} :: RawMetricData)

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

-- | The time that the metric was recorded.
rawMetricData_timestamp :: Lens.Lens' RawMetricData Prelude.UTCTime
rawMetricData_timestamp :: Lens' RawMetricData UTCTime
rawMetricData_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RawMetricData' {POSIX
timestamp :: POSIX
$sel:timestamp:RawMetricData' :: RawMetricData -> POSIX
timestamp} -> POSIX
timestamp) (\s :: RawMetricData
s@RawMetricData' {} POSIX
a -> RawMetricData
s {$sel:timestamp:RawMetricData' :: POSIX
timestamp = POSIX
a} :: RawMetricData) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The metric value.
rawMetricData_value :: Lens.Lens' RawMetricData Prelude.Double
rawMetricData_value :: Lens' RawMetricData Double
rawMetricData_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RawMetricData' {Double
value :: Double
$sel:value:RawMetricData' :: RawMetricData -> Double
value} -> Double
value) (\s :: RawMetricData
s@RawMetricData' {} Double
a -> RawMetricData
s {$sel:value:RawMetricData' :: Double
value = Double
a} :: RawMetricData)

instance Prelude.Hashable RawMetricData where
  hashWithSalt :: Int -> RawMetricData -> Int
hashWithSalt Int
_salt RawMetricData' {Double
Maybe Natural
Text
POSIX
value :: Double
timestamp :: POSIX
metricName :: Text
step :: Maybe Natural
$sel:value:RawMetricData' :: RawMetricData -> Double
$sel:timestamp:RawMetricData' :: RawMetricData -> POSIX
$sel:metricName:RawMetricData' :: RawMetricData -> Text
$sel:step:RawMetricData' :: RawMetricData -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
step
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
metricName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
timestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
value

instance Prelude.NFData RawMetricData where
  rnf :: RawMetricData -> ()
rnf RawMetricData' {Double
Maybe Natural
Text
POSIX
value :: Double
timestamp :: POSIX
metricName :: Text
step :: Maybe Natural
$sel:value:RawMetricData' :: RawMetricData -> Double
$sel:timestamp:RawMetricData' :: RawMetricData -> POSIX
$sel:metricName:RawMetricData' :: RawMetricData -> Text
$sel:step:RawMetricData' :: RawMetricData -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
step
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
metricName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
timestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
value

instance Data.ToJSON RawMetricData where
  toJSON :: RawMetricData -> Value
toJSON RawMetricData' {Double
Maybe Natural
Text
POSIX
value :: Double
timestamp :: POSIX
metricName :: Text
step :: Maybe Natural
$sel:value:RawMetricData' :: RawMetricData -> Double
$sel:timestamp:RawMetricData' :: RawMetricData -> POSIX
$sel:metricName:RawMetricData' :: RawMetricData -> Text
$sel:step:RawMetricData' :: RawMetricData -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Step" 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
step,
            forall a. a -> Maybe a
Prelude.Just (Key
"MetricName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
metricName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Timestamp" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= POSIX
timestamp),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
value)
          ]
      )