{-# 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.LookoutMetrics.Types.AnomalyGroupStatistics
-- 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.LookoutMetrics.Types.AnomalyGroupStatistics where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LookoutMetrics.Types.ItemizedMetricStats
import qualified Amazonka.Prelude as Prelude

-- | Aggregated statistics for a group of anomalous metrics.
--
-- /See:/ 'newAnomalyGroupStatistics' smart constructor.
data AnomalyGroupStatistics = AnomalyGroupStatistics'
  { -- | The start of the time range that was searched.
    AnomalyGroupStatistics -> Maybe Text
evaluationStartDate :: Prelude.Maybe Prelude.Text,
    -- | Statistics for individual metrics within the group.
    AnomalyGroupStatistics -> Maybe [ItemizedMetricStats]
itemizedMetricStatsList :: Prelude.Maybe [ItemizedMetricStats],
    -- | The number of groups found.
    AnomalyGroupStatistics -> Maybe Int
totalCount :: Prelude.Maybe Prelude.Int
  }
  deriving (AnomalyGroupStatistics -> AnomalyGroupStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnomalyGroupStatistics -> AnomalyGroupStatistics -> Bool
$c/= :: AnomalyGroupStatistics -> AnomalyGroupStatistics -> Bool
== :: AnomalyGroupStatistics -> AnomalyGroupStatistics -> Bool
$c== :: AnomalyGroupStatistics -> AnomalyGroupStatistics -> Bool
Prelude.Eq, ReadPrec [AnomalyGroupStatistics]
ReadPrec AnomalyGroupStatistics
Int -> ReadS AnomalyGroupStatistics
ReadS [AnomalyGroupStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnomalyGroupStatistics]
$creadListPrec :: ReadPrec [AnomalyGroupStatistics]
readPrec :: ReadPrec AnomalyGroupStatistics
$creadPrec :: ReadPrec AnomalyGroupStatistics
readList :: ReadS [AnomalyGroupStatistics]
$creadList :: ReadS [AnomalyGroupStatistics]
readsPrec :: Int -> ReadS AnomalyGroupStatistics
$creadsPrec :: Int -> ReadS AnomalyGroupStatistics
Prelude.Read, Int -> AnomalyGroupStatistics -> ShowS
[AnomalyGroupStatistics] -> ShowS
AnomalyGroupStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnomalyGroupStatistics] -> ShowS
$cshowList :: [AnomalyGroupStatistics] -> ShowS
show :: AnomalyGroupStatistics -> String
$cshow :: AnomalyGroupStatistics -> String
showsPrec :: Int -> AnomalyGroupStatistics -> ShowS
$cshowsPrec :: Int -> AnomalyGroupStatistics -> ShowS
Prelude.Show, forall x. Rep AnomalyGroupStatistics x -> AnomalyGroupStatistics
forall x. AnomalyGroupStatistics -> Rep AnomalyGroupStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnomalyGroupStatistics x -> AnomalyGroupStatistics
$cfrom :: forall x. AnomalyGroupStatistics -> Rep AnomalyGroupStatistics x
Prelude.Generic)

-- |
-- Create a value of 'AnomalyGroupStatistics' 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:
--
-- 'evaluationStartDate', 'anomalyGroupStatistics_evaluationStartDate' - The start of the time range that was searched.
--
-- 'itemizedMetricStatsList', 'anomalyGroupStatistics_itemizedMetricStatsList' - Statistics for individual metrics within the group.
--
-- 'totalCount', 'anomalyGroupStatistics_totalCount' - The number of groups found.
newAnomalyGroupStatistics ::
  AnomalyGroupStatistics
newAnomalyGroupStatistics :: AnomalyGroupStatistics
newAnomalyGroupStatistics =
  AnomalyGroupStatistics'
    { $sel:evaluationStartDate:AnomalyGroupStatistics' :: Maybe Text
evaluationStartDate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:itemizedMetricStatsList:AnomalyGroupStatistics' :: Maybe [ItemizedMetricStats]
itemizedMetricStatsList = forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:AnomalyGroupStatistics' :: Maybe Int
totalCount = forall a. Maybe a
Prelude.Nothing
    }

-- | The start of the time range that was searched.
anomalyGroupStatistics_evaluationStartDate :: Lens.Lens' AnomalyGroupStatistics (Prelude.Maybe Prelude.Text)
anomalyGroupStatistics_evaluationStartDate :: Lens' AnomalyGroupStatistics (Maybe Text)
anomalyGroupStatistics_evaluationStartDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroupStatistics' {Maybe Text
evaluationStartDate :: Maybe Text
$sel:evaluationStartDate:AnomalyGroupStatistics' :: AnomalyGroupStatistics -> Maybe Text
evaluationStartDate} -> Maybe Text
evaluationStartDate) (\s :: AnomalyGroupStatistics
s@AnomalyGroupStatistics' {} Maybe Text
a -> AnomalyGroupStatistics
s {$sel:evaluationStartDate:AnomalyGroupStatistics' :: Maybe Text
evaluationStartDate = Maybe Text
a} :: AnomalyGroupStatistics)

