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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.CostExplorer.Types.CostCategoryInheritedValueDimensionName
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | When you create or update a cost category, you can define the
-- @CostCategoryRule@ rule type as @INHERITED_VALUE@. This rule type adds
-- the flexibility to define a rule that dynamically inherits the cost
-- category value from the dimension value that\'s defined by
-- @CostCategoryInheritedValueDimension@. For example, suppose that you
-- want to dynamically group costs that are based on the value of a
-- specific tag key. First, choose an inherited value rule type, and then
-- choose the tag dimension and specify the tag key to use.
--
-- /See:/ 'newCostCategoryInheritedValueDimension' smart constructor.
data CostCategoryInheritedValueDimension = CostCategoryInheritedValueDimension'
  { -- | The key to extract cost category values.
    CostCategoryInheritedValueDimension -> Maybe Text
dimensionKey :: Prelude.Maybe Prelude.Text,
    -- | The name of the dimension that\'s used to group costs.
    --
    -- If you specify @LINKED_ACCOUNT_NAME@, the cost category value is based
    -- on account name. If you specify @TAG@, the cost category value is based
    -- on the value of the specified tag key.
    CostCategoryInheritedValueDimension
-> Maybe CostCategoryInheritedValueDimensionName
dimensionName :: Prelude.Maybe CostCategoryInheritedValueDimensionName
  }
  deriving (CostCategoryInheritedValueDimension
-> CostCategoryInheritedValueDimension -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CostCategoryInheritedValueDimension
-> CostCategoryInheritedValueDimension -> Bool
$c/= :: CostCategoryInheritedValueDimension
-> CostCategoryInheritedValueDimension -> Bool
== :: CostCategoryInheritedValueDimension
-> CostCategoryInheritedValueDimension -> Bool
$c== :: CostCategoryInheritedValueDimension
-> CostCategoryInheritedValueDimension -> Bool
Prelude.Eq, ReadPrec [CostCategoryInheritedValueDimension]
ReadPrec CostCategoryInheritedValueDimension
Int -> ReadS CostCategoryInheritedValueDimension
ReadS [CostCategoryInheritedValueDimension]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CostCategoryInheritedValueDimension]
$creadListPrec :: ReadPrec [CostCategoryInheritedValueDimension]
readPrec :: ReadPrec CostCategoryInheritedValueDimension
$creadPrec :: ReadPrec CostCategoryInheritedValueDimension
readList :: ReadS [CostCategoryInheritedValueDimension]
$creadList :: ReadS [CostCategoryInheritedValueDimension]
readsPrec :: Int -> ReadS CostCategoryInheritedValueDimension
$creadsPrec :: Int -> ReadS CostCategoryInheritedValueDimension
Prelude.Read, Int -> CostCategoryInheritedValueDimension -> ShowS
[CostCategoryInheritedValueDimension] -> ShowS
CostCategoryInheritedValueDimension -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CostCategoryInheritedValueDimension] -> ShowS
$cshowList :: [CostCategoryInheritedValueDimension] -> ShowS
show :: CostCategoryInheritedValueDimension -> String
$cshow :: CostCategoryInheritedValueDimension -> String
showsPrec :: Int -> CostCategoryInheritedValueDimension -> ShowS
$cshowsPrec :: Int -> CostCategoryInheritedValueDimension -> ShowS
Prelude.Show, forall x.
Rep CostCategoryInheritedValueDimension x
-> CostCategoryInheritedValueDimension
forall x.
CostCategoryInheritedValueDimension
-> Rep CostCategoryInheritedValueDimension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CostCategoryInheritedValueDimension x
-> CostCategoryInheritedValueDimension
$cfrom :: forall x.
CostCategoryInheritedValueDimension
-> Rep CostCategoryInheritedValueDimension x
Prelude.Generic)

-- |
-- Create a value of 'CostCategoryInheritedValueDimension' 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:
--
-- 'dimensionKey', 'costCategoryInheritedValueDimension_dimensionKey' - The key to extract cost category values.
--
-- 'dimensionName', 'costCategoryInheritedValueDimension_dimensionName' - The name of the dimension that\'s used to group costs.
--
-- If you specify @LINKED_ACCOUNT_NAME@, the cost category value is based
-- on account name. If you specify @TAG@, the cost category value is based
-- on the value of the specified tag key.
newCostCategoryInheritedValueDimension ::
  CostCategoryInheritedValueDimension
newCostCategoryInheritedValueDimension :: CostCategoryInheritedValueDimension
newCostCategoryInheritedValueDimension =
  CostCategoryInheritedValueDimension'
    { $sel:dimensionKey:CostCategoryInheritedValueDimension' :: Maybe Text
dimensionKey =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dimensionName:CostCategoryInheritedValueDimension' :: Maybe CostCategoryInheritedValueDimensionName
dimensionName = forall a. Maybe a
Prelude.Nothing
    }

