in samtranslator/model/api/api_generator.py [0:0]
def _construct_rest_api(self) -> ApiGatewayRestApi:
"""Constructs and returns the ApiGateway RestApi.
:returns: the RestApi to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayRestApi
"""
self._validate_properties()
rest_api = ApiGatewayRestApi(self.logical_id, depends_on=self.depends_on, attributes=self.resource_attributes)
# NOTE: For backwards compatibility we need to retain BinaryMediaTypes on the CloudFormation Property
# Removing this and only setting x-amazon-apigateway-binary-media-types results in other issues.
rest_api.BinaryMediaTypes = self.binary_media
rest_api.MinimumCompressionSize = self.minimum_compression_size
if self.endpoint_configuration:
self._set_endpoint_configuration(rest_api, self.endpoint_configuration)
elif not RegionConfiguration.is_apigw_edge_configuration_supported():
# Since this region does not support EDGE configuration, we explicitly set the endpoint type
# to Regional which is the only supported config.
self._set_endpoint_configuration(rest_api, "REGIONAL")
self._add_cors()
self._add_auth()
self._add_gateway_responses()
self._add_binary_media_types()
self._add_models()
if self.fail_on_warnings:
rest_api.FailOnWarnings = self.fail_on_warnings
if self.disable_execute_api_endpoint is not None:
self._add_endpoint_extension()
if self.definition_uri:
rest_api.BodyS3Location = self._construct_body_s3_dict()
elif self.definition_body:
# # Post Process OpenApi Auth Settings
self.definition_body = self._openapi_postprocess(self.definition_body)
rest_api.Body = self.definition_body
if self.name:
rest_api.Name = self.name
if self.description:
rest_api.Description = self.description
if self.mode:
rest_api.Mode = self.mode
if self.api_key_source_type:
rest_api.ApiKeySourceType = self.api_key_source_type
if self.policy:
rest_api.Policy = self.policy
return rest_api