-- | Statistics for individual metrics within the group.
anomalyGroupStatistics_itemizedMetricStatsList :: Lens.Lens' AnomalyGroupStatistics (Prelude.Maybe [ItemizedMetricStats])
anomalyGroupStatistics_itemizedMetricStatsList :: Lens' AnomalyGroupStatistics (Maybe [ItemizedMetricStats])
anomalyGroupStatistics_itemizedMetricStatsList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroupStatistics' {Maybe [ItemizedMetricStats]
itemizedMetricStatsList :: Maybe [ItemizedMetricStats]
$sel:itemizedMetricStatsList:AnomalyGroupStatistics' :: AnomalyGroupStatistics -> Maybe [ItemizedMetricStats]
itemizedMetricStatsList} -> Maybe [ItemizedMetricStats]
itemizedMetricStatsList) (\s :: AnomalyGroupStatistics
s@AnomalyGroupStatistics' {} Maybe [ItemizedMetricStats]
a -> AnomalyGroupStatistics
s {$sel:itemizedMetricStatsList:AnomalyGroupStatistics' :: Maybe [ItemizedMetricStats]
itemizedMetricStatsList = Maybe [ItemizedMetricStats]
a} :: AnomalyGroupStatistics) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The number of groups found.
anomalyGroupStatistics_totalCount :: Lens.Lens' AnomalyGroupStatistics (Prelude.Maybe Prelude.Int)
anomalyGroupStatistics_totalCount :: Lens' AnomalyGroupStatistics (Maybe Int)
anomalyGroupStatistics_totalCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroupStatistics' {Maybe Int
totalCount :: Maybe Int
$sel:totalCount:AnomalyGroupStatistics' :: AnomalyGroupStatistics -> Maybe Int
totalCount} -> Maybe Int
totalCount) (\s :: AnomalyGroupStatistics
s@AnomalyGroupStatistics' {} Maybe Int
a -> AnomalyGroupStatistics
s {$sel:totalCount:AnomalyGroupStatistics' :: Maybe Int
totalCount = Maybe Int
a} :: AnomalyGroupStatistics)

instance Data.FromJSON AnomalyGroupStatistics where
  parseJSON :: Value -> Parser AnomalyGroupStatistics
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AnomalyGroupStatistics"
      ( \Object
x ->
          Maybe Text
-> Maybe [ItemizedMetricStats]
-> Maybe Int
-> AnomalyGroupStatistics
AnomalyGroupStatistics'
            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
"EvaluationStartDate")
            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
"ItemizedMetricStatsList"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"TotalCount")
      )

instance Prelude.Hashable AnomalyGroupStatistics where
  hashWithSalt :: Int -> AnomalyGroupStatistics -> Int
hashWithSalt Int
_salt AnomalyGroupStatistics' {Maybe Int
Maybe [ItemizedMetricStats]
Maybe Text
totalCount :: Maybe Int
itemizedMetricStatsList :: Maybe [ItemizedMetricStats]
evaluationStartDate :: Maybe Text
$sel:totalCount:AnomalyGroupStatistics' :: AnomalyGroupStatistics -> Maybe Int
$sel:itemizedMetricStatsList:AnomalyGroupStatistics' :: AnomalyGroupStatistics -> Maybe [ItemizedMetricStats]
$sel:evaluationStartDate:AnomalyGroupStatistics' :: AnomalyGroupStatistics -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
evaluationStartDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ItemizedMetricStats]
itemizedMetricStatsList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
totalCount

instance Prelude.NFData AnomalyGroupStatistics where
  rnf :: AnomalyGroupStatistics -> ()
rnf AnomalyGroupStatistics' {Maybe Int
Maybe [ItemizedMetricStats]
Maybe Text
totalCount :: Maybe Int
itemizedMetricStatsList :: Maybe [ItemizedMetricStats]
evaluationStartDate :: Maybe Text
$sel:totalCount:AnomalyGroupStatistics' :: AnomalyGroupStatistics -> Maybe Int
$sel:itemizedMetricStatsList:AnomalyGroupStatistics' :: AnomalyGroupStatistics -> Maybe [ItemizedMetricStats]
$sel:evaluationStartDate:AnomalyGroupStatistics' :: AnomalyGroupStatistics -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
evaluationStartDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ItemizedMetricStats]
itemizedMetricStatsList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
totalCount