From 6fed3eec407f9457260fb586067d76a35318445c Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 19 Oct 2021 16:45:26 +0300 Subject: wqflask: resource_manager: Add "resource_id" to resource dict --- wqflask/wqflask/resource_manager.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'wqflask') 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": -- cgit v1.2.3