{-# 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.GetAPIKeys
(
getAPIKeys
, GetAPIKeys
, gakIncludeValues
, gakCustomerId
, gakNameQuery
, gakLimit
, gakPosition
, getAPIKeysResponse
, GetAPIKeysResponse
, gakrsItems
, gakrsWarnings
, gakrsPosition
, gakrsResponseStatus
) 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 GetAPIKeys = GetAPIKeys'
{ _gakIncludeValues :: !(Maybe Bool)
, _gakCustomerId :: !(Maybe Text)
, _gakNameQuery :: !(Maybe Text)
, _gakLimit :: !(Maybe Int)
, _gakPosition :: !(Maybe Text)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getAPIKeys
:: GetAPIKeys
getAPIKeys =
GetAPIKeys'
{ _gakIncludeValues = Nothing
, _gakCustomerId = Nothing
, _gakNameQuery = Nothing
, _gakLimit = Nothing
, _gakPosition = Nothing
}
gakIncludeValues :: Lens' GetAPIKeys (Maybe Bool)
gakIncludeValues = lens _gakIncludeValues (\ s a -> s{_gakIncludeValues = a})
gakCustomerId :: Lens' GetAPIKeys (Maybe Text)
gakCustomerId = lens _gakCustomerId (\ s a -> s{_gakCustomerId = a})
gakNameQuery :: Lens' GetAPIKeys (Maybe Text)
gakNameQuery = lens _gakNameQuery (\ s a -> s{_gakNameQuery = a})
gakLimit :: Lens' GetAPIKeys (Maybe Int)
gakLimit = lens _gakLimit (\ s a -> s{_gakLimit = a})
gakPosition :: Lens' GetAPIKeys (Maybe Text)
gakPosition = lens _gakPosition (\ s a -> s{_gakPosition = a})
instance AWSPager GetAPIKeys where
page rq rs
| stop (rs ^. gakrsPosition) = Nothing
| stop (rs ^. gakrsItems) = Nothing
| otherwise =
Just $ rq & gakPosition .~ rs ^. gakrsPosition
instance AWSRequest GetAPIKeys where
type Rs GetAPIKeys = GetAPIKeysResponse
request = get apiGateway
response
= receiveJSON
(\ s h x ->
GetAPIKeysResponse' <$>
(x .?> "item" .!@ mempty) <*>
(x .?> "warnings" .!@ mempty)
<*> (x .?> "position")
<*> (pure (fromEnum s)))
instance Hashable GetAPIKeys where
instance NFData GetAPIKeys where
instance ToHeaders GetAPIKeys where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToPath GetAPIKeys where
toPath = const "/apikeys"
instance ToQuery GetAPIKeys where
toQuery GetAPIKeys'{..}
= mconcat
["includeValues" =: _gakIncludeValues,
"customerId" =: _gakCustomerId,
"name" =: _gakNameQuery, "limit" =: _gakLimit,
"position" =: _gakPosition]
data GetAPIKeysResponse = GetAPIKeysResponse'
{ _gakrsItems :: !(Maybe [APIKey])
, _gakrsWarnings :: !(Maybe [Text])
, _gakrsPosition :: !(Maybe Text)
, _gakrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getAPIKeysResponse
:: Int
-> GetAPIKeysResponse
getAPIKeysResponse pResponseStatus_ =
GetAPIKeysResponse'
{ _gakrsItems = Nothing
, _gakrsWarnings = Nothing
, _gakrsPosition = Nothing
, _gakrsResponseStatus = pResponseStatus_
}
gakrsItems :: Lens' GetAPIKeysResponse [APIKey]
gakrsItems = lens _gakrsItems (\ s a -> s{_gakrsItems = a}) . _Default . _Coerce
gakrsWarnings :: Lens' GetAPIKeysResponse [Text]
gakrsWarnings = lens _gakrsWarnings (\ s a -> s{_gakrsWarnings = a}) . _Default . _Coerce
gakrsPosition :: Lens' GetAPIKeysResponse (Maybe Text)
gakrsPosition = lens _gakrsPosition (\ s a -> s{_gakrsPosition = a})
gakrsResponseStatus :: Lens' GetAPIKeysResponse Int
gakrsResponseStatus = lens _gakrsResponseStatus (\ s a -> s{_gakrsResponseStatus = a})
instance NFData GetAPIKeysResponse where