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

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

-- | Details about a dimension that contributed to an anomaly.
--
-- /See:/ 'newDimensionContribution' smart constructor.
data DimensionContribution = DimensionContribution'
  { -- | A list of dimension values that contributed to the anomaly.
    DimensionContribution -> Maybe [DimensionValueContribution]
dimensionValueContributionList :: Prelude.Maybe [DimensionValueContribution],
    -- | The name of the dimension.
    DimensionContribution -> Maybe Text
dimensionName :: Prelude.Maybe Prelude.Text
  }
  deriving (DimensionContribution -> DimensionContribution -> Bool
(DimensionContribution -> DimensionContribution -> Bool)
-> (DimensionContribution -> DimensionContribution -> Bool)
-> Eq DimensionContribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DimensionContribution -> DimensionContribution -> Bool
$c/= :: DimensionContribution -> DimensionContribution -> Bool
== :: DimensionContribution -> DimensionContribution -> Bool
$c== :: DimensionContribution -> DimensionContribution -> Bool
Prelude.Eq, ReadPrec [DimensionContribution]
ReadPrec DimensionContribution
Int -> ReadS DimensionContribution
ReadS [DimensionContribution]
(Int -> ReadS DimensionContribution)
-> ReadS [DimensionContribution]
-> ReadPrec DimensionContribution
-> ReadPrec [DimensionContribution]
-> Read DimensionContribution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DimensionContribution]
$creadListPrec :: ReadPrec [DimensionContribution]
readPrec :: ReadPrec DimensionContribution
$creadPrec :: ReadPrec DimensionContribution
readList :: ReadS [DimensionContribution]
$creadList :: ReadS [DimensionContribution]
readsPrec :: Int -> ReadS DimensionContribution
$creadsPrec :: Int -> ReadS DimensionContribution
Prelude.Read, Int -> DimensionContribution -> ShowS
[DimensionContribution] -> ShowS
DimensionContribution -> String
(Int -> DimensionContribution -> ShowS)
-> (DimensionContribution -> String)
-> ([DimensionContribution] -> ShowS)
-> Show DimensionContribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DimensionContribution] -> ShowS
$cshowList :: [DimensionContribution] -> ShowS
show :: DimensionContribution -> String
$cshow :: DimensionContribution -> String
showsPrec :: Int -> DimensionContribution -> ShowS
$cshowsPrec :: Int -> DimensionContribution -> ShowS
Prelude.Show, (forall x. DimensionContribution -> Rep DimensionContribution x)
-> (forall x. Rep DimensionContribution x -> DimensionContribution)
-> Generic DimensionContribution
forall x. Rep DimensionContribution x -> DimensionContribution
forall x. DimensionContribution -> Rep DimensionContribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DimensionContribution x -> DimensionContribution
$cfrom :: forall x. DimensionContribution -> Rep DimensionContribution x
Prelude.Generic)

-- |
-- Create a value of 'DimensionContribution' 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:
--
-- 'dimensionValueContributionList', 'dimensionContribution_dimensionValueContributionList' - A list of dimension values that contributed to the anomaly.
--
-- 'dimensionName', 'dimensionContribution_dimensionName' - The name of the dimension.
newDimensionContribution ::
  DimensionContribution
newDimensionContribution :: DimensionContribution
newDimensionContribution =
  DimensionContribution' :: Maybe [DimensionValueContribution]
