Documentation
¶
Overview ¶
Package gcp provides authenticated HTTP access to GCP APIs using Application Default Credentials. It is a shared foundation used by the Vertex AI inference provider and the GCF dispatch provisioner.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractErrorMessage ¶
ExtractErrorMessage parses a GCP API error response and returns only the error message, avoiding leakage of sensitive metadata.
Types ¶
type Client ¶
type Client struct {
QuotaProject string
// contains filtered or unexported fields
}
Client provides authenticated HTTP access to GCP APIs using Application Default Credentials.
func NewClientWithHTTP ¶
NewClientWithHTTP creates a Client that uses the given HTTP client and a static "test-token" for auth. Intended for unit tests that redirect GCP API calls to httptest servers.
func (*Client) AccessToken ¶
AccessToken obtains a GCP access token using Application Default Credentials.
func (*Client) DoRequest ¶
DoRequest creates and executes an authenticated HTTP request. It retries transient failures using exponential backoff with jitter, but only for idempotent HTTP methods (GET, HEAD, PUT, DELETE) to avoid duplicating side effects for non-idempotent requests.
Retryable conditions (idempotent methods only):
- HTTP status codes 500, 502, 503, 504
- Transport errors: connection resets, timeouts, unexpected EOF
Non-idempotent methods (POST, PATCH) are never retried because the server may have processed the request before returning the error or dropping the connection. For example, retrying AddSecretVersion (POST) after a 500 could create a duplicate secret version.
HTTP 429 is not retried here; callers that need 429 retry (e.g. doWIFRequestWithRetry) handle it at a higher level with their own backoff strategy.