Files
ragflow/api/apps/restful_apis/config_api.py
Jin Hai fa75aee3b9 Refactor system API (#13958)
### What problem does this PR solve?

- ping
- token
- log level

### Type of change

- [x] Refactoring


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* System endpoints consolidated under /api/v1/system: ping, health
check, and token management moved to the centralized API surface.
* Token management unified at /api/v1/system/tokens with
list/create/delete behavior.

* **Documentation**
  * API reference updated to reflect the new /api/v1/system paths.

* **Tests**
* Client fixtures and test utilities updated to use
/api/v1/system/tokens; one unit test for health/oceanbase status
removed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-04-08 15:26:18 +08:00

72 lines
2.2 KiB
Python

#
# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from api.apps import login_required
from api.utils.api_utils import get_json_result, get_data_error_result
from common.log_utils import get_log_levels, set_log_level
@manager.route("/config/log", methods=["GET"]) # noqa: F821
@login_required
async def get_logger_levels():
"""
Get current log levels for all packages.
---
tags:
- System
responses:
200:
description: Return current log levels
"""
return get_json_result(data=get_log_levels())
@manager.route("/config/log", methods=["PUT"]) # noqa: F821
@login_required
async def set_logger_level():
"""
Set log level for a package.
---
tags:
- System
parameters:
- in: body
name: body
required: true
schema:
type: object
properties:
pkg_name:
type: string
description: Package name (e.g., "rag.utils.es_conn")
level:
type: string
description: Log level (DEBUG, INFO, WARNING, ERROR)
responses:
200:
description: Log level updated successfully
"""
from quart import request
data = await request.get_json()
if not data or "pkg_name" not in data or "level" not in data:
return get_data_error_result(message="pkg_name and level are required")
pkg_name = data["pkg_name"]
level = data["level"]
success = set_log_level(pkg_name, level)
if success:
return get_json_result(data={"pkg_name": pkg_name, "level": level})
else:
return get_data_error_result(message=f"Invalid log level: {level}")