Skip to content

Add admin-directory as built-in service alias for Admin SDK Directory API#476

Open
Jah-yee wants to merge 1 commit intogoogleworkspace:mainfrom
Jah-yee:admin-directory-feature
Open

Add admin-directory as built-in service alias for Admin SDK Directory API#476
Jah-yee wants to merge 1 commit intogoogleworkspace:mainfrom
Jah-yee:admin-directory-feature

Conversation

@Jah-yee
Copy link

@Jah-yee Jah-yee commented Mar 13, 2026

Summary

This PR adds a new built-in service alias admin-directory for the Admin SDK Directory API (admin:directory_v1), addressing issue #473.

Changes

  • Add ServiceEntry for admin-directory in src/services.rs
  • Add test case for resolve_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 gws requires using the admin-reports alias with a version override:

gws admin-reports --api-version directory_v1 groups list

This works but is unintuitive — admin-reports implies audit/usage reporting, not user/group management. A built-in admin-directory alias makes the CLI more discoverable and self-documenting.

Usage

After this change, users can:

gws admin-directory groups list --params '{"domain":"example.com"}'
gws admin-directory members list --params '{"groupKey":"group@example.com"}'
gws admin-directory users get --params '{"userKey":"user@example.com"}'

Testing

Added unit test for resolve_service("admin-directory") that verifies it returns the correct (api_name, version) tuple.

Fixes: #473

… 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
@google-cla
Copy link

google-cla bot commented Mar 13, 2026

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.

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

⚠️ No Changeset found

Latest commit: f5d0913

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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

  • New Service Alias: Added admin-directory as a built-in service alias for the Admin SDK Directory API (admin:directory_v1), making it more intuitive and discoverable for managing users, groups, and organizational units.
  • Test Coverage: Included a new test case to verify that resolve_service("admin-directory") correctly returns the admin:directory_v1 API.
Changelog
  • src/services.rs
    • Introduced a new ServiceEntry for admin-directory to map to the admin:directory_v1 API.
    • Added a unit test to confirm that resolve_service("admin-directory") correctly returns the admin:directory_v1 API.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +173 to +176
assert_eq!(
resolve_service("admin-directory").unwrap(),
("admin".to_string(), "directory_v1".to_string())
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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);
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add admin-directory as a built-in service alias for Admin SDK Directory API

2 participants