add: backup version converter/ backup logic 1.0

This commit is contained in:
h z
2025-04-25 13:00:41 +01:00
parent 35c8934963
commit 84494827ad
15 changed files with 2107 additions and 76 deletions

View File

@@ -8,6 +8,18 @@ from db.models.WebhookSetting import WebhookSetting
@setting_bp.route('/path/webhook/', methods=['GET'])
@require_auth(roles=['admin'])
def list_webhook_settings():
"""
List all webhook settings.
This endpoint retrieves a list of all webhook settings in the system.
It requires authentication with the 'admin' role.
Returns:
A JSON array containing all webhook settings.
Response Codes:
- 200: Success
"""
with get_db() as session:
settings = session.query(WebhookSetting).all()
return jsonify([s.to_dict() for s in settings]), 200
@@ -16,6 +28,22 @@ def list_webhook_settings():
@setting_bp.route('/path/webhook/<int:setting_id>', methods=['GET'])
@require_auth(roles=['admin'])
def webhook_setting(setting_id):
"""
Get a specific webhook setting by ID.
This endpoint retrieves a webhook setting by its ID.
It requires authentication with the 'admin' role.
Request:
- setting_id (int): The ID of the webhook setting to retrieve
Returns:
A JSON object containing the webhook setting.
Response Codes:
- 200: Success
- 204: No content (setting not found)
"""
with get_db() as session:
setting = session.query(WebhookSetting).filter(WebhookSetting.id == setting_id).first()
if not setting:
@@ -26,6 +54,25 @@ def webhook_setting(setting_id):
@setting_bp.route('/path/webhook/', methods=['POST'])
@require_auth(roles=['admin'])
def create_webhook_setting():
"""
Create a new webhook setting.
This endpoint creates a new webhook setting with the provided parameters.
It requires authentication with the 'admin' role.
Request:
- webhook_id (int): The ID of the webhook to associate
- recursive (bool, optional): Whether the webhook applies to subpaths (default: false)
- additional_header (str, optional): Additional headers for the webhook (default: '')
- enabled (bool, optional): Whether the webhook is enabled (default: true)
- on_events (int, optional): Event types that trigger the webhook (default: 1)
Returns:
A JSON object containing the created webhook setting.
Response Codes:
- 201: Created successfully
"""
data = request.json
with get_db() as session:
setting = WebhookSetting(
@@ -43,6 +90,27 @@ def create_webhook_setting():
@setting_bp.route('/path/webhook/<int:setting_id>', methods=['PUT', 'PATCH'])
@require_auth(roles=['admin'])
def update_webhook_setting(setting_id):
"""
Update a webhook setting.
This endpoint updates an existing webhook setting with the provided parameters.
It requires authentication with the 'admin' role.
Request:
- setting_id (int): The ID of the webhook setting to update
- webhook_id (int, optional): The new webhook ID
- recursive (bool, optional): Whether the webhook applies to subpaths
- additional_header (str, optional): Additional headers for the webhook
- enabled (bool, optional): Whether the webhook is enabled
- on_events (int, optional): Event types that trigger the webhook
Returns:
A JSON object containing the updated webhook setting.
Response Codes:
- 200: Updated successfully
- 404: Webhook setting not found
"""
data = request.json
with get_db() as session:
setting = session.query(WebhookSetting).get(setting_id)
@@ -66,6 +134,22 @@ def update_webhook_setting(setting_id):
@setting_bp.route('/path/webhook/<int:setting_id>', methods=['DELETE'])
@require_auth(roles=['admin'])
def delete_webhook_setting(setting_id):
"""
Delete a webhook setting.
This endpoint deletes an existing webhook setting.
It requires authentication with the 'admin' role.
Request:
- setting_id (int): The ID of the webhook setting to delete
Returns:
A JSON object with a success message.
Response Codes:
- 200: Deleted successfully
- 404: Webhook setting not found
"""
with get_db() as session:
setting = session.query(WebhookSetting).get(setting_id)
if not setting:
@@ -74,4 +158,3 @@ def delete_webhook_setting(setting_id):
session.delete(setting)
session.commit()
return jsonify({'message': 'Webhook setting deleted'}), 200