Skip to content

test_invoke_authorizer

test_invoke_authorizer(
    rest_api_id: String,
    authorizer_id: String,
    *,
    config_overrides: Optional[APIGatewayClientConfig] = None,
    headers: Optional[MapOfStringToString] = None,
    multi_value_headers: Optional[MapOfStringToList] = None,
    path_with_query_string: Optional[String] = None,
    body: Optional[String] = None,
    stage_variables: Optional[MapOfStringToString] = None,
    additional_context: Optional[MapOfStringToString] = None,
) -> TestInvokeAuthorizerResponse

Simulate the execution of an Authorizer in your RestApi with headers, parameters, and an incoming request body.

Parameters:

  • rest_api_id (String) –

    The string identifier of the associated RestApi.

  • authorizer_id (String) –

    Specifies a test invoke authorizer request's Authorizer ID.

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

    A key-value map of headers to simulate an incoming invocation request. This is where the incoming authorization token, or identity source, should be specified.

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

    The headers as a map from string to list of values to simulate an incoming invocation request. This is where the incoming authorization token, or identity source, may be specified.

  • 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.

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

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

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

    A key-value map of additional context variables.

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_authorizer(
    self,
    rest_api_id: "capo_api_gateway.types.string.String",
    authorizer_id: "capo_api_gateway.types.string.String",
    *,
    config_overrides: Optional[APIGatewayClientConfig] = 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,
    path_with_query_string: Optional["capo_api_gateway.types.string.String"] = None,
    body: Optional["capo_api_gateway.types.string.String"] = None,
    stage_variables: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
    additional_context: Optional[
        "capo_api_gateway.types.map_of_string_to_string.MapOfStringToString"
    ] = None,
) -> "capo_api_gateway.types.test_invoke_authorizer_response.TestInvokeAuthorizerResponse":
    """<p>Simulate the execution of an Authorizer 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>
        authorizer_id: <p>Specifies a test invoke authorizer request's Authorizer ID.</p>
        headers: <p>A key-value map of headers to simulate an incoming invocation request. This is where the incoming authorization token, or identity source, should be specified.</p>
        multi_value_headers: <p>The headers as a map from string to list of values to simulate an incoming invocation request. This is where the incoming authorization token, or identity source, may be specified.</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>
        stage_variables: <p>A key-value map of stage variables to simulate an invocation on a deployed Stage.</p>
        additional_context: <p>A key-value map of additional context variables.</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_authorizer_request.TestInvokeAuthorizerRequest]",
    ) -> OperationResponse[
        "capo_api_gateway.types.test_invoke_authorizer_response.TestInvokeAuthorizerResponse"
    ]:
        import capo_api_gateway._operations.backplane_control_service.test_invoke_authorizer

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TestInvokeAuthorizer")
    )
    input_: capo_api_gateway.types.test_invoke_authorizer_request.TestInvokeAuthorizerRequest = {
        "rest_api_id": rest_api_id,
        "authorizer_id": authorizer_id,
    }
    if headers is not None:
        input_["headers"] = headers
    if multi_value_headers is not None:
        input_["multi_value_headers"] = multi_value_headers
    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 stage_variables is not None:
        input_["stage_variables"] = stage_variables
    if additional_context is not None:
        input_["additional_context"] = additional_context

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