-> Maybe Text -> DimensionContribution
DimensionContribution'
    { $sel:dimensionValueContributionList:DimensionContribution' :: Maybe [DimensionValueContribution]
dimensionValueContributionList =
        Maybe [DimensionValueContribution]
forall a. Maybe a
Prelude.Nothing,
      $sel:dimensionName:DimensionContribution' :: Maybe Text
dimensionName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of dimension values that contributed to the anomaly.
dimensionContribution_dimensionValueContributionList :: Lens.Lens' DimensionContribution (Prelude.Maybe [DimensionValueContribution])
dimensionContribution_dimensionValueContributionList :: (Maybe [DimensionValueContribution]
 -> f (Maybe [DimensionValueContribution]))
-> DimensionContribution -> f DimensionContribution
dimensionContribution_dimensionValueContributionList = (DimensionContribution -> Maybe [DimensionValueContribution])
-> (DimensionContribution
    -> Maybe [DimensionValueContribution] -> DimensionContribution)
-> Lens
     DimensionContribution
     DimensionContribution
     (Maybe [DimensionValueContribution])
     (Maybe [DimensionValueContribution])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionContribution' {Maybe [DimensionValueContribution]
dimensionValueContributionList :: Maybe [DimensionValueContribution]
$sel:dimensionValueContributionList:DimensionContribution' :: DimensionContribution -> Maybe [DimensionValueContribution]
dimensionValueContributionList} -> Maybe [DimensionValueContribution]
dimensionValueContributionList) (\s :: DimensionContribution
s@DimensionContribution' {} Maybe [DimensionValueContribution]
a -> DimensionContribution
s {$sel:dimensionValueContributionList:DimensionContribution' :: Maybe [DimensionValueContribution]
dimensionValueContributionList = Maybe [DimensionValueContribution]
a} :: DimensionContribution) ((Maybe [DimensionValueContribution]
  -> f (Maybe [DimensionValueContribution]))
 -> DimensionContribution -> f DimensionContribution)
-> ((Maybe [DimensionValueContribution]
     -> f (Maybe [DimensionValueContribution]))
    -> Maybe [DimensionValueContribution]
    -> f (Maybe [DimensionValueContribution]))
-> (Maybe [DimensionValueContribution]
    -> f (Maybe [DimensionValueContribution]))
-> DimensionContribution
-> f DimensionContribution
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DimensionValueContribution]
  [DimensionValueContribution]
  [DimensionValueContribution]
  [DimensionValueContribution]
-> Iso
     (Maybe [DimensionValueContribution])
     (Maybe [DimensionValueContribution])
     (Maybe [DimensionValueContribution])
     (Maybe [DimensionValueContribution])
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
  [DimensionValueContribution]
  [DimensionValueContribution]
  [DimensionValueContribution]
  [DimensionValueContribution]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the dimension.
dimensionContribution_dimensionName :: Lens.Lens' DimensionContribution (Prelude.Maybe Prelude.Text)
dimensionContribution_dimensionName :: (Maybe Text -> f (Maybe Text))
-> DimensionContribution -> f DimensionContribution
dimensionContribution_dimensionName = (DimensionContribution -> Maybe Text)
-> (DimensionContribution -> Maybe Text -> DimensionContribution)
-> Lens
     DimensionContribution
     DimensionContribution
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DimensionContribution' {Maybe Text
dimensionName :: Maybe Text
$sel:dimensionName:DimensionContribution' :: DimensionContribution -> Maybe Text
dimensionName} -> Maybe Text
dimensionName) (\s :: DimensionContribution
s@DimensionContribution' {} Maybe Text
a -> DimensionContribution
s {$sel:dimensionName:DimensionContribution' :: Maybe Text
dimensionName = Maybe Text
a} :: DimensionContribution)

instance Core.FromJSON DimensionContribution where
  parseJSON :: Value -> Parser DimensionContribution
parseJSON =
    String
-> (Object -> Parser DimensionContribution)
-> Value
-> Parser DimensionContribution
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DimensionContribution"
      ( \Object
x ->
          Maybe [DimensionValueContribution]
-> Maybe Text -> DimensionContribution
DimensionContribution'
            (Maybe [DimensionValueContribution]
 -> Maybe Text -> DimensionContribution)
-> Parser (Maybe [DimensionValueContribution])
-> Parser (Maybe Text -> DimensionContribution)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [DimensionValueContribution]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DimensionValueContributionList"
                            Parser (Maybe (Maybe [DimensionValueContribution]))
-> Maybe [DimensionValueContribution]
-> Parser (Maybe [DimensionValueContribution])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DimensionValueContribution]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> DimensionContribution)
-> Parser (Maybe Text) -> Parser DimensionContribution
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
"DimensionName")
      )

instance Prelude.Hashable DimensionContribution

instance Prelude.NFData DimensionContribution