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

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

-- | Details about a measure affected by an anomaly.
--
-- /See:/ 'newMetricLevelImpact' smart constructor.
data MetricLevelImpact = MetricLevelImpact'
  { -- | Details about the dimensions that contributed to the anomaly.
    MetricLevelImpact -> Maybe ContributionMatrix
contributionMatrix :: Prelude.Maybe ContributionMatrix,
    -- | The name of the measure.
    MetricLevelImpact -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The number of anomalous metrics for the measure.
    MetricLevelImpact -> Maybe Int
numTimeSeries :: Prelude.Maybe Prelude.Int
  }
  deriving (MetricLevelImpact -> MetricLevelImpact -> Bool
(MetricLevelImpact -> MetricLevelImpact -> Bool)
-> (MetricLevelImpact -> MetricLevelImpact -> Bool)
-> Eq MetricLevelImpact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricLevelImpact -> MetricLevelImpact -> Bool
$c/= :: MetricLevelImpact -> MetricLevelImpact -> Bool
== :: MetricLevelImpact -> MetricLevelImpact -> Bool
$c== :: MetricLevelImpact -> MetricLevelImpact -> Bool
Prelude.Eq, ReadPrec [MetricLevelImpact]
ReadPrec MetricLevelImpact
Int -> ReadS MetricLevelImpact
ReadS [MetricLevelImpact]
(Int -> ReadS MetricLevelImpact)
-> ReadS [MetricLevelImpact]
-> ReadPrec MetricLevelImpact
-> ReadPrec [MetricLevelImpact]
-> Read MetricLevelImpact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricLevelImpact]
$creadListPrec :: ReadPrec [MetricLevelImpact]
readPrec :: ReadPrec MetricLevelImpact
$creadPrec :: ReadPrec MetricLevelImpact
readList :: ReadS [MetricLevelImpact]
$creadList :: ReadS [MetricLevelImpact]
readsPrec :: Int -> ReadS MetricLevelImpact
$creadsPrec :: Int -> ReadS MetricLevelImpact
Prelude.Read, Int -> MetricLevelImpact -> ShowS
[MetricLevelImpact] -> ShowS
MetricLevelImpact -> String
(Int -> MetricLevelImpact -> ShowS)
-> (MetricLevelImpact -> String)
-> ([MetricLevelImpact] -> ShowS)
-> Show MetricLevelImpact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricLevelImpact] -> ShowS
$cshowList :: [MetricLevelImpact] -> ShowS
show :: MetricLevelImpact -> String
$cshow :: MetricLevelImpact -> String
showsPrec :: Int -> MetricLevelImpact -> ShowS
$cshowsPrec :: Int -> MetricLevelImpact -> ShowS
Prelude.Show, (forall x. MetricLevelImpact -> Rep MetricLevelImpact x)
-> (forall x. Rep MetricLevelImpact x -> MetricLevelImpact)
-> Generic MetricLevelImpact
forall x. Rep MetricLevelImpact x -> MetricLevelImpact
forall x. MetricLevelImpact -> Rep MetricLevelImpact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricLevelImpact x -> MetricLevelImpact
$cfrom :: forall x. MetricLevelImpact -> Rep MetricLevelImpact x
Prelude.Generic)

-- |
-- Create a value of 'MetricLevelImpact' 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:
--
-- 'contributionMatrix', 'metricLevelImpact_contributionMatrix' - Details about the dimensions that contributed to the anomaly.
--
-- 'metricName', 'metricLevelImpact_metricName' - The name of the measure.
--
-- 'numTimeSeries', 'metricLevelImpact_numTimeSeries' - The number of anomalous metrics for the measure.
newMetricLevelImpact ::
  MetricLevelImpact
newMetricLevelImpact :: MetricLevelImpact
newMetricLevelImpact =
  MetricLevelImpact' :: Maybe ContributionMatrix
