{-# 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.GetModels
(
getModels
, GetModels
, gmsLimit
, gmsPosition
, gmsRestAPIId
, getModelsResponse
, GetModelsResponse
, gmrsItems
, gmrsPosition
, gmrsResponseStatus
) 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 GetModels = GetModels'
{ _gmsLimit :: !(Maybe Int)
, _gmsPosition :: !(Maybe Text)
, _gmsRestAPIId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getModels
:: Text
-> GetModels
getModels pRestAPIId_ =
GetModels'
{ _gmsLimit = Nothing
, _gmsPosition = Nothing
, _gmsRestAPIId = pRestAPIId_
}
gmsLimit :: Lens' GetModels (Maybe Int)
gmsLimit = lens _gmsLimit (\ s a -> s{_gmsLimit = a});
gmsPosition :: Lens' GetModels (Maybe Text)
gmsPosition = lens _gmsPosition (\ s a -> s{_gmsPosition = a});
gmsRestAPIId :: Lens' GetModels Text
gmsRestAPIId = lens _gmsRestAPIId (\ s a -> s{_gmsRestAPIId = a});
instance AWSPager GetModels where
page rq rs
| stop (rs ^. gmrsPosition) = Nothing
| stop (rs ^. gmrsItems) = Nothing
| otherwise =
Just $ rq & gmsPosition .~ rs ^. gmrsPosition
instance AWSRequest GetModels where
type Rs GetModels = GetModelsResponse
request = get apiGateway
response
= receiveJSON
(\ s h x ->
GetModelsResponse' <$>
(x .?> "item" .!@ mempty) <*> (x .?> "position") <*>
(pure (fromEnum s)))
instance Hashable GetModels
instance NFData GetModels
instance ToHeaders GetModels where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToPath GetModels where
toPath GetModels'{..}
= mconcat
["/restapis/", toBS _gmsRestAPIId, "/models"]
instance ToQuery GetModels where
toQuery GetModels'{..}
= mconcat
["limit" =: _gmsLimit, "position" =: _gmsPosition]
data GetModelsResponse = GetModelsResponse'
{ _gmrsItems :: !(Maybe [Model])
, _gmrsPosition :: !(Maybe Text)
, _gmrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getModelsResponse
:: Int
-> GetModelsResponse
getModelsResponse pResponseStatus_ =
GetModelsResponse'
{ _gmrsItems = Nothing
, _gmrsPosition = Nothing
, _gmrsResponseStatus = pResponseStatus_
}
gmrsItems :: Lens' GetModelsResponse [Model]
gmrsItems = lens _gmrsItems (\ s a -> s{_gmrsItems = a}) . _Default . _Coerce;
gmrsPosition :: Lens' GetModelsResponse (Maybe Text)
gmrsPosition = lens _gmrsPosition (\ s a -> s{_gmrsPosition = a});
gmrsResponseStatus :: Lens' GetModelsResponse Int
gmrsResponseStatus = lens _gmrsResponseStatus (\ s a -> s{_gmrsResponseStatus = a});
instance NFData GetModelsResponse