feat(BA-5769): add my-role SDK, CLI, and v2 component tests#11179
Open
feat(BA-5769): add my-role SDK, CLI, and v2 component tests#11179
Conversation
fregataa
added a commit
that referenced
this pull request
Apr 18, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a self-service “my role assignments” search flow to the v2 RBAC REST API, wires it through the v2 SDK and CLI, and expands component coverage for role assignment operations. This also includes a small naming cleanup for the role-assignment search DTO/function that is shared across REST and GraphQL.
Changes:
- Add
POST /v2/rbac/assignments/my/search(auth-required) and handler/adapter support for querying the current user’s assignments. - Add v2 SDK method
V2RBACClient.my_search_assignmentsand CLI command groupbai my role search. - Add v2 REST component tests for assign/revoke/my-search assignment flows and rename
AdminSearchRoleAssignmentsGQLInput→AdminSearchRoleAssignmentsInputacross call sites.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/manager/api/gql/rbac/test_my_roles_resolver.py | Updates mocks to match the renamed adapter method. |
| tests/component/rbac/test_rbac_role_v2.py | Adds component tests for v2 assign/revoke and my-search assignment operations. |
| src/ai/backend/manager/api/rest/v2/rbac/registry.py | Registers the new /assignments/my/search route with auth_required. |
| src/ai/backend/manager/api/rest/v2/rbac/handler.py | Implements my_search_assignments REST handler and updates admin search handler to renamed adapter method. |
| src/ai/backend/manager/api/gql/rbac/types/role.py | Updates role-user assignment lookup to use renamed search input/method. |
| src/ai/backend/manager/api/gql/rbac/resolver/role.py | Updates resolvers to use renamed search input/method; preserves base_conditions for my_roles. |
| src/ai/backend/manager/api/adapters/rbac.py | Adds my_search_role_assignments adapter helper and renames admin assignment search method. |
| src/ai/backend/common/dto/manager/v2/rbac/request.py | Renames the role-assignment search request DTO. |
| src/ai/backend/common/dto/manager/v2/rbac/init.py | Re-exports the renamed request DTO. |
| src/ai/backend/client/v2/domains_v2/rbac.py | Adds SDK my_search_assignments and updates request DTO type for assignment search. |
| src/ai/backend/client/cli/v2/rbac/assignment.py | Updates CLI to use renamed request DTO for admin assignment search. |
| src/ai/backend/client/cli/v2/my/role.py | Adds bai my role search CLI command using the new SDK endpoint. |
| src/ai/backend/client/cli/v2/my/init.py | Registers the new my role CLI group. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add my_search_role_assignments adapter method with current_user() scope - Add REST v2 endpoint POST /assignments/my/search (auth_required) - Add my_search_assignments SDK method in V2RBACClient - Add CLI command: ./bai my role search - Add component tests for assign/revoke/my-search via v2 REST SDK - Rename AdminSearchRoleAssignmentsGQLInput -> AdminSearchRoleAssignmentsInput - Rename admin_search_role_assignments_gql -> admin_search_role_assignments Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add my_search_role_assignments adapter method with current_user() scope - Add REST v2 endpoint POST /assignments/my/search (auth_required) - Add my_search_assignments SDK method in V2RBACClient - Add CLI command: ./bai my role search - Add component tests for assign/revoke/my-search via v2 REST SDK - Rename AdminSearchRoleAssignmentsGQLInput -> SearchRoleAssignmentsInput - Rename AdminSearchRoleAssignmentsPayload -> SearchRoleAssignmentsPayload - Rename admin_search_role_assignments_gql -> admin_search_role_assignments Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d241a64 to
fa434ae
Compare
…ter naming - Change RoleAssignmentFilter.role_id from UUID to UUIDFilter for consistent filtering (supports equals/in/not_equals/not_in) - Use click.UUID type for --role-id CLI options in my/role.py and rbac/assignment.py for proper input validation - Extract _search_role_assignments private method in RBACAdapter so my_search_role_assignments no longer calls admin_search_role_assignments - Add by_role_id_equals/by_role_id_in to AssignedUserConditions for convert_uuid_filter compatibility Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: octodog <mu001@lablup.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
my_search_assignmentsendpoint (POST /v2/rbac/assignments/my/search) for users to query their own role assignmentsV2RBACClient.my_search_assignments) and CLI command (./bai my role search)AdminSearchRoleAssignmentsGQLInput→AdminSearchRoleAssignmentsInputandadmin_search_role_assignments_gql→admin_search_role_assignmentsTest plan
TestAssignRoleV2(admin assign success, user permission denied)TestRevokeRoleV2(admin revoke success, user permission denied)TestMySearchAssignmentsV2(own assignments visible, other users' hidden, empty result)pants test tests/component/rbac/test_rbac_role_v2.py)Resolves BA-5769