{-# 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.GetDeployments
(
getDeployments
, GetDeployments
, gdLimit
, gdPosition
, gdRestAPIId
, getDeploymentsResponse
, GetDeploymentsResponse
, gdrsItems
, gdrsPosition
, gdrsResponseStatus
) 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 GetDeployments = GetDeployments'
{ _gdLimit :: !(Maybe Int)
, _gdPosition :: !(Maybe Text)
, _gdRestAPIId :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getDeployments
:: Text
-> GetDeployments
getDeployments pRestAPIId_ =
GetDeployments'
{ _gdLimit = Nothing
, _gdPosition = Nothing
, _gdRestAPIId = pRestAPIId_
}
gdLimit :: Lens' GetDeployments (Maybe Int)
gdLimit = lens _gdLimit (\ s a -> s{_gdLimit = a});
gdPosition :: Lens' GetDeployments (Maybe Text)
gdPosition = lens _gdPosition (\ s a -> s{_gdPosition = a});
gdRestAPIId :: Lens' GetDeployments Text
gdRestAPIId = lens _gdRestAPIId (\ s a -> s{_gdRestAPIId = a});
instance AWSPager GetDeployments where
page rq rs
| stop (rs ^. gdrsPosition) = Nothing
| stop (rs ^. gdrsItems) = Nothing
| otherwise =
Just $ rq & gdPosition .~ rs ^. gdrsPosition
instance AWSRequest GetDeployments where
type Rs GetDeployments = GetDeploymentsResponse
request = get apiGateway
response
= receiveJSON
(\ s h x ->
GetDeploymentsResponse' <$>
(x .?> "item" .!@ mempty) <*> (x .?> "position") <*>
(pure (fromEnum s)))
instance Hashable GetDeployments
instance NFData GetDeployments
instance ToHeaders GetDeployments where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToPath GetDeployments where
toPath GetDeployments'{..}
= mconcat
["/restapis/", toBS _gdRestAPIId, "/deployments"]
instance ToQuery GetDeployments where
toQuery GetDeployments'{..}
= mconcat
["limit" =: _gdLimit, "position" =: _gdPosition]
data GetDeploymentsResponse = GetDeploymentsResponse'
{ _gdrsItems :: !(Maybe [Deployment])
, _gdrsPosition :: !(Maybe Text)
, _gdrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getDeploymentsResponse
:: Int
-> GetDeploymentsResponse
getDeploymentsResponse pResponseStatus_ =
GetDeploymentsResponse'
{ _gdrsItems = Nothing
, _gdrsPosition = Nothing
, _gdrsResponseStatus = pResponseStatus_
}
gdrsItems :: Lens' GetDeploymentsResponse [Deployment]
gdrsItems = lens _gdrsItems (\ s a -> s{_gdrsItems = a}) . _Default . _Coerce;
gdrsPosition :: Lens' GetDeploymentsResponse (Maybe Text)
gdrsPosition = lens _gdrsPosition (\ s a -> s{_gdrsPosition = a});
gdrsResponseStatus :: Lens' GetDeploymentsResponse Int
gdrsResponseStatus = lens _gdrsResponseStatus (\ s a -> s{_gdrsResponseStatus = a});
instance NFData GetDeploymentsResponse