{-# 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.IoT.Types.Statistics
-- 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.IoT.Types.Statistics where

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

-- | A map of key-value pairs for all supported statistics. Currently, only
-- count is supported.
--
-- /See:/ 'newStatistics' smart constructor.
data Statistics = Statistics'
  { -- | The standard deviation of the aggregated field values.
    Statistics -> Maybe Double
stdDeviation :: Prelude.Maybe Prelude.Double,
    -- | The maximum aggregated field value.
    Statistics -> Maybe Double
maximum :: Prelude.Maybe Prelude.Double,
    -- | The average of the aggregated field values.
    Statistics -> Maybe Double
average :: Prelude.Maybe Prelude.Double,
    -- | The count of things that match the query.
    Statistics -> Maybe Int
count :: Prelude.Maybe Prelude.Int,
    -- | The minimum aggregated field value.
    Statistics -> Maybe Double
minimum :: Prelude.Maybe Prelude.Double,
    -- | The variance of the aggregated field values.
    Statistics -> Maybe Double
variance :: Prelude.Maybe Prelude.Double,
    -- | The sum of the squares of the aggregated field values.
    Statistics -> Maybe Double
sumOfSquares :: Prelude.Maybe Prelude.Double,
    -- | The sum of the aggregated field values.
    Statistics -> Maybe Double
sum :: Prelude.Maybe Prelude.Double
  }
  deriving (Statistics -> Statistics -> Bool
(Statistics -> Statistics -> Bool)
-> (Statistics -> Statistics -> Bool) -> Eq Statistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Statistics -> Statistics -> Bool
$c/= :: Statistics -> Statistics -> Bool
== :: Statistics -> Statistics -> Bool
$c== :: Statistics -> Statistics -> Bool
Prelude.Eq, ReadPrec [Statistics]
ReadPrec Statistics
Int -> ReadS Statistics
ReadS [Statistics]
(Int -> ReadS Statistics)
-> ReadS [Statistics]
-> ReadPrec Statistics
-> ReadPrec [Statistics]
-> Read Statistics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Statistics]
$creadListPrec :: ReadPrec [Statistics]
readPrec :: ReadPrec Statistics
$creadPrec :: ReadPrec Statistics
readList :: ReadS [Statistics]
$creadList :: ReadS [Statistics]
readsPrec :: Int -> ReadS Statistics
$creadsPrec :: Int -> ReadS Statistics
Prelude.Read, Int -> Statistics -> ShowS
[Statistics] -> ShowS
Statistics -> String
(Int -> Statistics -> ShowS)
-> (Statistics -> String)
-> ([Statistics] -> ShowS)
-> Show Statistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Statistics] -> ShowS
$cshowList :: [Statistics] -> ShowS
show :: Statistics -> String
$cshow :: Statistics -> String
showsPrec :: Int -> Statistics -> ShowS
$cshowsPrec :: Int -> Statistics -> ShowS
Prelude.Show, (forall x. Statistics -> Rep Statistics x)
-> (forall x. Rep Statistics x -> Statistics) -> Generic Statistics
forall x. Rep Statistics x -> Statistics
forall x. Statistics -> Rep Statistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Statistics x -> Statistics
$cfrom :: forall x. Statistics -> Rep Statistics x
Prelude.Generic)

-- |
-- Create a value of 'Statistics' 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:
--
-- 'stdDeviation', 'statistics_stdDeviation' - The standard deviation of the aggregated field values.
--
-- 'maximum', 'statistics_maximum' - The maximum aggregated field value.
--
-- 'average', 'statistics_average' - The average of the aggregated field values.
--
-- 'count', 'statistics_count' - The count of things that match the query.
--
-- 'minimum', 'statistics_minimum' - The minimum aggregated field value.
--
-- 'variance', 'statistics_variance' - The variance of the aggregated field values.
--
-- 'sumOfSquares', 'statistics_sumOfSquares' - The sum of the squares of the aggregated field values.
--
-- 'sum', 'statistics_sum' - The sum of the aggregated field values.
newStatistics ::
  Statistics
newStatistics :: Statistics
newStatistics =
  Statistics' :: Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Int
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Statistics
Statistics'
    { $sel:stdDeviation:Statistics' :: Maybe Double
stdDeviation = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:maximum:Statistics' :: Maybe Double
maximum = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:average:Statistics' :: Maybe Double
average = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:count:Statistics' :: Maybe Int
count = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:minimum:Statistics' :: Maybe Double
minimum = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:variance:Statistics' :: Maybe Double
variance = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:sumOfSquares:Statistics' :: Maybe Double
sumOfSquares = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:sum:Statistics' :: Maybe Double
sum = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The standard deviation of the aggregated field values.
statistics_stdDeviation :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_stdDeviation :: (Maybe Double -> f (Maybe Double)) -> Statistics -> f Statistics
statistics_stdDeviation = (Statistics -> Maybe Double)
-> (Statistics -> Maybe Double -> Statistics)
-> Lens Statistics Statistics (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statistics' {Maybe Double
stdDeviation :: Maybe Double
$sel:stdDeviation:Statistics' :: Statistics -> Maybe Double
stdDeviation} -> Maybe Double
stdDeviation) (\s :: Statistics
s@Statistics' {} Maybe Double
a -> Statistics
s {$sel:stdDeviation:Statistics' :: Maybe Double
stdDeviation = Maybe Double
a} :: Statistics)

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

