ironic.api.validation package

Submodules

Module contents

API request/response validating middleware.

class ironic.api.validation.Schemas[source]

Bases: object

A microversion-aware schema container.

Allow definition and retrieval of schemas on a microversion-aware basis.

__call__() dict[str, object] | None[source]

Call self as a function.

add_schema(schema: tuple[dict[str, object]], min_version: int | None, max_version: int | None) None[source]
ironic.api.validation.api_version(min_version: int | None, max_version: int | None = None, message: str | None = None, exception_class: ~typing.Type[~webob.exc.HTTPException] = <class 'webob.exc.HTTPNotFound'>)[source]

Decorator for marking lower and upper bounds on API methods.

Parameters:
  • min_version – An integer representing the minimum API version that the API is available under.

  • max_version – An integer representing the maximum API version that the API is available under.

  • message – A message to return if the API is not supported.

  • exception_class – The exception class to raise if the API version is not supported (default is HTTPNotFound).

ironic.api.validation.request_body_schema(schema: Dict[str, Any], min_version: str | None = None, max_version: str | None = None)[source]

Decorator for registering a request body schema on API methods.

schema will be used for validating the request body just before the API method is executed.

Parameters:
  • schema – The JSON Schema schema used to validate the target.

  • min_version – A string indicating the minimum API version schema applies against.

  • max_version – A string indicating the maximum API version schema applies against.

ironic.api.validation.request_parameter_schema(schema: Dict[str, Any], min_version: int | None = None, max_version: int | None = None)[source]

Decorator for registering a request parameter schema on API methods.

schema will be used for validating request parameters just before the API method is executed.

Parameters:
  • schema – The JSON Schema schema used to validate the target.

  • min_version – An integer indicating the minimum API version schema applies against.

  • max_version – An integer indicating the maximum API version schema applies against.

ironic.api.validation.request_query_schema(schema: Dict[str, Any], min_version: int | None = None, max_version: int | None = None)[source]

Decorator for registering a request query string schema on API methods.

schema will be used for validating request query strings just before the API method is executed.

Parameters:
  • schema – The JSON Schema schema used to validate the target.

  • min_version – An integer indicating the minimum API version schema applies against.

  • max_version – An integer indicating the maximum API version schema applies against.

ironic.api.validation.response_body_schema(schema: Dict[str, Any], min_version: str | None = None, max_version: str | None = None)[source]

Decorator for registering a response body schema on API methods.

schema will be used for validating the response body just after the API method is executed.

Parameters:
  • schema – The JSON Schema schema used to validate the target.

  • min_version – A string indicating the minimum API version schema applies against.

  • max_version – A string indicating the maximum API version schema applies against.