{-# 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.CreateNotification
(
CreateNotification (..),
newCreateNotification,
createNotification_accountId,
createNotification_budgetName,
createNotification_notification,
createNotification_subscribers,
CreateNotificationResponse (..),
newCreateNotificationResponse,
createNotificationResponse_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 CreateNotification = CreateNotification'
{
CreateNotification -> Text
accountId :: Prelude.Text,
CreateNotification -> Text
budgetName :: Prelude.Text,
CreateNotification -> Notification
notification :: Notification,
CreateNotification -> NonEmpty Subscriber
subscribers :: Prelude.NonEmpty Subscriber
}
deriving (CreateNotification -> CreateNotification -> Bool
(CreateNotification -> CreateNotification -> Bool)
-> (CreateNotification -> CreateNotification -> Bool)
-> Eq CreateNotification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateNotification -> CreateNotification -> Bool
$c/= :: CreateNotification -> CreateNotification -> Bool
== :: CreateNotification -> CreateNotification -> Bool
$c== :: CreateNotification -> CreateNotification -> Bool
Prelude.Eq, Int -> CreateNotification -> ShowS
[CreateNotification] -> ShowS
CreateNotification -> String
(Int -> CreateNotification -> ShowS)
-> (CreateNotification -> String)
-> ([CreateNotification] -> ShowS)
-> Show CreateNotification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateNotification] -> ShowS
$cshowList :: [CreateNotification] -> ShowS
show :: CreateNotification -> String
$cshow :: CreateNotification -> String
showsPrec :: Int -> CreateNotification -> ShowS
$cshowsPrec :: Int -> CreateNotification -> ShowS
Prelude.Show, (forall x. CreateNotification -> Rep CreateNotification x)
-> (forall x. Rep CreateNotification x -> CreateNotification)
-> Generic CreateNotification
forall x. Rep CreateNotification x -> CreateNotification
forall x. CreateNotification -> Rep CreateNotification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateNotification x -> CreateNotification
$cfrom :: forall x. CreateNotification -> Rep CreateNotification x
Prelude.Generic)
newCreateNotification ::
Prelude.Text ->
Prelude.Text ->
Notification ->
Prelude.NonEmpty Subscriber ->
CreateNotification
newCreateNotification :: Text
-> Text
-> Notification
-> NonEmpty Subscriber
-> CreateNotification
newCreateNotification
Text
pAccountId_
Text
pBudgetName_
Notification
pNotification_
NonEmpty Subscriber
pSubscribers_ =
CreateNotification' :: Text
-> Text
-> Notification
-> NonEmpty Subscriber
-> CreateNotification
CreateNotification'
{ $sel:accountId:CreateNotification' :: Text
accountId = Text
pAccountId_,
$sel:budgetName:CreateNotification' :: Text
budgetName = Text
pBudgetName_,
$sel:notification:CreateNotification' :: Notification
notification = Notification
pNotification_,
$sel:subscribers:CreateNotification' :: NonEmpty Subscriber
subscribers = Tagged (NonEmpty Subscriber) (Identity (NonEmpty Subscriber))
-> Tagged (NonEmpty Subscriber) (Identity (NonEmpty Subscriber))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Subscriber) (Identity (NonEmpty Subscriber))
-> Tagged (NonEmpty Subscriber) (Identity (NonEmpty Subscriber)))
-> NonEmpty Subscriber -> NonEmpty Subscriber
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Subscriber
pSubscribers_
}
createNotification_accountId :: Lens.Lens' CreateNotification Prelude.Text
createNotification_accountId :: (Text -> f Text) -> CreateNotification -> f CreateNotification
createNotification_accountId = (CreateNotification -> Text)
-> (CreateNotification -> Text -> CreateNotification)
-> Lens CreateNotification CreateNotification Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotification' {Text
accountId :: Text
$sel:accountId:CreateNotification' :: CreateNotification -> Text
accountId} -> Text
accountId) (\s :: CreateNotification
s@CreateNotification' {} Text
a -> CreateNotification
s {$sel:accountId:CreateNotification' :: Text
accountId = Text
a} :: CreateNotification)
createNotification_budgetName :: Lens.Lens' CreateNotification Prelude.Text
createNotification_budgetName :: (Text -> f Text) -> CreateNotification -> f CreateNotification
createNotification_budgetName = (CreateNotification -> Text)
-> (CreateNotification -> Text -> CreateNotification)
-> Lens CreateNotification CreateNotification Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotification' {Text
budgetName :: Text
$sel:budgetName:CreateNotification' :: CreateNotification -> Text
budgetName} -> Text
budgetName) (\s :: CreateNotification
s@CreateNotification' {} Text
a -> CreateNotification
s {$sel:budgetName:CreateNotification' :: Text
budgetName = Text
a} :: CreateNotification)
createNotification_notification :: Lens.Lens' CreateNotification Notification
createNotification_notification :: (Notification -> f Notification)
-> CreateNotification -> f CreateNotification
createNotification_notification = (CreateNotification -> Notification)
-> (CreateNotification -> Notification -> CreateNotification)
-> Lens
CreateNotification CreateNotification Notification Notification
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotification' {Notification
notification :: Notification
$sel:notification:CreateNotification' :: CreateNotification -> Notification
notification} -> Notification
notification) (\s :: CreateNotification
s@CreateNotification' {} Notification
a -> CreateNotification
s {$sel:notification:CreateNotification' :: Notification
notification = Notification
a} :: CreateNotification)
createNotification_subscribers :: Lens.Lens' CreateNotification (Prelude.NonEmpty Subscriber)
createNotification_subscribers :: (NonEmpty Subscriber -> f (NonEmpty Subscriber))
-> CreateNotification -> f CreateNotification
createNotification_subscribers = (CreateNotification -> NonEmpty Subscriber)
-> (CreateNotification
-> NonEmpty Subscriber -> CreateNotification)
-> Lens
CreateNotification
CreateNotification
(NonEmpty Subscriber)
(NonEmpty Subscriber)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotification' {NonEmpty Subscriber
subscribers :: NonEmpty Subscriber
$sel:subscribers:CreateNotification' :: CreateNotification -> NonEmpty Subscriber
subscribers} -> NonEmpty Subscriber
subscribers) (\s :: CreateNotification
s@CreateNotification' {} NonEmpty Subscriber
a -> CreateNotification
s {$sel:subscribers:CreateNotification' :: NonEmpty Subscriber
subscribers = NonEmpty Subscriber
a} :: CreateNotification) ((NonEmpty Subscriber -> f (NonEmpty Subscriber))
-> CreateNotification -> f CreateNotification)
-> ((NonEmpty Subscriber -> f (NonEmpty Subscriber))
-> NonEmpty Subscriber -> f (NonEmpty Subscriber))
-> (NonEmpty Subscriber -> f (NonEmpty Subscriber))
-> CreateNotification
-> f CreateNotification
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Subscriber -> f (NonEmpty Subscriber))
-> NonEmpty Subscriber -> f (NonEmpty Subscriber)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest CreateNotification where
type
AWSResponse CreateNotification =
CreateNotificationResponse
request :: CreateNotification -> Request CreateNotification
request = Service -> CreateNotification -> Request CreateNotification
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateNotification
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateNotification)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse CreateNotification))
-> Logger
-> Service
-> Proxy CreateNotification
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateNotification)))
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 -> CreateNotificationResponse
CreateNotificationResponse'
(Int -> CreateNotificationResponse)
-> Either String Int -> Either String CreateNotificationResponse
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 CreateNotification
instance Prelude.NFData CreateNotification
instance Core.ToHeaders CreateNotification where
toHeaders :: CreateNotification -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateNotification -> 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.CreateNotification" ::
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 CreateNotification where
toJSON :: CreateNotification -> Value
toJSON CreateNotification' {NonEmpty Subscriber
Text
Notification
subscribers :: NonEmpty Subscriber
notification :: Notification
budgetName :: Text
accountId :: Text
$sel:subscribers:CreateNotification' :: CreateNotification -> NonEmpty Subscriber
$sel:notification:CreateNotification' :: CreateNotification -> Notification
$sel:budgetName:CreateNotification' :: CreateNotification -> Text
$sel:accountId:CreateNotification' :: CreateNotification -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ 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
"BudgetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
budgetName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Notification" Text -> Notification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Notification
notification),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Subscribers" Text -> NonEmpty Subscriber -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Subscriber
subscribers)
]
)
instance Core.ToPath CreateNotification where
toPath :: CreateNotification -> ByteString
toPath = ByteString -> CreateNotification -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateNotification where
toQuery :: CreateNotification -> QueryString
toQuery = QueryString -> CreateNotification -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateNotificationResponse = CreateNotificationResponse'
{
CreateNotificationResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateNotificationResponse -> CreateNotificationResponse -> Bool
(CreateNotificationResponse -> CreateNotificationResponse -> Bool)
-> (CreateNotificationResponse
-> CreateNotificationResponse -> Bool)
-> Eq CreateNotificationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateNotificationResponse -> CreateNotificationResponse -> Bool
$c/= :: CreateNotificationResponse -> CreateNotificationResponse -> Bool
== :: CreateNotificationResponse -> CreateNotificationResponse -> Bool
$c== :: CreateNotificationResponse -> CreateNotificationResponse -> Bool
Prelude.Eq, ReadPrec [CreateNotificationResponse]
ReadPrec CreateNotificationResponse
Int -> ReadS CreateNotificationResponse
ReadS [CreateNotificationResponse]
(Int -> ReadS CreateNotificationResponse)
-> ReadS [CreateNotificationResponse]
-> ReadPrec CreateNotificationResponse
-> ReadPrec [CreateNotificationResponse]
-> Read CreateNotificationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateNotificationResponse]
$creadListPrec :: ReadPrec [CreateNotificationResponse]
readPrec :: ReadPrec CreateNotificationResponse
$creadPrec :: ReadPrec CreateNotificationResponse
readList :: ReadS [CreateNotificationResponse]
$creadList :: ReadS [CreateNotificationResponse]
readsPrec :: Int -> ReadS CreateNotificationResponse
$creadsPrec :: Int -> ReadS CreateNotificationResponse
Prelude.Read, Int -> CreateNotificationResponse -> ShowS
[CreateNotificationResponse] -> ShowS
CreateNotificationResponse -> String
(Int -> CreateNotificationResponse -> ShowS)
-> (CreateNotificationResponse -> String)
-> ([CreateNotificationResponse] -> ShowS)
-> Show CreateNotificationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateNotificationResponse] -> ShowS
$cshowList :: [CreateNotificationResponse] -> ShowS
show :: CreateNotificationResponse -> String
$cshow :: CreateNotificationResponse -> String
showsPrec :: Int -> CreateNotificationResponse -> ShowS
$cshowsPrec :: Int -> CreateNotificationResponse -> ShowS
Prelude.Show, (forall x.
CreateNotificationResponse -> Rep CreateNotificationResponse x)
-> (forall x.
Rep CreateNotificationResponse x -> CreateNotificationResponse)
-> Generic CreateNotificationResponse
forall x.
Rep CreateNotificationResponse x -> CreateNotificationResponse
forall x.
CreateNotificationResponse -> Rep CreateNotificationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateNotificationResponse x -> CreateNotificationResponse
$cfrom :: forall x.
CreateNotificationResponse -> Rep CreateNotificationResponse x
Prelude.Generic)
newCreateNotificationResponse ::
Prelude.Int ->
CreateNotificationResponse
newCreateNotificationResponse :: Int -> CreateNotificationResponse
newCreateNotificationResponse Int
pHttpStatus_ =
CreateNotificationResponse' :: Int -> CreateNotificationResponse
CreateNotificationResponse'
{ $sel:httpStatus:CreateNotificationResponse' :: Int
httpStatus =
Int
pHttpStatus_
}
createNotificationResponse_httpStatus :: Lens.Lens' CreateNotificationResponse Prelude.Int
createNotificationResponse_httpStatus :: (Int -> f Int)
-> CreateNotificationResponse -> f CreateNotificationResponse
createNotificationResponse_httpStatus = (CreateNotificationResponse -> Int)
-> (CreateNotificationResponse
-> Int -> CreateNotificationResponse)
-> Lens
CreateNotificationResponse CreateNotificationResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateNotificationResponse' :: CreateNotificationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateNotificationResponse
s@CreateNotificationResponse' {} Int
a -> CreateNotificationResponse
s {$sel:httpStatus:CreateNotificationResponse' :: Int
httpStatus = Int
a} :: CreateNotificationResponse)
instance Prelude.NFData CreateNotificationResponse