{-# 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.ListTopics
(
listTopics
, ListTopics
, ltNextToken
, listTopicsResponse
, ListTopicsResponse
, ltrsTopics
, ltrsNextToken
, ltrsResponseStatus
) 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 ListTopics = ListTopics'
{ _ltNextToken :: Maybe Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listTopics
:: ListTopics
listTopics = ListTopics' {_ltNextToken = Nothing}
ltNextToken :: Lens' ListTopics (Maybe Text)
ltNextToken = lens _ltNextToken (\ s a -> s{_ltNextToken = a})
instance AWSPager ListTopics where
page rq rs
| stop (rs ^. ltrsNextToken) = Nothing
| stop (rs ^. ltrsTopics) = Nothing
| otherwise =
Just $ rq & ltNextToken .~ rs ^. ltrsNextToken
instance AWSRequest ListTopics where
type Rs ListTopics = ListTopicsResponse
request = postQuery sns
response
= receiveXMLWrapper "ListTopicsResult"
(\ s h x ->
ListTopicsResponse' <$>
(x .@? "Topics" .!@ mempty >>=
may (parseXMLList "member"))
<*> (x .@? "NextToken")
<*> (pure (fromEnum s)))
instance Hashable ListTopics where
instance NFData ListTopics where
instance ToHeaders ListTopics where
toHeaders = const mempty
instance ToPath ListTopics where
toPath = const "/"
instance ToQuery ListTopics where
toQuery ListTopics'{..}
= mconcat
["Action" =: ("ListTopics" :: ByteString),
"Version" =: ("2010-03-31" :: ByteString),
"NextToken" =: _ltNextToken]
data ListTopicsResponse = ListTopicsResponse'
{ _ltrsTopics :: !(Maybe [Topic])
, _ltrsNextToken :: !(Maybe Text)
, _ltrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listTopicsResponse
:: Int
-> ListTopicsResponse
listTopicsResponse pResponseStatus_ =
ListTopicsResponse'
{ _ltrsTopics = Nothing
, _ltrsNextToken = Nothing
, _ltrsResponseStatus = pResponseStatus_
}
ltrsTopics :: Lens' ListTopicsResponse [Topic]
ltrsTopics = lens _ltrsTopics (\ s a -> s{_ltrsTopics = a}) . _Default . _Coerce
ltrsNextToken :: Lens' ListTopicsResponse (Maybe Text)
ltrsNextToken = lens _ltrsNextToken (\ s a -> s{_ltrsNextToken = a})
ltrsResponseStatus :: Lens' ListTopicsResponse Int
ltrsResponseStatus = lens _ltrsResponseStatus (\ s a -> s{_ltrsResponseStatus = a})
instance NFData ListTopicsResponse where