#NEWLINE# def create_and_setup_methods( self , api_id , resource_id , lambda_arn , report_progress ) : #NEWLINE# #INDENT# "\n        Sets up the methods, integration responses and method responses for a given API Gateway resource.\n\n        Returns the given API's resource_id.\n\n        " #NEWLINE# client = self . boto_session . client ( 'apigateway' ) #NEWLINE# for method in self . http_methods : #NEWLINE# #INDENT# response = client . put_method ( restApiId = api_id , resourceId = resource_id , httpMethod = method , authorizationType = 'none' , apiKeyRequired = False ) #NEWLINE# report_progress ( ) #NEWLINE# template_mapping = TEMPLATE_MAPPING #NEWLINE# post_template_mapping = POST_TEMPLATE_MAPPING #NEWLINE# form_encoded_template_mapping = FORM_ENCODED_TEMPLATE_MAPPING #NEWLINE# content_mapping_templates = { #NEWLINE# #INDENT# 'application/json' : template_mapping , #NEWLINE# 'application/x-www-form-urlencoded' : post_template_mapping , #NEWLINE# 'multipart/form-data' : form_encoded_template_mapping , #NEWLINE# #UNINDENT# } #NEWLINE# credentials = self . credentials_arn #NEWLINE# uri = ( ( ( ( 'arn:aws:apigateway:' + self . boto_session . region_name ) + ':lambda:path/2015-03-31/functions/' ) + lambda_arn ) + '/invocations' ) #NEWLINE# client . put_integration ( restApiId = api_id , resourceId = resource_id , httpMethod = method . upper ( ) , type = 'AWS' , integrationHttpMethod = 'POST' , uri = uri , credentials = credentials , requestParameters = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , requestTemplates = content_mapping_templates , cacheNamespace = 'none' , cacheKeyParameters = [ ] ) #NEWLINE# report_progress ( ) #NEWLINE# for response in self . method_response_codes : #NEWLINE# #INDENT# status_code = str ( response ) #NEWLINE# response_parameters = { ( 'method.response.header.' + header_type ) : False for header_type in self . method_header_types } #NEWLINE# response_models = { content_type : 'Empty' for content_type in self . method_content_types } #NEWLINE# method_response = client . put_method_response ( restApiId = api_id , resourceId = resource_id , httpMethod = method , statusCode = status_code , responseParameters = response_parameters , responseModels = response_models ) #NEWLINE# report_progress ( ) #NEWLINE# #UNINDENT# for response in self . integration_response_codes : #NEWLINE# #INDENT# status_code = str ( response ) #NEWLINE# response_parameters = { ( 'method.response.header.' + header_type ) : ( 'integration.response.body.' + header_type ) for header_type in self . method_header_types } #NEWLINE# if ( status_code == '200' ) : #NEWLINE# #INDENT# response_templates = { content_type : RESPONSE_TEMPLATE for content_type in self . integration_content_types } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( status_code in [ '301' , '302' ] ) : #NEWLINE# #INDENT# response_templates = { content_type : REDIRECT_RESPONSE_TEMPLATE for content_type in self . integration_content_types } #NEWLINE# response_parameters [ 'method.response.header.Location' ] = 'integration.response.body.errorMessage' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# response_templates = { content_type : ERROR_RESPONSE_TEMPLATE for content_type in self . integration_content_types } #NEWLINE# #UNINDENT# #UNINDENT# integration_response = client . put_integration_response ( restApiId = api_id , resourceId = resource_id , httpMethod = method , statusCode = status_code , selectionPattern = self . selection_pattern ( status_code ) , responseParameters = response_parameters , responseTemplates = response_templates ) #NEWLINE# report_progress ( ) #NEWLINE# #UNINDENT# #UNINDENT# return resource_id