Skip to content

feat: add API endpoint override for reverse proxy deployments#871

Open
tasuku43 wants to merge 1 commit into
googleworkspace:mainfrom
tasuku43:feat/api-endpoint-override
Open

feat: add API endpoint override for reverse proxy deployments#871
tasuku43 wants to merge 1 commit into
googleworkspace:mainfrom
tasuku43:feat/api-endpoint-override

Conversation

@tasuku43

@tasuku43 tasuku43 commented Jul 9, 2026

Copy link
Copy Markdown

Description

Add an opt-in API endpoint base URL override via GOOGLE_WORKSPACE_CLI_API_ENDPOINT_BASE_URL for deployments that route Google API calls through an internal reverse proxy or API gateway.

The implementation rewrites only the scheme, host, and port of Discovery-derived rootUrl and baseUrl, preserving Google API paths. Discovery documents are still fetched directly from Google, and cached Discovery JSON remains the original Google document so the override can be enabled or disabled without clearing the cache.

This is separate from standard http_proxy / https_proxy forward proxy support: those configure transport proxying, while this configures the API endpoint origin. Existing authentication behavior is unchanged, and OAuth authorization/token endpoints are not rewritten.

Notes:

  • Default behavior is unchanged when the variable is unset or empty.
  • Any path in GOOGLE_WORKSPACE_CLI_API_ENDPOINT_BASE_URL is ignored for routing purposes; the Google API path from Discovery is preserved.
  • Some services share the same Discovery path prefix, such as Analytics Admin and Analytics Data both using /v1beta/. Proxies that route only by path may need their own disambiguation rules for those services.
  • Includes a behavior-preserving clippy cleanup in script.rs required by the current stable toolchain.

Dry Run Output:

N/A. This PR does not add a new command or request body; it changes the base URL used for existing Discovery-driven API requests.

Checklist:

  • My code follows the AGENTS.md guidelines (no generated google-* crates).
  • I have run cargo fmt --all to format the code perfectly.
  • I have run cargo clippy -- -D warnings and resolved all warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have provided a Changeset file (e.g. via pnpx changeset) to document my changes.

Testing

  • cargo fmt
  • cargo build
  • cargo clippy -- -D warnings
  • cargo test

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9252d42

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Minor

Not sure what this means? Click here to learn what changesets are.

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

@google-cla

google-cla Bot commented Jul 9, 2026

Copy link
Copy Markdown

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.

@tasuku43 tasuku43 force-pushed the feat/api-endpoint-override branch from b681e42 to 9252d42 Compare July 9, 2026 14:33
@googleworkspace-bot

Copy link
Copy Markdown
Collaborator

/gemini review

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

Copy link
Copy Markdown
Contributor

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 introduces an opt-in API endpoint base URL override via the GOOGLE_WORKSPACE_CLI_API_ENDPOINT_BASE_URL environment variable. This allows routing Discovery-driven Google API requests through an internal reverse proxy or API gateway by rewriting the scheme, host, and port of the API URLs while preserving their paths. The changes include documentation updates, environment variable handling, URL rewriting logic in discovery.rs, and comprehensive unit tests. Additionally, a minor refactoring was done in script.rs to simplify JSON file matching. There are no review comments, so we have no feedback to provide.

@tasuku43 tasuku43 marked this pull request as ready for review July 9, 2026 14:37
@gemini-code-assist

Copy link
Copy Markdown
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 introduces a new feature allowing users to override the base URL for Google API requests via an environment variable. This is particularly useful for deployments that route API calls through an internal reverse proxy or API gateway. The implementation intelligently rewrites only the origin (scheme, host, port) of API endpoints derived from Discovery documents, ensuring that Google API paths remain intact and Discovery caching behavior is preserved.

Highlights

  • API Endpoint Override: Introduced an opt-in API endpoint base URL override using the GOOGLE_WORKSPACE_CLI_API_ENDPOINT_BASE_URL environment variable, enabling routing through internal reverse proxies or API gateways.
  • URL Rewriting Logic: Implemented logic to rewrite only the scheme, host, and port of Discovery-derived rootUrl and baseUrl for Google API requests, ensuring original API paths are preserved.
  • Discovery Document Handling: Ensured that Discovery documents are still fetched directly from Google and cached in their original form, allowing the override to be enabled or disabled without cache invalidation.
  • Scope Clarification: Clarified that this override is distinct from standard http_proxy/https_proxy support and does not affect OAuth authorization or token endpoints.
  • Code Cleanup: Performed a minor code cleanup in script.rs to align with current stable toolchain clippy requirements.
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 the 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 counterproductive. 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.

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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

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.

2 participants