-> Maybe Text -> Maybe Int -> MetricLevelImpact
MetricLevelImpact'
    { $sel:contributionMatrix:MetricLevelImpact' :: Maybe ContributionMatrix
contributionMatrix =
        Maybe ContributionMatrix
forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:MetricLevelImpact' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:numTimeSeries:MetricLevelImpact' :: Maybe Int
numTimeSeries = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Details about the dimensions that contributed to the anomaly.
metricLevelImpact_contributionMatrix :: Lens.Lens' MetricLevelImpact (Prelude.Maybe ContributionMatrix)
metricLevelImpact_contributionMatrix :: (Maybe ContributionMatrix -> f (Maybe ContributionMatrix))
-> MetricLevelImpact -> f MetricLevelImpact
metricLevelImpact_contributionMatrix = (MetricLevelImpact -> Maybe ContributionMatrix)
-> (MetricLevelImpact
    -> Maybe ContributionMatrix -> MetricLevelImpact)
-> Lens
     MetricLevelImpact
     MetricLevelImpact
     (Maybe ContributionMatrix)
     (Maybe ContributionMatrix)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricLevelImpact' {Maybe ContributionMatrix
contributionMatrix :: Maybe ContributionMatrix
$sel:contributionMatrix:MetricLevelImpact' :: MetricLevelImpact -> Maybe ContributionMatrix
contributionMatrix} -> Maybe ContributionMatrix
contributionMatrix) (\s :: MetricLevelImpact
s@MetricLevelImpact' {} Maybe ContributionMatrix
a -> MetricLevelImpact
s {$sel:contributionMatrix:MetricLevelImpact' :: Maybe ContributionMatrix
contributionMatrix = Maybe ContributionMatrix
a} :: MetricLevelImpact)

-- | The name of the measure.
metricLevelImpact_metricName :: Lens.Lens' MetricLevelImpact (Prelude.Maybe Prelude.Text)
metricLevelImpact_metricName :: (Maybe Text -> f (Maybe Text))
-> MetricLevelImpact -> f MetricLevelImpact
metricLevelImpact_metricName = (MetricLevelImpact -> Maybe Text)
-> (MetricLevelImpact -> Maybe Text -> MetricLevelImpact)
-> Lens
     MetricLevelImpact MetricLevelImpact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricLevelImpact' {Maybe Text
metricName :: Maybe Text
$sel:metricName:MetricLevelImpact' :: MetricLevelImpact -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: MetricLevelImpact
s@MetricLevelImpact' {} Maybe Text
a -> MetricLevelImpact
s {$sel:metricName:MetricLevelImpact' :: Maybe Text
metricName = Maybe Text
a} :: MetricLevelImpact)

-- | The number of anomalous metrics for the measure.
metricLevelImpact_numTimeSeries :: Lens.Lens' MetricLevelImpact (Prelude.Maybe Prelude.Int)
metricLevelImpact_numTimeSeries :: (Maybe Int -> f (Maybe Int))
-> MetricLevelImpact -> f MetricLevelImpact
metricLevelImpact_numTimeSeries = (MetricLevelImpact -> Maybe Int)
-> (MetricLevelImpact -> Maybe Int -> MetricLevelImpact)
-> Lens MetricLevelImpact MetricLevelImpact (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricLevelImpact' {Maybe Int
numTimeSeries :: Maybe Int
$sel:numTimeSeries:MetricLevelImpact' :: MetricLevelImpact -> Maybe Int
numTimeSeries} -> Maybe Int
numTimeSeries) (\s :: MetricLevelImpact
s@MetricLevelImpact' {} Maybe Int
a -> MetricLevelImpact
s {$sel:numTimeSeries:MetricLevelImpact' :: Maybe Int
numTimeSeries = Maybe Int
a} :: MetricLevelImpact)

instance Core.FromJSON MetricLevelImpact where
  parseJSON :: Value -> Parser MetricLevelImpact
parseJSON =
    String
-> (Object -> Parser MetricLevelImpact)
-> Value
-> Parser MetricLevelImpact
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricLevelImpact"
      ( \Object
x ->
          Maybe ContributionMatrix
-> Maybe Text -> Maybe Int -> MetricLevelImpact
MetricLevelImpact'
            (Maybe ContributionMatrix
 -> Maybe Text -> Maybe Int -> MetricLevelImpact)
-> Parser (Maybe ContributionMatrix)
-> Parser (Maybe Text -> Maybe Int -> MetricLevelImpact)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ContributionMatrix)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ContributionMatrix")
            Parser (Maybe Text -> Maybe Int -> MetricLevelImpact)
-> Parser (Maybe Text) -> Parser (Maybe Int -> MetricLevelImpact)
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
"MetricName")
            Parser (Maybe Int -> MetricLevelImpact)
-> Parser (Maybe Int) -> Parser MetricLevelImpact
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
"NumTimeSeries")
      )

instance Prelude.Hashable MetricLevelImpact

instance Prelude.NFData MetricLevelImpact