add: backup version converter/ backup logic 1.0
This commit is contained in:
@@ -9,6 +9,21 @@ from db.models.PathTemplate import PathTemplate
|
||||
@template_bp.route('/path/<int:template_id>', methods=['GET'])
|
||||
@etag_response
|
||||
def get_path_template(template_id):
|
||||
"""
|
||||
Get a specific path template by ID.
|
||||
|
||||
This endpoint retrieves a path template by its ID.
|
||||
|
||||
Request:
|
||||
- template_id (int): The ID of the template to retrieve
|
||||
|
||||
Returns:
|
||||
A JSON object containing the path template.
|
||||
|
||||
Response Codes:
|
||||
- 200: Success
|
||||
- 204: No content (template not found)
|
||||
"""
|
||||
with get_db() as session:
|
||||
template = session.query(PathTemplate).get(template_id)
|
||||
if template is None:
|
||||
@@ -18,6 +33,17 @@ def get_path_template(template_id):
|
||||
@template_bp.route('/path/', methods=['GET'])
|
||||
@etag_response
|
||||
def get_path_templates():
|
||||
"""
|
||||
List all path templates.
|
||||
|
||||
This endpoint retrieves a list of all path templates in the system.
|
||||
|
||||
Returns:
|
||||
A JSON array containing all path templates.
|
||||
|
||||
Response Codes:
|
||||
- 200: Success
|
||||
"""
|
||||
with get_db() as session:
|
||||
templates = session.query(PathTemplate).all()
|
||||
return jsonify([template.to_dict() for template in templates]), 200
|
||||
@@ -26,6 +52,23 @@ def get_path_templates():
|
||||
@template_bp.route('/path/', methods=['POST'])
|
||||
@require_auth(roles=['admin'])
|
||||
def create_path_template():
|
||||
"""
|
||||
Create a new path template.
|
||||
|
||||
This endpoint creates a new path template with the provided data.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- title (str): The title of the template (required)
|
||||
- structure (str): The structure definition for the template
|
||||
|
||||
Returns:
|
||||
A JSON object containing the created template.
|
||||
|
||||
Response Codes:
|
||||
- 200: Created successfully
|
||||
- 400: Bad request (missing title or other error)
|
||||
"""
|
||||
data = request.json
|
||||
if "title" not in data:
|
||||
return jsonify({"error": "title is missing"}), 400
|
||||
@@ -44,6 +87,24 @@ def create_path_template():
|
||||
@template_bp.route('/path/<int:template_id>', methods=['PUT', 'PATCH'])
|
||||
@require_auth(roles=['admin'])
|
||||
def update_path_template(template_id):
|
||||
"""
|
||||
Update a path template.
|
||||
|
||||
This endpoint updates an existing path template with the provided data.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- template_id (int): The ID of the template to update
|
||||
- title (str, optional): The new title for the template
|
||||
- structure (str, optional): The new structure definition for the template
|
||||
|
||||
Returns:
|
||||
A JSON object containing the updated template.
|
||||
|
||||
Response Codes:
|
||||
- 200: Updated successfully
|
||||
- 400: Bad request (template not found)
|
||||
"""
|
||||
data = request.json
|
||||
with get_db() as session:
|
||||
template = session.query(PathTemplate).get(template_id)
|
||||
@@ -60,6 +121,22 @@ def update_path_template(template_id):
|
||||
@template_bp.route('/path/<int:template_id>', methods=['DELETE'])
|
||||
@require_auth(roles=['admin'])
|
||||
def delete_path_template(template_id):
|
||||
"""
|
||||
Delete a path template.
|
||||
|
||||
This endpoint deletes an existing path template.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- template_id (int): The ID of the template to delete
|
||||
|
||||
Returns:
|
||||
A JSON object with a success message.
|
||||
|
||||
Response Codes:
|
||||
- 200: Deleted successfully
|
||||
- 400: Bad request (template not found)
|
||||
"""
|
||||
with get_db() as session:
|
||||
template = session.query(PathTemplate).get(template_id)
|
||||
if template is None:
|
||||
|
||||
Reference in New Issue
Block a user