Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 2.1 API version for UC paths #498

Merged
merged 2 commits into from
Jun 23, 2022
Merged
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
7 changes: 7 additions & 0 deletions databricks_cli/sdk/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from urllib3 import exceptions
from urllib3.util.retry import Retry

from databricks_cli.sdk.version import UC_API_VERSION
from databricks_cli.version import version as databricks_cli_version

class TlsV1HttpAdapter(HTTPAdapter):
Expand Down Expand Up @@ -152,9 +153,15 @@ def get_url(self, path, version=None):
return self.url + version + path
elif self.jobs_api_version and path and path.startswith('/jobs'):
return self.url + self.jobs_api_version + path
elif path and _is_uc_path(path):
return self.url + UC_API_VERSION + path
return self.url + self.api_version + path


def _is_uc_path(path):
return path.startswith('/unity-catalog') or path.startswith('/lineage-tracking')


def _translate_boolean_to_query_param(value):
assert not isinstance(value, list), 'GET parameters cannot pass list of objects'
if isinstance(value, bool):
Expand Down
2 changes: 2 additions & 0 deletions databricks_cli/sdk/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@

API_VERSION = '2.0'

UC_API_VERSION = '2.1'

# Available API versions
API_VERSIONS = ['2.0', '2.1']
18 changes: 0 additions & 18 deletions examples/unity_catalog/replace-permissions1.json

This file was deleted.

6 changes: 6 additions & 0 deletions tests/sdk/test_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def test_get_url():
assert client.get_url('/endpoint') == 'https://databricks.com/api/2.0/endpoint'
assert client.get_url('/jobs/list') == 'https://databricks.com/api/2.1/jobs/list'
assert client.get_url('/jobs/list', '3.0') == 'https://databricks.com/api/3.0/jobs/list'
# Check that UC APIs use '2.1'
assert client.get_url('/unity-catalog/catalogs') == \
'https://databricks.com/api/2.1/unity-catalog/catalogs'
# Can override version for UC API
assert client.get_url('/unity-catalog/catalogs', '2.0') == \
'https://databricks.com/api/2.0/unity-catalog/catalogs'


def test_api_client_url_parsing():
Expand Down