{-# 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.ContributionMatrix
-- 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.ContributionMatrix 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.DimensionContribution
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'ContributionMatrix' 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:
--
-- 'dimensionContributionList', 'contributionMatrix_dimensionContributionList' - A list of contributing dimensions.
newContributionMatrix ::
  ContributionMatrix
newContributionMatrix :: ContributionMatrix
newContributionMatrix =
  ContributionMatrix'
    { $sel:dimensionContributionList:ContributionMatrix' :: Maybe [DimensionContribution]
dimensionContributionList =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A list of contributing dimensions.
contributionMatrix_dimensionContributionList :: Lens.Lens' ContributionMatrix (Prelude.Maybe [DimensionContribution])
contributionMatrix_dimensionContributionList :: Lens' ContributionMatrix (Maybe [DimensionContribution])
contributionMatrix_dimensionContributionList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContributionMatrix' {Maybe [DimensionContribution]
dimensionContributionList :: Maybe [DimensionContribution]
$sel:dimensionContributionList:ContributionMatrix' :: ContributionMatrix -> Maybe [DimensionContribution]
dimensionContributionList} -> Maybe [DimensionContribution]
dimensionContributionList) (\s :: ContributionMatrix
s@ContributionMatrix' {} Maybe [DimensionContribution]
a -> ContributionMatrix
s {$sel:dimensionContributionList:ContributionMatrix' :: Maybe [DimensionContribution]
dimensionContributionList = Maybe [DimensionContribution]
a} :: ContributionMatrix) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ContributionMatrix where
  parseJSON :: Value -> Parser ContributionMatrix
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContributionMatrix"
      ( \Object
x ->
          Maybe [DimensionContribution] -> ContributionMatrix
ContributionMatrix'
            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
"DimensionContributionList"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ContributionMatrix where
  hashWithSalt :: Int -> ContributionMatrix -> Int
hashWithSalt Int
_salt ContributionMatrix' {Maybe [DimensionContribution]
dimensionContributionList :: Maybe [DimensionContribution]
$sel:dimensionContributionList:ContributionMatrix' :: ContributionMatrix -> Maybe [DimensionContribution]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DimensionContribution]
dimensionContributionList

instance Prelude.NFData ContributionMatrix where
  rnf :: ContributionMatrix -> ()
rnf ContributionMatrix' {Maybe [DimensionContribution]
dimensionContributionList :: Maybe [DimensionContribution]
$sel:dimensionContributionList:ContributionMatrix' :: ContributionMatrix -> Maybe [DimensionContribution]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DimensionContribution]
dimensionContributionList