{-# 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.CostExplorer.Types.RootCause
-- 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.CostExplorer.Types.RootCause where

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

-- | The combination of Amazon Web Service, linked account, linked account
-- name, Region, and usage type where a cost anomaly is observed. The
-- linked account name will only be available when the account name can be
-- identified.
--
-- /See:/ 'newRootCause' smart constructor.
data RootCause = RootCause'
  { -- | The member account value that\'s associated with the cost anomaly.
    RootCause -> Maybe Text
linkedAccount :: Prelude.Maybe Prelude.Text,
    -- | The member account name value that\'s associated with the cost anomaly.
    RootCause -> Maybe Text
linkedAccountName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Region that\'s associated with the cost anomaly.
    RootCause -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Service name that\'s associated with the cost anomaly.
    RootCause -> Maybe Text
service :: Prelude.Maybe Prelude.Text,
    -- | The @UsageType@ value that\'s associated with the cost anomaly.
    RootCause -> Maybe Text
usageType :: Prelude.Maybe Prelude.Text
  }
  deriving (RootCause -> RootCause -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RootCause -> RootCause -> Bool
$c/= :: RootCause -> RootCause -> Bool
== :: RootCause -> RootCause -> Bool
$c== :: RootCause -> RootCause -> Bool
Prelude.Eq, ReadPrec [RootCause]
ReadPrec RootCause
Int -> ReadS RootCause
ReadS [RootCause]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RootCause]
$creadListPrec :: ReadPrec [RootCause]
readPrec :: ReadPrec RootCause
$creadPrec :: ReadPrec RootCause
readList :: ReadS [RootCause]
$creadList :: ReadS [RootCause]
readsPrec :: Int -> ReadS RootCause
$creadsPrec :: Int -> ReadS RootCause
Prelude.Read, Int -> RootCause -> ShowS
[RootCause] -> ShowS
RootCause -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RootCause] -> ShowS
$cshowList :: [RootCause] -> ShowS
show :: RootCause -> String
$cshow :: RootCause -> String
showsPrec :: Int -> RootCause -> ShowS
$cshowsPrec :: Int -> RootCause -> ShowS
Prelude.Show, forall x. Rep RootCause x -> RootCause
forall x. RootCause -> Rep RootCause x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RootCause x -> RootCause
$cfrom :: forall x. RootCause -> Rep RootCause x
Prelude.Generic)

-- |
-- Create a value of 'RootCause' 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:
--
-- 'linkedAccount', 'rootCause_linkedAccount' - The member account value that\'s associated with the cost anomaly.
--
-- 'linkedAccountName', 'rootCause_linkedAccountName' - The member account name value that\'s associated with the cost anomaly.
--
-- 'region', 'rootCause_region' - The Amazon Web Services Region that\'s associated with the cost anomaly.
--
-- 'service', 'rootCause_service' - The Amazon Web Service name that\'s associated with the cost anomaly.
--
-- 'usageType', 'rootCause_usageType' - The @UsageType@ value that\'s associated with the cost anomaly.
newRootCause ::
  RootCause
newRootCause :: RootCause
newRootCause =
  RootCause'
    { $sel:linkedAccount:RootCause' :: Maybe Text
linkedAccount = forall a. Maybe a
Prelude.Nothing,
      $sel:linkedAccountName:RootCause' :: Maybe Text
linkedAccountName = forall a. Maybe a
Prelude.Nothing,
      $sel:region:RootCause' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing,
      $sel:service:RootCause' :: Maybe Text
service = forall a. Maybe a
Prelude.Nothing,
      $sel:usageType:RootCause' :: Maybe Text
usageType = forall a. Maybe a
Prelude.Nothing
    }

-- | The member account value that\'s associated with the cost anomaly.
rootCause_linkedAccount :: Lens.Lens' RootCause (Prelude.Maybe Prelude.Text)
rootCause_linkedAccount :: Lens' RootCause (Maybe Text)
rootCause_linkedAccount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RootCause' {Maybe Text
linkedAccount :: Maybe Text
$sel:linkedAccount:RootCause' :: RootCause -> Maybe Text
linkedAccount} -> Maybe Text
linkedAccount) (\s :: RootCause
s@RootCause' {} Maybe Text
a -> RootCause
s {$sel:linkedAccount:RootCause' :: Maybe Text
linkedAccount = Maybe Text
a} :: RootCause)

