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

Adds job_id as path param in update permission #38962

Merged
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
6 changes: 3 additions & 3 deletions airflow/providers/databricks/hooks/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
REPAIR_RUN_ENDPOINT = ("POST", "api/2.1/jobs/runs/repair")
OUTPUT_RUNS_JOB_ENDPOINT = ("GET", "api/2.1/jobs/runs/get-output")
CANCEL_ALL_RUNS_ENDPOINT = ("POST", "api/2.1/jobs/runs/cancel-all")
UPDATE_PERMISSION_ENDPOINT = ("PATCH", "api/2.0/permissions/jobs")

INSTALL_LIBS_ENDPOINT = ("POST", "api/2.0/libraries/install")
UNINSTALL_LIBS_ENDPOINT = ("POST", "api/2.0/libraries/uninstall")
Expand Down Expand Up @@ -656,14 +655,15 @@ def get_repo_by_path(self, path: str) -> str | None:

return None

def update_job_permission(self, json: dict[str, Any]) -> dict:
def update_job_permission(self, job_id: int, json: dict[str, Any]) -> dict:
"""
Update databricks job permission.

:param job_id: job id
:param json: payload
:return: json containing permission specification
"""
return self._do_api_call(UPDATE_PERMISSION_ENDPOINT, json)
return self._do_api_call(("PATCH", f"api/2.0/permissions/jobs/{job_id}"), json)

def test_connection(self) -> tuple[bool, str]:
"""Test the Databricks connectivity from UI."""
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/databricks/operators/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def execute(self, context: Context) -> int:
self._hook.reset_job(str(job_id), self.json)
if (access_control_list := self.json.get("access_control_list")) is not None:
acl_json = {"access_control_list": access_control_list}
self._hook.update_job_permission(normalise_json_content(acl_json))
self._hook.update_job_permission(job_id, normalise_json_content(acl_json))

return job_id

Expand Down
2 changes: 1 addition & 1 deletion tests/providers/databricks/operators/test_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def test_exec_update_job_permission(self, db_mock_class):
caller="DatabricksCreateJobsOperator",
)

db_mock.update_job_permission.assert_called_once_with(expected)
db_mock.update_job_permission.assert_called_once_with(JOB_ID, expected)

@mock.patch("airflow.providers.databricks.operators.databricks.DatabricksHook")
def test_exec_update_job_permission_with_empty_acl(self, db_mock_class):
Expand Down