Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .github/workflows/tagging.yml
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* Add `alert_output` field for `databricks.sdk.service.jobs.RunOutput`.
* Add `alert_task` field for `databricks.sdk.service.jobs.RunTask`.
* Add `alert_task` field for `databricks.sdk.service.jobs.SubmitTask`.
* Add `alert_task` field for `databricks.sdk.service.jobs.Task`.
* Add `alert_task` field for `databricks.sdk.service.jobs.Task`.
69 changes: 21 additions & 48 deletions databricks/sdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
OAuthCredentialsProvider)
from .environments import (ALL_ENVS, AzureEnvironment, Cloud,
DatabricksEnvironment, get_environment_for_hostname)
from .oauth import (OidcEndpoints, Token, get_account_endpoints,
from .oauth import (OidcEndpoints, Token,
get_azure_entra_id_workspace_endpoints,
get_endpoints_from_url, get_host_metadata,
get_unified_endpoints, get_workspace_endpoints)
get_endpoints_from_url, get_host_metadata)

logger = logging.getLogger("databricks.sdk")

Expand Down Expand Up @@ -415,14 +414,14 @@ def is_aws(self) -> bool:

@property
def host_type(self) -> HostType:
"""Determine the type of host based on the configuration.

Returns the HostType which can be ACCOUNTS, WORKSPACE, or UNIFIED.
"""
# Check if explicitly marked as unified host
if self.experimental_is_unified_host:
return HostType.UNIFIED
[DEPRECATED]
Host type and client type are deprecated. Some hosts can now support both workspace and account APIs.
This method returns the HostType based on the host pattern, which is not accurate.
For example, a unified host can support both workspace and account APIs, but WORKSPACE is returned.

This method still returns the correct value for legacy hosts which only support either workspace or account APIs.
"""
if not self.host:
return HostType.WORKSPACE

Expand All @@ -434,15 +433,13 @@ def host_type(self) -> HostType:

@property
def client_type(self) -> ClientType:
"""Determine the type of client configuration.

This is separate from host_type. For example, a unified host can support both
workspace and account client types.

Returns ClientType.ACCOUNT or ClientType.WORKSPACE based on the configuration.
"""
[DEPRECATED]
Host type and client type are deprecated. Some hosts can now support both workspace and account APIs.
This method returns the ClientType based on the host pattern, which is not accurate.
For example, a unified host can support both workspace and account APIs, but WORKSPACE is returned.

For unified hosts, account_id must be set. If workspace_id is also set,
returns WORKSPACE, otherwise returns ACCOUNT.
This method still returns the correct value for legacy hosts which only support either workspace or account APIs.
"""
host_type = self.host_type

Expand All @@ -452,25 +449,18 @@ def client_type(self) -> ClientType:
if host_type == HostType.WORKSPACE:
return ClientType.WORKSPACE

if host_type == HostType.UNIFIED:
if not self.account_id:
raise ValueError("Unified host requires account_id to be set")
if self.workspace_id:
return ClientType.WORKSPACE
return ClientType.ACCOUNT

# Default to workspace for backward compatibility
return ClientType.WORKSPACE

@property
def is_account_client(self) -> bool:
"""[Deprecated]
Host type and client type are deprecated. Clients can now support both workspace and account APIs.
Host type and client type are deprecated. Some hosts can now support both workspace and account APIs.
This method returns True if the host is an accounts host, which is not accurate.
For example, a unified host can support both workspace and account APIs, but False is returned.

This method still returns the correct value for legacy hosts which only support either workspace or account APIs.
"""
if self.experimental_is_unified_host:
raise ValueError(
"is_account_client cannot be used with unified hosts; use host_type or client_type instead"
)
if not self.host:
return False
return self.host.startswith("https://accounts.") or self.host.startswith("https://accounts-dod.")
Expand Down Expand Up @@ -535,21 +525,7 @@ def databricks_oidc_endpoints(self) -> Optional[OidcEndpoints]:
if not self.host:
return None

if self.discovery_url:
return get_endpoints_from_url(self.discovery_url)

# Handle unified hosts
if self.host_type == HostType.UNIFIED:
if not self.account_id:
raise ValueError("Unified host requires account_id to be set for OAuth endpoints")
return get_unified_endpoints(self.host, self.account_id)

# Handle traditional account hosts
if self.host_type == HostType.ACCOUNTS and self.account_id:
return get_account_endpoints(self.host, self.account_id)

# Default to workspace endpoints
return get_workspace_endpoints(self.host)
return get_endpoints_from_url(self.discovery_url)

@property
def oidc_endpoints(self) -> Optional[OidcEndpoints]:
Expand Down Expand Up @@ -647,15 +623,12 @@ def attributes(cls) -> Iterable[ConfigAttribute]:
return cls._attributes

def _resolve_host_metadata(self) -> None:
"""[Experimental] Populate missing config fields from the host's
"""Populate missing config fields from the host's
/.well-known/databricks-config discovery endpoint.

Fills in account_id, workspace_id, and discovery_url (derived from oidc_endpoint,
with any {account_id} placeholder substituted) if not already set.
"""
# TODO: Enable this everywhere
if not self.host_type == HostType.UNIFIED:
return
if not self.host:
return
try:
Expand Down
15 changes: 4 additions & 11 deletions databricks/sdk/credentials_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,7 @@ def _oidc_credentials_provider(

# Determine the audience for token exchange
audience = cfg.token_audience
if audience is None and cfg.client_type == ClientType.ACCOUNT:
audience = cfg.account_id
if audience is None and cfg.client_type != ClientType.ACCOUNT:
if audience is None:
Copy link
Contributor Author

@hectorcast-db hectorcast-db Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For account level hosts, audience is set during host metadata resolution.

audience = cfg.databricks_oidc_endpoints.token_endpoint

# Try to get an OIDC token. If no supplier returns a token, we cannot use this authentication mode.
Expand Down Expand Up @@ -986,14 +984,9 @@ def _validate_token_scopes(self, token: oauth.Token):
def _build_host_args(cfg: "Config") -> List[str]:
"""Build CLI arguments using --host (legacy path)."""
args = ["auth", "token", "--host", cfg.host]
if cfg.experimental_is_unified_host:
# For unified hosts, pass account_id, workspace_id, and experimental flag
args += ["--experimental-is-unified-host"]
if cfg.account_id:
args += ["--account-id", cfg.account_id]
if cfg.workspace_id:
args += ["--workspace-id", str(cfg.workspace_id)]
elif cfg.client_type == ClientType.ACCOUNT:
# This is here to support older versions of the Databricks CLI, so we need to keep the client type check.
# This won't work for unified hosts, but it is not supposed to.
if cfg.client_type == ClientType.ACCOUNT:
args += ["--account-id", cfg.account_id]
return args

Expand Down
13 changes: 6 additions & 7 deletions databricks/sdk/service/agentbricks.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading