{-# 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.AnomalyGroup
-- 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.AnomalyGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutMetrics.Types.MetricLevelImpact
import qualified Amazonka.Prelude as Prelude

-- | A group of anomalous metrics
--
-- /See:/ 'newAnomalyGroup' smart constructor.
data AnomalyGroup = AnomalyGroup'
  { -- | A list of measures affected by the anomaly.
    AnomalyGroup -> Maybe [MetricLevelImpact]
metricLevelImpactList :: Prelude.Maybe [MetricLevelImpact],
    -- | The start time for the group.
    AnomalyGroup -> Maybe Text
startTime :: Prelude.Maybe Prelude.Text,
    -- | The ID of the anomaly group.
    AnomalyGroup -> Maybe Text
anomalyGroupId :: Prelude.Maybe Prelude.Text,
    -- | The severity score of the group.
    AnomalyGroup -> Maybe Double
anomalyGroupScore :: Prelude.Maybe Prelude.Double,
    -- | The name of the primary affected measure for the group.
    AnomalyGroup -> Maybe Text
primaryMetricName :: Prelude.Maybe Prelude.Text,
    -- | The end time for the group.
    AnomalyGroup -> Maybe Text
endTime :: Prelude.Maybe Prelude.Text
  }
  deriving (AnomalyGroup -> AnomalyGroup -> Bool
(AnomalyGroup -> AnomalyGroup -> Bool)
-> (AnomalyGroup -> AnomalyGroup -> Bool) -> Eq AnomalyGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnomalyGroup -> AnomalyGroup -> Bool
$c/= :: AnomalyGroup -> AnomalyGroup -> Bool
== :: AnomalyGroup -> AnomalyGroup -> Bool
$c== :: AnomalyGroup -> AnomalyGroup -> Bool
Prelude.Eq, ReadPrec [AnomalyGroup]
ReadPrec AnomalyGroup
Int -> ReadS AnomalyGroup
ReadS [AnomalyGroup]
(Int -> ReadS AnomalyGroup)
-> ReadS [AnomalyGroup]
-> ReadPrec AnomalyGroup
-> ReadPrec [AnomalyGroup]
-> Read AnomalyGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnomalyGroup]
$creadListPrec :: ReadPrec [AnomalyGroup]
readPrec :: ReadPrec AnomalyGroup
$creadPrec :: ReadPrec AnomalyGroup
readList :: ReadS [AnomalyGroup]
$creadList :: ReadS [AnomalyGroup]
readsPrec :: Int -> ReadS AnomalyGroup
$creadsPrec :: Int -> ReadS AnomalyGroup
Prelude.Read, Int -> AnomalyGroup -> ShowS
[AnomalyGroup] -> ShowS
AnomalyGroup -> String
(Int -> AnomalyGroup -> ShowS)
-> (AnomalyGroup -> String)
-> ([AnomalyGroup] -> ShowS)
-> Show AnomalyGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnomalyGroup] -> ShowS
$cshowList :: [AnomalyGroup] -> ShowS
show :: AnomalyGroup -> String
$cshow :: AnomalyGroup -> String
showsPrec :: Int -> AnomalyGroup -> ShowS
$cshowsPrec :: Int -> AnomalyGroup -> ShowS
Prelude.Show, (forall x. AnomalyGroup -> Rep AnomalyGroup x)
-> (forall x. Rep AnomalyGroup x -> AnomalyGroup)
-> Generic AnomalyGroup
forall x. Rep AnomalyGroup x -> AnomalyGroup
forall x. AnomalyGroup -> Rep AnomalyGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnomalyGroup x -> AnomalyGroup
$cfrom :: forall x. AnomalyGroup -> Rep AnomalyGroup x
Prelude.Generic)

-- |
-- Create a value of 'AnomalyGroup' 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:
--
-- 'metricLevelImpactList', 'anomalyGroup_metricLevelImpactList' - A list of measures affected by the anomaly.
--
-- 'startTime', 'anomalyGroup_startTime' - The start time for the group.
--
-- 'anomalyGroupId', 'anomalyGroup_anomalyGroupId' - The ID of the anomaly group.
--
-- 'anomalyGroupScore', 'anomalyGroup_anomalyGroupScore' - The severity score of the group.
--
-- 'primaryMetricName', 'anomalyGroup_primaryMetricName' - The name of the primary affected measure for the group.
--
-- 'endTime', 'anomalyGroup_endTime' - The end time for the group.
newAnomalyGroup ::
  AnomalyGroup
newAnomalyGroup :: AnomalyGroup
newAnomalyGroup =
  AnomalyGroup' :: Maybe [MetricLevelImpact]
