deseasion.backend.resources.utils module

deseasion.backend.resources.utils.check_permission(obj)

Check if the user of the request has permissions on the object

Raises:

PermissionError if the user does not have permissions

deseasion.backend.resources.utils.check_permission_for_id(obj_class, obj_id)

Check if the user of the request has permissions on the object with the given id

Raises:

PermissionError if the user does not have permissions

deseasion.backend.resources.utils.dump_data(serializer, **kwargs)
deseasion.backend.resources.utils.get_json_content(exception=True)
deseasion.backend.resources.utils.type2openapi(type_: type | str) str

Convert python type to openAPI compliant type.

Parameters:

type

Returns:

openAPI type

deseasion.backend.resources.utils.with_query_arg(name: str, type_: str | type | None = None, required: bool = True, description: str = '', **kwargs)

Annotate operation function with openAPI parameters for query args.

Parameters:
  • name

  • type

  • required

  • description

Note

any additional keyword argument is added as is in the openAPI parameter created by this decorator

deseasion.backend.resources.utils.with_request_body(schema: Schema | Type[Schema] | list[Schema | Type[Schema]] | str = None, description: str = '', required: bool = True, content: dict = None)

Annotate operation function with openAPI requestBody.

If schema is set, it will add an application/json content with it as schema.

Parameters:
  • schema – either a schema or schema instance (for one schema) or a list of schema instances or classes (for polymorphism with response type). Can also be a string that will be used ‘as is’ for the schema reference.

  • description

  • required

  • content

deseasion.backend.resources.utils.with_response(status: int, schema: Schema | Type[Schema] | list[Schema | Type[Schema]] | str = None, description: str = '', content: dict | None = None)

Annotate operation function with openAPI response.

If schema is set, it will add an application/json content with it as schema.

Parameters:
  • status

  • schema – either a schema or schema instance (for one schema) or a list of schema instances or classes (for polymorphism with response type). Can also be a string that will be used ‘as is’ for the schema reference.

  • description

  • content