{-# 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.MwAA.Types.MetricDatum
-- 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.MwAA.Types.MetricDatum where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MwAA.Types.Dimension
import Amazonka.MwAA.Types.StatisticSet
import Amazonka.MwAA.Types.Unit
import qualified Amazonka.Prelude as Prelude

-- | Internal only API.
--
-- /See:/ 'newMetricDatum' smart constructor.
data MetricDatum = MetricDatum'
  { -- | Internal only API.
    MetricDatum -> Maybe Double
value :: Prelude.Maybe Prelude.Double,
    -- | Internal only API.
    MetricDatum -> Maybe [Dimension]
dimensions :: Prelude.Maybe [Dimension],
    MetricDatum -> Maybe Unit
unit :: Prelude.Maybe Unit,
    -- | Internal only API.
    MetricDatum -> Maybe StatisticSet
statisticValues :: Prelude.Maybe StatisticSet,
    -- | Internal only API.
    MetricDatum -> Text
metricName :: Prelude.Text,
    -- | Internal only API.
    MetricDatum -> POSIX
timestamp :: Core.POSIX
  }
  deriving (MetricDatum -> MetricDatum -> Bool
(MetricDatum -> MetricDatum -> Bool)
-> (MetricDatum -> MetricDatum -> Bool) -> Eq MetricDatum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricDatum -> MetricDatum -> Bool
$c/= :: MetricDatum -> MetricDatum -> Bool
== :: MetricDatum -> MetricDatum -> Bool
$c== :: MetricDatum -> MetricDatum -> Bool
Prelude.Eq, ReadPrec [MetricDatum]
ReadPrec MetricDatum
Int -> ReadS MetricDatum
ReadS [MetricDatum]
(Int -> ReadS MetricDatum)
-> ReadS [MetricDatum]
-> ReadPrec MetricDatum
-> ReadPrec [MetricDatum]
-> Read MetricDatum
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricDatum]
$creadListPrec :: ReadPrec [MetricDatum]
readPrec :: ReadPrec MetricDatum
$creadPrec :: ReadPrec MetricDatum
readList :: ReadS [MetricDatum]
$creadList :: ReadS [MetricDatum]
readsPrec :: Int -> ReadS MetricDatum
$creadsPrec :: Int -> ReadS MetricDatum
Prelude.Read, Int -> MetricDatum -> ShowS
[MetricDatum] -> ShowS
MetricDatum -> String
(Int -> MetricDatum -> ShowS)
-> (MetricDatum -> String)
-> ([MetricDatum] -> ShowS)
-> Show MetricDatum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricDatum] -> ShowS
$cshowList :: [MetricDatum] -> ShowS
show :: MetricDatum -> String
$cshow :: MetricDatum -> String
showsPrec :: Int -> MetricDatum -> ShowS
$cshowsPrec :: Int -> MetricDatum -> ShowS
Prelude.Show, (forall x. MetricDatum -> Rep MetricDatum x)
-> (forall x. Rep MetricDatum x -> MetricDatum)
-> Generic MetricDatum
forall x. Rep MetricDatum x -> MetricDatum
forall x. MetricDatum -> Rep MetricDatum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricDatum x -> MetricDatum
$cfrom :: forall x. MetricDatum -> Rep MetricDatum x
Prelude.Generic)

-- |
-- Create a value of 'MetricDatum' 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:
--
-- 'value', 'metricDatum_value' - Internal only API.
--
-- 'dimensions', 'metricDatum_dimensions' - Internal only API.
--
-- 'unit', 'metricDatum_unit' - Undocumented member.
--
-- 'statisticValues', 'metricDatum_statisticValues' - Internal only API.
--
-- 'metricName', 'metricDatum_metricName' - Internal only API.
--
-- 'timestamp', 'metricDatum_timestamp' - Internal only API.
newMetricDatum ::
  -- | 'metricName'
  Prelude.Text ->
  -- | 'timestamp'
  Prelude.UTCTime ->
  MetricDatum
newMetricDatum :: Text -> UTCTime -> MetricDatum
newMetricDatum Text
pMetricName_ UTCTime
pTimestamp_ =
  MetricDatum' :: Maybe Double
