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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The severity of a value of a dimension that contributed to an anomaly.
--
-- /See:/ 'newDimensionValueContribution' smart constructor.
data DimensionValueContribution = DimensionValueContribution'
  { -- | The value of the dimension.
    DimensionValueContribution -> Maybe Text
dimensionValue :: Prelude.Maybe Prelude.Text,
    -- | The severity score of the value.
    DimensionValueContribution -> Maybe Double
contributionScore :: Prelude.Maybe Prelude.Double
  }
  deriving (DimensionValueContribution -> DimensionValueContribution -> Bool
(DimensionValueContribution -> DimensionValueContribution -> Bool)
-> (DimensionValueContribution
    -> DimensionValueContribution -> Bool)
-> Eq DimensionValueContribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DimensionValueContribution -> DimensionValueContribution -> Bool
$c/= :: DimensionValueContribution -> DimensionValueContribution -> Bool
== :: DimensionValueContribution -> DimensionValueContribution -> Bool
$c== :: DimensionValueContribution -> DimensionValueContribution -> Bool
Prelude.Eq, ReadPrec [DimensionValueContribution]
ReadPrec DimensionValueContribution
Int -> ReadS DimensionValueContribution
ReadS [DimensionValueContribution]
(Int -> ReadS DimensionValueContribution)
-> ReadS [DimensionValueContribution]
-> ReadPrec DimensionValueContribution
-> ReadPrec [DimensionValueContribution]
-> Read DimensionValueContribution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DimensionValueContribution]
$creadListPrec :: ReadPrec [DimensionValueContribution]
readPrec :: ReadPrec DimensionValueContribution
$creadPrec :: ReadPrec DimensionValueContribution
readList :: ReadS [DimensionValueContribution]
$creadList :: ReadS [DimensionValueContribution]
readsPrec :: Int -> ReadS DimensionValueContribution
$creadsPrec :: Int -> ReadS DimensionValueContribution
Prelude.Read, Int -> DimensionValueContribution -> ShowS
[DimensionValueContribution] -> ShowS
DimensionValueContribution -> String
(Int -> DimensionValueContribution -> ShowS)
-> (DimensionValueContribution -> String)
-> ([DimensionValueContribution] -> ShowS)
-> Show DimensionValueContribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DimensionValueContribution] -> ShowS
$cshowList :: [DimensionValueContribution] -> ShowS
show :: DimensionValueContribution -> String
$cshow :: DimensionValueContribution -> String
showsPrec :: Int -> DimensionValueContribution -> ShowS
$cshowsPrec :: Int -> DimensionValueContribution -> ShowS
Prelude.Show, (forall x.
 DimensionValueContribution -> Rep DimensionValueContribution x)
-> (forall x.
    Rep DimensionValueContribution x -> DimensionValueContribution)
-> Generic DimensionValueContribution
forall x.
Rep DimensionValueContribution x -> DimensionValueContribution
forall x.
DimensionValueContribution -> Rep DimensionValueContribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DimensionValueContribution x -> DimensionValueContribution
$cfrom :: forall x.
DimensionValueContribution -> Rep DimensionValueContribution x
Prelude.Generic)

-- |
-- Create a value of 'DimensionValueContribution' 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:
--
-- 'dimensionValue', 'dimensionValueContribution_dimensionValue' - The value of the dimension.
--
-- 'contributionScore', 'dimensionValueContribution_contributionScore' - The severity score of the value.
newDimensionValueContribution ::
  DimensionValueContribution
newDimensionValueContribution :: DimensionValueContribution
newDimensionValueContribution =
  DimensionValueContribution' :: Maybe Text -> Maybe Double -> DimensionValueContribution
DimensionValueContribution'
    { $sel:dimensionValue:DimensionValueContribution' :: Maybe Text
dimensionValue =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contributionScore:DimensionValueContribution' :: Maybe Double
contributionScore = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the dimension.
dimensionValueContribution_dimensionValue :: Lens.Lens' DimensionValueContribution (Prelude.Maybe Prelude.Text)
dimensionValueContribution_dimensionValue :: (Maybe Text -> f (Maybe Text))
-> DimensionValueContribution -> f DimensionValueContribution
dimensionValueContribution_dimensionValue = (DimensionValueContribution -> Maybe Text)
-> (DimensionValueContribution
    -> Maybe Text -> DimensionValueContribution)
-> Lens
     DimensionValueContribution
     DimensionValueContribution
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionValueContribution' {Maybe Text
dimensionValue :: Maybe Text
$sel:dimensionValue:DimensionValueContribution' :: DimensionValueContribution -> Maybe Text
dimensionValue} -> Maybe Text
dimensionValue) (\s :: DimensionValueContribution
s@DimensionValueContribution' {} Maybe Text
a -> DimensionValueContribution
s {$sel:dimensionValue:DimensionValueContribution' :: Maybe Text
dimensionValue = Maybe Text
a} :: DimensionValueContribution)

-- | The severity score of the value.
dimensionValueContribution_contributionScore :: Lens.Lens' DimensionValueContribution (Prelude.Maybe Prelude.Double)
dimensionValueContribution_contributionScore :: (Maybe Double -> f (Maybe Double))
-> DimensionValueContribution -> f DimensionValueContribution
dimensionValueContribution_contributionScore = (DimensionValueContribution -> Maybe Double)
-> (DimensionValueContribution
    -> Maybe Double -> DimensionValueContribution)
-> Lens
     DimensionValueContribution
     DimensionValueContribution
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionValueContribution' {Maybe Double
contributionScore :: Maybe Double
$sel:contributionScore:DimensionValueContribution' :: DimensionValueContribution -> Maybe Double
contributionScore} -> Maybe Double
contributionScore) (\s :: DimensionValueContribution
s@DimensionValueContribution' {} Maybe Double
a -> DimensionValueContribution
s {$sel:contributionScore:DimensionValueContribution' :: Maybe Double
contributionScore = Maybe Double
a} :: DimensionValueContribution)

instance Core.FromJSON DimensionValueContribution where
  parseJSON :: Value -> Parser DimensionValueContribution
parseJSON =
    String
-> (Object -> Parser DimensionValueContribution)
-> Value
-> Parser DimensionValueContribution
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DimensionValueContribution"
      ( \Object
x ->
          Maybe Text -> Maybe Double -> DimensionValueContribution
DimensionValueContribution'
            (Maybe Text -> Maybe Double -> DimensionValueContribution)
-> Parser (Maybe Text)
-> Parser (Maybe Double -> DimensionValueContribution)
forall (f :: * -> *) a b. Functor 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
"DimensionValue")
            Parser (Maybe Double -> DimensionValueContribution)
-> Parser (Maybe Double) -> Parser DimensionValueContribution
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
"ContributionScore")
      )

instance Prelude.Hashable DimensionValueContribution

instance Prelude.NFData DimensionValueContribution