module Network.AWS.DataPipeline.QueryObjects
(
queryObjects
, QueryObjects
, qoQuery
, qoMarker
, qoLimit
, qoPipelineId
, qoSphere
, queryObjectsResponse
, QueryObjectsResponse
, qorsHasMoreResults
, qorsIds
, qorsMarker
, qorsResponseStatus
) where
import Network.AWS.DataPipeline.Types
import Network.AWS.DataPipeline.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data QueryObjects = QueryObjects'
{ _qoQuery :: !(Maybe Query)
, _qoMarker :: !(Maybe Text)
, _qoLimit :: !(Maybe Int)
, _qoPipelineId :: !Text
, _qoSphere :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
queryObjects
:: Text
-> Text
-> QueryObjects
queryObjects pPipelineId_ pSphere_ =
QueryObjects'
{ _qoQuery = Nothing
, _qoMarker = Nothing
, _qoLimit = Nothing
, _qoPipelineId = pPipelineId_
, _qoSphere = pSphere_
}
qoQuery :: Lens' QueryObjects (Maybe Query)
qoQuery = lens _qoQuery (\ s a -> s{_qoQuery = a});
qoMarker :: Lens' QueryObjects (Maybe Text)
qoMarker = lens _qoMarker (\ s a -> s{_qoMarker = a});
qoLimit :: Lens' QueryObjects (Maybe Int)
qoLimit = lens _qoLimit (\ s a -> s{_qoLimit = a});
qoPipelineId :: Lens' QueryObjects Text
qoPipelineId = lens _qoPipelineId (\ s a -> s{_qoPipelineId = a});
qoSphere :: Lens' QueryObjects Text
qoSphere = lens _qoSphere (\ s a -> s{_qoSphere = a});
instance AWSPager QueryObjects where
page rq rs
| stop (rs ^. qorsHasMoreResults) = Nothing
| isNothing (rs ^. qorsMarker) = Nothing
| otherwise =
Just $ rq & qoMarker .~ rs ^. qorsMarker
instance AWSRequest QueryObjects where
type Rs QueryObjects = QueryObjectsResponse
request = postJSON dataPipeline
response
= receiveJSON
(\ s h x ->
QueryObjectsResponse' <$>
(x .?> "hasMoreResults") <*> (x .?> "ids" .!@ mempty)
<*> (x .?> "marker")
<*> (pure (fromEnum s)))
instance Hashable QueryObjects
instance ToHeaders QueryObjects where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("DataPipeline.QueryObjects" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON QueryObjects where
toJSON QueryObjects'{..}
= object
(catMaybes
[("query" .=) <$> _qoQuery,
("marker" .=) <$> _qoMarker,
("limit" .=) <$> _qoLimit,
Just ("pipelineId" .= _qoPipelineId),
Just ("sphere" .= _qoSphere)])
instance ToPath QueryObjects where
toPath = const "/"
instance ToQuery QueryObjects where
toQuery = const mempty
data QueryObjectsResponse = QueryObjectsResponse'
{ _qorsHasMoreResults :: !(Maybe Bool)
, _qorsIds :: !(Maybe [Text])
, _qorsMarker :: !(Maybe Text)
, _qorsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
queryObjectsResponse
:: Int
-> QueryObjectsResponse
queryObjectsResponse pResponseStatus_ =
QueryObjectsResponse'
{ _qorsHasMoreResults = Nothing
, _qorsIds = Nothing
, _qorsMarker = Nothing
, _qorsResponseStatus = pResponseStatus_
}
qorsHasMoreResults :: Lens' QueryObjectsResponse (Maybe Bool)
qorsHasMoreResults = lens _qorsHasMoreResults (\ s a -> s{_qorsHasMoreResults = a});
qorsIds :: Lens' QueryObjectsResponse [Text]
qorsIds = lens _qorsIds (\ s a -> s{_qorsIds = a}) . _Default . _Coerce;
qorsMarker :: Lens' QueryObjectsResponse (Maybe Text)
qorsMarker = lens _qorsMarker (\ s a -> s{_qorsMarker = a});
qorsResponseStatus :: Lens' QueryObjectsResponse Int
qorsResponseStatus = lens _qorsResponseStatus (\ s a -> s{_qorsResponseStatus = a});