Share via


RestApiOperation Class

RestApiOperation.

Note: This class is marked as 'experimental' and may change in the future.

Initialize the RestApiOperation.

Constructor

RestApiOperation(id: str, method: str, servers: list[dict[str, Any]], path: str, summary: str | None = None, description: str | None = None, params: list[RestApiParameter] | None = None, request_body: RestApiPayload | None = None, responses: dict[str, RestApiExpectedResponse] | None = None, security_requirements: list[RestApiSecurityRequirement] | None = None)

Parameters

Name Description
id
Required
method
Required
servers
Required
path
Required
summary
Default value: None
description
Default value: None
params
Default value: None
request_body
Default value: None
responses
Default value: None
security_requirements
Default value: None

Methods

build_headers

Build the headers for the operation.

build_operation_url

Build the URL for the operation.

build_path

Build the path for the operation.

build_query_string

Build the query string for the operation.

create_content_type_artificial_parameter

Create an artificial parameter for the content type of the REST API request body.

create_payload_artificial_parameter

Create an artificial parameter for the REST API request body.

freeze

Make the instance and its components immutable.

get_default_response

Get the default response for the operation.

If no appropriate response is found, returns None.

get_default_return_parameter

Get the default return parameter for the operation.

get_parameters

Get the parameters for the operation.

get_payload_parameters

Get the payload parameters for the operation.

get_server_url

Get the server URL for the operation.

replace_invalid_symbols

Replace invalid symbols in the parameter name with underscores.

url_join

Join a base URL and a path, correcting for any missing slashes.

build_headers

Build the headers for the operation.

build_headers(arguments: dict[str, Any]) -> dict[str, str]

Parameters

Name Description
arguments
Required

build_operation_url

Build the URL for the operation.

build_operation_url(arguments, server_url_override=None, api_host_url=None)

Parameters

Name Description
arguments
Required
server_url_override
Default value: None
api_host_url
Default value: None

build_path

Build the path for the operation.

build_path(path_template: str, arguments: dict[str, Any]) -> str

Parameters

Name Description
path_template
Required
arguments
Required

build_query_string

Build the query string for the operation.

build_query_string(arguments: dict[str, Any]) -> str

Parameters

Name Description
arguments
Required

create_content_type_artificial_parameter

Create an artificial parameter for the content type of the REST API request body.

create_content_type_artificial_parameter() -> RestApiParameter

create_payload_artificial_parameter

Create an artificial parameter for the REST API request body.

create_payload_artificial_parameter(operation: RestApiOperation) -> RestApiParameter

Parameters

Name Description
operation
Required

freeze

Make the instance and its components immutable.

freeze()

get_default_response

Get the default response for the operation.

If no appropriate response is found, returns None.

get_default_response(responses: dict[str, RestApiExpectedResponse], preferred_responses: list[str]) -> RestApiExpectedResponse | None

Parameters

Name Description
responses
Required
preferred_responses
Required

get_default_return_parameter

Get the default return parameter for the operation.

get_default_return_parameter(preferred_responses: list[str] | None = None) -> KernelParameterMetadata

Parameters

Name Description
preferred_responses
Default value: None

get_parameters

Get the parameters for the operation.

get_parameters(operation: RestApiOperation, add_payload_params_from_metadata: bool = True, enable_payload_spacing: bool = False) -> list[RestApiParameter]

Parameters

Name Description
operation
Required
add_payload_params_from_metadata
Default value: True
enable_payload_spacing
Default value: False

get_payload_parameters

Get the payload parameters for the operation.

get_payload_parameters(operation: RestApiOperation, use_parameters_from_metadata: bool, enable_namespacing: bool)

Parameters

Name Description
operation
Required
use_parameters_from_metadata
Required
enable_namespacing
Required

get_server_url

Get the server URL for the operation.

get_server_url(server_url_override=None, api_host_url=None, arguments=None)

Parameters

Name Description
server_url_override
Default value: None
api_host_url
Default value: None
arguments
Default value: None

replace_invalid_symbols

Replace invalid symbols in the parameter name with underscores.

replace_invalid_symbols(parameter_name)

Parameters

Name Description
parameter_name
Required

url_join

Join a base URL and a path, correcting for any missing slashes.

url_join(base_url: str, path: str)

Parameters

Name Description
base_url
Required
path
Required

Attributes

description

Get the description of the operation.

id

Get the ID of the operation.

method

Get the method of the operation.

parameters

Get the parameters of the operation.

path

Get the path of the operation.

request_body

Get the request body of the operation.

responses

Get the responses of the operation.

security_requirements

Get the security requirements of the operation.

servers

Get the servers of the operation.

summary

Get the summary of the operation.

CONTENT_TYPE_ARGUMENT_NAME

CONTENT_TYPE_ARGUMENT_NAME = 'content-type'

INVALID_SYMBOLS_REGEX

INVALID_SYMBOLS_REGEX = re.compile('[^0-9A-Za-z_]+')

MEDIA_TYPE_TEXT_PLAIN

MEDIA_TYPE_TEXT_PLAIN = 'text/plain'

PAYLOAD_ARGUMENT_NAME

PAYLOAD_ARGUMENT_NAME = 'payload'

is_experimental

is_experimental = True

stage_status

stage_status = 'experimental'