{-# 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.SageMakerEdge.Types.EdgeMetric
-- 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.SageMakerEdge.Types.EdgeMetric 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

-- | Information required for edge device metrics.
--
-- /See:/ 'newEdgeMetric' smart constructor.
data EdgeMetric = EdgeMetric'
  { -- | The dimension of metrics published.
    EdgeMetric -> Maybe Text
dimension :: Prelude.Maybe Prelude.Text,
    -- | Returns the name of the metric.
    EdgeMetric -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | Timestamp of when the metric was requested.
    EdgeMetric -> Maybe POSIX
timestamp :: Prelude.Maybe Data.POSIX,
    -- | Returns the value of the metric.
    EdgeMetric -> Maybe Double
value :: Prelude.Maybe Prelude.Double
  }
  deriving (EdgeMetric -> EdgeMetric -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EdgeMetric -> EdgeMetric -> Bool
$c/= :: EdgeMetric -> EdgeMetric -> Bool
== :: EdgeMetric -> EdgeMetric -> Bool
$c== :: EdgeMetric -> EdgeMetric -> Bool
Prelude.Eq, ReadPrec [EdgeMetric]
ReadPrec EdgeMetric
Int -> ReadS EdgeMetric
ReadS [EdgeMetric]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EdgeMetric]
$creadListPrec :: ReadPrec [EdgeMetric]
readPrec :: ReadPrec EdgeMetric
$creadPrec :: ReadPrec EdgeMetric
readList :: ReadS [EdgeMetric]
$creadList :: ReadS [EdgeMetric]
readsPrec :: Int -> ReadS EdgeMetric
$creadsPrec :: Int -> ReadS EdgeMetric
Prelude.Read, Int -> EdgeMetric -> ShowS
[EdgeMetric] -> ShowS
EdgeMetric -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EdgeMetric] -> ShowS
$cshowList :: [EdgeMetric] -> ShowS
show :: EdgeMetric -> String
$cshow :: EdgeMetric -> String
showsPrec :: Int -> EdgeMetric -> ShowS
$cshowsPrec :: Int -> EdgeMetric -> ShowS
Prelude.Show, forall x. Rep EdgeMetric x -> EdgeMetric
forall x. EdgeMetric -> Rep EdgeMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EdgeMetric x -> EdgeMetric
$cfrom :: forall x. EdgeMetric -> Rep EdgeMetric x
Prelude.Generic)

-- |
-- Create a value of 'EdgeMetric' 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:
--
-- 'dimension', 'edgeMetric_dimension' - The dimension of metrics published.
--
-- 'metricName', 'edgeMetric_metricName' - Returns the name of the metric.
--
-- 'timestamp', 'edgeMetric_timestamp' - Timestamp of when the metric was requested.
--
-- 'value', 'edgeMetric_value' - Returns the value of the metric.
newEdgeMetric ::
  EdgeMetric
newEdgeMetric :: EdgeMetric
newEdgeMetric =
  EdgeMetric'
    { $sel:dimension:EdgeMetric' :: Maybe Text
dimension = forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:EdgeMetric' :: Maybe Text
metricName = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:EdgeMetric' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:value:EdgeMetric' :: Maybe Double
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The dimension of metrics published.
edgeMetric_dimension :: Lens.Lens' EdgeMetric (Prelude.Maybe Prelude.Text)
edgeMetric_dimension :: Lens' EdgeMetric (Maybe Text)
edgeMetric_dimension = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeMetric' {Maybe Text
dimension :: Maybe Text
$sel:dimension:EdgeMetric' :: EdgeMetric -> Maybe Text
dimension} -> Maybe Text
dimension) (\s :: EdgeMetric
s@EdgeMetric' {} Maybe Text
a -> EdgeMetric
s {$sel:dimension:EdgeMetric' :: Maybe Text
dimension = Maybe Text
a} :: EdgeMetric)

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

-- | Timestamp of when the metric was requested.
edgeMetric_timestamp :: Lens.Lens' EdgeMetric (Prelude.Maybe Prelude.UTCTime)
edgeMetric_timestamp :: Lens' EdgeMetric (Maybe UTCTime)
edgeMetric_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdgeMetric' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:EdgeMetric' :: EdgeMetric -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: EdgeMetric
s@EdgeMetric' {} Maybe POSIX
a -> EdgeMetric
s {$sel:timestamp:EdgeMetric' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: EdgeMetric) 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

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

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

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