Add admin-directory as built-in service alias for Admin SDK Directory API#476
Add admin-directory as built-in service alias for Admin SDK Directory API#476Jah-yee wants to merge 1 commit intogoogleworkspace:mainfrom
Conversation
… API
- Add ServiceEntry for admin-directory pointing to admin:directory_v1
- This enables intuitive access to Directory API for user/group management
- Add test case for resolve_service('admin-directory')
Fixes: googleworkspace#473
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the command-line interface by introducing a dedicated and more descriptive alias for the Google Workspace Admin SDK Directory API. This change improves the discoverability and usability of the tool for common administrative tasks, eliminating the need for less intuitive workarounds previously required to access this API. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a new built-in service alias admin-directory. The implementation is correct, but my review identified a potential for future correctness issues due to the lack of validation for unique service aliases. I've added a comment suggesting the addition of a new test case to ensure all aliases in the SERVICES list are unique, which would improve the long-term maintainability and robustness of the code.
| assert_eq!( | ||
| resolve_service("admin-directory").unwrap(), | ||
| ("admin".to_string(), "directory_v1".to_string()) | ||
| ); |
There was a problem hiding this comment.
To prevent future bugs from duplicate service aliases, it's important to ensure all aliases are unique. The current implementation of resolve_service will silently use the first match it finds, which can lead to subtle bugs if an alias is accidentally duplicated. Please add a new test to verify the uniqueness of all aliases across the SERVICES list. This will improve the long-term maintainability and correctness of service resolution.
Here is a suggested implementation for the test:
#[test]
fn test_all_aliases_are_unique() {
let mut all_aliases = std::collections::HashSet::new();
for service in SERVICES {
for &alias in service.aliases {
assert!(all_aliases.insert(alias), "Duplicate alias found: {}", alias);
}
}
}
Summary
This PR adds a new built-in service alias
admin-directoryfor the Admin SDK Directory API (admin:directory_v1), addressing issue #473.Changes
ServiceEntryforadmin-directoryinsrc/services.rsresolve_service("admin-directory")Motivation
The Admin SDK Directory API is one of the most commonly used Google Workspace APIs for managing users, groups, and organizational units. Currently, accessing it through
gwsrequires using theadmin-reportsalias with a version override:This works but is unintuitive —
admin-reportsimplies audit/usage reporting, not user/group management. A built-inadmin-directoryalias makes the CLI more discoverable and self-documenting.Usage
After this change, users can:
Testing
Added unit test for
resolve_service("admin-directory")that verifies it returns the correct (api_name, version) tuple.Fixes: #473