{-# 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.Budgets.Types.CalculatedSpend where
import Amazonka.Budgets.Types.Spend
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data CalculatedSpend = CalculatedSpend'
{
CalculatedSpend -> Maybe Spend
forecastedSpend :: Prelude.Maybe Spend,
CalculatedSpend -> Spend
actualSpend :: Spend
}
deriving (CalculatedSpend -> CalculatedSpend -> Bool
(CalculatedSpend -> CalculatedSpend -> Bool)
-> (CalculatedSpend -> CalculatedSpend -> Bool)
-> Eq CalculatedSpend
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CalculatedSpend -> CalculatedSpend -> Bool
$c/= :: CalculatedSpend -> CalculatedSpend -> Bool
== :: CalculatedSpend -> CalculatedSpend -> Bool
$c== :: CalculatedSpend -> CalculatedSpend -> Bool
Prelude.Eq, ReadPrec [CalculatedSpend]
ReadPrec CalculatedSpend
Int -> ReadS CalculatedSpend
ReadS [CalculatedSpend]
(Int -> ReadS CalculatedSpend)
-> ReadS [CalculatedSpend]
-> ReadPrec CalculatedSpend
-> ReadPrec [CalculatedSpend]
-> Read CalculatedSpend
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CalculatedSpend]
$creadListPrec :: ReadPrec [CalculatedSpend]
readPrec :: ReadPrec CalculatedSpend
$creadPrec :: ReadPrec CalculatedSpend
readList :: ReadS [CalculatedSpend]
$creadList :: ReadS [CalculatedSpend]
readsPrec :: Int -> ReadS CalculatedSpend
$creadsPrec :: Int -> ReadS CalculatedSpend
Prelude.Read, Int -> CalculatedSpend -> ShowS
[CalculatedSpend] -> ShowS
CalculatedSpend -> String
(Int -> CalculatedSpend -> ShowS)
-> (CalculatedSpend -> String)
-> ([CalculatedSpend] -> ShowS)
-> Show CalculatedSpend
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CalculatedSpend] -> ShowS
$cshowList :: [CalculatedSpend] -> ShowS
show :: CalculatedSpend -> String
$cshow :: CalculatedSpend -> String
showsPrec :: Int -> CalculatedSpend -> ShowS
$cshowsPrec :: Int -> CalculatedSpend -> ShowS
Prelude.Show, (forall x. CalculatedSpend -> Rep CalculatedSpend x)
-> (forall x. Rep CalculatedSpend x -> CalculatedSpend)
-> Generic CalculatedSpend
forall x. Rep CalculatedSpend x -> CalculatedSpend
forall x. CalculatedSpend -> Rep CalculatedSpend x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CalculatedSpend x -> CalculatedSpend
$cfrom :: forall x. CalculatedSpend -> Rep CalculatedSpend x
Prelude.Generic)
newCalculatedSpend ::
Spend ->
CalculatedSpend
newCalculatedSpend :: Spend -> CalculatedSpend
newCalculatedSpend Spend
pActualSpend_ =
CalculatedSpend' :: Maybe Spend -> Spend -> CalculatedSpend
CalculatedSpend'
{ $sel:forecastedSpend:CalculatedSpend' :: Maybe Spend
forecastedSpend = Maybe Spend
forall a. Maybe a
Prelude.Nothing,
$sel:actualSpend:CalculatedSpend' :: Spend
actualSpend = Spend
pActualSpend_
}
calculatedSpend_forecastedSpend :: Lens.Lens' CalculatedSpend (Prelude.Maybe Spend)
calculatedSpend_forecastedSpend :: (Maybe Spend -> f (Maybe Spend))
-> CalculatedSpend -> f CalculatedSpend
calculatedSpend_forecastedSpend = (CalculatedSpend -> Maybe Spend)
-> (CalculatedSpend -> Maybe Spend -> CalculatedSpend)
-> Lens CalculatedSpend CalculatedSpend (Maybe Spend) (Maybe Spend)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculatedSpend' {Maybe Spend
forecastedSpend :: Maybe Spend
$sel:forecastedSpend:CalculatedSpend' :: CalculatedSpend -> Maybe Spend
forecastedSpend} -> Maybe Spend
forecastedSpend) (\s :: CalculatedSpend
s@CalculatedSpend' {} Maybe Spend
a -> CalculatedSpend
s {$sel:forecastedSpend:CalculatedSpend' :: Maybe Spend
forecastedSpend = Maybe Spend
a} :: CalculatedSpend)
calculatedSpend_actualSpend :: Lens.Lens' CalculatedSpend Spend
calculatedSpend_actualSpend :: (Spend -> f Spend) -> CalculatedSpend -> f CalculatedSpend
calculatedSpend_actualSpend = (CalculatedSpend -> Spend)
-> (CalculatedSpend -> Spend -> CalculatedSpend)
-> Lens CalculatedSpend CalculatedSpend Spend Spend
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculatedSpend' {Spend
actualSpend :: Spend
$sel:actualSpend:CalculatedSpend' :: CalculatedSpend -> Spend
actualSpend} -> Spend
actualSpend) (\s :: CalculatedSpend
s@CalculatedSpend' {} Spend
a -> CalculatedSpend
s {$sel:actualSpend:CalculatedSpend' :: Spend
actualSpend = Spend
a} :: CalculatedSpend)
instance Core.FromJSON CalculatedSpend where
parseJSON :: Value -> Parser CalculatedSpend
parseJSON =
String
-> (Object -> Parser CalculatedSpend)
-> Value
-> Parser CalculatedSpend
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"CalculatedSpend"
( \Object
x ->
Maybe Spend -> Spend -> CalculatedSpend
CalculatedSpend'
(Maybe Spend -> Spend -> CalculatedSpend)
-> Parser (Maybe Spend) -> Parser (Spend -> CalculatedSpend)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Spend)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ForecastedSpend")
Parser (Spend -> CalculatedSpend)
-> Parser Spend -> Parser CalculatedSpend
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Spend
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ActualSpend")
)
instance Prelude.Hashable CalculatedSpend
instance Prelude.NFData CalculatedSpend
instance Core.ToJSON CalculatedSpend where
toJSON :: CalculatedSpend -> Value
toJSON CalculatedSpend' {Maybe Spend
Spend
actualSpend :: Spend
forecastedSpend :: Maybe Spend
$sel:actualSpend:CalculatedSpend' :: CalculatedSpend -> Spend
$sel:forecastedSpend:CalculatedSpend' :: CalculatedSpend -> Maybe Spend
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ForecastedSpend" Text -> Spend -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Spend -> Pair) -> Maybe Spend -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Spend
forecastedSpend,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ActualSpend" Text -> Spend -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Spend
actualSpend)
]
)