Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
from airflow.providers.common.compat.sdk import AirflowException
from airflow.providers.databricks.hooks.databricks_base import BaseDatabricksHook

GET_CLUSTER_ENDPOINT = ("GET", "2.2/clusters/get")
RESTART_CLUSTER_ENDPOINT = ("POST", "2.2/clusters/restart")
START_CLUSTER_ENDPOINT = ("POST", "2.2/clusters/start")
TERMINATE_CLUSTER_ENDPOINT = ("POST", "2.2/clusters/delete")
GET_CLUSTER_ENDPOINT = ("GET", "2.1/clusters/get")
RESTART_CLUSTER_ENDPOINT = ("POST", "2.1/clusters/restart")
START_CLUSTER_ENDPOINT = ("POST", "2.1/clusters/start")
TERMINATE_CLUSTER_ENDPOINT = ("POST", "2.1/clusters/delete")

CREATE_ENDPOINT = ("POST", "2.2/jobs/create")
RESET_ENDPOINT = ("POST", "2.2/jobs/reset")
Expand All @@ -54,20 +54,20 @@
OUTPUT_RUNS_JOB_ENDPOINT = ("GET", "2.2/jobs/runs/get-output")
CANCEL_ALL_RUNS_ENDPOINT = ("POST", "2.2/jobs/runs/cancel-all")

INSTALL_LIBS_ENDPOINT = ("POST", "2.2/libraries/install")
UNINSTALL_LIBS_ENDPOINT = ("POST", "2.2/libraries/uninstall")
UPDATE_REPO_ENDPOINT = ("PATCH", "2.2/repos/")
DELETE_REPO_ENDPOINT = ("DELETE", "2.2/repos/")
CREATE_REPO_ENDPOINT = ("POST", "2.2/repos")
INSTALL_LIBS_ENDPOINT = ("POST", "2.0/libraries/install")
UNINSTALL_LIBS_ENDPOINT = ("POST", "2.0/libraries/uninstall")
UPDATE_REPO_ENDPOINT = ("PATCH", "2.0/repos/")
DELETE_REPO_ENDPOINT = ("DELETE", "2.0/repos/")
CREATE_REPO_ENDPOINT = ("POST", "2.0/repos")

LIST_JOBS_ENDPOINT = ("GET", "2.2/jobs/list")
LIST_PIPELINES_ENDPOINT = ("GET", "2.2/pipelines")
LIST_SQL_ENDPOINTS_ENDPOINT = ("GET", "2.2/sql/endpoints")
LIST_PIPELINES_ENDPOINT = ("GET", "2.0/pipelines")
LIST_SQL_ENDPOINTS_ENDPOINT = ("GET", "2.0/sql/warehouses")

WORKSPACE_GET_STATUS_ENDPOINT = ("GET", "2.2/workspace/get-status")
WORKSPACE_GET_STATUS_ENDPOINT = ("GET", "2.0/workspace/get-status")

SPARK_VERSIONS_ENDPOINT = ("GET", "2.2/clusters/spark-versions")
SQL_STATEMENTS_ENDPOINT = "2.2/sql/statements"
SPARK_VERSIONS_ENDPOINT = ("GET", "2.1/clusters/spark-versions")
SQL_STATEMENTS_ENDPOINT = "2.0/sql/statements"


class RunLifeCycleState(Enum):
Expand Down Expand Up @@ -717,7 +717,7 @@ def install(self, json: dict) -> None:
"""
Install libraries on the cluster.

Utility function to call the ``2.2/libraries/install`` endpoint.
Utility function to call the ``2.0/libraries/install`` endpoint.

:param json: json dictionary containing cluster_id and an array of library
"""
Expand All @@ -727,7 +727,7 @@ def uninstall(self, json: dict) -> None:
"""
Uninstall libraries on the cluster.

Utility function to call the ``2.2/libraries/uninstall`` endpoint.
Utility function to call the ``2.0/libraries/uninstall`` endpoint.

:param json: json dictionary containing cluster_id and an array of library
"""
Expand Down Expand Up @@ -790,7 +790,7 @@ def update_job_permission(self, job_id: int, json: dict[str, Any]) -> dict:
:param json: payload
:return: json containing permission specification
"""
return self._do_api_call(("PATCH", f"2.2/permissions/jobs/{job_id}"), json)
return self._do_api_call(("PATCH", f"2.0/permissions/jobs/{job_id}"), json)

def post_sql_statement(self, json: dict[str, Any]) -> str:
"""
Expand Down
22 changes: 11 additions & 11 deletions providers/databricks/tests/unit/databricks/hooks/test_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,42 +216,42 @@ def get_cluster_endpoint(host):
"""
Utility function to generate the get run endpoint given the host.
"""
return f"https://{host}/api/2.2/clusters/get"
return f"https://{host}/api/2.1/clusters/get"


def start_cluster_endpoint(host):
"""
Utility function to generate the get run endpoint given the host.
"""
return f"https://{host}/api/2.2/clusters/start"
return f"https://{host}/api/2.1/clusters/start"


def restart_cluster_endpoint(host):
"""
Utility function to generate the get run endpoint given the host.
"""
return f"https://{host}/api/2.2/clusters/restart"
return f"https://{host}/api/2.1/clusters/restart"


def terminate_cluster_endpoint(host):
"""
Utility function to generate the get run endpoint given the host.
"""
return f"https://{host}/api/2.2/clusters/delete"
return f"https://{host}/api/2.1/clusters/delete"


def install_endpoint(host):
"""
Utility function to generate the install endpoint given the host.
"""
return f"https://{host}/api/2.2/libraries/install"
return f"https://{host}/api/2.0/libraries/install"


def uninstall_endpoint(host):
"""
Utility function to generate the uninstall endpoint given the host.
"""
return f"https://{host}/api/2.2/libraries/uninstall"
return f"https://{host}/api/2.0/libraries/uninstall"


def list_jobs_endpoint(host):
Expand All @@ -265,19 +265,19 @@ def list_pipelines_endpoint(host):
"""
Utility function to generate the list jobs endpoint given the host
"""
return f"https://{host}/api/2.2/pipelines"
return f"https://{host}/api/2.0/pipelines"


def list_spark_versions_endpoint(host):
"""Utility function to generate the list spark versions endpoint given the host"""
return f"https://{host}/api/2.2/clusters/spark-versions"
return f"https://{host}/api/2.1/clusters/spark-versions"


def permissions_endpoint(host, job_id):
"""
Utility function to generate the permissions endpoint given the host
"""
return f"https://{host}/api/2.2/permissions/jobs/{job_id}"
return f"https://{host}/api/2.0/permissions/jobs/{job_id}"


def create_valid_response_mock(content):
Expand All @@ -289,7 +289,7 @@ def create_valid_response_mock(content):

def sql_statements_endpoint(host):
"""Utility function to generate the sql statements endpoint given the host."""
return f"https://{host}/api/2.2/sql/statements"
return f"https://{host}/api/2.0/sql/statements"


def create_successful_response_mock(content):
Expand Down Expand Up @@ -1302,7 +1302,7 @@ def test_update_job_permission(self, mock_requests):
self.hook.update_job_permission(1, ACCESS_CONTROL_DICT)

mock_requests.patch.assert_called_once_with(
f"https://{HOST}/api/2.2/permissions/jobs/1",
f"https://{HOST}/api/2.0/permissions/jobs/1",
json=utils.normalise_json_content(ACCESS_CONTROL_DICT),
params=None,
auth=HTTPBasicAuth(LOGIN, PASSWORD),
Expand Down