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

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

-- | The combination of Amazon Web Services service, linked account, Region,
-- and usage type where a cost anomaly is observed.
--
-- /See:/ 'newRootCause' smart constructor.
data RootCause = RootCause'
  { -- | The Amazon Web Services 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,
    -- | The member account value that\'s associated with the cost anomaly.
    RootCause -> Maybe Text
linkedAccount :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Region that\'s associated with the cost anomaly.
    RootCause -> Maybe Text
region :: Prelude.Maybe Prelude.Text
  }
  deriving (RootCause -> RootCause -> Bool
(RootCause -> RootCause -> Bool)
-> (RootCause -> RootCause -> Bool) -> Eq RootCause
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]
(Int -> ReadS RootCause)
-> ReadS [RootCause]
-> ReadPrec RootCause
-> ReadPrec [RootCause]
-> Read 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
(Int -> RootCause -> ShowS)
-> (RootCause -> String)
-> ([RootCause] -> ShowS)
-> Show RootCause
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. RootCause -> Rep RootCause x)
-> (forall x. Rep RootCause x -> RootCause) -> Generic RootCause
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:
--
-- 'service', 'rootCause_service' - The Amazon Web Services service name that\'s associated with the cost
-- anomaly.
--
-- 'usageType', 'rootCause_usageType' - The @UsageType@ value that\'s associated with the cost anomaly.
--
-- 'linkedAccount', 'rootCause_linkedAccount' - The member account value that\'s associated with the cost anomaly.
--
-- 'region', 'rootCause_region' - The Amazon Web Services Region that\'s associated with the cost anomaly.
newRootCause ::
  RootCause
newRootCause :: RootCause
newRootCause =
  RootCause' :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> RootCause
RootCause'
    { $sel:service:RootCause' :: Maybe Text
service = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:usageType:RootCause' :: Maybe Text
usageType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:linkedAccount:RootCause' :: Maybe Text
linkedAccount = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:RootCause' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Web Services service name that\'s associated with the cost
-- anomaly.
rootCause_service :: Lens.Lens' RootCause (Prelude.Maybe Prelude.Text)
rootCause_service :: (Maybe Text -> f (Maybe Text)) -> RootCause -> f RootCause
rootCause_service = (RootCause -> Maybe Text)
-> (RootCause -> Maybe Text -> RootCause)
-> Lens RootCause RootCause (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> RootCause -> f RootCause
rootCause_usageType = (RootCause -> Maybe Text)
-> (RootCause -> Maybe Text -> RootCause)
-> Lens RootCause RootCause (Maybe Text) (Maybe Text)
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)

-- | The member account value that\'s associated with the cost anomaly.
rootCause_linkedAccount :: Lens.Lens' RootCause (Prelude.Maybe Prelude.Text)
rootCause_linkedAccount :: (Maybe Text -> f (Maybe Text)) -> RootCause -> f RootCause
rootCause_linkedAccount = (RootCause -> Maybe Text)
-> (RootCause -> Maybe Text -> RootCause)
-> Lens RootCause RootCause (Maybe Text) (Maybe Text)
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 Amazon Web Services Region that\'s associated with the cost anomaly.
rootCause_region :: Lens.Lens' RootCause (Prelude.Maybe Prelude.Text)
rootCause_region :: (Maybe Text -> f (Maybe Text)) -> RootCause -> f RootCause
rootCause_region = (RootCause -> Maybe Text)
-> (RootCause -> Maybe Text -> RootCause)
-> Lens RootCause RootCause (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable RootCause

instance Prelude.NFData RootCause