feat(api): add raw Firestore REST API subcommand#56
Merged
Conversation
Adds `firestore api <path>`, a gh-api-style escape hatch for Firestore
operations the CLI does not wrap yet (named databases, :runQuery, admin
endpoints, etc.). Relative paths expand under the project's documents
collection; paths starting with `projects/` are sent verbatim. Supports
{project}/{database} placeholders, -X/--method, and --input (file or STDIN).
Auth reuses ADC; falls back to the emulator when --host is set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
firestore api <path>— agh api-style escape hatch for hitting any Firestore REST endpoint with the project and credentials already configured. Covers interactions the CLI does not wrap yet (named databases,:runQuery,:batchGet, field masks, admin endpoints, ...) without needing a bespoke command for each.Behaviour
users/u1) expand underprojects/<project>/databases/(default)/documents/; paths starting withprojects/are sent verbatim (after/v1/) for admin/query endpoints.{project}→--project/PROJECT_ID,{database}→(default).-X/--method(default GET, or POST when a body is given);--input <file>or--input -(STDIN), with automaticapplication/jsoncontent-type.firestore auth login); uses the emulator with no real creds when--host/FIRESTORE_EMULATOR_HOSTis set.firestore api --help.No new dependencies —
golang.org/x/oauth2/googlewas already available.Testing
go build,go vet ./...,go test ./...all green; unit tests cover path resolution (relative/verbatim/placeholders/leading-slash) and method defaulting.:runQuerywith placeholders, delete, and a 404 returning a non-zero exit with the error body — all verified.