# Path: alignak_backend/app.py
# class MyTokenAuth(TokenAuth):
# class MyValidator(Validator):
#     def check_auth(self, token, allowed_roles, resource, method):
#     def add_resources_realms(self, right, data, custom, resource, resource_list, parents=None):
#     def _validate_skill_level(self, skill_level, field, value):
#     def _validate_title(self, title, field, value):
#     def _validate_comment(self, comment, field, value):
#     def _validate_schema_version(self, schema_version, field, value):
# def notify_alignak(event=None, parameters=None, notification=None):
# def pre_get(resource, user_request, lookup):
# def pre_post(resource, user_request):
# def pre_patch(resource, user_request, lookup):
# def pre_delete(resource, user_request, lookup):
# def pre_hostescalation_post(items):
# def pre_serviceescalation_post(items):
# def pre_history_post(items):
# def pre_logcheckresult_post(items):
# def after_insert_logcheckresult(items):
# def pre_post_action_right(actrequestp):
# def pre_submit_action_right(actrequest, lookup):
# def pre_actionacknowledge_post(items):
# def after_insert_actionacknowledge(items):
# def after_update_actionacknowledge(updated, original):
# def pre_actiondowntime_post(items):
# def after_insert_actiondowntime(items):
# def after_update_actiondowntime(updated, original):
# def pre_actionforcecheck_post(items):
# def after_insert_actionforcecheck(items):
# def after_update_actionforcecheck(updated, original):
# def pre_hostgroup_post(items):
# def pre_hostgroup_patch(updates, original):
# def pre_servicegroup_post(items):
# def pre_servicegroup_patch(updates, original):
# def pre_usergroup_post(items):
# def pre_usergroup_patch(updates, original):
# def pre_timeseries_post(items):
# def pre_realm_post(items):
# def pre_realm_patch(updates, original):
# def after_insert_realm(items):
# def after_update_realm(updated, original):
# def pre_delete_realm(item):
# def after_delete_realm(item):
# def after_delete_resource_realm():
# def pre_delete_host(item):
# def after_delete_host(item):
# def pre_alignak_patch(updates, original):
# def pre_host_patch(updates, original):
# def after_insert_host(items):
# def pre_service_patch(updates, original):
# def after_insert_service(items):
# def update_etag(myrequest, payload):
# def after_updated_service(updated, original):
# def pre_user_post(items):
# def pre_user_patch(updates, original):
# def after_insert_user(items):
# def pre_service_post(items):
# def keep_default_items_resource(resource, delete_request, lookup):
# def keep_default_items_item(resource, item):
# def on_fetched_resource_tree(resource_name, response):
# def on_fetched_item_tree(resource_name, itemresp):
# def pre_post_alias(resource_name, items):
# def generate_token():
# def get_settings(prev_settings):
#     def log_endpoint(_resource, _request, _payload):  # pylint: disable=unused-argument
# def login_app():  # pylint: disable=inconsistent-return-statements
# def logout_app():
# def backend_config():
# def backend_version():
# def cron_alignak():
# def cron_timeseries():
#     def get_grafana_configuration(cfg_file_name, queries):
#     def grafana_search(engine='jsonify'):
#     def grafana_query(engine='jsonify'):
#     def after_request(response):
#     def grafana_annotations(engine='jsonify'):
# def cron_grafana(engine='jsonify'):
# def cron_livesynthesis_history():
# def redir_index():
# def index(path):
# def main():


