add: backup version converter/ backup logic 1.0
This commit is contained in:
@@ -13,6 +13,21 @@ logger = logging.getLogger(__name__)
|
||||
@limiter.limit(api.get_rate_limit)
|
||||
@etag_response
|
||||
def get_path_setting(setting_id):
|
||||
"""
|
||||
Get a specific path setting by ID.
|
||||
|
||||
This endpoint retrieves a path setting by its ID.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the path setting to retrieve
|
||||
|
||||
Returns:
|
||||
A JSON object containing the path setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Success
|
||||
- 204: No content (setting not found)
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.query(PathSetting).get(setting_id)
|
||||
if setting is None:
|
||||
@@ -22,6 +37,23 @@ def get_path_setting(setting_id):
|
||||
@setting_bp.route('/path/', methods=['POST'])
|
||||
@require_auth(roles=['admin'])
|
||||
def create_path_setting():
|
||||
"""
|
||||
Create a new path setting.
|
||||
|
||||
This endpoint creates a new path setting with the provided webhook and template settings.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- webhook_setting_id (int, optional): The ID of the webhook setting to associate
|
||||
- template_setting_id (int, optional): The ID of the template setting to associate
|
||||
|
||||
Returns:
|
||||
A JSON object containing the created path setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Created successfully
|
||||
- 500: Server error
|
||||
"""
|
||||
data = request.json
|
||||
webhook_setting_id = data.get('webhook_setting_id')
|
||||
template_setting_id = data.get('template_setting_id')
|
||||
@@ -42,6 +74,25 @@ def create_path_setting():
|
||||
@setting_bp.route('/path/<int:setting_id>', methods=['PUT', 'PATCH'])
|
||||
@require_auth(roles=['admin'])
|
||||
def update_path_setting(setting_id):
|
||||
"""
|
||||
Update a path setting.
|
||||
|
||||
This endpoint updates an existing path setting with the provided webhook and template settings.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the path setting to update
|
||||
- webhook_setting_id (int, optional): The new webhook setting ID
|
||||
- template_setting_id (int, optional): The new template setting ID
|
||||
|
||||
Returns:
|
||||
A JSON object containing the updated path setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Updated successfully
|
||||
- 400: Bad request (setting not found)
|
||||
- 500: Server error
|
||||
"""
|
||||
data = request.json
|
||||
with get_db() as session:
|
||||
try:
|
||||
@@ -60,10 +111,25 @@ def update_path_setting(setting_id):
|
||||
@setting_bp.route('/path/<int:setting_id>', methods=['DELETE'])
|
||||
@require_auth(roles=['admin'])
|
||||
def delete_path_setting(setting_id):
|
||||
"""
|
||||
Delete a path setting.
|
||||
|
||||
This endpoint deletes an existing path setting.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the path setting to delete
|
||||
|
||||
Returns:
|
||||
A JSON object with a success message.
|
||||
|
||||
Response Codes:
|
||||
- 200: Deleted successfully
|
||||
- 400: Bad request (setting not found)
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.query(PathSetting).get(setting_id)
|
||||
if setting is None:
|
||||
return jsonify({"error": "setting not exists"}), 400
|
||||
session.delete(setting)
|
||||
return jsonify({"message": "deleted"}), 200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user