{-# 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.SNS.ListSubscriptions
(
listSubscriptions
, ListSubscriptions
, lsNextToken
, listSubscriptionsResponse
, ListSubscriptionsResponse
, lsrsNextToken
, lsrsSubscriptions
, lsrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.SNS.Types
import Network.AWS.SNS.Types.Product
newtype ListSubscriptions = ListSubscriptions'
{ _lsNextToken :: Maybe Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listSubscriptions
:: ListSubscriptions
listSubscriptions = ListSubscriptions' {_lsNextToken = Nothing}
lsNextToken :: Lens' ListSubscriptions (Maybe Text)
lsNextToken = lens _lsNextToken (\ s a -> s{_lsNextToken = a})
instance AWSPager ListSubscriptions where
page rq rs
| stop (rs ^. lsrsNextToken) = Nothing
| stop (rs ^. lsrsSubscriptions) = Nothing
| otherwise =
Just $ rq & lsNextToken .~ rs ^. lsrsNextToken
instance AWSRequest ListSubscriptions where
type Rs ListSubscriptions = ListSubscriptionsResponse
request = postQuery sns
response
= receiveXMLWrapper "ListSubscriptionsResult"
(\ s h x ->
ListSubscriptionsResponse' <$>
(x .@? "NextToken") <*>
(x .@? "Subscriptions" .!@ mempty >>=
may (parseXMLList "member"))
<*> (pure (fromEnum s)))
instance Hashable ListSubscriptions where
instance NFData ListSubscriptions where
instance ToHeaders ListSubscriptions where
toHeaders = const mempty
instance ToPath ListSubscriptions where
toPath = const "/"
instance ToQuery ListSubscriptions where
toQuery ListSubscriptions'{..}
= mconcat
["Action" =: ("ListSubscriptions" :: ByteString),
"Version" =: ("2010-03-31" :: ByteString),
"NextToken" =: _lsNextToken]
data ListSubscriptionsResponse = ListSubscriptionsResponse'
{ _lsrsNextToken :: !(Maybe Text)
, _lsrsSubscriptions :: !(Maybe [Subscription])
, _lsrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listSubscriptionsResponse
:: Int
-> ListSubscriptionsResponse
listSubscriptionsResponse pResponseStatus_ =
ListSubscriptionsResponse'
{ _lsrsNextToken = Nothing
, _lsrsSubscriptions = Nothing
, _lsrsResponseStatus = pResponseStatus_
}
lsrsNextToken :: Lens' ListSubscriptionsResponse (Maybe Text)
lsrsNextToken = lens _lsrsNextToken (\ s a -> s{_lsrsNextToken = a})
lsrsSubscriptions :: Lens' ListSubscriptionsResponse [Subscription]
lsrsSubscriptions = lens _lsrsSubscriptions (\ s a -> s{_lsrsSubscriptions = a}) . _Default . _Coerce
lsrsResponseStatus :: Lens' ListSubscriptionsResponse Int
lsrsResponseStatus = lens _lsrsResponseStatus (\ s a -> s{_lsrsResponseStatus = a})
instance NFData ListSubscriptionsResponse where