{-# 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.APIGateway.GetResources
(
getResources
, GetResources
, grsLimit
, grsPosition
, grsRestAPIId
, getResourcesResponse
, GetResourcesResponse
, grrsItems
, grrsPosition
, grrsResponseStatus
) where
import Network.AWS.APIGateway.Types
import Network.AWS.APIGateway.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetResources = GetResources'
{ _grsLimit :: !(Maybe Int)
, _grsPosition :: !(Maybe Text)
, _grsRestAPIId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getResources
:: Text
-> GetResources
getResources pRestAPIId_ =
GetResources'
{ _grsLimit = Nothing
, _grsPosition = Nothing
, _grsRestAPIId = pRestAPIId_
}
grsLimit :: Lens' GetResources (Maybe Int)
grsLimit = lens _grsLimit (\ s a -> s{_grsLimit = a});
grsPosition :: Lens' GetResources (Maybe Text)
grsPosition = lens _grsPosition (\ s a -> s{_grsPosition = a});
grsRestAPIId :: Lens' GetResources Text
grsRestAPIId = lens _grsRestAPIId (\ s a -> s{_grsRestAPIId = a});
instance AWSPager GetResources where
page rq rs
| stop (rs ^. grrsPosition) = Nothing
| stop (rs ^. grrsItems) = Nothing
| otherwise =
Just $ rq & grsPosition .~ rs ^. grrsPosition
instance AWSRequest GetResources where
type Rs GetResources = GetResourcesResponse
request = get apiGateway
response
= receiveJSON
(\ s h x ->
GetResourcesResponse' <$>
(x .?> "item" .!@ mempty) <*> (x .?> "position") <*>
(pure (fromEnum s)))
instance Hashable GetResources
instance NFData GetResources
instance ToHeaders GetResources where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToPath GetResources where
toPath GetResources'{..}
= mconcat
["/restapis/", toBS _grsRestAPIId, "/resources"]
instance ToQuery GetResources where
toQuery GetResources'{..}
= mconcat
["limit" =: _grsLimit, "position" =: _grsPosition]
data GetResourcesResponse = GetResourcesResponse'
{ _grrsItems :: !(Maybe [Resource])
, _grrsPosition :: !(Maybe Text)
, _grrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getResourcesResponse
:: Int
-> GetResourcesResponse
getResourcesResponse pResponseStatus_ =
GetResourcesResponse'
{ _grrsItems = Nothing
, _grrsPosition = Nothing
, _grrsResponseStatus = pResponseStatus_
}
grrsItems :: Lens' GetResourcesResponse [Resource]
grrsItems = lens _grrsItems (\ s a -> s{_grrsItems = a}) . _Default . _Coerce;
grrsPosition :: Lens' GetResourcesResponse (Maybe Text)
grrsPosition = lens _grrsPosition (\ s a -> s{_grrsPosition = a});
grrsResponseStatus :: Lens' GetResourcesResponse Int
grrsResponseStatus = lens _grrsResponseStatus (\ s a -> s{_grrsResponseStatus = a});
instance NFData GetResourcesResponse