def _process_resource()

in syndicate/core/transform/cloudformation/converter/cf_api_gateway_converter.py [0:0]


    def _process_resource(self, authorizers_mapping, meta, path, resource_meta, rest_api):
        if not path.startswith('/'):
            raise AssertionError(
                "API resource must starts with '/', "
                "but found {}".format(path))
        enable_cors = str(resource_meta.get('enable_cors')).lower() == 'true'
        target_resource = self._convert_resource(rest_api=rest_api,
                                                 resource_path=path)
        methods = []
        for method, method_meta in resource_meta.items():
            method_res = apigateway.Method(api_gateway_method_logic_name(path, method))
            if method == 'enable_cors' or method not in SUPPORTED_METHODS:
                continue
            authorization_type = method_meta.get('authorization_type')
            authorizer_id = None
            if authorization_type not in ['NONE', 'AWS_IAM']:
                authorizer_id = authorizers_mapping.get(
                    to_logic_name('ApiGatewayAuthorizer', authorization_type))
                if not authorizer_id:
                    raise AssertionError(
                        'Authorizer {0} is not present in '
                        'the build meta.'.format(authorization_type))
                authorization_type = 'CUSTOM'
            self._convert_request_validator(method_meta, method_res, rest_api)

            integration_type = method_meta.get('integration_type')
            integration = self._convert_method_integration(
                integration_type=integration_type,
                method=method,
                method_meta=method_meta,
                path=path,
                rest_api=rest_api)

            method_res.ApiKeyRequired = bool(method_meta.get('api_key_required'))
            method_res.AuthorizationType = authorization_type
            if authorizer_id:
                method_res.AuthorizerId = authorizer_id
            method_res.HttpMethod = method
            if integration:
                method_res.Integration = integration
            if method_meta.get('method_request_models'):
                method_res.RequestModels = method_meta.get('method_request_models')
            if method_meta.get('method_request_parameters'):
                method_res.RequestParameters = method_meta.get('method_request_parameters')
            method_res.ResourceId = Ref(target_resource)
            method_res.RestApiId = Ref(rest_api)
            self.template.add_resource(method_res)

            responses = self._convert_method_responses(enable_cors, meta, method_meta)
            method_res.MethodResponses = responses

            integration_responses = self._convert_integration_responses(enable_cors, meta, method_meta)
            integration.IntegrationResponses = integration_responses
            methods.append(method_res)
        if enable_cors:
            methods.append(self._enable_cors_for_resource(rest_api, path, target_resource))
        return methods