{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.Budgets.CreateBudget
(
CreateBudget (..),
newCreateBudget,
createBudget_notificationsWithSubscribers,
createBudget_accountId,
createBudget_budget,
CreateBudgetResponse (..),
newCreateBudgetResponse,
createBudgetResponse_httpStatus,
)
where
import Amazonka.Budgets.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateBudget = CreateBudget'
{
CreateBudget -> Maybe [NotificationWithSubscribers]
notificationsWithSubscribers :: Prelude.Maybe [NotificationWithSubscribers],
CreateBudget -> Text
accountId :: Prelude.Text,
CreateBudget -> Budget
budget :: Budget
}
deriving (CreateBudget -> CreateBudget -> Bool
(CreateBudget -> CreateBudget -> Bool)
-> (CreateBudget -> CreateBudget -> Bool) -> Eq CreateBudget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBudget -> CreateBudget -> Bool
$c/= :: CreateBudget -> CreateBudget -> Bool
== :: CreateBudget -> CreateBudget -> Bool
$c== :: CreateBudget -> CreateBudget -> Bool
Prelude.Eq, Int -> CreateBudget -> ShowS
[CreateBudget] -> ShowS
CreateBudget -> String
(Int -> CreateBudget -> ShowS)
-> (CreateBudget -> String)
-> ([CreateBudget] -> ShowS)
-> Show CreateBudget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBudget] -> ShowS
$cshowList :: [CreateBudget] -> ShowS
show :: CreateBudget -> String
$cshow :: CreateBudget -> String
showsPrec :: Int -> CreateBudget -> ShowS
$cshowsPrec :: Int -> CreateBudget -> ShowS
Prelude.Show, (forall x. CreateBudget -> Rep CreateBudget x)
-> (forall x. Rep CreateBudget x -> CreateBudget)
-> Generic CreateBudget
forall x. Rep CreateBudget x -> CreateBudget
forall x. CreateBudget -> Rep CreateBudget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBudget x -> CreateBudget
$cfrom :: forall x. CreateBudget -> Rep CreateBudget x
Prelude.Generic)
newCreateBudget ::
Prelude.Text ->
Budget ->
CreateBudget
newCreateBudget :: Text -> Budget -> CreateBudget
newCreateBudget Text
pAccountId_ Budget
pBudget_ =
CreateBudget' :: Maybe [NotificationWithSubscribers]
-> Text -> Budget -> CreateBudget
CreateBudget'
{ $sel:notificationsWithSubscribers:CreateBudget' :: Maybe [NotificationWithSubscribers]
notificationsWithSubscribers =
Maybe [NotificationWithSubscribers]
forall a. Maybe a
Prelude.Nothing,
$sel:accountId:CreateBudget' :: Text
accountId = Text
pAccountId_,
$sel:budget:CreateBudget' :: Budget
budget = Budget
pBudget_
}
createBudget_notificationsWithSubscribers :: Lens.Lens' CreateBudget (Prelude.Maybe [NotificationWithSubscribers])
createBudget_notificationsWithSubscribers :: (Maybe [NotificationWithSubscribers]
-> f (Maybe [NotificationWithSubscribers]))
-> CreateBudget -> f CreateBudget
createBudget_notificationsWithSubscribers = (CreateBudget -> Maybe [NotificationWithSubscribers])
-> (CreateBudget
-> Maybe [NotificationWithSubscribers] -> CreateBudget)
-> Lens
CreateBudget
CreateBudget
(Maybe [NotificationWithSubscribers])
(Maybe [NotificationWithSubscribers])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBudget' {Maybe [NotificationWithSubscribers]
notificationsWithSubscribers :: Maybe [NotificationWithSubscribers]
$sel:notificationsWithSubscribers:CreateBudget' :: CreateBudget -> Maybe [NotificationWithSubscribers]
notificationsWithSubscribers} -> Maybe [NotificationWithSubscribers]
notificationsWithSubscribers) (\s :: CreateBudget
s@CreateBudget' {} Maybe [NotificationWithSubscribers]
a -> CreateBudget
s {$sel:notificationsWithSubscribers:CreateBudget' :: Maybe [NotificationWithSubscribers]
notificationsWithSubscribers = Maybe [NotificationWithSubscribers]
a} :: CreateBudget) ((Maybe [NotificationWithSubscribers]
-> f (Maybe [NotificationWithSubscribers]))
-> CreateBudget -> f CreateBudget)
-> ((Maybe [NotificationWithSubscribers]
-> f (Maybe [NotificationWithSubscribers]))
-> Maybe [NotificationWithSubscribers]
-> f (Maybe [NotificationWithSubscribers]))
-> (Maybe [NotificationWithSubscribers]
-> f (Maybe [NotificationWithSubscribers]))
-> CreateBudget
-> f CreateBudget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[NotificationWithSubscribers]
[NotificationWithSubscribers]
[NotificationWithSubscribers]
[NotificationWithSubscribers]
-> Iso
(Maybe [NotificationWithSubscribers])
(Maybe [NotificationWithSubscribers])
(Maybe [NotificationWithSubscribers])
(Maybe [NotificationWithSubscribers])
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
[NotificationWithSubscribers]
[NotificationWithSubscribers]
[NotificationWithSubscribers]
[NotificationWithSubscribers]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createBudget_accountId :: Lens.Lens' CreateBudget Prelude.Text
createBudget_accountId :: (Text -> f Text) -> CreateBudget -> f CreateBudget
createBudget_accountId = (CreateBudget -> Text)
-> (CreateBudget -> Text -> CreateBudget)
-> Lens CreateBudget CreateBudget Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBudget' {Text
accountId :: Text
$sel:accountId:CreateBudget' :: CreateBudget -> Text
accountId} -> Text
accountId) (\s :: CreateBudget
s@CreateBudget' {} Text
a -> CreateBudget
s {$sel:accountId:CreateBudget' :: Text
accountId = Text
a} :: CreateBudget)
createBudget_budget :: Lens.Lens' CreateBudget Budget
createBudget_budget :: (Budget -> f Budget) -> CreateBudget -> f CreateBudget
createBudget_budget = (CreateBudget -> Budget)
-> (CreateBudget -> Budget -> CreateBudget)
-> Lens CreateBudget CreateBudget Budget Budget
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBudget' {Budget
budget :: Budget
$sel:budget:CreateBudget' :: CreateBudget -> Budget
budget} -> Budget
budget) (\s :: CreateBudget
s@CreateBudget' {} Budget
a -> CreateBudget
s {$sel:budget:CreateBudget' :: Budget
budget = Budget
a} :: CreateBudget)
instance Core.AWSRequest CreateBudget where
type AWSResponse CreateBudget = CreateBudgetResponse
request :: CreateBudget -> Request CreateBudget
request = Service -> CreateBudget -> Request CreateBudget
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateBudget
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBudget)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse CreateBudget))
-> Logger
-> Service
-> Proxy CreateBudget
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBudget)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> CreateBudgetResponse
CreateBudgetResponse'
(Int -> CreateBudgetResponse)
-> Either String Int -> Either String CreateBudgetResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateBudget
instance Prelude.NFData CreateBudget
instance Core.ToHeaders CreateBudget where
toHeaders :: CreateBudget -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateBudget -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSBudgetServiceGateway.CreateBudget" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateBudget where
toJSON :: CreateBudget -> Value
toJSON CreateBudget' {Maybe [NotificationWithSubscribers]
Text
Budget
budget :: Budget
accountId :: Text
notificationsWithSubscribers :: Maybe [NotificationWithSubscribers]
$sel:budget:CreateBudget' :: CreateBudget -> Budget
$sel:accountId:CreateBudget' :: CreateBudget -> Text
$sel:notificationsWithSubscribers:CreateBudget' :: CreateBudget -> Maybe [NotificationWithSubscribers]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"NotificationsWithSubscribers" Text -> [NotificationWithSubscribers] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
([NotificationWithSubscribers] -> Pair)
-> Maybe [NotificationWithSubscribers] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [NotificationWithSubscribers]
notificationsWithSubscribers,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
accountId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Budget" Text -> Budget -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Budget
budget)
]
)
instance Core.ToPath CreateBudget where
toPath :: CreateBudget -> ByteString
toPath = ByteString -> CreateBudget -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateBudget where
toQuery :: CreateBudget -> QueryString
toQuery = QueryString -> CreateBudget -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateBudgetResponse = CreateBudgetResponse'
{
CreateBudgetResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateBudgetResponse -> CreateBudgetResponse -> Bool
(CreateBudgetResponse -> CreateBudgetResponse -> Bool)
-> (CreateBudgetResponse -> CreateBudgetResponse -> Bool)
-> Eq CreateBudgetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBudgetResponse -> CreateBudgetResponse -> Bool
$c/= :: CreateBudgetResponse -> CreateBudgetResponse -> Bool
== :: CreateBudgetResponse -> CreateBudgetResponse -> Bool
$c== :: CreateBudgetResponse -> CreateBudgetResponse -> Bool
Prelude.Eq, ReadPrec [CreateBudgetResponse]
ReadPrec CreateBudgetResponse
Int -> ReadS CreateBudgetResponse
ReadS [CreateBudgetResponse]
(Int -> ReadS CreateBudgetResponse)
-> ReadS [CreateBudgetResponse]
-> ReadPrec CreateBudgetResponse
-> ReadPrec [CreateBudgetResponse]
-> Read CreateBudgetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBudgetResponse]
$creadListPrec :: ReadPrec [CreateBudgetResponse]
readPrec :: ReadPrec CreateBudgetResponse
$creadPrec :: ReadPrec CreateBudgetResponse
readList :: ReadS [CreateBudgetResponse]
$creadList :: ReadS [CreateBudgetResponse]
readsPrec :: Int -> ReadS CreateBudgetResponse
$creadsPrec :: Int -> ReadS CreateBudgetResponse
Prelude.Read, Int -> CreateBudgetResponse -> ShowS
[CreateBudgetResponse] -> ShowS
CreateBudgetResponse -> String
(Int -> CreateBudgetResponse -> ShowS)
-> (CreateBudgetResponse -> String)
-> ([CreateBudgetResponse] -> ShowS)
-> Show CreateBudgetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBudgetResponse] -> ShowS
$cshowList :: [CreateBudgetResponse] -> ShowS
show :: CreateBudgetResponse -> String
$cshow :: CreateBudgetResponse -> String
showsPrec :: Int -> CreateBudgetResponse -> ShowS
$cshowsPrec :: Int -> CreateBudgetResponse -> ShowS
Prelude.Show, (forall x. CreateBudgetResponse -> Rep CreateBudgetResponse x)
-> (forall x. Rep CreateBudgetResponse x -> CreateBudgetResponse)
-> Generic CreateBudgetResponse
forall x. Rep CreateBudgetResponse x -> CreateBudgetResponse
forall x. CreateBudgetResponse -> Rep CreateBudgetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBudgetResponse x -> CreateBudgetResponse
$cfrom :: forall x. CreateBudgetResponse -> Rep CreateBudgetResponse x
Prelude.Generic)
newCreateBudgetResponse ::
Prelude.Int ->
CreateBudgetResponse
newCreateBudgetResponse :: Int -> CreateBudgetResponse
newCreateBudgetResponse Int
pHttpStatus_ =
CreateBudgetResponse' :: Int -> CreateBudgetResponse
CreateBudgetResponse' {$sel:httpStatus:CreateBudgetResponse' :: Int
httpStatus = Int
pHttpStatus_}
createBudgetResponse_httpStatus :: Lens.Lens' CreateBudgetResponse Prelude.Int
createBudgetResponse_httpStatus :: (Int -> f Int) -> CreateBudgetResponse -> f CreateBudgetResponse
createBudgetResponse_httpStatus = (CreateBudgetResponse -> Int)
-> (CreateBudgetResponse -> Int -> CreateBudgetResponse)
-> Lens CreateBudgetResponse CreateBudgetResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBudgetResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateBudgetResponse' :: CreateBudgetResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateBudgetResponse
s@CreateBudgetResponse' {} Int
a -> CreateBudgetResponse
s {$sel:httpStatus:CreateBudgetResponse' :: Int
httpStatus = Int
a} :: CreateBudgetResponse)
instance Prelude.NFData CreateBudgetResponse