The zaqar.common.api.api module

class Api

Bases: object

get_schema(action)

Returns the schema for an action

Parameters:action (six.text_type) – Action for which params need to be validated.
Returns:Action’s schema
Return type:dict
Raises:errors.InvalidAction if the action does not exist
schema = {}
validate(action, body)

Validates the request data

This method relies on jsonschema and exists just as a way for third-party transport to validate the request. It’s not recommended to validate every request since they are already validated server side.

Parameters:
  • action (six.text_type) – Action’s for which body need to be validated.
  • body (dict) – Params to validate
Returns:

True if the schema is valid, False otherwise

Raises:

errors.InvalidAction if the action does not exist

validators = {}