-- | The average of the aggregated field values.
statistics_average :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_average :: (Maybe Double -> f (Maybe Double)) -> Statistics -> f Statistics
statistics_average = (Statistics -> Maybe Double)
-> (Statistics -> Maybe Double -> Statistics)
-> Lens Statistics Statistics (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statistics' {Maybe Double
average :: Maybe Double
$sel:average:Statistics' :: Statistics -> Maybe Double
average} -> Maybe Double
average) (\s :: Statistics
s@Statistics' {} Maybe Double
a -> Statistics
s {$sel:average:Statistics' :: Maybe Double
average = Maybe Double
a} :: Statistics)

-- | The count of things that match the query.
statistics_count :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Int)
statistics_count :: (Maybe Int -> f (Maybe Int)) -> Statistics -> f Statistics
statistics_count = (Statistics -> Maybe Int)
-> (Statistics -> Maybe Int -> Statistics)
-> Lens Statistics Statistics (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statistics' {Maybe Int
count :: Maybe Int
$sel:count:Statistics' :: Statistics -> Maybe Int
count} -> Maybe Int
count) (\s :: Statistics
s@Statistics' {} Maybe Int
a -> Statistics
s {$sel:count:Statistics' :: Maybe Int
count = Maybe Int
a} :: Statistics)

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

-- | The variance of the aggregated field values.
statistics_variance :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_variance :: (Maybe Double -> f (Maybe Double)) -> Statistics -> f Statistics
statistics_variance = (Statistics -> Maybe Double)
-> (Statistics -> Maybe Double -> Statistics)
-> Lens Statistics Statistics (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statistics' {Maybe Double
variance :: Maybe Double
$sel:variance:Statistics' :: Statistics -> Maybe Double
variance} -> Maybe Double
variance) (\s :: Statistics
s@Statistics' {} Maybe Double
a -> Statistics
s {$sel:variance:Statistics' :: Maybe Double
variance = Maybe Double
a} :: Statistics)

-- | The sum of the squares of the aggregated field values.
statistics_sumOfSquares :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_sumOfSquares :: (Maybe Double -> f (Maybe Double)) -> Statistics -> f Statistics
statistics_sumOfSquares = (Statistics -> Maybe Double)
-> (Statistics -> Maybe Double -> Statistics)
-> Lens Statistics Statistics (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statistics' {Maybe Double
sumOfSquares :: Maybe Double
$sel:sumOfSquares:Statistics' :: Statistics -> Maybe Double
sumOfSquares} -> Maybe Double
sumOfSquares) (\s :: Statistics
s@Statistics' {} Maybe Double
a -> Statistics
s {$sel:sumOfSquares:Statistics' :: Maybe Double
sumOfSquares = Maybe Double
a} :: Statistics)

-- | The sum of the aggregated field values.
statistics_sum :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_sum :: (Maybe Double -> f (Maybe Double)) -> Statistics -> f Statistics
statistics_sum = (Statistics -> Maybe Double)
-> (Statistics -> Maybe Double -> Statistics)
-> Lens Statistics Statistics (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statistics' {Maybe Double
sum :: Maybe Double
$sel:sum:Statistics' :: Statistics -> Maybe Double
sum} -> Maybe Double
sum) (\s :: Statistics
s@Statistics' {} Maybe Double
a -> Statistics
s {$sel:sum:Statistics' :: Maybe Double
sum = Maybe Double
a} :: Statistics)

instance Core.FromJSON Statistics where
  parseJSON :: Value -> Parser Statistics
parseJSON =
    String
-> (Object -> Parser Statistics) -> Value -> Parser Statistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Statistics"
      ( \Object
x ->
          Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Int
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Statistics
Statistics'
            (Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Int
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Statistics)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double
      -> Maybe Double
      -> Maybe Int
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Statistics)
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
"stdDeviation")
            Parser
  (Maybe Double
   -> Maybe Double
   -> Maybe Int
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Statistics)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double
      -> Maybe Int
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Statistics)
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 Int
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Statistics)
-> Parser (Maybe Double)
-> Parser
     (Maybe Int
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Statistics)
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 Int
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Statistics)
-> Parser (Maybe Int)
-> Parser
     (Maybe Double
      -> Maybe Double -> Maybe Double -> Maybe Double -> Statistics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"count")
            Parser
  (Maybe Double
   -> Maybe Double -> Maybe Double -> Maybe Double -> Statistics)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double -> Maybe Double -> Maybe Double -> Statistics)
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 -> Maybe Double -> Statistics)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> Maybe Double -> Statistics)
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
"variance")
            Parser (Maybe Double -> Maybe Double -> Statistics)
-> Parser (Maybe Double) -> Parser (Maybe Double -> Statistics)
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
"sumOfSquares")
            Parser (Maybe Double -> Statistics)
-> Parser (Maybe Double) -> Parser Statistics
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 Statistics

instance Prelude.NFData Statistics