{-# 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.Kinesis.ListStreams
(
listStreams
, ListStreams
, lsLimit
, lsExclusiveStartStreamName
, listStreamsResponse
, ListStreamsResponse
, lsrsResponseStatus
, lsrsStreamNames
, lsrsHasMoreStreams
) where
import Network.AWS.Kinesis.Types
import Network.AWS.Kinesis.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListStreams = ListStreams'
{ _lsLimit :: !(Maybe Nat)
, _lsExclusiveStartStreamName :: !(Maybe Text)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listStreams
:: ListStreams
listStreams =
ListStreams' {_lsLimit = Nothing, _lsExclusiveStartStreamName = Nothing}
lsLimit :: Lens' ListStreams (Maybe Natural)
lsLimit = lens _lsLimit (\ s a -> s{_lsLimit = a}) . mapping _Nat
lsExclusiveStartStreamName :: Lens' ListStreams (Maybe Text)
lsExclusiveStartStreamName = lens _lsExclusiveStartStreamName (\ s a -> s{_lsExclusiveStartStreamName = a})
instance AWSPager ListStreams where
page rq rs
| stop (rs ^. lsrsHasMoreStreams) = Nothing
| isNothing (rs ^? lsrsStreamNames . _last) = Nothing
| otherwise =
Just $ rq &
lsExclusiveStartStreamName .~
rs ^? lsrsStreamNames . _last
instance AWSRequest ListStreams where
type Rs ListStreams = ListStreamsResponse
request = postJSON kinesis
response
= receiveJSON
(\ s h x ->
ListStreamsResponse' <$>
(pure (fromEnum s)) <*>
(x .?> "StreamNames" .!@ mempty)
<*> (x .:> "HasMoreStreams"))
instance Hashable ListStreams where
instance NFData ListStreams where
instance ToHeaders ListStreams where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Kinesis_20131202.ListStreams" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListStreams where
toJSON ListStreams'{..}
= object
(catMaybes
[("Limit" .=) <$> _lsLimit,
("ExclusiveStartStreamName" .=) <$>
_lsExclusiveStartStreamName])
instance ToPath ListStreams where
toPath = const "/"
instance ToQuery ListStreams where
toQuery = const mempty
data ListStreamsResponse = ListStreamsResponse'
{ _lsrsResponseStatus :: !Int
, _lsrsStreamNames :: ![Text]
, _lsrsHasMoreStreams :: !Bool
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listStreamsResponse
:: Int
-> Bool
-> ListStreamsResponse
listStreamsResponse pResponseStatus_ pHasMoreStreams_ =
ListStreamsResponse'
{ _lsrsResponseStatus = pResponseStatus_
, _lsrsStreamNames = mempty
, _lsrsHasMoreStreams = pHasMoreStreams_
}
lsrsResponseStatus :: Lens' ListStreamsResponse Int
lsrsResponseStatus = lens _lsrsResponseStatus (\ s a -> s{_lsrsResponseStatus = a})
lsrsStreamNames :: Lens' ListStreamsResponse [Text]
lsrsStreamNames = lens _lsrsStreamNames (\ s a -> s{_lsrsStreamNames = a}) . _Coerce
lsrsHasMoreStreams :: Lens' ListStreamsResponse Bool
lsrsHasMoreStreams = lens _lsrsHasMoreStreams (\ s a -> s{_lsrsHasMoreStreams = a})
instance NFData ListStreamsResponse where