Skip to content

put_rest_api async

put_rest_api(
    rest_api_id: String,
    body: Blob,
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    mode: Optional[PutMode] = None,
    fail_on_warnings: Optional[Boolean] = None,
    parameters: Optional[MapOfStringToString] = None,
) -> RestApi

A feature of the API Gateway control service for updating an existing API with an input of external API definitions. The update can take the form of merging the supplied definition into the existing API or overwriting the existing API.

Parameters:

  • rest_api_id (String) –

    The string identifier of the associated RestApi.

  • mode (Optional[PutMode], default: None ) –

    The mode query parameter to specify the update mode. Valid values are "merge" and "overwrite". By default, the update mode is "merge".

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

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

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

    Custom header parameters as part of the request. For example, to exclude DocumentationParts from an imported API, set ignore=documentation as a parameters value, as in the AWS CLI command of aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'.

  • body (Blob) –

    The PUT 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/async_api_gateway.py
async def put_rest_api(
    self,
    rest_api_id: "capo_api_gateway.types.string.String",
    body: "capo_api_gateway.types.blob.Blob",
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    mode: Optional["capo_api_gateway.types.put_mode.PutMode"] = 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 updating an existing API with an input of external API definitions. The update can take the form of merging the supplied definition into the existing API or overwriting the existing API.</p>

    Args:
        rest_api_id: <p>The string identifier of the associated RestApi.</p>
        mode: <p>The <code>mode</code> query parameter to specify the update mode. Valid values are "merge" and "overwrite". By default, the update mode is "merge".</p>
        fail_on_warnings: <p>A query parameter to indicate whether to rollback the API update (<code>true</code>) or not (<code>false</code>) when a warning is encountered. The default value is <code>false</code>.</p>
        parameters: <p>Custom header parameters as part of the request. For example, to exclude DocumentationParts from an imported API, set <code>ignore=documentation</code> as a <code>parameters</code> value, as in the AWS CLI command of <code>aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json'</code>.</p>
        body: <p>The PUT 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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_api_gateway.types.put_rest_api_request.PutRestApiRequest]",
    ) -> AsyncOperationResponse["capo_api_gateway.types.rest_api.RestApi"]:
        import capo_api_gateway._operations.backplane_control_service.put_rest_api

        (
            output,
            http_response,
        ) = await capo_api_gateway._operations.backplane_control_service.put_rest_api.async_put_rest_api(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutRestApi")
    )
    input_: capo_api_gateway.types.put_rest_api_request.PutRestApiRequest = {
        "rest_api_id": rest_api_id,
        "body": body,
    }
    if mode is not None:
        input_["mode"] = mode
    if fail_on_warnings is not None:
        input_["fail_on_warnings"] = fail_on_warnings
    if parameters is not None:
        input_["parameters"] = parameters

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output