Skip to content

put_method_response async

put_method_response(
    rest_api_id: String,
    resource_id: String,
    http_method: String,
    status_code: StatusCode,
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    response_parameters: Optional[MapOfStringToBoolean] = None,
    response_models: Optional[MapOfStringToString] = None,
) -> MethodResponse

Adds a MethodResponse to an existing Method resource.

Parameters:

  • rest_api_id (String) –

    The string identifier of the associated RestApi.

  • resource_id (String) –

    The Resource identifier for the Method resource.

  • http_method (String) –

    The HTTP verb of the Method resource.

  • status_code (StatusCode) –

    The method response's status code.

  • response_parameters (Optional[MapOfStringToBoolean], default: None ) –

    A key-value map specifying required or optional response parameters that API Gateway can send back to the caller. A key defines a method response header name and the associated value is a Boolean flag indicating whether the method response parameter is required or not. The method response header names must match the pattern of method.response.header.{name}, where name is a valid and unique header name. The response parameter names defined here are available in the integration response to be mapped from an integration response header expressed in integration.response.header.{name}, a static value enclosed within a pair of single quotes (e.g., 'application/json'), or a JSON expression from the back-end response payload in the form of integration.response.body.{JSON-expression}, where JSON-expression is a valid JSON expression without the $ prefix.)

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

    Specifies the Model resources used for the response's content type. Response models are represented as a key/value map, with a content type as the key and a Model name as the value.

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_method_response(
    self,
    rest_api_id: "capo_api_gateway.types.string.String",
    resource_id: "capo_api_gateway.types.string.String",
    http_method: "capo_api_gateway.types.string.String",
    status_code: "capo_api_gateway.types.status_code.StatusCode",
    *,
    config_overrides: Optional[AsyncAPIGatewayClientConfig] = None,
    response_parameters: Optional[
        "capo_api_gateway.types.map_of_string_to_boolean.MapOfStringToBoolean"
    ] = None,
    response_models: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
) -> "capo_api_gateway.types.method_response.MethodResponse":
    """<p>Adds a MethodResponse to an existing Method resource.</p>

    Args:
        rest_api_id: <p>The string identifier of the associated RestApi.</p>
        resource_id: <p>The Resource identifier for the Method resource.</p>
        http_method: <p>The HTTP verb of the Method resource.</p>
        status_code: <p>The method response's status code.</p>
        response_parameters: <p>A key-value map specifying required or optional response parameters that API Gateway can send back to the caller. A key defines a method response header name and the associated value is a Boolean flag indicating whether the method response parameter is required or not. The method response header names must match the pattern of <code>method.response.header.{name}</code>, where <code>name</code> is a valid and unique header name. The response parameter names defined here are available in the integration response to be mapped from an integration response header expressed in <code>integration.response.header.{name}</code>, a static value enclosed within a pair of single quotes (e.g., <code>'application/json'</code>), or a JSON expression from the back-end response payload in the form of <code>integration.response.body.{JSON-expression}</code>, where <code>JSON-expression</code> is a valid JSON expression without the <code>$</code> prefix.)</p>
        response_models: <p>Specifies the Model resources used for the response's content type. Response models are represented as a key/value map, with a content type as the key and a Model name as the value.</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_method_response_request.PutMethodResponseRequest]",
    ) -> AsyncOperationResponse[
        "capo_api_gateway.types.method_response.MethodResponse"
    ]:
        import capo_api_gateway._operations.backplane_control_service.put_method_response

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutMethodResponse")
    )
    input_: capo_api_gateway.types.put_method_response_request.PutMethodResponseRequest = {
        "rest_api_id": rest_api_id,
        "resource_id": resource_id,
        "http_method": http_method,
        "status_code": status_code,
    }
    if response_parameters is not None:
        input_["response_parameters"] = response_parameters
    if response_models is not None:
        input_["response_models"] = response_models

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