sunyuhan1998 opened a new pull request, #11058:
URL: https://github.com/apache/gravitino/pull/11058
### What changes were proposed in this pull request?
This PR is split from #10783 to make review easier. It focuses on the
**User** part of the authorization model; Group, Role, Privilege,
SecurableObject and grant/revoke operations will follow in subsequent
PRs.
Changes in this PR:
1. **API layer** (`gravitino/api/authorization/`)
- `User` — user interface with `name()` / `roles()` accessors
2. **DTO layer** (`gravitino/dto/authorization/`)
- `UserDTO` — immutable DTO with builder pattern, serialization
and audit info
3. **Request / Response DTOs** (`gravitino/dto/`)
- `UserAddRequest`
- `UserResponse` / `UserListResponse` / `UserNamesListResponse`
- `RemoveResponse` (shared boolean-remove response used across
authorization operations)
4. **Client layer** (`gravitino/client/gravitino_metalake.py`)
- Five new public methods on `GravitinoMetalake`:
`add_user` / `get_user` / `remove_user` / `list_users` /
`list_user_names`
5. **Exception handling** (`gravitino/exceptions/`)
- `NoSuchUserException`, `UserAlreadyExistsException`
- `UserErrorHandler` mapping REST error codes to the above
### Why are the changes needed?
The Python SDK currently has no authorization management capabilities,
while the Java SDK and REST API have full support. This PR starts
bringing the Python SDK to feature parity with the Java SDK, beginning
with User management as the most foundational entity.
Fix: #10782
### Does this PR introduce _any_ user-facing change?
Yes. New public API:
- `GravitinoMetalake.add_user(name)` / `get_user(name)` /
`remove_user(name)` / `list_users()` / `list_user_names()`
- New exceptions: `NoSuchUserException`, `UserAlreadyExistsException`
No existing APIs or behaviors are changed.
### How was this patch tested?
28 new unit tests (all passing, `ruff` + `pylint 10.00/10`):
- **DTO tests** (`tests/unittests/dto/test_user_dto.py`,
`tests/unittests/dto/responses/test_user_response.py`) — cover
builder, serialization / deserialization roundtrip, equality
- **Client-level mock tests**
(`tests/unittests/client/test_metalake_user_operations.py`) —
cover URL, HTTP method, request body, response parsing, and
error propagation for all five `GravitinoMetalake` methods
- **Error-handler tests** (added to
`tests/unittests/test_error_handler.py`) — verify the full error
code mapping table for `UserErrorHandler`
Integration tests will be added in the final PR of the split together
with grant/revoke operations, where end-to-end multi-entity behavior
needs to be validated against a real server.
cc @jerryshao — could you help review this when you have time? Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]