{-# 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.Lightsail.Types.MetricDatapoint
-- 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.Lightsail.Types.MetricDatapoint where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.MetricUnit
import qualified Amazonka.Prelude as Prelude

-- | Describes the metric data point.
--
-- /See:/ 'newMetricDatapoint' smart constructor.
data MetricDatapoint = MetricDatapoint'
  { -- | The sample count.
    MetricDatapoint -> Maybe Double
sampleCount :: Prelude.Maybe Prelude.Double,
    -- | The maximum.
    MetricDatapoint -> Maybe Double
maximum :: Prelude.Maybe Prelude.Double,
    -- | The average.
    MetricDatapoint -> Maybe Double
average :: Prelude.Maybe Prelude.Double,
    -- | The minimum.
    MetricDatapoint -> Maybe Double
minimum :: Prelude.Maybe Prelude.Double,
    -- | The sum.
    MetricDatapoint -> Maybe Double
sum :: Prelude.Maybe Prelude.Double,
    -- | The timestamp (e.g., @1479816991.349@).
    MetricDatapoint -> Maybe POSIX
timestamp :: Prelude.Maybe Core.POSIX,
    -- | The unit.
    MetricDatapoint -> Maybe MetricUnit
unit :: Prelude.Maybe MetricUnit
  }
  deriving (MetricDatapoint -> MetricDatapoint -> Bool
(MetricDatapoint -> MetricDatapoint -> Bool)
-> (MetricDatapoint -> MetricDatapoint -> Bool)
-> Eq MetricDatapoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricDatapoint -> MetricDatapoint -> Bool
$c/= :: MetricDatapoint -> MetricDatapoint -> Bool
== :: MetricDatapoint -> MetricDatapoint -> Bool
$c== :: MetricDatapoint -> MetricDatapoint -> Bool
Prelude.Eq, ReadPrec [MetricDatapoint]
ReadPrec MetricDatapoint
Int -> ReadS MetricDatapoint
ReadS [MetricDatapoint]
(Int -> ReadS MetricDatapoint)
-> ReadS [MetricDatapoint]
-> ReadPrec MetricDatapoint
-> ReadPrec [MetricDatapoint]
-> Read MetricDatapoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricDatapoint]
$creadListPrec :: ReadPrec [MetricDatapoint]
readPrec :: ReadPrec MetricDatapoint
$creadPrec :: ReadPrec MetricDatapoint
readList :: ReadS [MetricDatapoint]
$creadList :: ReadS [MetricDatapoint]
readsPrec :: Int -> ReadS MetricDatapoint
$creadsPrec :: Int -> ReadS MetricDatapoint
Prelude.Read, Int -> MetricDatapoint -> ShowS
[MetricDatapoint] -> ShowS
MetricDatapoint -> String
(Int -> MetricDatapoint -> ShowS)
-> (MetricDatapoint -> String)
-> ([MetricDatapoint] -> ShowS)
-> Show MetricDatapoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricDatapoint] -> ShowS
$cshowList :: [MetricDatapoint] -> ShowS
show :: MetricDatapoint -> String
$cshow :: MetricDatapoint -> String
showsPrec :: Int -> MetricDatapoint -> ShowS
$cshowsPrec :: Int -> MetricDatapoint -> ShowS
Prelude.Show, (forall x. MetricDatapoint -> Rep MetricDatapoint x)
-> (forall x. Rep MetricDatapoint x -> MetricDatapoint)
-> Generic MetricDatapoint
forall x. Rep MetricDatapoint x -> MetricDatapoint
forall x. MetricDatapoint -> Rep MetricDatapoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricDatapoint x -> MetricDatapoint
$cfrom :: forall x. MetricDatapoint -> Rep MetricDatapoint x
Prelude.Generic)

-- |
-- Create a value of 'MetricDatapoint' 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:
--
-- 'sampleCount', 'metricDatapoint_sampleCount' - The sample count.
--
-- 'maximum', 'metricDatapoint_maximum' - The maximum.
--
-- 'average', 'metricDatapoint_average' - The average.
--
-- 'minimum', 'metricDatapoint_minimum' - The minimum.
--
-- 'sum', 'metricDatapoint_sum' - The sum.
--
-- 'timestamp', 'metricDatapoint_timestamp' - The timestamp (e.g., @1479816991.349@).
--
-- 'unit', 'metricDatapoint_unit' - The unit.
newMetricDatapoint ::
  MetricDatapoint
