{-# 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-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.MetricLevelImpact 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.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
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]
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
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. 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'
    { $sel:contributionMatrix:MetricLevelImpact' :: Maybe ContributionMatrix
contributionMatrix =
        forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:MetricLevelImpact' :: Maybe Text
metricName = forall a. Maybe a
Prelude.Nothing,
      $sel:numTimeSeries:MetricLevelImpact' :: Maybe Int
numTimeSeries = 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 :: Lens' MetricLevelImpact (Maybe ContributionMatrix)
metricLevelImpact_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 :: Lens' MetricLevelImpact (Maybe Text)
metricLevelImpact_metricName = 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 :: Lens' MetricLevelImpact (Maybe Int)
metricLevelImpact_numTimeSeries = 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 Data.FromJSON MetricLevelImpact where
  parseJSON :: Value -> Parser MetricLevelImpact
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MetricLevelImpact"
      ( \Object
x ->
          Maybe ContributionMatrix
-> Maybe Text -> Maybe Int -> MetricLevelImpact
MetricLevelImpact'
            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
"ContributionMatrix")
            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
"MetricName")
            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
"NumTimeSeries")
      )

instance Prelude.Hashable MetricLevelImpact where
  hashWithSalt :: Int -> MetricLevelImpact -> Int
hashWithSalt Int
_salt MetricLevelImpact' {Maybe Int
Maybe Text
Maybe ContributionMatrix
numTimeSeries :: Maybe Int
metricName :: Maybe Text
contributionMatrix :: Maybe ContributionMatrix
$sel:numTimeSeries:MetricLevelImpact' :: MetricLevelImpact -> Maybe Int
$sel:metricName:MetricLevelImpact' :: MetricLevelImpact -> Maybe Text
$sel:contributionMatrix:MetricLevelImpact' :: MetricLevelImpact -> Maybe ContributionMatrix
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ContributionMatrix
contributionMatrix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
metricName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
numTimeSeries

instance Prelude.NFData MetricLevelImpact where
  rnf :: MetricLevelImpact -> ()
rnf MetricLevelImpact' {Maybe Int
Maybe Text
Maybe ContributionMatrix
numTimeSeries :: Maybe Int
metricName :: Maybe Text
contributionMatrix :: Maybe ContributionMatrix
$sel:numTimeSeries:MetricLevelImpact' :: MetricLevelImpact -> Maybe Int
$sel:metricName:MetricLevelImpact' :: MetricLevelImpact -> Maybe Text
$sel:contributionMatrix:MetricLevelImpact' :: MetricLevelImpact -> Maybe ContributionMatrix
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ContributionMatrix
contributionMatrix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
metricName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
numTimeSeries