{-# 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.DevOpsGuru.Types.TimestampMetricValuePair
-- 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.DevOpsGuru.Types.TimestampMetricValuePair 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

-- | A pair that contains metric values at the respective timestamp.
--
-- /See:/ 'newTimestampMetricValuePair' smart constructor.
data TimestampMetricValuePair = TimestampMetricValuePair'
  { -- | Value of the anomalous metric data point at respective Timestamp.
    TimestampMetricValuePair -> Maybe Double
metricValue :: Prelude.Maybe Prelude.Double,
    -- | A @Timestamp@ that specifies the time the event occurred.
    TimestampMetricValuePair -> Maybe POSIX
timestamp :: Prelude.Maybe Data.POSIX
  }
  deriving (TimestampMetricValuePair -> TimestampMetricValuePair -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimestampMetricValuePair -> TimestampMetricValuePair -> Bool
$c/= :: TimestampMetricValuePair -> TimestampMetricValuePair -> Bool
== :: TimestampMetricValuePair -> TimestampMetricValuePair -> Bool
$c== :: TimestampMetricValuePair -> TimestampMetricValuePair -> Bool
Prelude.Eq, ReadPrec [TimestampMetricValuePair]
ReadPrec TimestampMetricValuePair
Int -> ReadS TimestampMetricValuePair
ReadS [TimestampMetricValuePair]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimestampMetricValuePair]
$creadListPrec :: ReadPrec [TimestampMetricValuePair]
readPrec :: ReadPrec TimestampMetricValuePair
$creadPrec :: ReadPrec TimestampMetricValuePair
readList :: ReadS [TimestampMetricValuePair]
$creadList :: ReadS [TimestampMetricValuePair]
readsPrec :: Int -> ReadS TimestampMetricValuePair
$creadsPrec :: Int -> ReadS TimestampMetricValuePair
Prelude.Read, Int -> TimestampMetricValuePair -> ShowS
[TimestampMetricValuePair] -> ShowS
TimestampMetricValuePair -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimestampMetricValuePair] -> ShowS
$cshowList :: [TimestampMetricValuePair] -> ShowS
show :: TimestampMetricValuePair -> String
$cshow :: TimestampMetricValuePair -> String
showsPrec :: Int -> TimestampMetricValuePair -> ShowS
$cshowsPrec :: Int -> TimestampMetricValuePair -> ShowS
Prelude.Show, forall x.
Rep TimestampMetricValuePair x -> TimestampMetricValuePair
forall x.
TimestampMetricValuePair -> Rep TimestampMetricValuePair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TimestampMetricValuePair x -> TimestampMetricValuePair
$cfrom :: forall x.
TimestampMetricValuePair -> Rep TimestampMetricValuePair x
Prelude.Generic)

-- |
-- Create a value of 'TimestampMetricValuePair' 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:
--
-- 'metricValue', 'timestampMetricValuePair_metricValue' - Value of the anomalous metric data point at respective Timestamp.
--
-- 'timestamp', 'timestampMetricValuePair_timestamp' - A @Timestamp@ that specifies the time the event occurred.
newTimestampMetricValuePair ::
  TimestampMetricValuePair
newTimestampMetricValuePair :: TimestampMetricValuePair
newTimestampMetricValuePair =
  TimestampMetricValuePair'
    { $sel:metricValue:TimestampMetricValuePair' :: Maybe Double
metricValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:TimestampMetricValuePair' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | Value of the anomalous metric data point at respective Timestamp.
timestampMetricValuePair_metricValue :: Lens.Lens' TimestampMetricValuePair (Prelude.Maybe Prelude.Double)
timestampMetricValuePair_metricValue :: Lens' TimestampMetricValuePair (Maybe Double)
timestampMetricValuePair_metricValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestampMetricValuePair' {Maybe Double
metricValue :: Maybe Double
$sel:metricValue:TimestampMetricValuePair' :: TimestampMetricValuePair -> Maybe Double
metricValue} -> Maybe Double
metricValue) (\s :: TimestampMetricValuePair
s@TimestampMetricValuePair' {} Maybe Double
a -> TimestampMetricValuePair
s {$sel:metricValue:TimestampMetricValuePair' :: Maybe Double
metricValue = Maybe Double
a} :: TimestampMetricValuePair)

-- | A @Timestamp@ that specifies the time the event occurred.
timestampMetricValuePair_timestamp :: Lens.Lens' TimestampMetricValuePair (Prelude.Maybe Prelude.UTCTime)
timestampMetricValuePair_timestamp :: Lens' TimestampMetricValuePair (Maybe UTCTime)
timestampMetricValuePair_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestampMetricValuePair' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:TimestampMetricValuePair' :: TimestampMetricValuePair -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: TimestampMetricValuePair
s@TimestampMetricValuePair' {} Maybe POSIX
a -> TimestampMetricValuePair
s {$sel:timestamp:TimestampMetricValuePair' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: TimestampMetricValuePair) 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

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

instance Prelude.Hashable TimestampMetricValuePair where
  hashWithSalt :: Int -> TimestampMetricValuePair -> Int
hashWithSalt Int
_salt TimestampMetricValuePair' {Maybe Double
Maybe POSIX
timestamp :: Maybe POSIX
metricValue :: Maybe Double
$sel:timestamp:TimestampMetricValuePair' :: TimestampMetricValuePair -> Maybe POSIX
$sel:metricValue:TimestampMetricValuePair' :: TimestampMetricValuePair -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
metricValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
timestamp

instance Prelude.NFData TimestampMetricValuePair where
  rnf :: TimestampMetricValuePair -> ()
rnf TimestampMetricValuePair' {Maybe Double
Maybe POSIX
timestamp :: Maybe POSIX
metricValue :: Maybe Double
$sel:timestamp:TimestampMetricValuePair' :: TimestampMetricValuePair -> Maybe POSIX
$sel:metricValue:TimestampMetricValuePair' :: TimestampMetricValuePair -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
metricValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
timestamp