Conversation
Adds `HostMetadata` and a package-private `getHostMetadata()` on
`DatabricksConfig` for parsing the `/.well-known/databricks-config`
discovery endpoint.
The method returns raw metadata with no substitution (e.g.
`{account_id}` placeholders are left as-is), keeping it a pure
discovery primitive. Callers decide how to interpret the result.
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
| Request request = new Request("GET", url); | ||
| Response resp = getHttpClient().execute(request); | ||
| if (resp.getStatusCode() != 200) { |
There was a problem hiding this comment.
Thoughts on checking only for 200 vs making it flexible with other status codes 2xx?
There was a problem hiding this comment.
If the server is returning a valid response, 200 is enough here:
────────────────────────────────────────
Code: 200
Name: OK
Meaning: Request succeeded, body contains the resource
Why it doesn't apply: This is the only valid response — a GET
for a config document should return the document.
────────────────────────────────────────
Code: 201
Name: Created
Meaning: A new resource was created
Why it doesn't apply: Only for POST/PUT that creates a
resource. A read-only GET cannot create anything.
────────────────────────────────────────
Code: 202
Name: Accepted
Meaning: Request accepted for async processing
Why it doesn't apply: Implies the response body is not yet
available — we'd have nothing to parse.
────────────────────────────────────────
Code: 203
Name: Non-Authoritative Information
Meaning: Response from a proxy/cache, not the origin server
Why it doesn't apply: The body might be valid, but this
signals
the data may be stale or transformed. Not something we'd
expect from a well-known endpoint.
────────────────────────────────────────
Code: 204
Name: No Content
Meaning: Success but no body
Why it doesn't apply: The body would be empty —
ObjectMapper.readValue would throw, and a config endpoint
with no config is meaningless.
────────────────────────────────────────
Code: 205
Name: Reset Content
Meaning: Success, client should reset its view
Why it doesn't apply: Intended for form resets in browsers;
has
no semantic meaning for an API client.
────────────────────────────────────────
Code: 206
Name: Partial Content
Meaning: Response is a byte-range chunk
Why it doesn't apply: Only for range requests (Range: header).
We send no Range header, so the server should never return
this.
────────────────────────────────────────
Code: 207
Name: Multi-Status
Meaning: Multiple status codes in a single body (WebDAV)
Why it doesn't apply: WebDAV-specific. Not part of HTTP for a
REST endpoint.
────────────────────────────────────────
Code: 208
Name: Already Reported
Meaning: Resource already listed earlier (WebDAV)
Why it doesn't apply: WebDAV-specific, same as above.
────────────────────────────────────────
Code: 226
Name: IM Used
Meaning: Response is a delta encoding
Why it doesn't apply: Requires the client to send A-IM: header
with a delta-encoding request. We don't
🥞 Stacked PR
Use this link to review incremental changes.
Summary
Adds
HostMetadataand a package-privategetHostMetadata()onDatabricksConfigfor parsing the/.well-known/databricks-configdiscovery endpoint.Why
Databricks hosts expose a standard
/.well-known/databricks-configendpoint that returns the OIDC endpoint, account ID, and workspace ID in a single request. The SDK had no primitive to consume it — OIDC endpoint discovery was handled entirely through host-type-specific logic that requires the caller to already know whether the host is a workspace, account console, or unified host.This PR introduces the foundational building block: a
HostMetadataclass and a package-privategetHostMetadata()onDatabricksConfigthat fetches and parses the endpoint. The method returns raw metadata with no substitution (e.g.{account_id}placeholders are left as-is), keeping it a pure discovery primitive. Callers decide how to interpret the result.What changed
Interface changes
HostMetadata— New class incom.databricks.sdk.core.oauthwith fieldsoidcEndpoint,accountId,workspaceId. Deserialized from JSON via Jackson.DatabricksConfig.getHostMetadata()(package-private) — Fetches{host}/.well-known/databricks-configand returns aHostMetadata. ThrowsDatabricksExceptionon any HTTP error.Behavioral changes
None. No existing code paths are modified.
Internal changes
Tests in
DatabricksConfigTestcovering the two response shapes (workspace with static OIDC endpoint, account host with{account_id}template) and the HTTP error path.How is this tested?
Unit tests in
DatabricksConfigTestusingFixtureServer. Both workspace and account host response shapes are exercised, plus an HTTP error case.NO_CHANGELOG=true