-> Maybe Text
-> Maybe Text
-> Maybe Double
-> Maybe Text
-> Maybe Text
-> AnomalyGroup
AnomalyGroup'
    { $sel:metricLevelImpactList:AnomalyGroup' :: Maybe [MetricLevelImpact]
metricLevelImpactList =
        Maybe [MetricLevelImpact]
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:AnomalyGroup' :: Maybe Text
startTime = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:anomalyGroupId:AnomalyGroup' :: Maybe Text
anomalyGroupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:anomalyGroupScore:AnomalyGroup' :: Maybe Double
anomalyGroupScore = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:primaryMetricName:AnomalyGroup' :: Maybe Text
primaryMetricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:AnomalyGroup' :: Maybe Text
endTime = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of measures affected by the anomaly.
anomalyGroup_metricLevelImpactList :: Lens.Lens' AnomalyGroup (Prelude.Maybe [MetricLevelImpact])
anomalyGroup_metricLevelImpactList :: (Maybe [MetricLevelImpact] -> f (Maybe [MetricLevelImpact]))
-> AnomalyGroup -> f AnomalyGroup
anomalyGroup_metricLevelImpactList = (AnomalyGroup -> Maybe [MetricLevelImpact])
-> (AnomalyGroup -> Maybe [MetricLevelImpact] -> AnomalyGroup)
-> Lens
     AnomalyGroup
     AnomalyGroup
     (Maybe [MetricLevelImpact])
     (Maybe [MetricLevelImpact])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroup' {Maybe [MetricLevelImpact]
metricLevelImpactList :: Maybe [MetricLevelImpact]
$sel:metricLevelImpactList:AnomalyGroup' :: AnomalyGroup -> Maybe [MetricLevelImpact]
metricLevelImpactList} -> Maybe [MetricLevelImpact]
metricLevelImpactList) (\s :: AnomalyGroup
s@AnomalyGroup' {} Maybe [MetricLevelImpact]
a -> AnomalyGroup
s {$sel:metricLevelImpactList:AnomalyGroup' :: Maybe [MetricLevelImpact]
metricLevelImpactList = Maybe [MetricLevelImpact]
a} :: AnomalyGroup) ((Maybe [MetricLevelImpact] -> f (Maybe [MetricLevelImpact]))
 -> AnomalyGroup -> f AnomalyGroup)
-> ((Maybe [MetricLevelImpact] -> f (Maybe [MetricLevelImpact]))
    -> Maybe [MetricLevelImpact] -> f (Maybe [MetricLevelImpact]))
-> (Maybe [MetricLevelImpact] -> f (Maybe [MetricLevelImpact]))
-> AnomalyGroup
-> f AnomalyGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MetricLevelImpact]
  [MetricLevelImpact]
  [MetricLevelImpact]
  [MetricLevelImpact]
-> Iso
     (Maybe [MetricLevelImpact])
     (Maybe [MetricLevelImpact])
     (Maybe [MetricLevelImpact])
     (Maybe [MetricLevelImpact])
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
  [MetricLevelImpact]
  [MetricLevelImpact]
  [MetricLevelImpact]
  [MetricLevelImpact]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The start time for the group.
anomalyGroup_startTime :: Lens.Lens' AnomalyGroup (Prelude.Maybe Prelude.Text)
anomalyGroup_startTime :: (Maybe Text -> f (Maybe Text)) -> AnomalyGroup -> f AnomalyGroup
anomalyGroup_startTime = (AnomalyGroup -> Maybe Text)
-> (AnomalyGroup -> Maybe Text -> AnomalyGroup)
-> Lens AnomalyGroup AnomalyGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroup' {Maybe Text
startTime :: Maybe Text
$sel:startTime:AnomalyGroup' :: AnomalyGroup -> Maybe Text
startTime} -> Maybe Text
startTime) (\s :: AnomalyGroup
s@AnomalyGroup' {} Maybe Text
a -> AnomalyGroup
s {$sel:startTime:AnomalyGroup' :: Maybe Text
startTime = Maybe Text
a} :: AnomalyGroup)

-- | The ID of the anomaly group.
anomalyGroup_anomalyGroupId :: Lens.Lens' AnomalyGroup (Prelude.Maybe Prelude.Text)
anomalyGroup_anomalyGroupId :: (Maybe Text -> f (Maybe Text)) -> AnomalyGroup -> f AnomalyGroup
anomalyGroup_anomalyGroupId = (AnomalyGroup -> Maybe Text)
-> (AnomalyGroup -> Maybe Text -> AnomalyGroup)
-> Lens AnomalyGroup AnomalyGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroup' {Maybe Text
anomalyGroupId :: Maybe Text
$sel:anomalyGroupId:AnomalyGroup' :: AnomalyGroup -> Maybe Text
anomalyGroupId} -> Maybe Text
anomalyGroupId) (\s :: AnomalyGroup
s@AnomalyGroup' {} Maybe Text
a -> AnomalyGroup
s {$sel:anomalyGroupId:AnomalyGroup' :: Maybe Text
anomalyGroupId = Maybe Text
a} :: AnomalyGroup)