newMetricDatapoint :: MetricDatapoint
newMetricDatapoint =
  MetricDatapoint' :: Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe POSIX
-> Maybe MetricUnit
-> MetricDatapoint
MetricDatapoint'
    { $sel:sampleCount:MetricDatapoint' :: Maybe Double
sampleCount = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:maximum:MetricDatapoint' :: Maybe Double
maximum = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:average:MetricDatapoint' :: Maybe Double
average = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:minimum:MetricDatapoint' :: Maybe Double
minimum = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:sum:MetricDatapoint' :: Maybe Double
sum = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:MetricDatapoint' :: Maybe POSIX
timestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:MetricDatapoint' :: Maybe MetricUnit
unit = Maybe MetricUnit
forall a. Maybe a
Prelude.Nothing
    }

-- | The sample count.
metricDatapoint_sampleCount :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_sampleCount :: (Maybe Double -> f (Maybe Double))
-> MetricDatapoint -> f MetricDatapoint
metricDatapoint_sampleCount = (MetricDatapoint -> Maybe Double)
-> (MetricDatapoint -> Maybe Double -> MetricDatapoint)
-> Lens
     MetricDatapoint MetricDatapoint (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatapoint' {Maybe Double
sampleCount :: Maybe Double
$sel:sampleCount:MetricDatapoint' :: MetricDatapoint -> Maybe Double
sampleCount} -> Maybe Double
sampleCount) (\s :: MetricDatapoint
s@MetricDatapoint' {} Maybe Double
a -> MetricDatapoint
s {$sel:sampleCount:MetricDatapoint' :: Maybe Double
sampleCount = Maybe Double
a} :: MetricDatapoint)

-- | The maximum.
metricDatapoint_maximum :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_maximum :: (Maybe Double -> f (Maybe Double))
-> MetricDatapoint -> f MetricDatapoint
metricDatapoint_maximum = (MetricDatapoint -> Maybe Double)
-> (MetricDatapoint -> Maybe Double -> MetricDatapoint)
-> Lens
     MetricDatapoint MetricDatapoint (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatapoint' {Maybe Double
maximum :: Maybe Double
$sel:maximum:MetricDatapoint' :: MetricDatapoint -> Maybe Double
maximum} -> Maybe Double
maximum) (\s :: MetricDatapoint
s@MetricDatapoint' {} Maybe Double
a -> MetricDatapoint
s {$sel:maximum:MetricDatapoint' :: Maybe Double
maximum = Maybe Double
a} :: MetricDatapoint)

-- | The average.
metricDatapoint_average :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_average :: (Maybe Double -> f (Maybe Double))
-> MetricDatapoint -> f MetricDatapoint
metricDatapoint_average = (MetricDatapoint -> Maybe Double)
-> (MetricDatapoint -> Maybe Double -> MetricDatapoint)
-> Lens
     MetricDatapoint MetricDatapoint (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatapoint' {Maybe Double
average :: Maybe Double
$sel:average:MetricDatapoint' :: MetricDatapoint -> Maybe Double
average} -> Maybe Double
average) (\s :: MetricDatapoint
s@MetricDatapoint' {} Maybe Double
a -> MetricDatapoint
s {$sel:average:MetricDatapoint' :: Maybe Double
average = Maybe Double
a} :: MetricDatapoint)

-- | The minimum.
metricDatapoint_minimum :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_minimum :: (Maybe Double -> f (Maybe Double))
-> MetricDatapoint -> f MetricDatapoint
metricDatapoint_minimum = (MetricDatapoint -> Maybe Double)
-> (MetricDatapoint -> Maybe Double -> MetricDatapoint)
-> Lens
     MetricDatapoint MetricDatapoint (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatapoint' {Maybe Double
minimum :: Maybe Double
$sel:minimum:MetricDatapoint' :: MetricDatapoint -> Maybe Double
minimum} -> Maybe Double
minimum) (\s :: MetricDatapoint
s@MetricDatapoint' {} Maybe Double
a -> MetricDatapoint
s {$sel:minimum:MetricDatapoint' :: Maybe Double
minimum = Maybe Double
a} :: MetricDatapoint)

