api.common package

Submodules

api.common.base module

class api.common.base.Api(app=None, prefix='', default_mediatype='application/json', decorators=None, catch_all_404s=False, serve_challenge_on_401=False, url_part_order='bae', errors=None)[source]

Bases: flask_restful.Api

Class extending the capabilities of the Flask-Restful API class

error_router(original_handler, e)[source]

Overrides error_router to custom errors/ webargs parsing errors

api.common.errors module

api.common.errors.generate_error(error, status_code, message=None)[source]

Generates an error message formatted for the error handlers.

Parameters
  • error (object) – error object

  • status_code (int) – HTTP status code

  • message (str, optional) – message, defaults to None

Returns

jsonified response

Return type

Response

api.common.errors.handle_400_errors(error)[source]

Handles 400 errors in resources

api.common.errors.handle_404_errors(error)[source]

Handles 404 errors in resources

api.common.errors.handle_server_errors(error)[source]

Handles all internal server errors

api.common.errors.register_errors(app)[source]

Registers the application errors

api.common.errors.register_errors_from_third_parties(app, third_party_errors=None)[source]

Registers the client-side errors from third parties

api.common.identifiers module

api.common.identifiers.get_identifier()[source]

Return a unique identifier

api.common.logging module

api.common.logging.configure_logging(app)[source]

Configures the API logging

api.common.logging.get_application_logger(app=None)[source]

Gets the application logger

api.common.logging.get_loggable_object(instance, identifier)[source]

Returns the loggable request/response objects

api.common.logging.get_logger(name, propagate=False)[source]

Gets the basic logger with the specified name and the propagation rule.

Parameters
  • name (str) – name of the logger

  • propagate (bool, optional) – logger propagation, defaults to False

Returns

Logger instance

Return type

<object>

api.common.logging.get_request_logger()[source]

Gets the request logger

api.common.logging.get_response_logger()[source]

Gets the response logger

api.common.logging.set_application_logger(app)[source]

Sets the application logger

api.common.utilities module

api.common.utilities.measure_runtime(method)[source]

Decorator that measures the runtime of the <method>.

Parameters

method (callable) – method to decorate

Returns

decorated method

Return type

<method>

Module contents