{-# 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.GetUsage
(
getUsage
, GetUsage
, guKeyId
, guLimit
, guPosition
, guUsagePlanId
, guStartDate
, guEndDate
, usage
, Usage
, uUsagePlanId
, uEndDate
, uItems
, uStartDate
, uPosition
) 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 GetUsage = GetUsage'
{ _guKeyId :: !(Maybe Text)
, _guLimit :: !(Maybe Int)
, _guPosition :: !(Maybe Text)
, _guUsagePlanId :: !Text
, _guStartDate :: !Text
, _guEndDate :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getUsage
:: Text
-> Text
-> Text
-> GetUsage
getUsage pUsagePlanId_ pStartDate_ pEndDate_ =
GetUsage'
{ _guKeyId = Nothing
, _guLimit = Nothing
, _guPosition = Nothing
, _guUsagePlanId = pUsagePlanId_
, _guStartDate = pStartDate_
, _guEndDate = pEndDate_
}
guKeyId :: Lens' GetUsage (Maybe Text)
guKeyId = lens _guKeyId (\ s a -> s{_guKeyId = a})
guLimit :: Lens' GetUsage (Maybe Int)
guLimit = lens _guLimit (\ s a -> s{_guLimit = a})
guPosition :: Lens' GetUsage (Maybe Text)
guPosition = lens _guPosition (\ s a -> s{_guPosition = a})
guUsagePlanId :: Lens' GetUsage Text
guUsagePlanId = lens _guUsagePlanId (\ s a -> s{_guUsagePlanId = a})
guStartDate :: Lens' GetUsage Text
guStartDate = lens _guStartDate (\ s a -> s{_guStartDate = a})
guEndDate :: Lens' GetUsage Text
guEndDate = lens _guEndDate (\ s a -> s{_guEndDate = a})
instance AWSPager GetUsage where
page rq rs
| stop (rs ^. uPosition) = Nothing
| stop (rs ^. uItems) = Nothing
| otherwise =
Just $ rq & guPosition .~ rs ^. uPosition
instance AWSRequest GetUsage where
type Rs GetUsage = Usage
request = get apiGateway
response = receiveJSON (\ s h x -> eitherParseJSON x)
instance Hashable GetUsage where
instance NFData GetUsage where
instance ToHeaders GetUsage where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToPath GetUsage where
toPath GetUsage'{..}
= mconcat
["/usageplans/", toBS _guUsagePlanId, "/usage"]
instance ToQuery GetUsage where
toQuery GetUsage'{..}
= mconcat
["keyId" =: _guKeyId, "limit" =: _guLimit,
"position" =: _guPosition,
"startDate" =: _guStartDate, "endDate" =: _guEndDate]