Skip to content

feat: refactor CLI to use direct API calls#713

Merged
eliasecchig merged 3 commits intomainfrom
feat/cli-api-improvements
Jan 19, 2026
Merged

feat: refactor CLI to use direct API calls#713
eliasecchig merged 3 commits intomainfrom
feat/cli-api-improvements

Conversation

@eliasecchig
Copy link
Collaborator

  • Add get_project_number() function using Resource Manager API
  • Replace gcloud projects describe calls with direct API calls in cicd.py
  • Add _build_api_headers() helper in register_gemini_enterprise.py
  • Include User-Agent and x-goog-api-client headers in Discovery Engine API calls

- Add get_project_number() function using Resource Manager API
- Replace gcloud projects describe calls with direct API calls in cicd.py
- Add _build_api_headers() helper in register_gemini_enterprise.py
- Include User-Agent and x-goog-api-client headers in Discovery Engine API calls
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @eliasecchig, 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 streamlines the CLI's interaction with Google Cloud by shifting from gcloud CLI commands to direct API calls for retrieving project numbers. It also centralizes and enhances the construction of API request headers for Discovery Engine services, ensuring consistent client identification and reducing boilerplate code.

Highlights

  • Direct API calls for project numbers: Replaced gcloud projects describe commands with direct calls to the Resource Manager API for fetching Google Cloud project numbers, reducing reliance on the gcloud CLI.
  • Standardized API headers: Introduced a new helper function _build_api_headers to consistently construct headers for Discovery Engine API requests.
  • Enhanced API client identification: Incorporated User-Agent and x-goog-api-client headers into Discovery Engine API calls, improving client telemetry and identification.
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 Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, 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 is a great improvement, refactoring gcloud CLI calls to direct API requests. This enhances performance and reduces external dependencies. The new get_project_number function and _build_api_headers helper are well-implemented. However, the refactoring appears to be incomplete. The get_project_number function within agent_starter_pack/cli/commands/register_gemini_enterprise.py still relies on the gcloud command and should be updated to use the new API-based implementation from agent_starter_pack/cli/utils/gcp.py. This also means its call sites need to be updated to handle exceptions instead of a None return value. I've also added a few specific comments to improve error handling and code structure.

- Make get_user_agent and get_x_goog_api_client_header public in gcp.py
- Add RESOURCE_MANAGER_API_BASE constant for API endpoint URL
- Use specific exceptions (PermissionError, ValueError) in get_project_number
- Update cicd.py to handle new exception types from get_project_number
- Update register_gemini_enterprise.py to use public function names
@eliasecchig eliasecchig merged commit 4a40775 into main Jan 19, 2026
34 checks passed
enriquekalven pushed a commit to enriquekalven/agent-starter-pack that referenced this pull request Feb 7, 2026
* feat: refactor CLI to use direct API calls

- Add get_project_number() function using Resource Manager API
- Replace gcloud projects describe calls with direct API calls in cicd.py
- Add _build_api_headers() helper in register_gemini_enterprise.py
- Include User-Agent and x-goog-api-client headers in Discovery Engine API calls

* fix: improve error handling and make API helper functions public

- Make get_user_agent and get_x_goog_api_client_header public in gcp.py
- Add RESOURCE_MANAGER_API_BASE constant for API endpoint URL
- Use specific exceptions (PermissionError, ValueError) in get_project_number
- Update cicd.py to handle new exception types from get_project_number
- Update register_gemini_enterprise.py to use public function names

* fix: remove extra ::: from development guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant