{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.Statistics 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 map of key-value pairs for all supported statistics. For issues with
-- missing or unexpected values for this API, consult
-- <https://docs.aws.amazon.com/iot/latest/developerguide/fleet-indexing-troubleshooting.html Fleet indexing troubleshooting guide>.
--
-- /See:/ 'newStatistics' smart constructor.
data Statistics = Statistics'
  { -- | The average of the aggregated field values.
    Statistics -> Maybe Double
average :: Prelude.Maybe Prelude.Double,
    -- | The count of things that match the query string criteria and contain a
    -- valid aggregation field value.
    Statistics -> Maybe Int
count :: Prelude.Maybe Prelude.Int,
    -- | The maximum aggregated field value.
    Statistics -> Maybe Double
maximum :: Prelude.Maybe Prelude.Double,
    -- | The minimum aggregated field value.
    Statistics -> Maybe Double
minimum :: Prelude.Maybe Prelude.Double,
    -- | The standard deviation of the aggregated field values.
    Statistics -> Maybe Double
stdDeviation :: Prelude.Maybe Prelude.Double,
    -- | The sum of the aggregated field values.
    Statistics -> Maybe Double
sum :: Prelude.Maybe Prelude.Double,
    -- | The sum of the squares of the aggregated field values.
    Statistics -> Maybe Double
sumOfSquares :: Prelude.Maybe Prelude.Double,
    -- | The variance of the aggregated field values.
    Statistics -> Maybe Double
variance :: Prelude.Maybe Prelude.Double
  }
  deriving (Statistics -> Statistics -> Bool
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]
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
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. 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:
--
-- 'average', 'statistics_average' - The average of the aggregated field values.
--
-- 'count', 'statistics_count' - The count of things that match the query string criteria and contain a
-- valid aggregation field value.
--
-- 'maximum', 'statistics_maximum' - The maximum aggregated field value.
--
-- 'minimum', 'statistics_minimum' - The minimum aggregated field value.
--
-- 'stdDeviation', 'statistics_stdDeviation' - The standard deviation of the aggregated field values.
--
-- 'sum', 'statistics_sum' - The sum of the aggregated field values.
--
-- 'sumOfSquares', 'statistics_sumOfSquares' - The sum of the squares of the aggregated field values.
--
-- 'variance', 'statistics_variance' - The variance of the aggregated field values.
newStatistics ::
  Statistics
newStatistics :: Statistics
newStatistics =
  Statistics'
    { $sel:average:Statistics' :: Maybe Double
average = forall a. Maybe a
Prelude.Nothing,
      $sel:count:Statistics' :: Maybe Int
count = forall a. Maybe a
Prelude.Nothing,
      $sel:maximum:Statistics' :: Maybe Double
maximum = forall a. Maybe a
Prelude.Nothing,
      $sel:minimum:Statistics' :: Maybe Double
minimum = forall a. Maybe a
Prelude.Nothing,
      $sel:stdDeviation:Statistics' :: Maybe Double
stdDeviation = forall a. Maybe a
Prelude.Nothing,
      $sel:sum:Statistics' :: Maybe Double
sum = forall a. Maybe a
Prelude.Nothing,
      $sel:sumOfSquares:Statistics' :: Maybe Double
sumOfSquares = forall a. Maybe a
Prelude.Nothing,
      $sel:variance:Statistics' :: Maybe Double
variance = forall a. Maybe a
Prelude.Nothing
    }

-- | The average of the aggregated field values.
statistics_average :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_average :: Lens' Statistics (Maybe Double)
statistics_average = 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 string criteria and contain a
-- valid aggregation field value.
statistics_count :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Int)
statistics_count :: Lens' Statistics (Maybe Int)
statistics_count = 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 maximum aggregated field value.
statistics_maximum :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_maximum :: Lens' Statistics (Maybe Double)
statistics_maximum = 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 minimum aggregated field value.
statistics_minimum :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_minimum :: Lens' Statistics (Maybe Double)
statistics_minimum = 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 standard deviation of the aggregated field values.
statistics_stdDeviation :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_stdDeviation :: Lens' Statistics (Maybe Double)
statistics_stdDeviation = 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 sum of the aggregated field values.
statistics_sum :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_sum :: Lens' Statistics (Maybe Double)
statistics_sum = 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)

-- | The sum of the squares of the aggregated field values.
statistics_sumOfSquares :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_sumOfSquares :: Lens' Statistics (Maybe Double)
statistics_sumOfSquares = 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 variance of the aggregated field values.
statistics_variance :: Lens.Lens' Statistics (Prelude.Maybe Prelude.Double)
statistics_variance :: Lens' Statistics (Maybe Double)
statistics_variance = 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)

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

instance Prelude.Hashable Statistics where
  hashWithSalt :: Int -> Statistics -> Int
hashWithSalt Int
_salt Statistics' {Maybe Double
Maybe Int
variance :: Maybe Double
sumOfSquares :: Maybe Double
sum :: Maybe Double
stdDeviation :: Maybe Double
minimum :: Maybe Double
maximum :: Maybe Double
count :: Maybe Int
average :: Maybe Double
$sel:variance:Statistics' :: Statistics -> Maybe Double
$sel:sumOfSquares:Statistics' :: Statistics -> Maybe Double
$sel:sum:Statistics' :: Statistics -> Maybe Double
$sel:stdDeviation:Statistics' :: Statistics -> Maybe Double
$sel:minimum:Statistics' :: Statistics -> Maybe Double
$sel:maximum:Statistics' :: Statistics -> Maybe Double
$sel:count:Statistics' :: Statistics -> Maybe Int
$sel:average:Statistics' :: Statistics -> 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 Int
count
      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
stdDeviation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
sum
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
sumOfSquares
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
variance

instance Prelude.NFData Statistics where
  rnf :: Statistics -> ()
rnf Statistics' {Maybe Double
Maybe Int
variance :: Maybe Double
sumOfSquares :: Maybe Double
sum :: Maybe Double
stdDeviation :: Maybe Double
minimum :: Maybe Double
maximum :: Maybe Double
count :: Maybe Int
average :: Maybe Double
$sel:variance:Statistics' :: Statistics -> Maybe Double
$sel:sumOfSquares:Statistics' :: Statistics -> Maybe Double
$sel:sum:Statistics' :: Statistics -> Maybe Double
$sel:stdDeviation:Statistics' :: Statistics -> Maybe Double
$sel:minimum:Statistics' :: Statistics -> Maybe Double
$sel:maximum:Statistics' :: Statistics -> Maybe Double
$sel:count:Statistics' :: Statistics -> Maybe Int
$sel:average:Statistics' :: Statistics -> 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 Int
count
      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
stdDeviation
      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 Double
sumOfSquares
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
variance