Skip to content

Commit

Permalink
Merge pull request swanchain#8 from filswan/feature/get-space-by-uuid
Browse files Browse the repository at this point in the history
Create API to get Space Dateils by UUID
  • Loading branch information
PlutoNbai authored Dec 5, 2023
2 parents 7a624b3 + 5530243 commit 9e59d2a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions backend/router/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,38 @@ def get_space_detail(wallet_address, name) -> tuple[Response, HTTPStatus]:
return jsonify(space_response), HTTPStatus.OK


@space_bp.route("/spaces/<string:space_uuid>", methods=["GET"])
def get_space_detail_by_uuid(space_uuid):
"""
Get space details by its UUID.
Args:
space_uuid (str): The UUID of the space to retrieve.
Returns:
Response: A JSON response containing space details or an error message.
"""

# Initialize response with a failure status
response = Response(status=constant.STATUS_FAILED)

# Attempt to retrieve the space by its UUID
try:
space = Space.get_by_uuid(space_uuid)
except Exception:
# Handle missing or invalid parameters
response.message = "Can not get Space by UUID, Query issue."
return jsonify(response.to_dict()), HTTPStatus.BAD_REQUEST
else:
# If the space exists, populate the response with its details
if space:
response.data = space_service.get_space_details(space)
response.status = constant.STATUS_SUCCESS
else:
# If the space does not exist, set an error message in the response
response.message = "space not found"

return jsonify(response.to_dict()), 200
@space_bp.route("/space/deployment", methods=["POST"])
@jwt_or_api_token_required
def create_space_deployment(user):
Expand Down

0 comments on commit 9e59d2a

Please sign in to comment.