{-# 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 #-}
module Amazonka.CostExplorer.Types.CostCategoryRule where
import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.CostCategoryInheritedValueDimension
import Amazonka.CostExplorer.Types.CostCategoryRuleType
import Amazonka.CostExplorer.Types.Expression
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data CostCategoryRule = CostCategoryRule'
{
CostCategoryRule -> Maybe CostCategoryInheritedValueDimension
inheritedValue :: Prelude.Maybe CostCategoryInheritedValueDimension,
CostCategoryRule -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
CostCategoryRule -> Maybe Expression
rule :: Prelude.Maybe Expression,
CostCategoryRule -> Maybe CostCategoryRuleType
type' :: Prelude.Maybe CostCategoryRuleType
}
deriving (CostCategoryRule -> CostCategoryRule -> Bool
(CostCategoryRule -> CostCategoryRule -> Bool)
-> (CostCategoryRule -> CostCategoryRule -> Bool)
-> Eq CostCategoryRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CostCategoryRule -> CostCategoryRule -> Bool
$c/= :: CostCategoryRule -> CostCategoryRule -> Bool
== :: CostCategoryRule -> CostCategoryRule -> Bool
$c== :: CostCategoryRule -> CostCategoryRule -> Bool
Prelude.Eq, ReadPrec [CostCategoryRule]
ReadPrec CostCategoryRule
Int -> ReadS CostCategoryRule
ReadS [CostCategoryRule]
(Int -> ReadS CostCategoryRule)
-> ReadS [CostCategoryRule]
-> ReadPrec CostCategoryRule
-> ReadPrec [CostCategoryRule]
-> Read CostCategoryRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CostCategoryRule]
$creadListPrec :: ReadPrec [CostCategoryRule]
readPrec :: ReadPrec CostCategoryRule
$creadPrec :: ReadPrec CostCategoryRule
readList :: ReadS [CostCategoryRule]
$creadList :: ReadS [CostCategoryRule]
readsPrec :: Int -> ReadS CostCategoryRule
$creadsPrec :: Int -> ReadS CostCategoryRule
Prelude.Read, Int -> CostCategoryRule -> ShowS
[CostCategoryRule] -> ShowS
CostCategoryRule -> String
(Int -> CostCategoryRule -> ShowS)
-> (CostCategoryRule -> String)
-> ([CostCategoryRule] -> ShowS)
-> Show CostCategoryRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CostCategoryRule] -> ShowS
$cshowList :: [CostCategoryRule] -> ShowS
show :: CostCategoryRule -> String
$cshow :: CostCategoryRule -> String
showsPrec :: Int -> CostCategoryRule -> ShowS
$cshowsPrec :: Int -> CostCategoryRule -> ShowS
Prelude.Show, (forall x. CostCategoryRule -> Rep CostCategoryRule x)
-> (forall x. Rep CostCategoryRule x -> CostCategoryRule)
-> Generic CostCategoryRule
forall x. Rep CostCategoryRule x -> CostCategoryRule
forall x. CostCategoryRule -> Rep CostCategoryRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CostCategoryRule x -> CostCategoryRule
$cfrom :: forall x. CostCategoryRule -> Rep CostCategoryRule x
Prelude.Generic)
newCostCategoryRule ::
CostCategoryRule
newCostCategoryRule :: CostCategoryRule
newCostCategoryRule =
CostCategoryRule' :: Maybe CostCategoryInheritedValueDimension
-> Maybe Text
-> Maybe Expression
-> Maybe CostCategoryRuleType
-> CostCategoryRule
CostCategoryRule'
{ $sel:inheritedValue:CostCategoryRule' :: Maybe CostCategoryInheritedValueDimension
inheritedValue = Maybe CostCategoryInheritedValueDimension
forall a. Maybe a
Prelude.Nothing,
$sel:value:CostCategoryRule' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:rule:CostCategoryRule' :: Maybe Expression
rule = Maybe Expression
forall a. Maybe a
Prelude.Nothing,
$sel:type':CostCategoryRule' :: Maybe CostCategoryRuleType
type' = Maybe CostCategoryRuleType
forall a. Maybe a
Prelude.Nothing
}
costCategoryRule_inheritedValue :: Lens.Lens' CostCategoryRule (Prelude.Maybe CostCategoryInheritedValueDimension)
costCategoryRule_inheritedValue :: (Maybe CostCategoryInheritedValueDimension
-> f (Maybe CostCategoryInheritedValueDimension))
-> CostCategoryRule -> f CostCategoryRule
costCategoryRule_inheritedValue = (CostCategoryRule -> Maybe CostCategoryInheritedValueDimension)
-> (CostCategoryRule
-> Maybe CostCategoryInheritedValueDimension -> CostCategoryRule)
-> Lens
CostCategoryRule
CostCategoryRule
(Maybe CostCategoryInheritedValueDimension)
(Maybe CostCategoryInheritedValueDimension)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategoryRule' {Maybe CostCategoryInheritedValueDimension
inheritedValue :: Maybe CostCategoryInheritedValueDimension
$sel:inheritedValue:CostCategoryRule' :: CostCategoryRule -> Maybe CostCategoryInheritedValueDimension
inheritedValue} -> Maybe CostCategoryInheritedValueDimension
inheritedValue) (\s :: CostCategoryRule
s@CostCategoryRule' {} Maybe CostCategoryInheritedValueDimension
a -> CostCategoryRule
s {$sel:inheritedValue:CostCategoryRule' :: Maybe CostCategoryInheritedValueDimension
inheritedValue = Maybe CostCategoryInheritedValueDimension
a} :: CostCategoryRule)
costCategoryRule_value :: Lens.Lens' CostCategoryRule (Prelude.Maybe Prelude.Text)
costCategoryRule_value :: (Maybe Text -> f (Maybe Text))
-> CostCategoryRule -> f CostCategoryRule
costCategoryRule_value = (CostCategoryRule -> Maybe Text)
-> (CostCategoryRule -> Maybe Text -> CostCategoryRule)
-> Lens CostCategoryRule CostCategoryRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategoryRule' {Maybe Text
value :: Maybe Text
$sel:value:CostCategoryRule' :: CostCategoryRule -> Maybe Text
value} -> Maybe Text
value) (\s :: CostCategoryRule
s@CostCategoryRule' {} Maybe Text
a -> CostCategoryRule
s {$sel:value:CostCategoryRule' :: Maybe Text
value = Maybe Text
a} :: CostCategoryRule)
costCategoryRule_rule :: Lens.Lens' CostCategoryRule (Prelude.Maybe Expression)
costCategoryRule_rule :: (Maybe Expression -> f (Maybe Expression))
-> CostCategoryRule -> f CostCategoryRule
costCategoryRule_rule = (CostCategoryRule -> Maybe Expression)
-> (CostCategoryRule -> Maybe Expression -> CostCategoryRule)
-> Lens
CostCategoryRule
CostCategoryRule
(Maybe Expression)
(Maybe Expression)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategoryRule' {Maybe Expression
rule :: Maybe Expression
$sel:rule:CostCategoryRule' :: CostCategoryRule -> Maybe Expression
rule} -> Maybe Expression
rule) (\s :: CostCategoryRule
s@CostCategoryRule' {} Maybe Expression
a -> CostCategoryRule
s {$sel:rule:CostCategoryRule' :: Maybe Expression
rule = Maybe Expression
a} :: CostCategoryRule)
costCategoryRule_type :: Lens.Lens' CostCategoryRule (Prelude.Maybe CostCategoryRuleType)
costCategoryRule_type :: (Maybe CostCategoryRuleType -> f (Maybe CostCategoryRuleType))
-> CostCategoryRule -> f CostCategoryRule
costCategoryRule_type = (CostCategoryRule -> Maybe CostCategoryRuleType)
-> (CostCategoryRule
-> Maybe CostCategoryRuleType -> CostCategoryRule)
-> Lens
CostCategoryRule
CostCategoryRule
(Maybe CostCategoryRuleType)
(Maybe CostCategoryRuleType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategoryRule' {Maybe CostCategoryRuleType
type' :: Maybe CostCategoryRuleType
$sel:type':CostCategoryRule' :: CostCategoryRule -> Maybe CostCategoryRuleType
type'} -> Maybe CostCategoryRuleType
type') (\s :: CostCategoryRule
s@CostCategoryRule' {} Maybe CostCategoryRuleType
a -> CostCategoryRule
s {$sel:type':CostCategoryRule' :: Maybe CostCategoryRuleType
type' = Maybe CostCategoryRuleType
a} :: CostCategoryRule)
instance Core.FromJSON CostCategoryRule where
parseJSON :: Value -> Parser CostCategoryRule
parseJSON =
String
-> (Object -> Parser CostCategoryRule)
-> Value
-> Parser CostCategoryRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"CostCategoryRule"
( \Object
x ->
Maybe CostCategoryInheritedValueDimension
-> Maybe Text
-> Maybe Expression
-> Maybe CostCategoryRuleType
-> CostCategoryRule
CostCategoryRule'
(Maybe CostCategoryInheritedValueDimension
-> Maybe Text
-> Maybe Expression
-> Maybe CostCategoryRuleType
-> CostCategoryRule)
-> Parser (Maybe CostCategoryInheritedValueDimension)
-> Parser
(Maybe Text
-> Maybe Expression
-> Maybe CostCategoryRuleType
-> CostCategoryRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe CostCategoryInheritedValueDimension)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InheritedValue")
Parser
(Maybe Text
-> Maybe Expression
-> Maybe CostCategoryRuleType
-> CostCategoryRule)
-> Parser (Maybe Text)
-> Parser
(Maybe Expression
-> Maybe CostCategoryRuleType -> CostCategoryRule)
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
"Value")
Parser
(Maybe Expression
-> Maybe CostCategoryRuleType -> CostCategoryRule)
-> Parser (Maybe Expression)
-> Parser (Maybe CostCategoryRuleType -> CostCategoryRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Expression)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Rule")
Parser (Maybe CostCategoryRuleType -> CostCategoryRule)
-> Parser (Maybe CostCategoryRuleType) -> Parser CostCategoryRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CostCategoryRuleType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
)
instance Prelude.Hashable CostCategoryRule
instance Prelude.NFData CostCategoryRule
instance Core.ToJSON CostCategoryRule where
toJSON :: CostCategoryRule -> Value
toJSON CostCategoryRule' {Maybe Text
Maybe CostCategoryInheritedValueDimension
Maybe CostCategoryRuleType
Maybe Expression
type' :: Maybe CostCategoryRuleType
rule :: Maybe Expression
value :: Maybe Text
inheritedValue :: Maybe CostCategoryInheritedValueDimension
$sel:type':CostCategoryRule' :: CostCategoryRule -> Maybe CostCategoryRuleType
$sel:rule:CostCategoryRule' :: CostCategoryRule -> Maybe Expression
$sel:value:CostCategoryRule' :: CostCategoryRule -> Maybe Text
$sel:inheritedValue:CostCategoryRule' :: CostCategoryRule -> Maybe CostCategoryInheritedValueDimension
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"InheritedValue" Text -> CostCategoryInheritedValueDimension -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(CostCategoryInheritedValueDimension -> Pair)
-> Maybe CostCategoryInheritedValueDimension -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CostCategoryInheritedValueDimension
inheritedValue,
(Text
"Value" 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
value,
(Text
"Rule" Text -> Expression -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Expression -> Pair) -> Maybe Expression -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Expression
rule,
(Text
"Type" Text -> CostCategoryRuleType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CostCategoryRuleType -> Pair)
-> Maybe CostCategoryRuleType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CostCategoryRuleType
type'
]
)