from alignak_backend.app import app, manifest
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main
"""
from __future__ import print_function



def main():  # pragma: no cover - tested but not covered
    """Main function to run the alignak backend

    This function is used by the `alignak-backend` script installed with setup.py.
    It is intended to run the backend in a single process mode. This mode is not
    recommended for production but may be useful in development to avoid setting-up
    an uWSGI server.
    """
    try:
        host = app.config.get('HOST', '127.0.0.1')
        if not host:
            host = '0.0.0.0'
        port = app.config.get('PORT', 5000)
        url = "http://%s:%d" % (host, port)
        print("--------------------------------------------------------------------------------")
        print("%s, listening on %s" % (manifest['name'], url))
        print("--------------------------------------------------------------------------------")

# Path: alignak_backend/app.py
# class MyTokenAuth(TokenAuth):
# class MyValidator(Validator):
#     def check_auth(self, token, allowed_roles, resource, method):
#     def add_resources_realms(self, right, data, custom, resource, resource_list, parents=None):
#     def _validate_skill_level(self, skill_level, field, value):
#     def _validate_title(self, title, field, value):
#     def _validate_comment(self, comment, field, value):
#     def _validate_schema_version(self, schema_version, field, value):
# def notify_alignak(event=None, parameters=None, notification=None):
# def pre_get(resource, user_request, lookup):
# def pre_post(resource, user_request):
# def pre_patch(resource, user_request, lookup):
# def pre_delete(resource, user_request, lookup):
# def pre_hostescalation_post(items):
# def pre_serviceescalation_post(items):
# def pre_history_post(items):
# def pre_logcheckresult_post(items):
# def after_insert_logcheckresult(items):
# def pre_post_action_right(actrequestp):
# def pre_submit_action_right(actrequest, lookup):
# def pre_actionacknowledge_post(items):
# def after_insert_actionacknowledge(items):
# def after_update_actionacknowledge(updated, original):
# def pre_actiondowntime_post(items):
# def after_insert_actiondowntime(items):
# def after_update_actiondowntime(updated, original):
# def pre_actionforcecheck_post(items):
# def after_insert_actionforcecheck(items):
# def after_update_actionforcecheck(updated, original):
# def pre_hostgroup_post(items):
# def pre_hostgroup_patch(updates, original):
# def pre_servicegroup_post(items):
# def pre_servicegroup_patch(updates, original):
# def pre_usergroup_post(items):
# def pre_usergroup_patch(updates, original):
# def pre_timeseries_post(items):
# def pre_realm_post(items):
# def pre_realm_patch(updates, original):
# def after_insert_realm(items):
# def after_update_realm(updated, original):
# def pre_delete_realm(item):
# def after_delete_realm(item):
# def after_delete_resource_realm():
# def pre_delete_host(item):
# def after_delete_host(item):
# def pre_alignak_patch(updates, original):
# def pre_host_patch(updates, original):
# def after_insert_host(items):
# def pre_service_patch(updates, original):
# def after_insert_service(items):
# def update_etag(myrequest, payload):
# def after_updated_service(updated, original):
# def pre_user_post(items):
# def pre_user_patch(updates, original):
# def after_insert_user(items):
# def pre_service_post(items):
# def keep_default_items_resource(resource, delete_request, lookup):
# def keep_default_items_item(resource, item):
# def on_fetched_resource_tree(resource_name, response):
# def on_fetched_item_tree(resource_name, itemresp):
# def pre_post_alias(resource_name, items):
# def generate_token():
# def get_settings(prev_settings):
#     def log_endpoint(_resource, _request, _payload):  # pylint: disable=unused-argument
# def login_app():  # pylint: disable=inconsistent-return-statements
# def logout_app():
# def backend_config():
# def backend_version():
# def cron_alignak():
# def cron_timeseries():
#     def get_grafana_configuration(cfg_file_name, queries):
#     def grafana_search(engine='jsonify'):
#     def grafana_query(engine='jsonify'):
#     def after_request(response):
#     def grafana_annotations(engine='jsonify'):
# def cron_grafana(engine='jsonify'):
# def cron_livesynthesis_history():
# def redir_index():
# def index(path):
# def main():


# Path: alignak_backend/main.py
from alignak_backend.app import app, manifest

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main
"""
from __future__ import print_function



def main():  # pragma: no cover - tested but not covered
    """Main function to run the alignak backend

    This function is used by the `alignak-backend` script installed with setup.py.
    It is intended to run the backend in a single process mode. This mode is not
    recommended for production but may be useful in development to avoid setting-up
    an uWSGI server.
    """
    try:
        host = app.config.get('HOST', '127.0.0.1')
        if not host:
            host = '0.0.0.0'
        port = app.config.get('PORT', 5000)
        url = "http://%s:%d" % (host, port)
        print("--------------------------------------------------------------------------------")
        print("%s, listening on %s" % (manifest['name'], url))
        print("--------------------------------------------------------------------------------")

        app.run(host=host, port=port, debug=app.config.get('DEBUG', False))