module Network.AWS.APIGateway.CreateUsagePlan
(
createUsagePlan
, CreateUsagePlan
, cupApiStages
, cupThrottle
, cupQuota
, cupDescription
, cupName
, usagePlan
, UsagePlan
, upApiStages
, upName
, upId
, upThrottle
, upQuota
, upDescription
, upProductCode
) where
import Network.AWS.APIGateway.Types
import Network.AWS.APIGateway.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateUsagePlan = CreateUsagePlan'
{ _cupApiStages :: !(Maybe [APIStage])
, _cupThrottle :: !(Maybe ThrottleSettings)
, _cupQuota :: !(Maybe QuotaSettings)
, _cupDescription :: !(Maybe Text)
, _cupName :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createUsagePlan
:: Text
-> CreateUsagePlan
createUsagePlan pName_ =
CreateUsagePlan'
{ _cupApiStages = Nothing
, _cupThrottle = Nothing
, _cupQuota = Nothing
, _cupDescription = Nothing
, _cupName = pName_
}
cupApiStages :: Lens' CreateUsagePlan [APIStage]
cupApiStages = lens _cupApiStages (\ s a -> s{_cupApiStages = a}) . _Default . _Coerce;
cupThrottle :: Lens' CreateUsagePlan (Maybe ThrottleSettings)
cupThrottle = lens _cupThrottle (\ s a -> s{_cupThrottle = a});
cupQuota :: Lens' CreateUsagePlan (Maybe QuotaSettings)
cupQuota = lens _cupQuota (\ s a -> s{_cupQuota = a});
cupDescription :: Lens' CreateUsagePlan (Maybe Text)
cupDescription = lens _cupDescription (\ s a -> s{_cupDescription = a});
cupName :: Lens' CreateUsagePlan Text
cupName = lens _cupName (\ s a -> s{_cupName = a});
instance AWSRequest CreateUsagePlan where
type Rs CreateUsagePlan = UsagePlan
request = postJSON apiGateway
response = receiveJSON (\ s h x -> eitherParseJSON x)
instance Hashable CreateUsagePlan where
instance NFData CreateUsagePlan where
instance ToHeaders CreateUsagePlan where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToJSON CreateUsagePlan where
toJSON CreateUsagePlan'{..}
= object
(catMaybes
[("apiStages" .=) <$> _cupApiStages,
("throttle" .=) <$> _cupThrottle,
("quota" .=) <$> _cupQuota,
("description" .=) <$> _cupDescription,
Just ("name" .= _cupName)])
instance ToPath CreateUsagePlan where
toPath = const "/usageplans"
instance ToQuery CreateUsagePlan where
toQuery = const mempty