ourobori.apps package¶
Subpackages¶
Submodules¶
ourobori.apps.http module¶
This module contains functions required to create
the app.py
for your own http-service based on ourobori.
-
ourobori.apps.http.
run_service
(*, routes, rules, swagger_definition=None, middlewares=None, options=None, dependencies=None)[source]¶ Creates and runs the service passed as
service_class
based on the passedrules
combined with the passedoptions
and with themiddlewares
. Ifauth
flag is passed as argument the service uses basic-authentication based onrules.auth
.Parameters: - routes – The routes for the service to run.
- rules – The servicerules
Rules
from the rules.py - swagger_definition – The path to the swagger_definition-file.
- middlewares – The middlewares to use. As default
ourobori.apps.middlewares.error_middleware()
is used. - options – The options for the service. As default the options are build
using
ourobori.apps.options.build_arguments()
. - dependencies – List of the dependencies of the service.
Return type: _Noreturn
ourobori.apps.middlewares module¶
This module contains the basic middlewares to be used (passed to
ourobori.apps.http.run_service()
) in the service.py
of your own
service based on ourobori.
-
ourobori.apps.middlewares.
error_middleware
(app, handler)[source]¶ Middleware to handle the errors occuring in the service. The handler defined inside handles different exception-cases as default. Additional error-handling has to be defined inside the service rules in
Rules.handle_exceptions
. The exceptions defined there have to inherit fromourobori.services.errors.BaseException
to be handled automatically by this error_middleware.Parameters: - app – The application serving the apis
- handler – The handler for the requested api
ourobori.apps.options module¶
This module contains the functions
(ourobori.apps.options.build_arguments()
) to create the
basic-service-arguments and helper-functions to be used for your own
argument-definitions (ourobori.apps.options.add_param()
and
ourobori.apps.options.add_flag()
).
These functions are used in your app.py
to build the options to be passed
to the ourobori.apps.http.run_service()
.
-
ourobori.apps.options.
add_flag
(*, parser, flag, help_str=None)[source]¶ Function to be used to add additional flag to an
ArgumentParser
-instance.Note
This function modifies the passed
parser
.Parameters: - parser – The ArgumentParser-instance to add the flag
- flag – The name for the flag
- help_str – Optional adding the help-string for the param
Return type: _Noreturn
-
ourobori.apps.options.
add_param
(*, parser, short, name, param_type, default=None, choices=None, help_str=None)[source]¶ Function to be used to add additional argument to an
ArgumentParser
-instance.Note
This function modifies the passed
parser
.Parameters: - parser – The ArgumentParser to add the param
- short – Short name for the param
- name – Full name for the param
- param_type – The type of the param
- default – Optional setting the default-value to use for this param
- choices – Optional setting the choices for the possible values of the param
- help_str – Optional adding the help-string for the param
Return type: _Noreturn
-
ourobori.apps.options.
build_arguments
(parser=None)[source]¶ Builds the default arguments for a service. To use additional arguments create a ArgumentParser add your arguments using the functions
add_param()
oradd_flag()
and pass the resulting parser-object to this function.Parameters: parser – Optional passed parser containing additional arguments Returns: The parsed arguments parsed as Namespace-object Return type: args