Skip to main content

Module discovery

Module discovery 

Source
Expand description

Discovery-driven API surface.

Google’s Discovery Service publishes a machine-readable description of every Workspace method: HTTP verb, path template, parameters and OAuth scopes. scripts/fetch-discovery.mjs distils those documents into a compact index (method id, verb, path, scopes, parameters) which this module embeds — 308 methods across ten services in ~350 KiB, versus several megabytes for the raw documents.

This is the escape hatch that makes the curated commands unnecessary for coverage: grr api call <service>.<resource>.<method> reaches every method Google publishes, including ones that did not exist when grr was written, with no code change and no release.

Two properties matter more than the coverage:

  1. Least privilege. Each method carries its own scope list, and grr authorises only the scopes the requested method needs. Asking for all 97 Workspace scopes up front would exceed the ~25-scope ceiling Google applies to unverified apps in testing mode, and would fail at consent; per-method authorisation sidesteps that entirely.
  2. Offline. The index is compiled in, so grr api list and describe work with no network and no cache directory.

Structs§

Method
Parameter
RefreshReport
One service’s refresh outcome, for the grr api refresh report.
Service

Functions§

build_path
Expand a discovery path template into a URL path, substituting {...} placeholders from the supplied parameters.
build_query
Render a parameter map as a query string, skipping path parameters (already substituted) and honouring repeated: true for multi-valued params such as Gmail’s labelIds.
cache_dir
Where grr api refresh stores fetched indexes, and where services() looks for a copy fresher than the embedded baseline.
refresh
Fetch fresh Discovery documents and write them to the cache directory.
resolve
Resolve service.resource.method (or service..method for the few top-level methods that have no resource).
services
Every service, keyed by name: the embedded baseline overlaid with any fresher on-disk cache. Parsed once, on first use.
value_to_string