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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | Statistics for individual metrics within the group.
    AnomalyGroupStatistics -> Maybe [ItemizedMetricStats]
itemizedMetricStatsList :: Prelude.Maybe [ItemizedMetricStats],
    -- | The start of the time range that was searched.
    AnomalyGroupStatistics -> Maybe Text
evaluationStartDate :: Prelude.Maybe Prelude.Text,
    -- | The number of groups found.
    AnomalyGroupStatistics -> Maybe Int
totalCount :: Prelude.Maybe Prelude.Int
  }
  deriving (AnomalyGroupStatistics -> AnomalyGroupStatistics -> Bool
(AnomalyGroupStatistics -> AnomalyGroupStatistics -> Bool)
-> (AnomalyGroupStatistics -> AnomalyGroupStatistics -> Bool)
-> Eq AnomalyGroupStatistics
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]
(Int -> ReadS AnomalyGroupStatistics)
-> ReadS [AnomalyGroupStatistics]
-> ReadPrec AnomalyGroupStatistics
-> ReadPrec [AnomalyGroupStatistics]
-> Read 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
(Int -> AnomalyGroupStatistics -> ShowS)
-> (AnomalyGroupStatistics -> String)
-> ([AnomalyGroupStatistics] -> ShowS)
-> Show AnomalyGroupStatistics
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. AnomalyGroupStatistics -> Rep AnomalyGroupStatistics x)
-> (forall x.
    Rep AnomalyGroupStatistics x -> AnomalyGroupStatistics)
-> Generic AnomalyGroupStatistics
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:
--
-- 'itemizedMetricStatsList', 'anomalyGroupStatistics_itemizedMetricStatsList' - Statistics for individual metrics within the group.
--
-- 'evaluationStartDate', 'anomalyGroupStatistics_evaluationStartDate' - The start of the time range that was searched.
--
-- 'totalCount', 'anomalyGroupStatistics_totalCount' - The number of groups found.
newAnomalyGroupStatistics ::
  AnomalyGroupStatistics
newAnomalyGroupStatistics :: AnomalyGroupStatistics
newAnomalyGroupStatistics =
  AnomalyGroupStatistics' :: Maybe [ItemizedMetricStats]
-> Maybe Text -> Maybe Int -> AnomalyGroupStatistics
AnomalyGroupStatistics'
    { $sel:itemizedMetricStatsList:AnomalyGroupStatistics' :: Maybe [ItemizedMetricStats]
itemizedMetricStatsList =
        Maybe [ItemizedMetricStats]
forall a. Maybe a
Prelude.Nothing,
      $sel:evaluationStartDate:AnomalyGroupStatistics' :: Maybe Text
evaluationStartDate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:AnomalyGroupStatistics' :: Maybe Int
totalCount = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Statistics for individual metrics within the group.
anomalyGroupStatistics_itemizedMetricStatsList :: Lens.Lens' AnomalyGroupStatistics (Prelude.Maybe [ItemizedMetricStats])
anomalyGroupStatistics_itemizedMetricStatsList :: (Maybe [ItemizedMetricStats] -> f (Maybe [ItemizedMetricStats]))
-> AnomalyGroupStatistics -> f AnomalyGroupStatistics
anomalyGroupStatistics_itemizedMetricStatsList = (AnomalyGroupStatistics -> Maybe [ItemizedMetricStats])
-> (AnomalyGroupStatistics
    -> Maybe [ItemizedMetricStats] -> AnomalyGroupStatistics)
-> Lens
     AnomalyGroupStatistics
     AnomalyGroupStatistics
     (Maybe [ItemizedMetricStats])
     (Maybe [ItemizedMetricStats])
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) ((Maybe [ItemizedMetricStats] -> f (Maybe [ItemizedMetricStats]))
 -> AnomalyGroupStatistics -> f AnomalyGroupStatistics)
-> ((Maybe [ItemizedMetricStats]
     -> f (Maybe [ItemizedMetricStats]))
    -> Maybe [ItemizedMetricStats] -> f (Maybe [ItemizedMetricStats]))
-> (Maybe [ItemizedMetricStats] -> f (Maybe [ItemizedMetricStats]))
-> AnomalyGroupStatistics
-> f AnomalyGroupStatistics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ItemizedMetricStats]
  [ItemizedMetricStats]
  [ItemizedMetricStats]
  [ItemizedMetricStats]
-> Iso
     (Maybe [ItemizedMetricStats])
     (Maybe [ItemizedMetricStats])
     (Maybe [ItemizedMetricStats])
     (Maybe [ItemizedMetricStats])
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 AnIso
  [ItemizedMetricStats]
  [ItemizedMetricStats]
  [ItemizedMetricStats]
  [ItemizedMetricStats]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The start of the time range that was searched.
anomalyGroupStatistics_evaluationStartDate :: Lens.Lens' AnomalyGroupStatistics (Prelude.Maybe Prelude.Text)
anomalyGroupStatistics_evaluationStartDate :: (Maybe Text -> f (Maybe Text))
-> AnomalyGroupStatistics -> f AnomalyGroupStatistics
anomalyGroupStatistics_evaluationStartDate = (AnomalyGroupStatistics -> Maybe Text)
-> (AnomalyGroupStatistics -> Maybe Text -> AnomalyGroupStatistics)
-> Lens
     AnomalyGroupStatistics
     AnomalyGroupStatistics
     (Maybe Text)
     (Maybe Text)
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)

-- | The number of groups found.
anomalyGroupStatistics_totalCount :: Lens.Lens' AnomalyGroupStatistics (Prelude.Maybe Prelude.Int)
anomalyGroupStatistics_totalCount :: (Maybe Int -> f (Maybe Int))
-> AnomalyGroupStatistics -> f AnomalyGroupStatistics
anomalyGroupStatistics_totalCount = (AnomalyGroupStatistics -> Maybe Int)
-> (AnomalyGroupStatistics -> Maybe Int -> AnomalyGroupStatistics)
-> Lens
     AnomalyGroupStatistics
     AnomalyGroupStatistics
     (Maybe Int)
     (Maybe Int)
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 Core.FromJSON AnomalyGroupStatistics where
  parseJSON :: Value -> Parser AnomalyGroupStatistics
parseJSON =
    String
-> (Object -> Parser AnomalyGroupStatistics)
-> Value
-> Parser AnomalyGroupStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AnomalyGroupStatistics"
      ( \Object
x ->
          Maybe [ItemizedMetricStats]
-> Maybe Text -> Maybe Int -> AnomalyGroupStatistics
AnomalyGroupStatistics'
            (Maybe [ItemizedMetricStats]
 -> Maybe Text -> Maybe Int -> AnomalyGroupStatistics)
-> Parser (Maybe [ItemizedMetricStats])
-> Parser (Maybe Text -> Maybe Int -> AnomalyGroupStatistics)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [ItemizedMetricStats]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ItemizedMetricStatsList"
                            Parser (Maybe (Maybe [ItemizedMetricStats]))
-> Maybe [ItemizedMetricStats]
-> Parser (Maybe [ItemizedMetricStats])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ItemizedMetricStats]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> Maybe Int -> AnomalyGroupStatistics)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> AnomalyGroupStatistics)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EvaluationStartDate")
            Parser (Maybe Int -> AnomalyGroupStatistics)
-> Parser (Maybe Int) -> Parser AnomalyGroupStatistics
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
"TotalCount")
      )

instance Prelude.Hashable AnomalyGroupStatistics

instance Prelude.NFData AnomalyGroupStatistics