28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
|
|
# pyrefly: ignore [missing-import]
|
||
|
|
from flask import Blueprint
|
||
|
|
|
||
|
|
from modules.monitor_config.controller import (
|
||
|
|
get_monitor_config,
|
||
|
|
update_monitor_config,
|
||
|
|
test_connection
|
||
|
|
)
|
||
|
|
|
||
|
|
# Khởi tạo Blueprint cho Module Monitor Config
|
||
|
|
# Blueprint này sẽ được đăng ký dưới prefix /api/devices trong app.py
|
||
|
|
monitor_config_bp = Blueprint("monitor_config", __name__)
|
||
|
|
|
||
|
|
# Đăng ký các endpoints cấu hình giám sát thiết bị:
|
||
|
|
# Luồng đi:
|
||
|
|
# 1. Client gửi request tương ứng tới endpoint.
|
||
|
|
# 2. Flask định tuyến (routing) request dựa trên method và url path.
|
||
|
|
# 3. Chuyển tiếp request cho hàm xử lý tương ứng trong controller.py.
|
||
|
|
|
||
|
|
# GET /api/devices/<device_id>/monitor-config -> Lấy cấu hình giám sát
|
||
|
|
monitor_config_bp.route("/<device_id>/monitor-config", methods=["GET"])(get_monitor_config)
|
||
|
|
|
||
|
|
# PUT /api/devices/<device_id>/monitor-config -> Cập nhật cấu hình giám sát
|
||
|
|
monitor_config_bp.route("/<device_id>/monitor-config", methods=["PUT"])(update_monitor_config)
|
||
|
|
|
||
|
|
# POST /api/devices/<device_id>/monitor-config/test -> Kiểm tra kết nối (Ping/SNMP)
|
||
|
|
monitor_config_bp.route("/<device_id>/monitor-config/test", methods=["POST"])(test_connection)
|