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.
fix(rest): fix workflow sharing endpoints after rebase (reanahub#658)
- Loading branch information
Showing
4 changed files
with
91 additions
and
145 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 |
---|---|---|
|
@@ -1332,9 +1332,7 @@ | |
"application/json": { | ||
"users_shared_with_you": [ | ||
{ | ||
"email": "[email protected]", | ||
"full_name": "John Doe", | ||
"username": "jdoe" | ||
"email": "[email protected]" | ||
} | ||
] | ||
} | ||
|
@@ -1346,12 +1344,6 @@ | |
"properties": { | ||
"email": { | ||
"type": "string" | ||
}, | ||
"full_name": { | ||
"type": "string" | ||
}, | ||
"username": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
|
@@ -1437,9 +1429,7 @@ | |
"application/json": { | ||
"users_you_shared_with": [ | ||
{ | ||
"email": "[email protected]", | ||
"full_name": "John Doe", | ||
"username": "jdoe" | ||
"email": "[email protected]" | ||
} | ||
] | ||
} | ||
|
@@ -1451,12 +1441,6 @@ | |
"properties": { | ||
"email": { | ||
"type": "string" | ||
}, | ||
"full_name": { | ||
"type": "string" | ||
}, | ||
"username": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
|
@@ -1610,14 +1594,14 @@ | |
"type": "boolean" | ||
}, | ||
{ | ||
"description": "Optional argument to list workflows shared by the specified user(s).", | ||
"description": "Optional argument to list workflows shared by the specified user.", | ||
"in": "query", | ||
"name": "shared_by", | ||
"required": false, | ||
"type": "string" | ||
}, | ||
{ | ||
"description": "Optional argument to list workflows shared with the specified user(s).", | ||
"description": "Optional argument to list workflows shared with the specified user.", | ||
"in": "query", | ||
"name": "shared_with", | ||
"required": false, | ||
|
@@ -1790,7 +1774,10 @@ | |
"type": "string" | ||
}, | ||
"shared_with": { | ||
"type": "string" | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"size": { | ||
"properties": { | ||
|
@@ -3351,7 +3338,15 @@ | |
} | ||
}, | ||
"400": { | ||
"description": "Request failed. The incoming data seems malformed." | ||
"description": "Request failed. The incoming data seems malformed.", | ||
"schema": { | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"401": { | ||
"description": "Request failed. User not signed in.", | ||
|
@@ -3391,6 +3386,14 @@ | |
"application/json": { | ||
"message": "Workflow cdcf48b1-c2f3-4693-8230-b066e088c6ac does not exist" | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"409": { | ||
|
@@ -3399,6 +3402,14 @@ | |
"application/json": { | ||
"message": "The workflow is already shared with the user." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"500": { | ||
|
@@ -3407,6 +3418,14 @@ | |
"application/json": { | ||
"message": "Internal controller error." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
} | ||
}, | ||
|
@@ -4397,20 +4416,11 @@ | |
"description": "Request failed. The incoming data specification seems malformed.", | ||
"examples": { | ||
"application/json": { | ||
"errors": [ | ||
"Missing data for required field." | ||
], | ||
"message": "Malformed request." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"errors": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
|
@@ -4422,19 +4432,11 @@ | |
"description": "Request failed. User is not allowed to unshare the workflow.", | ||
"examples": { | ||
"application/json": { | ||
"errors": [ | ||
"User is not allowed to unshare the workflow." | ||
] | ||
"message": "User is not allowed to unshare the workflow." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"errors": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
|
@@ -4446,20 +4448,11 @@ | |
"description": "Request failed. Workflow does not exist or user does not exist.", | ||
"examples": { | ||
"application/json": { | ||
"errors": [ | ||
"Workflow cdcf48b1-c2f3-4693-8230-b066e088c6ac does not exist" | ||
], | ||
"message": "Workflow cdcf48b1-c2f3-4693-8230-b066e088c6ac does not exist" | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"errors": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
|
@@ -4471,20 +4464,11 @@ | |
"description": "Request failed. The workflow is not shared with the user.", | ||
"examples": { | ||
"application/json": { | ||
"errors": [ | ||
"The workflow is not shared with the user." | ||
], | ||
"message": "The workflow is not shared with the user." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"errors": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
|
@@ -4496,20 +4480,11 @@ | |
"description": "Request failed. Internal controller error.", | ||
"examples": { | ||
"application/json": { | ||
"errors": [ | ||
"Internal controller error." | ||
], | ||
"message": "Internal controller error." | ||
} | ||
}, | ||
"schema": { | ||
"properties": { | ||
"errors": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
|
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 |
---|---|---|
|
@@ -392,18 +392,12 @@ def get_users_shared_with_you(user): | |
properties: | ||
email: | ||
type: string | ||
full_name: | ||
type: string | ||
username: | ||
type: string | ||
examples: | ||
application/json: | ||
{ | ||
"users_shared_with_you": [ | ||
{ | ||
"email": "[email protected]", | ||
"full_name": "John Doe", | ||
"username": "jdoe" | ||
} | ||
] | ||
} | ||
|
@@ -457,27 +451,16 @@ def get_users_shared_with_you(user): | |
shared_workflow_owners_ids = ( | ||
Session.query(Workflow.owner_id) | ||
.filter(Workflow.id_.in_(shared_workflows_ids)) | ||
.distinct() | ||
.subquery() | ||
) | ||
|
||
users = ( | ||
Session.query(User.email, User.full_name, User.username) | ||
Session.query(User.email) | ||
.filter(User.id_.in_(shared_workflow_owners_ids)) | ||
.all() | ||
) | ||
|
||
response = {"users_shared_with_you": []} | ||
|
||
for email, full_name, username in users: | ||
response["users_shared_with_you"].append( | ||
{ | ||
"email": email, | ||
"full_name": full_name, | ||
"username": username, | ||
} | ||
) | ||
|
||
response = {"users_shared_with_you": [{"email": user.email} for user in users]} | ||
return jsonify(response), 200 | ||
except HTTPError as e: | ||
logging.error(traceback.format_exc()) | ||
|
@@ -524,18 +507,12 @@ def get_users_you_shared_with(user): | |
properties: | ||
email: | ||
type: string | ||
full_name: | ||
type: string | ||
username: | ||
type: string | ||
examples: | ||
application/json: | ||
{ | ||
"users_you_shared_with": [ | ||
{ | ||
"email": "[email protected]", | ||
"full_name": "John Doe", | ||
"username": "jdoe" | ||
} | ||
] | ||
} | ||
|
@@ -592,22 +569,12 @@ def get_users_you_shared_with(user): | |
) | ||
|
||
users = ( | ||
Session.query(User.email, User.full_name, User.username) | ||
Session.query(User.email) | ||
.filter(User.id_.in_(users_you_shared_with_ids)) | ||
.all() | ||
) | ||
|
||
response = {"users_you_shared_with": []} | ||
|
||
for email, full_name, username in users: | ||
response["users_you_shared_with"].append( | ||
{ | ||
"email": email, | ||
"full_name": full_name, | ||
"username": username, | ||
} | ||
) | ||
|
||
response = {"users_you_shared_with": [{"email": user.email} for user in users]} | ||
return jsonify(response), 200 | ||
except HTTPError as e: | ||
logging.error(traceback.format_exc()) | ||
|
Oops, something went wrong.