diff options
author | BonfaceKilz | 2021-10-19 16:45:26 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-10-25 14:00:14 +0300 |
commit | 6fed3eec407f9457260fb586067d76a35318445c (patch) | |
tree | 183cfcc640dca19f7be2f8522492436f71868c93 /wqflask | |
parent | a5d24f3885239c4fe15fd6d5dd070ec28403473d (diff) | |
download | genenetwork2-6fed3eec407f9457260fb586067d76a35318445c.tar.gz |
wqflask: resource_manager: Add "resource_id" to resource dict
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/resource_manager.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/wqflask/wqflask/resource_manager.py b/wqflask/wqflask/resource_manager.py index 94c9ba4f..94c351a4 100644 --- a/wqflask/wqflask/resource_manager.py +++ b/wqflask/wqflask/resource_manager.py @@ -96,7 +96,9 @@ def get_user_access_roles(conn: redis.Redis, return {k: max(v) for k, v in access_role.items()} -def add_extra_resource_metadata(conn: redis.Redis, resource: Dict) -> Dict: +def add_extra_resource_metadata(conn: redis.Redis, + resource_id: str, + resource: Dict) -> Dict: """If resource['owner_id'] exists, add metadata about that user. Also, if the resource contains group masks, add the group name into the resource dict. Note that resource['owner_id'] and the group masks are @@ -104,14 +106,17 @@ unique identifiers so they aren't human readable names. Args: - conn: A redis connection with the responses decoded. + - resource_id: The unique identifier of the resource. - resource: A dict containing details(metadata) about a given resource. Returns: - An embellished dictionary with the human readable names of the - group masks and the owner id if it was set. + An embellished dictionary with its resource id; the human + readable names of the group masks; and the owner id if it was set. """ + resource["resource_id"] = resource_id + # Embellish the resource information with owner details if the # owner is set if (owner_id := resource.get("owner_id", "none").lower()) == "none": |