Skip to content

import_rest_api

import_rest_api(
    body: Blob,
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    fail_on_warnings: Optional[Boolean] = None,
    parameters: Optional[MapOfStringToString] = None,
) -> RestApi

A feature of the API Gateway control service for creating a new API from an external API definition file.

Parameters:

  • fail_on_warnings (Optional[Boolean], default: None ) –

    A query parameter to indicate whether to rollback the API creation (true) or not (false) when a warning is encountered. The default value is false.

  • parameters (Optional[MapOfStringToString], default: None ) –

    A key-value map of context-specific query string parameters specifying the behavior of different API importing operations. The following shows operation-specific parameters and their supported values.

    To exclude DocumentationParts from the import, set parameters as ignore=documentation.

    To configure the endpoint type, set parameters as endpointConfigurationTypes=EDGE, endpointConfigurationTypes=REGIONAL, or endpointConfigurationTypes=PRIVATE. The default endpoint type is EDGE.

    To handle imported basepath, set parameters as basepath=ignore, basepath=prepend or basepath=split.

  • body (Blob) –

    The POST request body containing external API definitions. Currently, only OpenAPI definition JSON/YAML files are supported. The maximum size of the API definition file is 6MB.

Raises:

  • BadRequestException –

    The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.

  • ConflictException –

    The request configuration has conflicts. For details, see the accompanying error message.

  • LimitExceededException –

    The request exceeded the rate limit. Retry after the specified time period.

  • NotFoundException –

    The requested resource is not found. Make sure that the request URI is correct.

  • TooManyRequestsException –

    The request has reached its throttling limit. Retry after the specified time period.

  • UnauthorizedException –

    The request is denied because the caller has insufficient permissions.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_api_gateway/_services/api_gateway.py
def import_rest_api(
    self,
    body: "capo_api_gateway.types.blob.Blob",
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    fail_on_warnings: Optional["capo_api_gateway.types.boolean.Boolean"] = None,
    parameters: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
) -> "capo_api_gateway.types.rest_api.RestApi":
    """<p>A feature of the API Gateway control service for creating a new API from an external API definition file.</p>

    Args:
        fail_on_warnings: <p>A query parameter to indicate whether to rollback the API creation (<code>true</code>) or not (<code>false</code>) when a warning is encountered. The default value is <code>false</code>.</p>
        parameters: <p>A key-value map of context-specific query string parameters specifying the behavior of different API importing operations. The following shows operation-specific parameters and their supported values.</p> <p> To exclude DocumentationParts from the import, set <code>parameters</code> as <code>ignore=documentation</code>.</p> <p> To configure the endpoint type, set <code>parameters</code> as <code>endpointConfigurationTypes=EDGE</code>, <code>endpointConfigurationTypes=REGIONAL</code>, or <code>endpointConfigurationTypes=PRIVATE</code>. The default endpoint type is <code>EDGE</code>.</p> <p> To handle imported <code>basepath</code>, set <code>parameters</code> as <code>basepath=ignore</code>, <code>basepath=prepend</code> or <code>basepath=split</code>.</p>
        body: <p>The POST request body containing external API definitions. Currently, only OpenAPI definition JSON/YAML files are supported. The maximum size of the API definition file is 6MB.</p>

    Raises:
        capo_api_gateway.errors.bad_request_exception.BadRequestException: <p>The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.</p>
        capo_api_gateway.errors.conflict_exception.ConflictException: <p>The request configuration has conflicts. For details, see the accompanying error message.</p>
        capo_api_gateway.errors.limit_exceeded_exception.LimitExceededException: <p>The request exceeded the rate limit. Retry after the specified time period.</p>
        capo_api_gateway.errors.not_found_exception.NotFoundException: <p>The requested resource is not found. Make sure that the request URI is correct.</p>
        capo_api_gateway.errors.too_many_requests_exception.TooManyRequestsException: <p>The request has reached its throttling limit. Retry after the specified time period.</p>
        capo_api_gateway.errors.unauthorized_exception.UnauthorizedException: <p>The request is denied because the caller has insufficient permissions.</p>
        capo_api_gateway.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_api_gateway.types.import_rest_api_request.ImportRestApiRequest]",
    ) -> OperationResponse["capo_api_gateway.types.rest_api.RestApi"]:
        import capo_api_gateway._operations.backplane_control_service.import_rest_api

        output, http_response = (
            capo_api_gateway._operations.backplane_control_service.import_rest_api.import_rest_api(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ImportRestApi")
    )
    input_: capo_api_gateway.types.import_rest_api_request.ImportRestApiRequest = {
        "body": body
    }
    if fail_on_warnings is not None:
        input_["fail_on_warnings"] = fail_on_warnings
    if parameters is not None:
        input_["parameters"] = parameters

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output