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

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

-- | When creating or updating a cost category, you can define the
-- @CostCategoryRule@ rule type as @INHERITED_VALUE@. This rule type adds
-- the flexibility of defining a rule that dynamically inherits the cost
-- category value from the dimension value defined by
-- @CostCategoryInheritedValueDimension@. For example, if you want to
-- dynamically group costs that are based on the value of a specific tag
-- key, first choose an inherited value rule type, then choose the tag
-- dimension and specify the tag key to use.
--
-- /See:/ 'newCostCategoryInheritedValueDimension' smart constructor.
data CostCategoryInheritedValueDimension = 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 will be
    -- based on the value of the specified tag key.
    CostCategoryInheritedValueDimension
-> Maybe CostCategoryInheritedValueDimensionName
dimensionName :: Prelude.Maybe CostCategoryInheritedValueDimensionName,
    -- | The key to extract cost category values.
    CostCategoryInheritedValueDimension -> Maybe Text
dimensionKey :: Prelude.Maybe Prelude.Text
  }
  deriving (CostCategoryInheritedValueDimension
-> CostCategoryInheritedValueDimension -> Bool
(CostCategoryInheritedValueDimension
 -> CostCategoryInheritedValueDimension -> Bool)
-> (CostCategoryInheritedValueDimension
    -> CostCategoryInheritedValueDimension -> Bool)
-> Eq CostCategoryInheritedValueDimension
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]
(Int -> ReadS CostCategoryInheritedValueDimension)
-> ReadS [CostCategoryInheritedValueDimension]
-> ReadPrec CostCategoryInheritedValueDimension
-> ReadPrec [CostCategoryInheritedValueDimension]
-> Read 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
(Int -> CostCategoryInheritedValueDimension -> ShowS)
-> (CostCategoryInheritedValueDimension -> String)
-> ([CostCategoryInheritedValueDimension] -> ShowS)
-> Show CostCategoryInheritedValueDimension
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.
 CostCategoryInheritedValueDimension
 -> Rep CostCategoryInheritedValueDimension x)
-> (forall x.
    Rep CostCategoryInheritedValueDimension x
    -> CostCategoryInheritedValueDimension)
-> Generic CostCategoryInheritedValueDimension
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:
--
-- '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 will be
-- based on the value of the specified tag key.
--
-- 'dimensionKey', 'costCategoryInheritedValueDimension_dimensionKey' - The key to extract cost category values.
newCostCategoryInheritedValueDimension ::
  CostCategoryInheritedValueDimension
newCostCategoryInheritedValueDimension :: CostCategoryInheritedValueDimension
newCostCategoryInheritedValueDimension =
  CostCategoryInheritedValueDimension' :: Maybe CostCategoryInheritedValueDimensionName
-> Maybe Text -> CostCategoryInheritedValueDimension
CostCategoryInheritedValueDimension'
    { $sel:dimensionName:CostCategoryInheritedValueDimension' :: Maybe CostCategoryInheritedValueDimensionName
dimensionName =
        Maybe CostCategoryInheritedValueDimensionName
forall a. Maybe a
Prelude.Nothing,
      $sel:dimensionKey:CostCategoryInheritedValueDimension' :: Maybe Text
dimensionKey = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 will be
-- based on the value of the specified tag key.
costCategoryInheritedValueDimension_dimensionName :: Lens.Lens' CostCategoryInheritedValueDimension (Prelude.Maybe CostCategoryInheritedValueDimensionName)
costCategoryInheritedValueDimension_dimensionName :: (Maybe CostCategoryInheritedValueDimensionName
 -> f (Maybe CostCategoryInheritedValueDimensionName))
-> CostCategoryInheritedValueDimension
-> f CostCategoryInheritedValueDimension
costCategoryInheritedValueDimension_dimensionName = (CostCategoryInheritedValueDimension
 -> Maybe CostCategoryInheritedValueDimensionName)
-> (CostCategoryInheritedValueDimension
    -> Maybe CostCategoryInheritedValueDimensionName
    -> CostCategoryInheritedValueDimension)
-> Lens
     CostCategoryInheritedValueDimension
     CostCategoryInheritedValueDimension
     (Maybe CostCategoryInheritedValueDimensionName)
     (Maybe CostCategoryInheritedValueDimensionName)
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)

-- | The key to extract cost category values.
costCategoryInheritedValueDimension_dimensionKey :: Lens.Lens' CostCategoryInheritedValueDimension (Prelude.Maybe Prelude.Text)
costCategoryInheritedValueDimension_dimensionKey :: (Maybe Text -> f (Maybe Text))
-> CostCategoryInheritedValueDimension
-> f CostCategoryInheritedValueDimension
costCategoryInheritedValueDimension_dimensionKey = (CostCategoryInheritedValueDimension -> Maybe Text)
-> (CostCategoryInheritedValueDimension
    -> Maybe Text -> CostCategoryInheritedValueDimension)
-> Lens
     CostCategoryInheritedValueDimension
     CostCategoryInheritedValueDimension
     (Maybe Text)
     (Maybe Text)
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)

instance
  Core.FromJSON
    CostCategoryInheritedValueDimension
  where
  parseJSON :: Value -> Parser CostCategoryInheritedValueDimension
parseJSON =
    String
-> (Object -> Parser CostCategoryInheritedValueDimension)
-> Value
-> Parser CostCategoryInheritedValueDimension
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CostCategoryInheritedValueDimension"
      ( \Object
x ->
          Maybe CostCategoryInheritedValueDimensionName
-> Maybe Text -> CostCategoryInheritedValueDimension
CostCategoryInheritedValueDimension'
            (Maybe CostCategoryInheritedValueDimensionName
 -> Maybe Text -> CostCategoryInheritedValueDimension)
-> Parser (Maybe CostCategoryInheritedValueDimensionName)
-> Parser (Maybe Text -> CostCategoryInheritedValueDimension)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe CostCategoryInheritedValueDimensionName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DimensionName")
            Parser (Maybe Text -> CostCategoryInheritedValueDimension)
-> Parser (Maybe Text)
-> Parser CostCategoryInheritedValueDimension
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
"DimensionKey")
      )

instance
  Prelude.Hashable
    CostCategoryInheritedValueDimension

instance
  Prelude.NFData
    CostCategoryInheritedValueDimension

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