-- | The key to extract cost category values.
costCategoryInheritedValueDimension_dimensionKey :: Lens.Lens' CostCategoryInheritedValueDimension (Prelude.Maybe Prelude.Text)
costCategoryInheritedValueDimension_dimensionKey :: Lens' CostCategoryInheritedValueDimension (Maybe Text)
costCategoryInheritedValueDimension_dimensionKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategoryInheritedValueDimension' {Maybe Text
dimensionKey :: Maybe Text
$sel:dimensionKey:CostCategoryInheritedValueDimension' :: CostCategoryInheritedValueDimension -> Maybe Text
dimensionKey} -> Maybe Text
dimensionKey) (\s :: CostCategoryInheritedValueDimension
s@CostCategoryInheritedValueDimension' {} Maybe Text
a -> CostCategoryInheritedValueDimension
s {$sel:dimensionKey:CostCategoryInheritedValueDimension' :: Maybe Text
dimensionKey = Maybe Text
a} :: CostCategoryInheritedValueDimension)

-- | The name of the dimension that\'s used to group costs.
--
-- If you specify @LINKED_ACCOUNT_NAME@, the cost category value is based
-- on account name. If you specify @TAG@, the cost category value is based
-- on the value of the specified tag key.
costCategoryInheritedValueDimension_dimensionName :: Lens.Lens' CostCategoryInheritedValueDimension (Prelude.Maybe CostCategoryInheritedValueDimensionName)
costCategoryInheritedValueDimension_dimensionName :: Lens'
  CostCategoryInheritedValueDimension
  (Maybe CostCategoryInheritedValueDimensionName)
costCategoryInheritedValueDimension_dimensionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategoryInheritedValueDimension' {Maybe CostCategoryInheritedValueDimensionName
dimensionName :: Maybe CostCategoryInheritedValueDimensionName
$sel:dimensionName:CostCategoryInheritedValueDimension' :: CostCategoryInheritedValueDimension
-> Maybe CostCategoryInheritedValueDimensionName
dimensionName} -> Maybe CostCategoryInheritedValueDimensionName
dimensionName) (\s :: CostCategoryInheritedValueDimension
s@CostCategoryInheritedValueDimension' {} Maybe CostCategoryInheritedValueDimensionName
a -> CostCategoryInheritedValueDimension
s {$sel:dimensionName:CostCategoryInheritedValueDimension' :: Maybe CostCategoryInheritedValueDimensionName
dimensionName = Maybe CostCategoryInheritedValueDimensionName
a} :: CostCategoryInheritedValueDimension)

instance
  Data.FromJSON
    CostCategoryInheritedValueDimension
  where
  parseJSON :: Value -> Parser CostCategoryInheritedValueDimension
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CostCategoryInheritedValueDimension"
      ( \Object
x ->
          Maybe Text
-> Maybe CostCategoryInheritedValueDimensionName
-> CostCategoryInheritedValueDimension
CostCategoryInheritedValueDimension'
            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
"DimensionKey")
            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
"DimensionName")
      )

instance
  Prelude.Hashable
    CostCategoryInheritedValueDimension
  where
  hashWithSalt :: Int -> CostCategoryInheritedValueDimension -> Int
hashWithSalt
    Int
_salt
    CostCategoryInheritedValueDimension' {Maybe Text
Maybe CostCategoryInheritedValueDimensionName
dimensionName :: Maybe CostCategoryInheritedValueDimensionName
dimensionKey :: Maybe Text
$sel:dimensionName:CostCategoryInheritedValueDimension' :: CostCategoryInheritedValueDimension
-> Maybe CostCategoryInheritedValueDimensionName
$sel:dimensionKey:CostCategoryInheritedValueDimension' :: CostCategoryInheritedValueDimension -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dimensionKey
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CostCategoryInheritedValueDimensionName
dimensionName

instance
  Prelude.NFData
    CostCategoryInheritedValueDimension
  where
  rnf :: CostCategoryInheritedValueDimension -> ()
rnf CostCategoryInheritedValueDimension' {Maybe Text
Maybe CostCategoryInheritedValueDimensionName
dimensionName :: Maybe CostCategoryInheritedValueDimensionName
dimensionKey :: Maybe Text
$sel:dimensionName:CostCategoryInheritedValueDimension' :: CostCategoryInheritedValueDimension
-> Maybe CostCategoryInheritedValueDimensionName
$sel:dimensionKey:CostCategoryInheritedValueDimension' :: CostCategoryInheritedValueDimension -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dimensionKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CostCategoryInheritedValueDimensionName
dimensionName

instance
  Data.ToJSON
    CostCategoryInheritedValueDimension
  where
  toJSON :: CostCategoryInheritedValueDimension -> Value
toJSON CostCategoryInheritedValueDimension' {Maybe Text
Maybe CostCategoryInheritedValueDimensionName
dimensionName :: Maybe CostCategoryInheritedValueDimensionName
dimensionKey :: Maybe Text
$sel:dimensionName:CostCategoryInheritedValueDimension' :: CostCategoryInheritedValueDimension
-> Maybe CostCategoryInheritedValueDimensionName
$sel:dimensionKey:CostCategoryInheritedValueDimension' :: CostCategoryInheritedValueDimension -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DimensionKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dimensionKey,
            (Key
"DimensionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CostCategoryInheritedValueDimensionName
dimensionName
          ]
      )