-> Maybe [Dimension]
-> Maybe Unit
-> Maybe StatisticSet
-> Text
-> POSIX
-> MetricDatum
MetricDatum'
    { $sel:value:MetricDatum' :: Maybe Double
value = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:dimensions:MetricDatum' :: Maybe [Dimension]
dimensions = Maybe [Dimension]
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:MetricDatum' :: Maybe Unit
unit = Maybe Unit
forall a. Maybe a
Prelude.Nothing,
      $sel:statisticValues:MetricDatum' :: Maybe StatisticSet
statisticValues = Maybe StatisticSet
forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:MetricDatum' :: Text
metricName = Text
pMetricName_,
      $sel:timestamp:MetricDatum' :: POSIX
timestamp = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pTimestamp_
    }

-- | Internal only API.
metricDatum_value :: Lens.Lens' MetricDatum (Prelude.Maybe Prelude.Double)
metricDatum_value :: (Maybe Double -> f (Maybe Double)) -> MetricDatum -> f MetricDatum
metricDatum_value = (MetricDatum -> Maybe Double)
-> (MetricDatum -> Maybe Double -> MetricDatum)
-> Lens MetricDatum MetricDatum (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatum' {Maybe Double
value :: Maybe Double
$sel:value:MetricDatum' :: MetricDatum -> Maybe Double
value} -> Maybe Double
value) (\s :: MetricDatum
s@MetricDatum' {} Maybe Double
a -> MetricDatum
s {$sel:value:MetricDatum' :: Maybe Double
value = Maybe Double
a} :: MetricDatum)

-- | Internal only API.
metricDatum_dimensions :: Lens.Lens' MetricDatum (Prelude.Maybe [Dimension])
metricDatum_dimensions :: (Maybe [Dimension] -> f (Maybe [Dimension]))
-> MetricDatum -> f MetricDatum
metricDatum_dimensions = (MetricDatum -> Maybe [Dimension])
-> (MetricDatum -> Maybe [Dimension] -> MetricDatum)
-> Lens
     MetricDatum MetricDatum (Maybe [Dimension]) (Maybe [Dimension])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatum' {Maybe [Dimension]
dimensions :: Maybe [Dimension]
$sel:dimensions:MetricDatum' :: MetricDatum -> Maybe [Dimension]
dimensions} -> Maybe [Dimension]
dimensions) (\s :: MetricDatum
s@MetricDatum' {} Maybe [Dimension]
a -> MetricDatum
s {$sel:dimensions:MetricDatum' :: Maybe [Dimension]
dimensions = Maybe [Dimension]
a} :: MetricDatum) ((Maybe [Dimension] -> f (Maybe [Dimension]))
 -> MetricDatum -> f MetricDatum)
-> ((Maybe [Dimension] -> f (Maybe [Dimension]))
    -> Maybe [Dimension] -> f (Maybe [Dimension]))
-> (Maybe [Dimension] -> f (Maybe [Dimension]))
-> MetricDatum
-> f MetricDatum
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Dimension] [Dimension] [Dimension] [Dimension]
-> Iso
     (Maybe [Dimension])
     (Maybe [Dimension])
     (Maybe [Dimension])
     (Maybe [Dimension])
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 [Dimension] [Dimension] [Dimension] [Dimension]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
metricDatum_unit :: Lens.Lens' MetricDatum (Prelude.Maybe Unit)
metricDatum_unit :: (Maybe Unit -> f (Maybe Unit)) -> MetricDatum -> f MetricDatum
metricDatum_unit = (MetricDatum -> Maybe Unit)
-> (MetricDatum -> Maybe Unit -> MetricDatum)
-> Lens MetricDatum MetricDatum (Maybe Unit) (Maybe Unit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatum' {Maybe Unit
unit :: Maybe Unit
$sel:unit:MetricDatum' :: MetricDatum -> Maybe Unit
unit} -> Maybe Unit
unit) (\s :: MetricDatum
s@MetricDatum' {} Maybe Unit
a -> MetricDatum
s {$sel:unit:MetricDatum' :: Maybe Unit
unit = Maybe Unit
a} :: MetricDatum)

