Skip to content

test_invoke_method

test_invoke_method(
    rest_api_id: String,
    resource_id: String,
    http_method: String,
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    path_with_query_string: Optional[String] = None,
    body: Optional[String] = None,
    headers: Optional[MapOfStringToString] = None,
    multi_value_headers: Optional[MapOfStringToList] = None,
    client_certificate_id: Optional[String] = None,
    stage_variables: Optional[MapOfStringToString] = None,
) -> TestInvokeMethodResponse

Simulate the invocation of a Method in your RestApi with headers, parameters, and an incoming request body.

Parameters:

  • rest_api_id (String) –

    The string identifier of the associated RestApi.

  • resource_id (String) –

    Specifies a test invoke method request's resource ID.

  • http_method (String) –

    Specifies a test invoke method request's HTTP method.

  • path_with_query_string (Optional[String], default: None ) –

    The URI path, including query string, of the simulated invocation request. Use this to specify path parameters and query string parameters.

  • body (Optional[String], default: None ) –

    The simulated request body of an incoming invocation request.

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

    A key-value map of headers to simulate an incoming invocation request.

  • multi_value_headers (Optional[MapOfStringToList], default: None ) –

    The headers as a map from string to list of values to simulate an incoming invocation request.

  • client_certificate_id (Optional[String], default: None ) –

    A ClientCertificate identifier to use in the test invocation. API Gateway will use the certificate when making the HTTPS request to the defined back-end endpoint.

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

    A key-value map of stage variables to simulate an invocation on a deployed Stage.

Raises:

  • BadRequestException –

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

  • 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 test_invoke_method(
    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",
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    path_with_query_string: Optional["capo_api_gateway.types.string.String"] = None,
    body: Optional["capo_api_gateway.types.string.String"] = None,
    headers: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
    multi_value_headers: Optional[
        "capo_api_gateway.types.map_of_string_to_list.MapOfStringToList"
    ] = None,
    client_certificate_id: Optional["capo_api_gateway.types.string.String"] = None,
    stage_variables: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
) -> "capo_api_gateway.types.test_invoke_method_response.TestInvokeMethodResponse":
    """<p>Simulate the invocation of a Method in your RestApi with headers, parameters, and an incoming request body.</p>

    Args:
        rest_api_id: <p>The string identifier of the associated RestApi.</p>
        resource_id: <p>Specifies a test invoke method request's resource ID.</p>
        http_method: <p>Specifies a test invoke method request's HTTP method.</p>
        path_with_query_string: <p>The URI path, including query string, of the simulated invocation request. Use this to specify path parameters and query string parameters.</p>
        body: <p>The simulated request body of an incoming invocation request.</p>
        headers: <p>A key-value map of headers to simulate an incoming invocation request.</p>
        multi_value_headers: <p>The headers as a map from string to list of values to simulate an incoming invocation request.</p>
        client_certificate_id: <p>A ClientCertificate identifier to use in the test invocation. API Gateway will use the certificate when making the HTTPS request to the defined back-end endpoint.</p>
        stage_variables: <p>A key-value map of stage variables to simulate an invocation on a deployed Stage.</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.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.test_invoke_method_request.TestInvokeMethodRequest]",
    ) -> OperationResponse[
        "capo_api_gateway.types.test_invoke_method_response.TestInvokeMethodResponse"
    ]:
        import capo_api_gateway._operations.backplane_control_service.test_invoke_method

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TestInvokeMethod")
    )
    input_: capo_api_gateway.types.test_invoke_method_request.TestInvokeMethodRequest = {
        "rest_api_id": rest_api_id,
        "resource_id": resource_id,
        "http_method": http_method,
    }
    if path_with_query_string is not None:
        input_["path_with_query_string"] = path_with_query_string
    if body is not None:
        input_["body"] = body
    if headers is not None:
        input_["headers"] = headers
    if multi_value_headers is not None:
        input_["multi_value_headers"] = multi_value_headers
    if client_certificate_id is not None:
        input_["client_certificate_id"] = client_certificate_id
    if stage_variables is not None:
        input_["stage_variables"] = stage_variables

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