amazonka-apigateway-1.4.4: gen/Network/AWS/APIGateway/PutMethod.hs
{-# 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 #-}
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- |
-- Module : Network.AWS.APIGateway.PutMethod
-- Copyright : (c) 2013-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Add a method to an existing < Resource> resource.
module Network.AWS.APIGateway.PutMethod
(
-- * Creating a Request
putMethod
, PutMethod
-- * Request Lenses
, putRequestModels
, putRequestParameters
, putAuthorizerId
, putApiKeyRequired
, putRestAPIId
, putResourceId
, putHttpMethod
, putAuthorizationType
-- * Destructuring the Response
, method
, Method
-- * Response Lenses
, mMethodResponses
, mHttpMethod
, mRequestModels
, mRequestParameters
, mAuthorizerId
, mAuthorizationType
, mApiKeyRequired
, mMethodIntegration
) 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
-- | Request to add a method to an existing < Resource> resource.
--
-- /See:/ 'putMethod' smart constructor.
data PutMethod = PutMethod'
{ _putRequestModels :: !(Maybe (Map Text Text))
, _putRequestParameters :: !(Maybe (Map Text Bool))
, _putAuthorizerId :: !(Maybe Text)
, _putApiKeyRequired :: !(Maybe Bool)
, _putRestAPIId :: !Text
, _putResourceId :: !Text
, _putHttpMethod :: !Text
, _putAuthorizationType :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'PutMethod' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'putRequestModels'
--
-- * 'putRequestParameters'
--
-- * 'putAuthorizerId'
--
-- * 'putApiKeyRequired'
--
-- * 'putRestAPIId'
--
-- * 'putResourceId'
--
-- * 'putHttpMethod'
--
-- * 'putAuthorizationType'
putMethod
:: Text -- ^ 'putRestAPIId'
-> Text -- ^ 'putResourceId'
-> Text -- ^ 'putHttpMethod'
-> Text -- ^ 'putAuthorizationType'
-> PutMethod
putMethod pRestAPIId_ pResourceId_ pHttpMethod_ pAuthorizationType_ =
PutMethod'
{ _putRequestModels = Nothing
, _putRequestParameters = Nothing
, _putAuthorizerId = Nothing
, _putApiKeyRequired = Nothing
, _putRestAPIId = pRestAPIId_
, _putResourceId = pResourceId_
, _putHttpMethod = pHttpMethod_
, _putAuthorizationType = pAuthorizationType_
}
-- | Specifies the < Model> resources used for the request\'s content type. Request models are represented as a key\/value map, with a content type as the key and a < Model> name as the value.
putRequestModels :: Lens' PutMethod (HashMap Text Text)
putRequestModels = lens _putRequestModels (\ s a -> s{_putRequestModels = a}) . _Default . _Map;
-- | A key-value map defining required or optional method request parameters that can be accepted by Amazon API Gateway. A key defines a method request parameter name matching the pattern of 'method.request.{location}.{name}', where 'location' is 'querystring', 'path', or 'header' and 'name' is a valid and unique parameter name. The value associated with the key is a Boolean flag indicating whether the parameter is required ('true') or optional ('false'). The method request parameter names defined here are available in < Integration> to be mapped to integration request parameters or body-mapping templates.
putRequestParameters :: Lens' PutMethod (HashMap Text Bool)
putRequestParameters = lens _putRequestParameters (\ s a -> s{_putRequestParameters = a}) . _Default . _Map;
-- | Specifies the identifier of an < Authorizer> to use on this Method, if the type is CUSTOM.
putAuthorizerId :: Lens' PutMethod (Maybe Text)
putAuthorizerId = lens _putAuthorizerId (\ s a -> s{_putAuthorizerId = a});
-- | Specifies whether the method required a valid < ApiKey>.
putApiKeyRequired :: Lens' PutMethod (Maybe Bool)
putApiKeyRequired = lens _putApiKeyRequired (\ s a -> s{_putApiKeyRequired = a});
-- | The < RestApi> identifier for the new < Method> resource.
putRestAPIId :: Lens' PutMethod Text
putRestAPIId = lens _putRestAPIId (\ s a -> s{_putRestAPIId = a});
-- | The < Resource> identifier for the new < Method> resource.
putResourceId :: Lens' PutMethod Text
putResourceId = lens _putResourceId (\ s a -> s{_putResourceId = a});
-- | Specifies the method request\'s HTTP method type.
putHttpMethod :: Lens' PutMethod Text
putHttpMethod = lens _putHttpMethod (\ s a -> s{_putHttpMethod = a});
-- | Specifies the type of authorization used for the method.
putAuthorizationType :: Lens' PutMethod Text
putAuthorizationType = lens _putAuthorizationType (\ s a -> s{_putAuthorizationType = a});
instance AWSRequest PutMethod where
type Rs PutMethod = Method
request = putJSON apiGateway
response = receiveJSON (\ s h x -> eitherParseJSON x)
instance Hashable PutMethod
instance NFData PutMethod
instance ToHeaders PutMethod where
toHeaders
= const
(mconcat
["Accept" =# ("application/json" :: ByteString)])
instance ToJSON PutMethod where
toJSON PutMethod'{..}
= object
(catMaybes
[("requestModels" .=) <$> _putRequestModels,
("requestParameters" .=) <$> _putRequestParameters,
("authorizerId" .=) <$> _putAuthorizerId,
("apiKeyRequired" .=) <$> _putApiKeyRequired,
Just ("authorizationType" .= _putAuthorizationType)])
instance ToPath PutMethod where
toPath PutMethod'{..}
= mconcat
["/restapis/", toBS _putRestAPIId, "/resources/",
toBS _putResourceId, "/methods/",
toBS _putHttpMethod]
instance ToQuery PutMethod where
toQuery = const mempty