From 6a6b92347456474cf2be0dcb495cb3d29914fc8b Mon Sep 17 00:00:00 2001 From: TuanaCelik Date: Tue, 10 Dec 2024 14:44:26 +0100 Subject: [PATCH] adding print statements --- .../code/python/howto.configure.rbac.roles.py | 19 +++-- developers/weaviate/configuration/roles.md | 73 +++---------------- 2 files changed, 24 insertions(+), 68 deletions(-) diff --git a/_includes/code/python/howto.configure.rbac.roles.py b/_includes/code/python/howto.configure.rbac.roles.py index dd12000ad..ddaae67e8 100644 --- a/_includes/code/python/howto.configure.rbac.roles.py +++ b/_includes/code/python/howto.configure.rbac.roles.py @@ -85,7 +85,9 @@ # END ListCurrentUserRoles # START ListUserRoles -admin_client.roles.roles.by_user(user="jane-doe") +user_roles = admin_client.roles.roles.by_user(user="jane-doe") +for role in user_roles: + print(role) # END ListUserRoles # START CheckRoleExists @@ -93,15 +95,21 @@ # END CheckRoleExists # START InspectRole -admin_client.roles.by_name(role_name="role-name") +print(admin_client.roles.by_name(role_name="role-name")) # END InspectRole # START AssignedUsers -admin_client.roles.assigned_users(role_name="role-name") +assigned_users = admin_client.roles.assigned_users(role_name="role-name") + +for user in assigned_users: + print(user) # END AssignedUsers # START ListAllRoles -admin_client.roles.list_all() +all_roles = admin_client.roles.list_all() + +for role_name, role in all_roles.items(): + print(role_name, role) # END ListAllRoles @@ -129,4 +137,5 @@ admin_client.roles.remove_permissions( role_name="devrel", permissions=permissions -)# END RemovePermissions \ No newline at end of file +) +# END RemovePermissions \ No newline at end of file diff --git a/developers/weaviate/configuration/roles.md b/developers/weaviate/configuration/roles.md index e8a8cf05c..a4a813432 100644 --- a/developers/weaviate/configuration/roles.md +++ b/developers/weaviate/configuration/roles.md @@ -139,7 +139,8 @@ This example confers viewer permissions to a user for collections starting with import RolePyCode from '!!raw-loader!/_includes/code/python/howto.configure.rbac.roles.py'; ## Role management -To manage roles, first we must connect to the client with an API key that has access to do so, such as an admin API key. +To manage roles, the authenticated user must have appropriate `role` resource permissions. +The example below that the admin key is associated with an admin user. For more information check out the [Authentication](./authentication.md) and [Authorization](./authorization.md) docs. @@ -257,69 +258,13 @@ This adds to the "devrel" role permissions to: - - ### Remove permissions from a role -You can provide a list of `Permissions` and a role name to the `remove_permissions` mehtod, to remove the permissions from that role. If the permissions you've provided do not exist in the first place, it will be ignored. If the permission is the last one available for a given role, this will delete the role. -In the example below, we are removing the permissions to read the data from collections that start with "Test-" and the permission to create and delete collections called "Test_DevRel" from the "devrel" role. +The example below, removes the permissions to: +- Read the data from collections that start with "Test-" +- Create and delete collections called "Test_DevRel" + +from the "devrel" role. @@ -346,8 +291,10 @@ In the example below, we are removing the permissions to read the data from coll +If the permission is the last one available for a given role, this will delete the role. + ### Assign a role to a user -When connected to weaviate as an admin, we can assign one or more roles to a given user. For example, let's assign the "devrel" role to "jane-doe" +The example below assigns the "devrel" role to "jane-doe".