-- | Internal only API.
metricDatum_statisticValues :: Lens.Lens' MetricDatum (Prelude.Maybe StatisticSet)
metricDatum_statisticValues :: (Maybe StatisticSet -> f (Maybe StatisticSet))
-> MetricDatum -> f MetricDatum
metricDatum_statisticValues = (MetricDatum -> Maybe StatisticSet)
-> (MetricDatum -> Maybe StatisticSet -> MetricDatum)
-> Lens
     MetricDatum MetricDatum (Maybe StatisticSet) (Maybe StatisticSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatum' {Maybe StatisticSet
statisticValues :: Maybe StatisticSet
$sel:statisticValues:MetricDatum' :: MetricDatum -> Maybe StatisticSet
statisticValues} -> Maybe StatisticSet
statisticValues) (\s :: MetricDatum
s@MetricDatum' {} Maybe StatisticSet
a -> MetricDatum
s {$sel:statisticValues:MetricDatum' :: Maybe StatisticSet
statisticValues = Maybe StatisticSet
a} :: MetricDatum)

-- | Internal only API.
metricDatum_metricName :: Lens.Lens' MetricDatum Prelude.Text
metricDatum_metricName :: (Text -> f Text) -> MetricDatum -> f MetricDatum
metricDatum_metricName = (MetricDatum -> Text)
-> (MetricDatum -> Text -> MetricDatum)
-> Lens MetricDatum MetricDatum Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatum' {Text
metricName :: Text
$sel:metricName:MetricDatum' :: MetricDatum -> Text
metricName} -> Text
metricName) (\s :: MetricDatum
s@MetricDatum' {} Text
a -> MetricDatum
s {$sel:metricName:MetricDatum' :: Text
metricName = Text
a} :: MetricDatum)

-- | Internal only API.
metricDatum_timestamp :: Lens.Lens' MetricDatum Prelude.UTCTime
metricDatum_timestamp :: (UTCTime -> f UTCTime) -> MetricDatum -> f MetricDatum
metricDatum_timestamp = (MetricDatum -> POSIX)
-> (MetricDatum -> POSIX -> MetricDatum)
-> Lens MetricDatum MetricDatum POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatum' {POSIX
timestamp :: POSIX
$sel:timestamp:MetricDatum' :: MetricDatum -> POSIX
timestamp} -> POSIX
timestamp) (\s :: MetricDatum
s@MetricDatum' {} POSIX
a -> MetricDatum
s {$sel:timestamp:MetricDatum' :: POSIX
timestamp = POSIX
a} :: MetricDatum) ((POSIX -> f POSIX) -> MetricDatum -> f MetricDatum)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> MetricDatum
-> f MetricDatum
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Prelude.Hashable MetricDatum

instance Prelude.NFData MetricDatum

instance Core.ToJSON MetricDatum where
  toJSON :: MetricDatum -> Value
toJSON MetricDatum' {Maybe Double
Maybe [Dimension]
Maybe StatisticSet
Maybe Unit
Text
POSIX
timestamp :: POSIX
metricName :: Text
statisticValues :: Maybe StatisticSet
unit :: Maybe Unit
dimensions :: Maybe [Dimension]
value :: Maybe Double
$sel:timestamp:MetricDatum' :: MetricDatum -> POSIX
$sel:metricName:MetricDatum' :: MetricDatum -> Text
$sel:statisticValues:MetricDatum' :: MetricDatum -> Maybe StatisticSet
$sel:unit:MetricDatum' :: MetricDatum -> Maybe Unit
$sel:dimensions:MetricDatum' :: MetricDatum -> Maybe [Dimension]
$sel:value:MetricDatum' :: MetricDatum -> Maybe Double
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"Dimensions" Text -> [Dimension] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Dimension] -> Pair) -> Maybe [Dimension] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Dimension]
dimensions,
            (Text
"Unit" Text -> Unit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Unit -> Pair) -> Maybe Unit -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Unit
unit,
            (Text
"StatisticValues" Text -> StatisticSet -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (StatisticSet -> Pair) -> Maybe StatisticSet -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StatisticSet
statisticValues,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MetricName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
metricName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Timestamp" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
timestamp)
          ]
      )