-- | The sum.
metricDatapoint_sum :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_sum :: (Maybe Double -> f (Maybe Double))
-> MetricDatapoint -> f MetricDatapoint
metricDatapoint_sum = (MetricDatapoint -> Maybe Double)
-> (MetricDatapoint -> Maybe Double -> MetricDatapoint)
-> Lens
     MetricDatapoint MetricDatapoint (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatapoint' {Maybe Double
sum :: Maybe Double
$sel:sum:MetricDatapoint' :: MetricDatapoint -> Maybe Double
sum} -> Maybe Double
sum) (\s :: MetricDatapoint
s@MetricDatapoint' {} Maybe Double
a -> MetricDatapoint
s {$sel:sum:MetricDatapoint' :: Maybe Double
sum = Maybe Double
a} :: MetricDatapoint)

-- | The timestamp (e.g., @1479816991.349@).
metricDatapoint_timestamp :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.UTCTime)
metricDatapoint_timestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> MetricDatapoint -> f MetricDatapoint
metricDatapoint_timestamp = (MetricDatapoint -> Maybe POSIX)
-> (MetricDatapoint -> Maybe POSIX -> MetricDatapoint)
-> Lens MetricDatapoint MetricDatapoint (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatapoint' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:MetricDatapoint' :: MetricDatapoint -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: MetricDatapoint
s@MetricDatapoint' {} Maybe POSIX
a -> MetricDatapoint
s {$sel:timestamp:MetricDatapoint' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: MetricDatapoint) ((Maybe POSIX -> f (Maybe POSIX))
 -> MetricDatapoint -> f MetricDatapoint)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> MetricDatapoint
-> f MetricDatapoint
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

-- | The unit.
metricDatapoint_unit :: Lens.Lens' MetricDatapoint (Prelude.Maybe MetricUnit)
metricDatapoint_unit :: (Maybe MetricUnit -> f (Maybe MetricUnit))
-> MetricDatapoint -> f MetricDatapoint
metricDatapoint_unit = (MetricDatapoint -> Maybe MetricUnit)
-> (MetricDatapoint -> Maybe MetricUnit -> MetricDatapoint)
-> Lens
     MetricDatapoint
     MetricDatapoint
     (Maybe MetricUnit)
     (Maybe MetricUnit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDatapoint' {Maybe MetricUnit
unit :: Maybe MetricUnit
$sel:unit:MetricDatapoint' :: MetricDatapoint -> Maybe MetricUnit
unit} -> Maybe MetricUnit
unit) (\s :: MetricDatapoint
s@MetricDatapoint' {} Maybe MetricUnit
a -> MetricDatapoint
s {$sel:unit:MetricDatapoint' :: Maybe MetricUnit
unit = Maybe MetricUnit
a} :: MetricDatapoint)

instance Core.FromJSON MetricDatapoint where
  parseJSON :: Value -> Parser MetricDatapoint
parseJSON =
    String
-> (Object -> Parser MetricDatapoint)
-> Value
-> Parser MetricDatapoint
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricDatapoint"
      ( \Object
x ->
          Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe POSIX
-> Maybe MetricUnit
-> MetricDatapoint
MetricDatapoint'
            (Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe POSIX
 -> Maybe MetricUnit
 -> MetricDatapoint)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe POSIX
      -> Maybe MetricUnit
      -> MetricDatapoint)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sampleCount")
            Parser
  (Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe POSIX
   -> Maybe MetricUnit
   -> MetricDatapoint)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe POSIX
      -> Maybe MetricUnit
      -> MetricDatapoint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"maximum")
            Parser
  (Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe POSIX
   -> Maybe MetricUnit
   -> MetricDatapoint)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double
      -> Maybe Double
      -> Maybe POSIX
      -> Maybe MetricUnit
      -> MetricDatapoint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"average")
            Parser
  (Maybe Double
   -> Maybe Double
   -> Maybe POSIX
   -> Maybe MetricUnit
   -> MetricDatapoint)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double
      -> Maybe POSIX -> Maybe MetricUnit -> MetricDatapoint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"minimum")
            Parser
  (Maybe Double
   -> Maybe POSIX -> Maybe MetricUnit -> MetricDatapoint)
-> Parser (Maybe Double)
-> Parser (Maybe POSIX -> Maybe MetricUnit -> MetricDatapoint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sum")
            Parser (Maybe POSIX -> Maybe MetricUnit -> MetricDatapoint)
-> Parser (Maybe POSIX)
-> Parser (Maybe MetricUnit -> MetricDatapoint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timestamp")
            Parser (Maybe MetricUnit -> MetricDatapoint)
-> Parser (Maybe MetricUnit) -> Parser MetricDatapoint
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MetricUnit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"unit")
      )

instance Prelude.Hashable MetricDatapoint

instance Prelude.NFData MetricDatapoint