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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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,
    -- | Returns the value of the metric.
    EdgeMetric -> Maybe Double
value :: Prelude.Maybe Prelude.Double,
    -- | Timestamp of when the metric was requested.
    EdgeMetric -> Maybe POSIX
timestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (EdgeMetric -> EdgeMetric -> Bool
(EdgeMetric -> EdgeMetric -> Bool)
-> (EdgeMetric -> EdgeMetric -> Bool) -> Eq EdgeMetric
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]
(Int -> ReadS EdgeMetric)
-> ReadS [EdgeMetric]
-> ReadPrec EdgeMetric
-> ReadPrec [EdgeMetric]
-> Read 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
(Int -> EdgeMetric -> ShowS)
-> (EdgeMetric -> String)
-> ([EdgeMetric] -> ShowS)
-> Show EdgeMetric
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. EdgeMetric -> Rep EdgeMetric x)
-> (forall x. Rep EdgeMetric x -> EdgeMetric) -> Generic EdgeMetric
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.
--
-- 'value', 'edgeMetric_value' - Returns the value of the metric.
--
-- 'timestamp', 'edgeMetric_timestamp' - Timestamp of when the metric was requested.
newEdgeMetric ::
  EdgeMetric
newEdgeMetric :: EdgeMetric
newEdgeMetric =
  EdgeMetric' :: Maybe Text
-> Maybe Text -> Maybe Double -> Maybe POSIX -> EdgeMetric
EdgeMetric'
    { $sel:dimension:EdgeMetric' :: Maybe Text
dimension = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:EdgeMetric' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:value:EdgeMetric' :: Maybe Double
value = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:EdgeMetric' :: Maybe POSIX
timestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The dimension of metrics published.
edgeMetric_dimension :: Lens.Lens' EdgeMetric (Prelude.Maybe Prelude.Text)
edgeMetric_dimension :: (Maybe Text -> f (Maybe Text)) -> EdgeMetric -> f EdgeMetric
edgeMetric_dimension = (EdgeMetric -> Maybe Text)
-> (EdgeMetric -> Maybe Text -> EdgeMetric)
-> Lens EdgeMetric EdgeMetric (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> EdgeMetric -> f EdgeMetric
edgeMetric_metricName = (EdgeMetric -> Maybe Text)
-> (EdgeMetric -> Maybe Text -> EdgeMetric)
-> Lens EdgeMetric EdgeMetric (Maybe Text) (Maybe Text)
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)

-- | Returns the value of the metric.
edgeMetric_value :: Lens.Lens' EdgeMetric (Prelude.Maybe Prelude.Double)
edgeMetric_value :: (Maybe Double -> f (Maybe Double)) -> EdgeMetric -> f EdgeMetric
edgeMetric_value = (EdgeMetric -> Maybe Double)
-> (EdgeMetric -> Maybe Double -> EdgeMetric)
-> Lens EdgeMetric EdgeMetric (Maybe Double) (Maybe Double)
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)

-- | Timestamp of when the metric was requested.
edgeMetric_timestamp :: Lens.Lens' EdgeMetric (Prelude.Maybe Prelude.UTCTime)
edgeMetric_timestamp :: (Maybe UTCTime -> f (Maybe UTCTime)) -> EdgeMetric -> f EdgeMetric
edgeMetric_timestamp = (EdgeMetric -> Maybe POSIX)
-> (EdgeMetric -> Maybe POSIX -> EdgeMetric)
-> Lens EdgeMetric EdgeMetric (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> EdgeMetric -> f EdgeMetric)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EdgeMetric
-> f EdgeMetric
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 Prelude.Hashable EdgeMetric

instance Prelude.NFData EdgeMetric

instance Core.ToJSON EdgeMetric where
  toJSON :: EdgeMetric -> Value
toJSON EdgeMetric' {Maybe Double
Maybe Text
Maybe POSIX
timestamp :: Maybe POSIX
value :: Maybe Double
metricName :: Maybe Text
dimension :: Maybe Text
$sel:timestamp:EdgeMetric' :: EdgeMetric -> Maybe POSIX
$sel:value:EdgeMetric' :: EdgeMetric -> Maybe Double
$sel:metricName:EdgeMetric' :: EdgeMetric -> Maybe Text
$sel:dimension:EdgeMetric' :: EdgeMetric -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Dimension" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dimension,
            (Text
"MetricName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
metricName,
            (Text
"Value" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
value,
            (Text
"Timestamp" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
timestamp
          ]
      )