with current_app.app_context(): object_manager = current_app.object_manager log_manager = current_app.log_manager user_manager = current_app.user_manager try: from cmdb.utils.error import CMDBError except ImportError: CMDBError = Exception LOGGER = logging.getLogger(__name__) object_blueprint = RootBlueprint('object_blueprint', __name__, url_prefix='/object') with current_app.app_context(): from cmdb.interface.rest_api.framework_routes.object_link_routes import link_rest object_blueprint.register_nested_blueprint(link_rest) # DEFAULT ROUTES @object_blueprint.route('/', methods=['GET']) @login_required @insert_request_user @right_required('base.framework.object.view') def get_object_list(request_user: User): """ get all objects in database Args: request_user: auto inserted user who made the request. Returns: list of rendered objects
from cmdb.utils.system_reader import SystemSettingsReader LOGGER = logging.getLogger(__name__) try: from cmdb.utils.error import CMDBError except ImportError: CMDBError = Exception settings_blueprint = RootBlueprint('settings_rest', __name__, url_prefix='/settings') with current_app.app_context(): from cmdb.interface.rest_api.settings_routes.system_routes import system_blueprint settings_blueprint.register_nested_blueprint(system_blueprint) system_settings_reader = SystemSettingsReader( database_manager=current_app.database_manager) @settings_blueprint.route('/<string:section>/', methods=['GET']) @settings_blueprint.route('/<string:section>', methods=['GET']) @login_required @insert_request_user @right_required('base.system.view') def get_settings_from_section(section: str, request_user: User): section_settings = system_settings_reader.get_all_values_from_section( section=section) if len(section_settings) < 1: return make_response([], 204)
with current_app.app_context(): object_manager: CmdbObjectManager = current_app.object_manager try: from cmdb.utils.error import CMDBError except ImportError: CMDBError = Exception LOGGER = logging.getLogger(__name__) collection_blueprint = RootBlueprint('collection_rest', __name__, url_prefix='/collection') collection_template_routes = NestedBlueprint(collection_blueprint, url_prefix='/template') collection_blueprint.register_nested_blueprint(collection_template_routes) @collection_blueprint.route('/', methods=['GET']) @login_required @insert_request_user @right_required('base.framework.collection.view') def get_collections(request_user: User): """Get all collections Returns: list of all collections """ try: collections = object_manager.get_collections() except ObjectManagerGetError: return abort(404)