forked from reanahub/reana-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rest): add get_workflow_share_status endpoint (reanahub#658)
Adds a new endpoint to retrieve whom a workflow is shared with. Closes reanahub/reana-client#686
- Loading branch information
1 parent
8ec2b0b
commit 7f89b45
Showing
2 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3180,6 +3180,139 @@ | |
"summary": "Share a workflow with another user." | ||
} | ||
}, | ||
"/api/workflows/{workflow_id_or_name}/share-status": { | ||
"get": { | ||
"description": "This resource returns the share status of a given workflow.", | ||
"operationId": "get_workflow_share_status", | ||
"parameters": [ | ||
{ | ||
"description": "The API access_token of workflow owner.", | ||
"in": "query", | ||
"name": "access_token", | ||
"required": false, | ||
"type": "string" | ||
}, | ||
{ | ||
"description": "Required. Workflow UUID or name.", | ||
"in": "path", | ||
"name": "workflow_id_or_name", | ||
"required": true, | ||
"type": "string" | ||
} | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "Request succeeded. The response contains the share status of the workflow.", | ||
"examples": { | ||
"application/json": { | ||
"shared_with": [ | ||
{ | ||
"user_email": "[email protected]", | ||
"valid_until": "2022-11-24T23:59:59" | ||
} | ||
], | ||
"workflow_id": "256b25f4-4cfb-4684-b7a8-73872ef455a1", | ||
"workflow_name": "mytest.1" | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"shared_with": { | ||
"items": { | ||
"properties": { | ||
"user_email": { | ||
"type": "string" | ||
}, | ||
"valid_until": { | ||
"type": "string", | ||
"x-nullable": true | ||
} | ||
}, | ||
"type": "object" | ||
}, | ||
"type": "array" | ||
}, | ||
"workflow_id": { | ||
"type": "string" | ||
}, | ||
"workflow_name": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"401": { | ||
"description": "Request failed. User not signed in.", | ||
"examples": { | ||
"application/json": { | ||
"message": "User not signed in." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"403": { | ||
"description": "Request failed. Credentials are invalid or revoked.", | ||
"examples": { | ||
"application/json": { | ||
"message": "Token not valid." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"404": { | ||
"description": "Request failed. Workflow does not exist.", | ||
"examples": { | ||
"application/json": { | ||
"message": "Workflow mytest.1 does not exist." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"500": { | ||
"description": "Request failed. Internal server error.", | ||
"examples": { | ||
"application/json": { | ||
"message": "Something went wrong." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
} | ||
}, | ||
"summary": "Get the share status of a workflow." | ||
} | ||
}, | ||
"/api/workflows/{workflow_id_or_name}/specification": { | ||
"get": { | ||
"description": "This resource returns the REANA workflow specification used to start the workflow run. Resource is expecting a workflow UUID.", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3564,3 +3564,132 @@ def unshare_workflow(workflow_id_or_name, user, user_email_to_unshare_with): | |
except Exception as e: | ||
logging.exception(str(e)) | ||
return jsonify({"message": str(e)}), 500 | ||
|
||
|
||
@blueprint.route("/workflows/<workflow_id_or_name>/share-status", methods=["GET"]) | ||
@signin_required() | ||
def get_workflow_share_status(workflow_id_or_name, user): | ||
r"""Get the share status of a workflow. | ||
--- | ||
get: | ||
summary: Get the share status of a workflow. | ||
description: >- | ||
This resource returns the share status of a given workflow. | ||
operationId: get_workflow_share_status | ||
produces: | ||
- application/json | ||
parameters: | ||
- name: access_token | ||
in: query | ||
description: The API access_token of workflow owner. | ||
required: false | ||
type: string | ||
- name: workflow_id_or_name | ||
in: path | ||
description: Required. Workflow UUID or name. | ||
required: true | ||
type: string | ||
responses: | ||
200: | ||
description: >- | ||
Request succeeded. The response contains the share status of the workflow. | ||
schema: | ||
type: object | ||
properties: | ||
workflow_id: | ||
type: string | ||
workflow_name: | ||
type: string | ||
shared_with: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
user_email: | ||
type: string | ||
valid_until: | ||
type: string | ||
x-nullable: true | ||
examples: | ||
application/json: | ||
{ | ||
"workflow_id": "256b25f4-4cfb-4684-b7a8-73872ef455a1", | ||
"workflow_name": "mytest.1", | ||
"shared_with": [ | ||
{ | ||
"user_email": "[email protected]", | ||
"valid_until": "2022-11-24T23:59:59" | ||
} | ||
] | ||
} | ||
401: | ||
description: >- | ||
Request failed. User not signed in. | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
examples: | ||
application/json: | ||
{ | ||
"message": "User not signed in." | ||
} | ||
403: | ||
description: >- | ||
Request failed. Credentials are invalid or revoked. | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
examples: | ||
application/json: | ||
{ | ||
"message": "Token not valid." | ||
} | ||
404: | ||
description: >- | ||
Request failed. Workflow does not exist. | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
examples: | ||
application/json: | ||
{ | ||
"message": "Workflow mytest.1 does not exist." | ||
} | ||
500: | ||
description: >- | ||
Request failed. Internal server error. | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
examples: | ||
application/json: | ||
{ | ||
"message": "Something went wrong." | ||
} | ||
""" | ||
try: | ||
share_status_params = { | ||
"workflow_id_or_name": workflow_id_or_name, | ||
"user_id": str(user.id_), | ||
} | ||
|
||
response, http_response = current_rwc_api_client.api.get_workflow_share_status( | ||
**share_status_params | ||
).result() | ||
|
||
return jsonify(response), 200 | ||
except HTTPError as e: | ||
logging.exception(str(e)) | ||
return jsonify(e.response.json()), e.response.status_code | ||
except Exception as e: | ||
logging.exception(str(e)) | ||
return jsonify({"message": str(e)}), 500 |