-- | The severity score of the group.
anomalyGroup_anomalyGroupScore :: Lens.Lens' AnomalyGroup (Prelude.Maybe Prelude.Double)
anomalyGroup_anomalyGroupScore :: (Maybe Double -> f (Maybe Double))
-> AnomalyGroup -> f AnomalyGroup
anomalyGroup_anomalyGroupScore = (AnomalyGroup -> Maybe Double)
-> (AnomalyGroup -> Maybe Double -> AnomalyGroup)
-> Lens AnomalyGroup AnomalyGroup (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroup' {Maybe Double
anomalyGroupScore :: Maybe Double
$sel:anomalyGroupScore:AnomalyGroup' :: AnomalyGroup -> Maybe Double
anomalyGroupScore} -> Maybe Double
anomalyGroupScore) (\s :: AnomalyGroup
s@AnomalyGroup' {} Maybe Double
a -> AnomalyGroup
s {$sel:anomalyGroupScore:AnomalyGroup' :: Maybe Double
anomalyGroupScore = Maybe Double
a} :: AnomalyGroup)

-- | The name of the primary affected measure for the group.
anomalyGroup_primaryMetricName :: Lens.Lens' AnomalyGroup (Prelude.Maybe Prelude.Text)
anomalyGroup_primaryMetricName :: (Maybe Text -> f (Maybe Text)) -> AnomalyGroup -> f AnomalyGroup
anomalyGroup_primaryMetricName = (AnomalyGroup -> Maybe Text)
-> (AnomalyGroup -> Maybe Text -> AnomalyGroup)
-> Lens AnomalyGroup AnomalyGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroup' {Maybe Text
primaryMetricName :: Maybe Text
$sel:primaryMetricName:AnomalyGroup' :: AnomalyGroup -> Maybe Text
primaryMetricName} -> Maybe Text
primaryMetricName) (\s :: AnomalyGroup
s@AnomalyGroup' {} Maybe Text
a -> AnomalyGroup
s {$sel:primaryMetricName:AnomalyGroup' :: Maybe Text
primaryMetricName = Maybe Text
a} :: AnomalyGroup)

-- | The end time for the group.
anomalyGroup_endTime :: Lens.Lens' AnomalyGroup (Prelude.Maybe Prelude.Text)
anomalyGroup_endTime :: (Maybe Text -> f (Maybe Text)) -> AnomalyGroup -> f AnomalyGroup
anomalyGroup_endTime = (AnomalyGroup -> Maybe Text)
-> (AnomalyGroup -> Maybe Text -> AnomalyGroup)
-> Lens AnomalyGroup AnomalyGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroup' {Maybe Text
endTime :: Maybe Text
$sel:endTime:AnomalyGroup' :: AnomalyGroup -> Maybe Text
endTime} -> Maybe Text
endTime) (\s :: AnomalyGroup
s@AnomalyGroup' {} Maybe Text
a -> AnomalyGroup
s {$sel:endTime:AnomalyGroup' :: Maybe Text
endTime = Maybe Text
a} :: AnomalyGroup)

instance Core.FromJSON AnomalyGroup where
  parseJSON :: Value -> Parser AnomalyGroup
parseJSON =
    String
-> (Object -> Parser AnomalyGroup) -> Value -> Parser AnomalyGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AnomalyGroup"
      ( \Object
x ->
          Maybe [MetricLevelImpact]
-> Maybe Text
-> Maybe Text
-> Maybe Double
-> Maybe Text
-> Maybe Text
-> AnomalyGroup
AnomalyGroup'
            (Maybe [MetricLevelImpact]
 -> Maybe Text
 -> Maybe Text
 -> Maybe Double
 -> Maybe Text
 -> Maybe Text
 -> AnomalyGroup)
-> Parser (Maybe [MetricLevelImpact])
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Double
      -> Maybe Text
      -> Maybe Text
      -> AnomalyGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [MetricLevelImpact]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricLevelImpactList"
                            Parser (Maybe (Maybe [MetricLevelImpact]))
-> Maybe [MetricLevelImpact] -> Parser (Maybe [MetricLevelImpact])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [MetricLevelImpact]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Double
   -> Maybe Text
   -> Maybe Text
   -> AnomalyGroup)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Double -> Maybe Text -> Maybe Text -> AnomalyGroup)
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
"StartTime")
            Parser
  (Maybe Text
   -> Maybe Double -> Maybe Text -> Maybe Text -> AnomalyGroup)
-> Parser (Maybe Text)
-> Parser
     (Maybe Double -> Maybe Text -> Maybe Text -> AnomalyGroup)
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
"AnomalyGroupId")
            Parser (Maybe Double -> Maybe Text -> Maybe Text -> AnomalyGroup)
-> Parser (Maybe Double)
-> Parser (Maybe Text -> Maybe Text -> AnomalyGroup)
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
"AnomalyGroupScore")
            Parser (Maybe Text -> Maybe Text -> AnomalyGroup)
-> Parser (Maybe Text) -> Parser (Maybe Text -> AnomalyGroup)
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
"PrimaryMetricName")
            Parser (Maybe Text -> AnomalyGroup)
-> Parser (Maybe Text) -> Parser AnomalyGroup
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
"EndTime")
      )

instance Prelude.Hashable AnomalyGroup

instance Prelude.NFData AnomalyGroup