{-# 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.CostCategorySplitChargeRule where
import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.CostCategorySplitChargeMethod
import Amazonka.CostExplorer.Types.CostCategorySplitChargeRuleParameter
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data CostCategorySplitChargeRule = CostCategorySplitChargeRule'
{
CostCategorySplitChargeRule
-> Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
parameters :: Prelude.Maybe (Prelude.NonEmpty CostCategorySplitChargeRuleParameter),
CostCategorySplitChargeRule -> Text
source :: Prelude.Text,
CostCategorySplitChargeRule -> NonEmpty Text
targets :: Prelude.NonEmpty Prelude.Text,
CostCategorySplitChargeRule -> CostCategorySplitChargeMethod
method :: CostCategorySplitChargeMethod
}
deriving (CostCategorySplitChargeRule -> CostCategorySplitChargeRule -> Bool
(CostCategorySplitChargeRule
-> CostCategorySplitChargeRule -> Bool)
-> (CostCategorySplitChargeRule
-> CostCategorySplitChargeRule -> Bool)
-> Eq CostCategorySplitChargeRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CostCategorySplitChargeRule -> CostCategorySplitChargeRule -> Bool
$c/= :: CostCategorySplitChargeRule -> CostCategorySplitChargeRule -> Bool
== :: CostCategorySplitChargeRule -> CostCategorySplitChargeRule -> Bool
$c== :: CostCategorySplitChargeRule -> CostCategorySplitChargeRule -> Bool
Prelude.Eq, ReadPrec [CostCategorySplitChargeRule]
ReadPrec CostCategorySplitChargeRule
Int -> ReadS CostCategorySplitChargeRule
ReadS [CostCategorySplitChargeRule]
(Int -> ReadS CostCategorySplitChargeRule)
-> ReadS [CostCategorySplitChargeRule]
-> ReadPrec CostCategorySplitChargeRule
-> ReadPrec [CostCategorySplitChargeRule]
-> Read CostCategorySplitChargeRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CostCategorySplitChargeRule]
$creadListPrec :: ReadPrec [CostCategorySplitChargeRule]
readPrec :: ReadPrec CostCategorySplitChargeRule
$creadPrec :: ReadPrec CostCategorySplitChargeRule
readList :: ReadS [CostCategorySplitChargeRule]
$creadList :: ReadS [CostCategorySplitChargeRule]
readsPrec :: Int -> ReadS CostCategorySplitChargeRule
$creadsPrec :: Int -> ReadS CostCategorySplitChargeRule
Prelude.Read, Int -> CostCategorySplitChargeRule -> ShowS
[CostCategorySplitChargeRule] -> ShowS
CostCategorySplitChargeRule -> String
(Int -> CostCategorySplitChargeRule -> ShowS)
-> (CostCategorySplitChargeRule -> String)
-> ([CostCategorySplitChargeRule] -> ShowS)
-> Show CostCategorySplitChargeRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CostCategorySplitChargeRule] -> ShowS
$cshowList :: [CostCategorySplitChargeRule] -> ShowS
show :: CostCategorySplitChargeRule -> String
$cshow :: CostCategorySplitChargeRule -> String
showsPrec :: Int -> CostCategorySplitChargeRule -> ShowS
$cshowsPrec :: Int -> CostCategorySplitChargeRule -> ShowS
Prelude.Show, (forall x.
CostCategorySplitChargeRule -> Rep CostCategorySplitChargeRule x)
-> (forall x.
Rep CostCategorySplitChargeRule x -> CostCategorySplitChargeRule)
-> Generic CostCategorySplitChargeRule
forall x.
Rep CostCategorySplitChargeRule x -> CostCategorySplitChargeRule
forall x.
CostCategorySplitChargeRule -> Rep CostCategorySplitChargeRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CostCategorySplitChargeRule x -> CostCategorySplitChargeRule
$cfrom :: forall x.
CostCategorySplitChargeRule -> Rep CostCategorySplitChargeRule x
Prelude.Generic)
newCostCategorySplitChargeRule ::
Prelude.Text ->
Prelude.NonEmpty Prelude.Text ->
CostCategorySplitChargeMethod ->
CostCategorySplitChargeRule
newCostCategorySplitChargeRule :: Text
-> NonEmpty Text
-> CostCategorySplitChargeMethod
-> CostCategorySplitChargeRule
newCostCategorySplitChargeRule
Text
pSource_
NonEmpty Text
pTargets_
CostCategorySplitChargeMethod
pMethod_ =
CostCategorySplitChargeRule' :: Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> Text
-> NonEmpty Text
-> CostCategorySplitChargeMethod
-> CostCategorySplitChargeRule
CostCategorySplitChargeRule'
{ $sel:parameters:CostCategorySplitChargeRule' :: Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
parameters =
Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
forall a. Maybe a
Prelude.Nothing,
$sel:source:CostCategorySplitChargeRule' :: Text
source = Text
pSource_,
$sel:targets:CostCategorySplitChargeRule' :: NonEmpty Text
targets = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pTargets_,
$sel:method:CostCategorySplitChargeRule' :: CostCategorySplitChargeMethod
method = CostCategorySplitChargeMethod
pMethod_
}
costCategorySplitChargeRule_parameters :: Lens.Lens' CostCategorySplitChargeRule (Prelude.Maybe (Prelude.NonEmpty CostCategorySplitChargeRuleParameter))
costCategorySplitChargeRule_parameters :: (Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> f (Maybe (NonEmpty CostCategorySplitChargeRuleParameter)))
-> CostCategorySplitChargeRule -> f CostCategorySplitChargeRule
costCategorySplitChargeRule_parameters = (CostCategorySplitChargeRule
-> Maybe (NonEmpty CostCategorySplitChargeRuleParameter))
-> (CostCategorySplitChargeRule
-> Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> CostCategorySplitChargeRule)
-> Lens
CostCategorySplitChargeRule
CostCategorySplitChargeRule
(Maybe (NonEmpty CostCategorySplitChargeRuleParameter))
(Maybe (NonEmpty CostCategorySplitChargeRuleParameter))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategorySplitChargeRule' {Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
parameters :: Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
$sel:parameters:CostCategorySplitChargeRule' :: CostCategorySplitChargeRule
-> Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
parameters} -> Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
parameters) (\s :: CostCategorySplitChargeRule
s@CostCategorySplitChargeRule' {} Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
a -> CostCategorySplitChargeRule
s {$sel:parameters:CostCategorySplitChargeRule' :: Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
parameters = Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
a} :: CostCategorySplitChargeRule) ((Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> f (Maybe (NonEmpty CostCategorySplitChargeRuleParameter)))
-> CostCategorySplitChargeRule -> f CostCategorySplitChargeRule)
-> ((Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> f (Maybe (NonEmpty CostCategorySplitChargeRuleParameter)))
-> Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> f (Maybe (NonEmpty CostCategorySplitChargeRuleParameter)))
-> (Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> f (Maybe (NonEmpty CostCategorySplitChargeRuleParameter)))
-> CostCategorySplitChargeRule
-> f CostCategorySplitChargeRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty CostCategorySplitChargeRuleParameter)
(NonEmpty CostCategorySplitChargeRuleParameter)
(NonEmpty CostCategorySplitChargeRuleParameter)
(NonEmpty CostCategorySplitChargeRuleParameter)
-> Iso
(Maybe (NonEmpty CostCategorySplitChargeRuleParameter))
(Maybe (NonEmpty CostCategorySplitChargeRuleParameter))
(Maybe (NonEmpty CostCategorySplitChargeRuleParameter))
(Maybe (NonEmpty CostCategorySplitChargeRuleParameter))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(NonEmpty CostCategorySplitChargeRuleParameter)
(NonEmpty CostCategorySplitChargeRuleParameter)
(NonEmpty CostCategorySplitChargeRuleParameter)
(NonEmpty CostCategorySplitChargeRuleParameter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
costCategorySplitChargeRule_source :: Lens.Lens' CostCategorySplitChargeRule Prelude.Text
costCategorySplitChargeRule_source :: (Text -> f Text)
-> CostCategorySplitChargeRule -> f CostCategorySplitChargeRule
costCategorySplitChargeRule_source = (CostCategorySplitChargeRule -> Text)
-> (CostCategorySplitChargeRule
-> Text -> CostCategorySplitChargeRule)
-> Lens
CostCategorySplitChargeRule CostCategorySplitChargeRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategorySplitChargeRule' {Text
source :: Text
$sel:source:CostCategorySplitChargeRule' :: CostCategorySplitChargeRule -> Text
source} -> Text
source) (\s :: CostCategorySplitChargeRule
s@CostCategorySplitChargeRule' {} Text
a -> CostCategorySplitChargeRule
s {$sel:source:CostCategorySplitChargeRule' :: Text
source = Text
a} :: CostCategorySplitChargeRule)
costCategorySplitChargeRule_targets :: Lens.Lens' CostCategorySplitChargeRule (Prelude.NonEmpty Prelude.Text)
costCategorySplitChargeRule_targets :: (NonEmpty Text -> f (NonEmpty Text))
-> CostCategorySplitChargeRule -> f CostCategorySplitChargeRule
costCategorySplitChargeRule_targets = (CostCategorySplitChargeRule -> NonEmpty Text)
-> (CostCategorySplitChargeRule
-> NonEmpty Text -> CostCategorySplitChargeRule)
-> Lens
CostCategorySplitChargeRule
CostCategorySplitChargeRule
(NonEmpty Text)
(NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategorySplitChargeRule' {NonEmpty Text
targets :: NonEmpty Text
$sel:targets:CostCategorySplitChargeRule' :: CostCategorySplitChargeRule -> NonEmpty Text
targets} -> NonEmpty Text
targets) (\s :: CostCategorySplitChargeRule
s@CostCategorySplitChargeRule' {} NonEmpty Text
a -> CostCategorySplitChargeRule
s {$sel:targets:CostCategorySplitChargeRule' :: NonEmpty Text
targets = NonEmpty Text
a} :: CostCategorySplitChargeRule) ((NonEmpty Text -> f (NonEmpty Text))
-> CostCategorySplitChargeRule -> f CostCategorySplitChargeRule)
-> ((NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> CostCategorySplitChargeRule
-> f CostCategorySplitChargeRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
costCategorySplitChargeRule_method :: Lens.Lens' CostCategorySplitChargeRule CostCategorySplitChargeMethod
costCategorySplitChargeRule_method :: (CostCategorySplitChargeMethod -> f CostCategorySplitChargeMethod)
-> CostCategorySplitChargeRule -> f CostCategorySplitChargeRule
costCategorySplitChargeRule_method = (CostCategorySplitChargeRule -> CostCategorySplitChargeMethod)
-> (CostCategorySplitChargeRule
-> CostCategorySplitChargeMethod -> CostCategorySplitChargeRule)
-> Lens
CostCategorySplitChargeRule
CostCategorySplitChargeRule
CostCategorySplitChargeMethod
CostCategorySplitChargeMethod
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CostCategorySplitChargeRule' {CostCategorySplitChargeMethod
method :: CostCategorySplitChargeMethod
$sel:method:CostCategorySplitChargeRule' :: CostCategorySplitChargeRule -> CostCategorySplitChargeMethod
method} -> CostCategorySplitChargeMethod
method) (\s :: CostCategorySplitChargeRule
s@CostCategorySplitChargeRule' {} CostCategorySplitChargeMethod
a -> CostCategorySplitChargeRule
s {$sel:method:CostCategorySplitChargeRule' :: CostCategorySplitChargeMethod
method = CostCategorySplitChargeMethod
a} :: CostCategorySplitChargeRule)
instance Core.FromJSON CostCategorySplitChargeRule where
parseJSON :: Value -> Parser CostCategorySplitChargeRule
parseJSON =
String
-> (Object -> Parser CostCategorySplitChargeRule)
-> Value
-> Parser CostCategorySplitChargeRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"CostCategorySplitChargeRule"
( \Object
x ->
Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> Text
-> NonEmpty Text
-> CostCategorySplitChargeMethod
-> CostCategorySplitChargeRule
CostCategorySplitChargeRule'
(Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> Text
-> NonEmpty Text
-> CostCategorySplitChargeMethod
-> CostCategorySplitChargeRule)
-> Parser (Maybe (NonEmpty CostCategorySplitChargeRuleParameter))
-> Parser
(Text
-> NonEmpty Text
-> CostCategorySplitChargeMethod
-> CostCategorySplitChargeRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Parser (Maybe (NonEmpty CostCategorySplitChargeRuleParameter))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parameters")
Parser
(Text
-> NonEmpty Text
-> CostCategorySplitChargeMethod
-> CostCategorySplitChargeRule)
-> Parser Text
-> Parser
(NonEmpty Text
-> CostCategorySplitChargeMethod -> CostCategorySplitChargeRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Source")
Parser
(NonEmpty Text
-> CostCategorySplitChargeMethod -> CostCategorySplitChargeRule)
-> Parser (NonEmpty Text)
-> Parser
(CostCategorySplitChargeMethod -> CostCategorySplitChargeRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Targets")
Parser
(CostCategorySplitChargeMethod -> CostCategorySplitChargeRule)
-> Parser CostCategorySplitChargeMethod
-> Parser CostCategorySplitChargeRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser CostCategorySplitChargeMethod
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Method")
)
instance Prelude.Hashable CostCategorySplitChargeRule
instance Prelude.NFData CostCategorySplitChargeRule
instance Core.ToJSON CostCategorySplitChargeRule where
toJSON :: CostCategorySplitChargeRule -> Value
toJSON CostCategorySplitChargeRule' {Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
NonEmpty Text
Text
CostCategorySplitChargeMethod
method :: CostCategorySplitChargeMethod
targets :: NonEmpty Text
source :: Text
parameters :: Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
$sel:method:CostCategorySplitChargeRule' :: CostCategorySplitChargeRule -> CostCategorySplitChargeMethod
$sel:targets:CostCategorySplitChargeRule' :: CostCategorySplitChargeRule -> NonEmpty Text
$sel:source:CostCategorySplitChargeRule' :: CostCategorySplitChargeRule -> Text
$sel:parameters:CostCategorySplitChargeRule' :: CostCategorySplitChargeRule
-> Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Parameters" Text -> NonEmpty CostCategorySplitChargeRuleParameter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty CostCategorySplitChargeRuleParameter -> Pair)
-> Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
-> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty CostCategorySplitChargeRuleParameter)
parameters,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Source" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
source),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Targets" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
targets),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Method" Text -> CostCategorySplitChargeMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CostCategorySplitChargeMethod
method)
]
)