test communication scheduler<->simclient
This commit is contained in:
@@ -6,6 +6,7 @@ sys.path.append('/workspace')
|
||||
|
||||
clients_bp = Blueprint("clients", __name__, url_prefix="/api/clients")
|
||||
|
||||
|
||||
@clients_bp.route("/without_description", methods=["GET"])
|
||||
def get_clients_without_description():
|
||||
session = Session()
|
||||
@@ -50,6 +51,7 @@ def set_client_description(uuid):
|
||||
session.close()
|
||||
return jsonify({"success": True})
|
||||
|
||||
|
||||
@clients_bp.route("", methods=["GET"])
|
||||
def get_clients():
|
||||
session = Session()
|
||||
@@ -93,3 +95,39 @@ def update_clients_group():
|
||||
session.commit()
|
||||
session.close()
|
||||
return jsonify({"success": True})
|
||||
|
||||
|
||||
@clients_bp.route("/<uuid>", methods=["PATCH"])
|
||||
def update_client(uuid):
|
||||
data = request.get_json()
|
||||
session = Session()
|
||||
client = session.query(Client).filter_by(uuid=uuid).first()
|
||||
if not client:
|
||||
session.close()
|
||||
return jsonify({"error": "Client nicht gefunden"}), 404
|
||||
allowed_fields = ["description", "model"]
|
||||
updated = False
|
||||
for field in allowed_fields:
|
||||
if field in data:
|
||||
setattr(client, field, data[field])
|
||||
updated = True
|
||||
if updated:
|
||||
session.commit()
|
||||
result = {"success": True}
|
||||
else:
|
||||
result = {"error": "Keine gültigen Felder zum Aktualisieren übergeben"}
|
||||
session.close()
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
# Neue Route: Liefert die aktuelle group_id für einen Client
|
||||
@clients_bp.route("/<uuid>/group", methods=["GET"])
|
||||
def get_client_group(uuid):
|
||||
session = Session()
|
||||
client = session.query(Client).filter_by(uuid=uuid).first()
|
||||
if not client:
|
||||
session.close()
|
||||
return jsonify({"error": "Client nicht gefunden"}), 404
|
||||
group_id = client.group_id
|
||||
session.close()
|
||||
return jsonify({"group_id": group_id})
|
||||
|
||||
Reference in New Issue
Block a user