Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration/test_rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def test_own_roles(client_factory: ClientFactory) -> None:
with client_factory(ports=RBAC_PORTS, auth_credentials=RBAC_AUTH_CREDS) as client:
if client._connection._weaviate_version.is_lower_than(1, 28, 0):
pytest.skip("This test requires Weaviate 1.28.0 or higher")
roles = client.roles.get_current_roles()
roles = client.roles.of_current_user()
assert len(roles) > 0


Expand Down
10 changes: 5 additions & 5 deletions weaviate/rbac/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ async def list_all(self) -> Dict[str, Role]:
"""
return {role["name"]: Role._from_weaviate_role(role) for role in await self._get_roles()}

async def get_current_roles(self) -> Dict[str, Role]:
"""Get all roles for current user.
async def of_current_user(self) -> Dict[str, Role]:
"""Get all roles for current user. The user is determined by the API key supplied to the client.

Returns:
A dictionary with user names as keys and the `Role` objects as values.
Expand Down Expand Up @@ -191,18 +191,18 @@ async def by_user(self, user: str) -> Dict[str, Role]:
for role in await self._get_roles_of_user(user)
}

async def users(self, user_name: str) -> Dict[str, User]:
async def assigned_users(self, role_name: str) -> Dict[str, User]:
"""Get the users that have been assigned this role.

Args:
user_name: The role to get the users for.
role_name: The role to get the users for.

Returns:
A dictionary with user names as keys and the `User` objects as values.
"""
return {
user: self.__user_from_weaviate_user(user)
for user in await self._get_users_of_role(user_name)
for user in await self._get_users_of_role(role_name)
}

async def delete(self, role_name: str) -> None:
Expand Down
4 changes: 2 additions & 2 deletions weaviate/rbac/sync.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ from weaviate.rbac.roles import _RolesBase

class _Roles(_RolesBase):
def list_all(self) -> Dict[str, Role]: ...
def get_current_roles(self) -> Dict[str, Role]: ...
def of_current_user(self) -> Dict[str, Role]: ...
def by_name(self, role_name: str) -> Optional[Role]: ...
def by_user(self, user: str) -> Dict[str, Role]: ...
def users(self, role_name: str) -> Dict[str, User]: ...
def assigned_users(self, role_name: str) -> Dict[str, User]: ...
def delete(self, role_name: str) -> None: ...
def create(self, *, role_name: str, permissions: PermissionsInputType) -> Role: ...
def assign(self, *, role_names: Union[str, List[str]], user: str) -> None: ...
Expand Down
Loading