{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.WorkDocs.CreateNotificationSubscription
(
createNotificationSubscription
, CreateNotificationSubscription
, cnsOrganizationId
, cnsEndpoint
, cnsProtocol
, cnsSubscriptionType
, createNotificationSubscriptionResponse
, CreateNotificationSubscriptionResponse
, cnsrsSubscription
, cnsrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.WorkDocs.Types
import Network.AWS.WorkDocs.Types.Product
data CreateNotificationSubscription = CreateNotificationSubscription'
{ _cnsOrganizationId :: !Text
, _cnsEndpoint :: !Text
, _cnsProtocol :: !SubscriptionProtocolType
, _cnsSubscriptionType :: !SubscriptionType
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createNotificationSubscription
:: Text
-> Text
-> SubscriptionProtocolType
-> SubscriptionType
-> CreateNotificationSubscription
createNotificationSubscription pOrganizationId_ pEndpoint_ pProtocol_ pSubscriptionType_ =
CreateNotificationSubscription'
{ _cnsOrganizationId = pOrganizationId_
, _cnsEndpoint = pEndpoint_
, _cnsProtocol = pProtocol_
, _cnsSubscriptionType = pSubscriptionType_
}
cnsOrganizationId :: Lens' CreateNotificationSubscription Text
cnsOrganizationId = lens _cnsOrganizationId (\ s a -> s{_cnsOrganizationId = a})
cnsEndpoint :: Lens' CreateNotificationSubscription Text
cnsEndpoint = lens _cnsEndpoint (\ s a -> s{_cnsEndpoint = a})
cnsProtocol :: Lens' CreateNotificationSubscription SubscriptionProtocolType
cnsProtocol = lens _cnsProtocol (\ s a -> s{_cnsProtocol = a})
cnsSubscriptionType :: Lens' CreateNotificationSubscription SubscriptionType
cnsSubscriptionType = lens _cnsSubscriptionType (\ s a -> s{_cnsSubscriptionType = a})
instance AWSRequest CreateNotificationSubscription
where
type Rs CreateNotificationSubscription =
CreateNotificationSubscriptionResponse
request = postJSON workDocs
response
= receiveJSON
(\ s h x ->
CreateNotificationSubscriptionResponse' <$>
(x .?> "Subscription") <*> (pure (fromEnum s)))
instance Hashable CreateNotificationSubscription
where
instance NFData CreateNotificationSubscription where
instance ToHeaders CreateNotificationSubscription
where
toHeaders
= const
(mconcat
["Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateNotificationSubscription where
toJSON CreateNotificationSubscription'{..}
= object
(catMaybes
[Just ("Endpoint" .= _cnsEndpoint),
Just ("Protocol" .= _cnsProtocol),
Just ("SubscriptionType" .= _cnsSubscriptionType)])
instance ToPath CreateNotificationSubscription where
toPath CreateNotificationSubscription'{..}
= mconcat
["/api/v1/organizations/", toBS _cnsOrganizationId,
"/subscriptions"]
instance ToQuery CreateNotificationSubscription where
toQuery = const mempty
data CreateNotificationSubscriptionResponse = CreateNotificationSubscriptionResponse'
{ _cnsrsSubscription :: !(Maybe Subscription)
, _cnsrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createNotificationSubscriptionResponse
:: Int
-> CreateNotificationSubscriptionResponse
createNotificationSubscriptionResponse pResponseStatus_ =
CreateNotificationSubscriptionResponse'
{_cnsrsSubscription = Nothing, _cnsrsResponseStatus = pResponseStatus_}
cnsrsSubscription :: Lens' CreateNotificationSubscriptionResponse (Maybe Subscription)
cnsrsSubscription = lens _cnsrsSubscription (\ s a -> s{_cnsrsSubscription = a})
cnsrsResponseStatus :: Lens' CreateNotificationSubscriptionResponse Int
cnsrsResponseStatus = lens _cnsrsResponseStatus (\ s a -> s{_cnsrsResponseStatus = a})
instance NFData
CreateNotificationSubscriptionResponse
where