{-# 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.IoTSiteWise.Types.Aggregates
-- 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.IoTSiteWise.Types.Aggregates where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the (pre-calculated) aggregate values for an asset property.
--
-- /See:/ 'newAggregates' smart constructor.
data Aggregates = Aggregates'
  { -- | The maximum value of the time series over a time interval window.
    Aggregates -> Maybe Double
maximum :: Prelude.Maybe Prelude.Double,
    -- | The average (mean) value of the time series over a time interval window.
    Aggregates -> Maybe Double
average :: Prelude.Maybe Prelude.Double,
    -- | The count of data points in the time series over a time interval window.
    Aggregates -> Maybe Double
count :: Prelude.Maybe Prelude.Double,
    -- | The minimum value of the time series over a time interval window.
    Aggregates -> Maybe Double
minimum :: Prelude.Maybe Prelude.Double,
    -- | The standard deviation of the time series over a time interval window.
    Aggregates -> Maybe Double
standardDeviation :: Prelude.Maybe Prelude.Double,
    -- | The sum of the time series over a time interval window.
    Aggregates -> Maybe Double
sum :: Prelude.Maybe Prelude.Double
  }
  deriving (Aggregates -> Aggregates -> Bool
(Aggregates -> Aggregates -> Bool)
-> (Aggregates -> Aggregates -> Bool) -> Eq Aggregates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Aggregates -> Aggregates -> Bool
$c/= :: Aggregates -> Aggregates -> Bool
== :: Aggregates -> Aggregates -> Bool
$c== :: Aggregates -> Aggregates -> Bool
Prelude.Eq, ReadPrec [Aggregates]
ReadPrec Aggregates
Int -> ReadS Aggregates
ReadS [Aggregates]
(Int -> ReadS Aggregates)
-> ReadS [Aggregates]
-> ReadPrec Aggregates
-> ReadPrec [Aggregates]
-> Read Aggregates
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Aggregates]
$creadListPrec :: ReadPrec [Aggregates]
readPrec :: ReadPrec Aggregates
$creadPrec :: ReadPrec Aggregates
readList :: ReadS [Aggregates]
$creadList :: ReadS [Aggregates]
readsPrec :: Int -> ReadS Aggregates
$creadsPrec :: Int -> ReadS Aggregates
Prelude.Read, Int -> Aggregates -> ShowS
[Aggregates] -> ShowS
Aggregates -> String
(Int -> Aggregates -> ShowS)
-> (Aggregates -> String)
-> ([Aggregates] -> ShowS)
-> Show Aggregates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Aggregates] -> ShowS
$cshowList :: [Aggregates] -> ShowS
show :: Aggregates -> String
$cshow :: Aggregates -> String
showsPrec :: Int -> Aggregates -> ShowS
$cshowsPrec :: Int -> Aggregates -> ShowS
Prelude.Show, (forall x. Aggregates -> Rep Aggregates x)
-> (forall x. Rep Aggregates x -> Aggregates) -> Generic Aggregates
forall x. Rep Aggregates x -> Aggregates
forall x. Aggregates -> Rep Aggregates x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Aggregates x -> Aggregates
$cfrom :: forall x. Aggregates -> Rep Aggregates x
Prelude.Generic)

-- |
-- Create a value of 'Aggregates' 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:
--
-- 'maximum', 'aggregates_maximum' - The maximum value of the time series over a time interval window.
--
-- 'average', 'aggregates_average' - The average (mean) value of the time series over a time interval window.
--
-- 'count', 'aggregates_count' - The count of data points in the time series over a time interval window.
--
-- 'minimum', 'aggregates_minimum' - The minimum value of the time series over a time interval window.
--
-- 'standardDeviation', 'aggregates_standardDeviation' - The standard deviation of the time series over a time interval window.
--
-- 'sum', 'aggregates_sum' - The sum of the time series over a time interval window.
newAggregates ::
  Aggregates
newAggregates :: Aggregates
newAggregates =
  Aggregates' :: Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Aggregates
Aggregates'
    { $sel:maximum:Aggregates' :: Maybe Double
maximum = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:average:Aggregates' :: Maybe Double
average = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:count:Aggregates' :: Maybe Double
count = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:minimum:Aggregates' :: Maybe Double
minimum = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:standardDeviation:Aggregates' :: Maybe Double
standardDeviation = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:sum:Aggregates' :: Maybe Double
sum = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum value of the time series over a time interval window.
aggregates_maximum :: Lens.Lens' Aggregates (Prelude.Maybe Prelude.Double)
aggregates_maximum :: (Maybe Double -> f (Maybe Double)) -> Aggregates -> f Aggregates
aggregates_maximum = (Aggregates -> Maybe Double)
-> (Aggregates -> Maybe Double -> Aggregates)
-> Lens Aggregates Aggregates (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Aggregates' {Maybe Double
maximum :: Maybe Double
$sel:maximum:Aggregates' :: Aggregates -> Maybe Double
maximum} -> Maybe Double
maximum) (\s :: Aggregates
s@Aggregates' {} Maybe Double
a -> Aggregates
s {$sel:maximum:Aggregates' :: Maybe Double
maximum = Maybe Double
a} :: Aggregates)

