{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Lightsail.Types.MetricDatapoint where

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

-- | Describes the metric data point.
--
-- /See:/ 'newMetricDatapoint' smart constructor.
data MetricDatapoint = MetricDatapoint'
  { -- | The average.
    MetricDatapoint -> Maybe Double
average :: Prelude.Maybe Prelude.Double,
    -- | The maximum.
    MetricDatapoint -> Maybe Double
maximum :: Prelude.Maybe Prelude.Double,
    -- | The minimum.
    MetricDatapoint -> Maybe Double
minimum :: Prelude.Maybe Prelude.Double,
    -- | The sample count.
    MetricDatapoint -> Maybe Double
sampleCount :: 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 Data.POSIX,
    -- | The unit.
    MetricDatapoint -> Maybe MetricUnit
unit :: Prelude.Maybe MetricUnit
  }
  deriving (MetricDatapoint -> MetricDatapoint -> Bool
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]
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
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. 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:
--
-- 'average', 'metricDatapoint_average' - The average.
--
-- 'maximum', 'metricDatapoint_maximum' - The maximum.
--
-- 'minimum', 'metricDatapoint_minimum' - The minimum.
--
-- 'sampleCount', 'metricDatapoint_sampleCount' - The sample count.
--
-- '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'
    { $sel:average:MetricDatapoint' :: Maybe Double
average = forall a. Maybe a
Prelude.Nothing,
      $sel:maximum:MetricDatapoint' :: Maybe Double
maximum = forall a. Maybe a
Prelude.Nothing,
      $sel:minimum:MetricDatapoint' :: Maybe Double
minimum = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleCount:MetricDatapoint' :: Maybe Double
sampleCount = forall a. Maybe a
Prelude.Nothing,
      $sel:sum:MetricDatapoint' :: Maybe Double
sum = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:MetricDatapoint' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:MetricDatapoint' :: Maybe MetricUnit
unit = forall a. Maybe a
Prelude.Nothing
    }

-- | The average.
metricDatapoint_average :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_average :: Lens' MetricDatapoint (Maybe Double)
metricDatapoint_average = 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 maximum.
metricDatapoint_maximum :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_maximum :: Lens' MetricDatapoint (Maybe Double)
metricDatapoint_maximum = 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 minimum.
metricDatapoint_minimum :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_minimum :: Lens' MetricDatapoint (Maybe Double)
metricDatapoint_minimum = 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 sample count.
metricDatapoint_sampleCount :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_sampleCount :: Lens' MetricDatapoint (Maybe Double)
metricDatapoint_sampleCount = 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 sum.
metricDatapoint_sum :: Lens.Lens' MetricDatapoint (Prelude.Maybe Prelude.Double)
metricDatapoint_sum :: Lens' MetricDatapoint (Maybe Double)
metricDatapoint_sum = 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 :: Lens' MetricDatapoint (Maybe UTCTime)
metricDatapoint_timestamp = 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) 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

-- | The unit.
metricDatapoint_unit :: Lens.Lens' MetricDatapoint (Prelude.Maybe MetricUnit)
metricDatapoint_unit :: Lens' MetricDatapoint (Maybe MetricUnit)
metricDatapoint_unit = 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 Data.FromJSON MetricDatapoint where
  parseJSON :: Value -> Parser MetricDatapoint
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MetricDatapoint"
      ( \Object
x ->
          Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe POSIX
-> Maybe MetricUnit
-> MetricDatapoint
MetricDatapoint'
            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
"average")
            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
"maximum")
            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
"minimum")
            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
"sampleCount")
            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
"sum")
            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")
            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
"unit")
      )

instance Prelude.Hashable MetricDatapoint where
  hashWithSalt :: Int -> MetricDatapoint -> Int
hashWithSalt Int
_salt MetricDatapoint' {Maybe Double
Maybe POSIX
Maybe MetricUnit
unit :: Maybe MetricUnit
timestamp :: Maybe POSIX
sum :: Maybe Double
sampleCount :: Maybe Double
minimum :: Maybe Double
maximum :: Maybe Double
average :: Maybe Double
$sel:unit:MetricDatapoint' :: MetricDatapoint -> Maybe MetricUnit
$sel:timestamp:MetricDatapoint' :: MetricDatapoint -> Maybe POSIX
$sel:sum:MetricDatapoint' :: MetricDatapoint -> Maybe Double
$sel:sampleCount:MetricDatapoint' :: MetricDatapoint -> Maybe Double
$sel:minimum:MetricDatapoint' :: MetricDatapoint -> Maybe Double
$sel:maximum:MetricDatapoint' :: MetricDatapoint -> Maybe Double
$sel:average:MetricDatapoint' :: MetricDatapoint -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
average
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
maximum
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
minimum
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
sampleCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
sum
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
timestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MetricUnit
unit

instance Prelude.NFData MetricDatapoint where
  rnf :: MetricDatapoint -> ()
rnf MetricDatapoint' {Maybe Double
Maybe POSIX
Maybe MetricUnit
unit :: Maybe MetricUnit
timestamp :: Maybe POSIX
sum :: Maybe Double
sampleCount :: Maybe Double
minimum :: Maybe Double
maximum :: Maybe Double
average :: Maybe Double
$sel:unit:MetricDatapoint' :: MetricDatapoint -> Maybe MetricUnit
$sel:timestamp:MetricDatapoint' :: MetricDatapoint -> Maybe POSIX
$sel:sum:MetricDatapoint' :: MetricDatapoint -> Maybe Double
$sel:sampleCount:MetricDatapoint' :: MetricDatapoint -> Maybe Double
$sel:minimum:MetricDatapoint' :: MetricDatapoint -> Maybe Double
$sel:maximum:MetricDatapoint' :: MetricDatapoint -> Maybe Double
$sel:average:MetricDatapoint' :: MetricDatapoint -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
average
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
maximum
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
minimum
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
sampleCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
sum
      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 MetricUnit
unit