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

[11/n][dagster-airbyte] Implement cancel_job method in AirbyteCloudClient #26430

Merged
merged 2 commits into from
Dec 26, 2024
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 @@ -1008,6 +1008,11 @@ def get_job_details(self, job_id: int) -> Mapping[str, Any]:
method="GET", endpoint=f"jobs/{job_id}", base_url=self.rest_api_base_url
)

def cancel_job(self, job_id: int) -> Mapping[str, Any]:
return self._make_request(
method="DELETE", endpoint=f"jobs/{job_id}", base_url=self.rest_api_base_url
)


@experimental
class AirbyteCloudWorkspace(ConfigurableResource):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,10 @@ def all_api_mocks_fixture(
json=SAMPLE_JOB_RESPONSE,
status=200,
)
fetch_workspace_data_api_mocks.add(
method=responses.DELETE,
url=f"{AIRBYTE_REST_API_BASE}/{AIRBYTE_REST_API_VERSION}/jobs/{TEST_JOB_ID}",
json=SAMPLE_JOB_RESPONSE,
status=200,
)
yield fetch_workspace_data_api_mocks
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ def test_basic_resource_request(
client.get_destination_details(destination_id=TEST_DESTINATION_ID)
client.start_sync_job(connection_id=TEST_CONNECTION_ID)
client.get_job_details(job_id=TEST_JOB_ID)
client.cancel_job(job_id=TEST_JOB_ID)

assert len(all_api_mocks.calls) == 6
assert len(all_api_mocks.calls) == 7
# The first call is to create the access token
api_calls = assert_token_call_and_split_calls(calls=all_api_mocks.calls)
# The next calls are actual API calls
Expand All @@ -142,3 +143,4 @@ def test_basic_resource_request(
assert_rest_api_call(call=api_calls[2], endpoint=f"destinations/{TEST_DESTINATION_ID}")
assert_rest_api_call(call=api_calls[3], endpoint="jobs", object_id=TEST_CONNECTION_ID)
assert_rest_api_call(call=api_calls[4], endpoint=f"jobs/{TEST_JOB_ID}")
assert_rest_api_call(call=api_calls[5], endpoint=f"jobs/{TEST_JOB_ID}")