-- | The average (mean) value of the time series over a time interval window.
aggregates_average :: Lens.Lens' Aggregates (Prelude.Maybe Prelude.Double)
aggregates_average :: (Maybe Double -> f (Maybe Double)) -> Aggregates -> f Aggregates
aggregates_average = (Aggregates -> Maybe Double)
-> (Aggregates -> Maybe Double -> Aggregates)
-> Lens Aggregates Aggregates (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Aggregates' {Maybe Double
average :: Maybe Double
$sel:average:Aggregates' :: Aggregates -> Maybe Double
average} -> Maybe Double
average) (\s :: Aggregates
s@Aggregates' {} Maybe Double
a -> Aggregates
s {$sel:average:Aggregates' :: Maybe Double
average = Maybe Double
a} :: Aggregates)

-- | The count of data points in the time series over a time interval window.
aggregates_count :: Lens.Lens' Aggregates (Prelude.Maybe Prelude.Double)
aggregates_count :: (Maybe Double -> f (Maybe Double)) -> Aggregates -> f Aggregates
aggregates_count = (Aggregates -> Maybe Double)
-> (Aggregates -> Maybe Double -> Aggregates)
-> Lens Aggregates Aggregates (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Aggregates' {Maybe Double
count :: Maybe Double
$sel:count:Aggregates' :: Aggregates -> Maybe Double
count} -> Maybe Double
count) (\s :: Aggregates
s@Aggregates' {} Maybe Double
a -> Aggregates
s {$sel:count:Aggregates' :: Maybe Double
count = Maybe Double
a} :: Aggregates)

-- | The minimum value of the time series over a time interval window.
aggregates_minimum :: Lens.Lens' Aggregates (Prelude.Maybe Prelude.Double)
aggregates_minimum :: (Maybe Double -> f (Maybe Double)) -> Aggregates -> f Aggregates
aggregates_minimum = (Aggregates -> Maybe Double)
-> (Aggregates -> Maybe Double -> Aggregates)
-> Lens Aggregates Aggregates (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Aggregates' {Maybe Double
minimum :: Maybe Double
$sel:minimum:Aggregates' :: Aggregates -> Maybe Double
minimum} -> Maybe Double
minimum) (\s :: Aggregates
s@Aggregates' {} Maybe Double
a -> Aggregates
s {$sel:minimum:Aggregates' :: Maybe Double
minimum = Maybe Double
a} :: Aggregates)

-- | The standard deviation of the time series over a time interval window.
aggregates_standardDeviation :: Lens.Lens' Aggregates (Prelude.Maybe Prelude.Double)
aggregates_standardDeviation :: (Maybe Double -> f (Maybe Double)) -> Aggregates -> f Aggregates
aggregates_standardDeviation = (Aggregates -> Maybe Double)
-> (Aggregates -> Maybe Double -> Aggregates)
-> Lens Aggregates Aggregates (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Aggregates' {Maybe Double
standardDeviation :: Maybe Double
$sel:standardDeviation:Aggregates' :: Aggregates -> Maybe Double
standardDeviation} -> Maybe Double
standardDeviation) (\s :: Aggregates
s@Aggregates' {} Maybe Double
a -> Aggregates
s {$sel:standardDeviation:Aggregates' :: Maybe Double
standardDeviation = Maybe Double
a} :: Aggregates)

-- | The sum of the time series over a time interval window.
aggregates_sum :: Lens.Lens' Aggregates (Prelude.Maybe Prelude.Double)
aggregates_sum :: (Maybe Double -> f (Maybe Double)) -> Aggregates -> f Aggregates
aggregates_sum = (Aggregates -> Maybe Double)
-> (Aggregates -> Maybe Double -> Aggregates)
-> Lens Aggregates Aggregates (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Aggregates' {Maybe Double
sum :: Maybe Double
$sel:sum:Aggregates' :: Aggregates -> Maybe Double
sum} -> Maybe Double
sum) (\s :: Aggregates
s@Aggregates' {} Maybe Double
a -> Aggregates
s {$sel:sum:Aggregates' :: Maybe Double
sum = Maybe Double
a} :: Aggregates)

instance Core.FromJSON Aggregates where
  parseJSON :: Value -> Parser Aggregates
parseJSON =
    String
-> (Object -> Parser Aggregates) -> Value -> Parser Aggregates
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Aggregates"
      ( \Object
x ->
          Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Aggregates
Aggregates'
            (Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Aggregates)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Aggregates)
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
"maximum")
            Parser
  (Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Aggregates)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double
      -> Maybe Double -> Maybe Double -> Maybe Double -> Aggregates)
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 Double -> Maybe Double -> Aggregates)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double -> Maybe Double -> Maybe Double -> Aggregates)
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
"count")
            Parser (Maybe Double -> Maybe Double -> Maybe Double -> Aggregates)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> Maybe Double -> Aggregates)
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 Double -> Aggregates)
-> Parser (Maybe Double) -> Parser (Maybe Double -> Aggregates)
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
"standardDeviation")
            Parser (Maybe Double -> Aggregates)
-> Parser (Maybe Double) -> Parser Aggregates
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")
      )

instance Prelude.Hashable Aggregates

instance Prelude.NFData Aggregates