-- | The member account name value that\'s associated with the cost anomaly.
rootCause_linkedAccountName :: Lens.Lens' RootCause (Prelude.Maybe Prelude.Text)
rootCause_linkedAccountName :: Lens' RootCause (Maybe Text)
rootCause_linkedAccountName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RootCause' {Maybe Text
linkedAccountName :: Maybe Text
$sel:linkedAccountName:RootCause' :: RootCause -> Maybe Text
linkedAccountName} -> Maybe Text
linkedAccountName) (\s :: RootCause
s@RootCause' {} Maybe Text
a -> RootCause
s {$sel:linkedAccountName:RootCause' :: Maybe Text
linkedAccountName = Maybe Text
a} :: RootCause)

-- | The Amazon Web Services Region that\'s associated with the cost anomaly.
rootCause_region :: Lens.Lens' RootCause (Prelude.Maybe Prelude.Text)
rootCause_region :: Lens' RootCause (Maybe Text)
rootCause_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RootCause' {Maybe Text
region :: Maybe Text
$sel:region:RootCause' :: RootCause -> Maybe Text
region} -> Maybe Text
region) (\s :: RootCause
s@RootCause' {} Maybe Text
a -> RootCause
s {$sel:region:RootCause' :: Maybe Text
region = Maybe Text
a} :: RootCause)

-- | The Amazon Web Service name that\'s associated with the cost anomaly.
rootCause_service :: Lens.Lens' RootCause (Prelude.Maybe Prelude.Text)
rootCause_service :: Lens' RootCause (Maybe Text)
rootCause_service = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RootCause' {Maybe Text
service :: Maybe Text
$sel:service:RootCause' :: RootCause -> Maybe Text
service} -> Maybe Text
service) (\s :: RootCause
s@RootCause' {} Maybe Text
a -> RootCause
s {$sel:service:RootCause' :: Maybe Text
service = Maybe Text
a} :: RootCause)

-- | The @UsageType@ value that\'s associated with the cost anomaly.
rootCause_usageType :: Lens.Lens' RootCause (Prelude.Maybe Prelude.Text)
rootCause_usageType :: Lens' RootCause (Maybe Text)
rootCause_usageType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RootCause' {Maybe Text
usageType :: Maybe Text
$sel:usageType:RootCause' :: RootCause -> Maybe Text
usageType} -> Maybe Text
usageType) (\s :: RootCause
s@RootCause' {} Maybe Text
a -> RootCause
s {$sel:usageType:RootCause' :: Maybe Text
usageType = Maybe Text
a} :: RootCause)

instance Data.FromJSON RootCause where
  parseJSON :: Value -> Parser RootCause
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RootCause"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> RootCause
RootCause'
            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
"LinkedAccount")
            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
"LinkedAccountName")
            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
"Region")
            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
"Service")
            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
"UsageType")
      )

instance Prelude.Hashable RootCause where
  hashWithSalt :: Int -> RootCause -> Int
hashWithSalt Int
_salt RootCause' {Maybe Text
usageType :: Maybe Text
service :: Maybe Text
region :: Maybe Text
linkedAccountName :: Maybe Text
linkedAccount :: Maybe Text
$sel:usageType:RootCause' :: RootCause -> Maybe Text
$sel:service:RootCause' :: RootCause -> Maybe Text
$sel:region:RootCause' :: RootCause -> Maybe Text
$sel:linkedAccountName:RootCause' :: RootCause -> Maybe Text
$sel:linkedAccount:RootCause' :: RootCause -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
linkedAccount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
linkedAccountName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
region
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
service
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
usageType

instance Prelude.NFData RootCause where
  rnf :: RootCause -> ()
rnf RootCause' {Maybe Text
usageType :: Maybe Text
service :: Maybe Text
region :: Maybe Text
linkedAccountName :: Maybe Text
linkedAccount :: Maybe Text
$sel:usageType:RootCause' :: RootCause -> Maybe Text
$sel:service:RootCause' :: RootCause -> Maybe Text
$sel:region:RootCause' :: RootCause -> Maybe Text
$sel:linkedAccountName:RootCause' :: RootCause -> Maybe Text
$sel:linkedAccount:RootCause' :: RootCause -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
linkedAccount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
linkedAccountName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
service
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
usageType