{-# 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.GetBasePathMappings
(
getBasePathMappings
, GetBasePathMappings
, gLimit
, gPosition
, gDomainName
, getBasePathMappingsResponse
, GetBasePathMappingsResponse
, gbpmrsItems
, gbpmrsPosition
, gbpmrsResponseStatus
) 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 GetBasePathMappings = GetBasePathMappings'
{ _gLimit :: !(Maybe Int)
, _gPosition :: !(Maybe Text)
, _gDomainName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getBasePathMappings
:: Text
-> GetBasePathMappings
getBasePathMappings pDomainName_ =
GetBasePathMappings'
{ _gLimit = Nothing
, _gPosition = Nothing
, _gDomainName = pDomainName_
}
gLimit :: Lens' GetBasePathMappings (Maybe Int)
gLimit = lens _gLimit (\ s a -> s{_gLimit = a});
gPosition :: Lens' GetBasePathMappings (Maybe Text)
gPosition = lens _gPosition (\ s a -> s{_gPosition = a});
gDomainName :: Lens' GetBasePathMappings Text
gDomainName = lens _gDomainName (\ s a -> s{_gDomainName = a});
instance AWSPager GetBasePathMappings where
page rq rs
| stop (rs ^. gbpmrsPosition) = Nothing
| stop (rs ^. gbpmrsItems) = Nothing
| otherwise =
Just $ rq & gPosition .~ rs ^. gbpmrsPosition
instance AWSRequest GetBasePathMappings where
type Rs GetBasePathMappings =
GetBasePathMappingsResponse
request = get apiGateway
response
= receiveJSON
(\ s h x ->
GetBasePathMappingsResponse' <$>
(x .?> "item" .!@ mempty) <*> (x .?> "position") <*>
(pure (fromEnum s)))
instance Hashable GetBasePathMappings
instance NFData GetBasePathMappings
instance ToHeaders GetBasePathMappings where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToPath GetBasePathMappings where
toPath GetBasePathMappings'{..}
= mconcat
["/domainnames/", toBS _gDomainName,
"/basepathmappings"]
instance ToQuery GetBasePathMappings where
toQuery GetBasePathMappings'{..}
= mconcat
["limit" =: _gLimit, "position" =: _gPosition]
data GetBasePathMappingsResponse = GetBasePathMappingsResponse'
{ _gbpmrsItems :: !(Maybe [BasePathMapping])
, _gbpmrsPosition :: !(Maybe Text)
, _gbpmrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getBasePathMappingsResponse
:: Int
-> GetBasePathMappingsResponse
getBasePathMappingsResponse pResponseStatus_ =
GetBasePathMappingsResponse'
{ _gbpmrsItems = Nothing
, _gbpmrsPosition = Nothing
, _gbpmrsResponseStatus = pResponseStatus_
}
gbpmrsItems :: Lens' GetBasePathMappingsResponse [BasePathMapping]
gbpmrsItems = lens _gbpmrsItems (\ s a -> s{_gbpmrsItems = a}) . _Default . _Coerce;
gbpmrsPosition :: Lens' GetBasePathMappingsResponse (Maybe Text)
gbpmrsPosition = lens _gbpmrsPosition (\ s a -> s{_gbpmrsPosition = a});
gbpmrsResponseStatus :: Lens' GetBasePathMappingsResponse Int
gbpmrsResponseStatus = lens _gbpmrsResponseStatus (\ s a -> s{_gbpmrsResponseStatus = a});
instance NFData GetBasePathMappingsResponse