diff --git a/cloud/README.md b/cloud/README.md index 3943923..872fef9 100644 --- a/cloud/README.md +++ b/cloud/README.md @@ -23,4 +23,16 @@ curl -X POST "https://smartwave.matthiasg.dev/alert" \ }, "logs": [] }' -``` \ No newline at end of file +``` + + +## Jobs + +### Trigger Server CVE Audit +`curl http://localhost:5000/debug/run-job/server_cve_audit_job` + +### Trigger Client IP Audit +`curl http://localhost:5000/debug/run-job/client_ip_audit_job` + +### Trigger Telemetry Request +`curl http://localhost:5000/debug/run-job/request_telemetry_job` \ No newline at end of file diff --git a/cloud/app.py b/cloud/app.py index 1ee12f5..4df564c 100644 --- a/cloud/app.py +++ b/cloud/app.py @@ -414,6 +414,29 @@ def debug_telemetryrequest(): except Exception as e: return jsonify({"error": f"Failed to publish MQTT command: {str(e)}"}), 500 +@app.route('/debug/run-job/', methods=['POST', 'GET']) +def trigger_job_manually(job_id): + """Manually triggers any scheduled job immediately by its ID.""" + job = scheduler.get_job(job_id) + if not job: + return jsonify({ + "error": f"Job '{job_id}' not found", + "available_jobs": [j.id for j in scheduler.get_jobs()] + }), 404 + + # Execute the underlying function with its configured arguments + try: + job.func(*job.args) + return jsonify({ + "status": "success", + "message": f"Job '{job_id}' executed successfully." + }), 200 + except Exception as e: + return jsonify({ + "status": "error", + "message": f"Job execution failed: {str(e)}" + }), 500 + @app.route("/debug", methods=["GET"]) def debug(): return safety_checker.check_dish_safety(os.path.join(CAMERA_IMAGE_DIR, "dish_0de0ee1dab8949fc8e78796947e24ed3.jpg"))