Skip to content

Commit 512f9af

Browse files
authored
Merge pull request #1463 from weaviate/rbac/refactor-api-methods
Rename methods in .roles for better UX
2 parents 75c9d82 + c785520 commit 512f9af

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

integration/test_rbac.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def test_own_roles(client_factory: ClientFactory) -> None:
272272
with client_factory(ports=RBAC_PORTS, auth_credentials=RBAC_AUTH_CREDS) as client:
273273
if client._connection._weaviate_version.is_lower_than(1, 28, 0):
274274
pytest.skip("This test requires Weaviate 1.28.0 or higher")
275-
roles = client.roles.get_current_roles()
275+
roles = client.roles.of_current_user()
276276
assert len(roles) > 0
277277

278278

weaviate/rbac/roles.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ async def list_all(self) -> Dict[str, Role]:
142142
"""
143143
return {role["name"]: Role._from_weaviate_role(role) for role in await self._get_roles()}
144144

145-
async def get_current_roles(self) -> Dict[str, Role]:
146-
"""Get all roles for current user.
145+
async def of_current_user(self) -> Dict[str, Role]:
146+
"""Get all roles for current user. The user is determined by the API key supplied to the client.
147147
148148
Returns:
149149
A dictionary with user names as keys and the `Role` objects as values.
@@ -191,18 +191,18 @@ async def by_user(self, user: str) -> Dict[str, Role]:
191191
for role in await self._get_roles_of_user(user)
192192
}
193193

194-
async def users(self, user_name: str) -> Dict[str, User]:
194+
async def assigned_users(self, role_name: str) -> Dict[str, User]:
195195
"""Get the users that have been assigned this role.
196196
197197
Args:
198-
user_name: The role to get the users for.
198+
role_name: The role to get the users for.
199199
200200
Returns:
201201
A dictionary with user names as keys and the `User` objects as values.
202202
"""
203203
return {
204204
user: self.__user_from_weaviate_user(user)
205-
for user in await self._get_users_of_role(user_name)
205+
for user in await self._get_users_of_role(role_name)
206206
}
207207

208208
async def delete(self, role_name: str) -> None:

weaviate/rbac/sync.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ from weaviate.rbac.roles import _RolesBase
55

66
class _Roles(_RolesBase):
77
def list_all(self) -> Dict[str, Role]: ...
8-
def get_current_roles(self) -> Dict[str, Role]: ...
8+
def of_current_user(self) -> Dict[str, Role]: ...
99
def by_name(self, role_name: str) -> Optional[Role]: ...
1010
def by_user(self, user: str) -> Dict[str, Role]: ...
11-
def users(self, role_name: str) -> Dict[str, User]: ...
11+
def assigned_users(self, role_name: str) -> Dict[str, User]: ...
1212
def delete(self, role_name: str) -> None: ...
1313
def create(self, *, role_name: str, permissions: PermissionsInputType) -> Role: ...
1414
def assign(self, *, role_names: Union[str, List[str]], user: str) -> None: ...

0 commit comments

Comments
 (0)