Skip to content

Commit 474d647

Browse files
authored
Merge pull request #64 from JupiterOne/add-abort-function
Add Sync API abort function
2 parents fb7f375 + c2f7405 commit 474d647

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,17 @@ result = j1.upload_combined_batch_json(
531531
print(f"Uploaded {len(combined_payload['entities'])} entities and {len(combined_payload['relationships'])} relationships")
532532
```
533533

534+
##### Abort Synchronization Job
535+
```python
536+
# Abort the sync job
537+
result = j1.abort_sync_job(instance_job_id='<id-of-integration-sync-job>')
538+
print(f"Abort sync job: {result['status'].get('id')}")
539+
540+
# Check job status
541+
if result['job']['status'] == 'ABORTED':
542+
print("Sync job Abort successfully")
543+
```
544+
534545
##### Finalize Synchronization Job
535546

536547
```python

jupiterone/client.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ def bulk_delete_entities(
951951
return response
952952

953953
def finalize_sync_job(self, instance_job_id: Optional[str] = None) -> Dict[str, Any]:
954-
"""Start a synchronization job.
954+
"""Finalize a synchronization job.
955955
956956
args:
957957
instance_job_id (str): The "Job ID" for the Custom Integration job
@@ -964,6 +964,20 @@ def finalize_sync_job(self, instance_job_id: Optional[str] = None) -> Dict[str,
964964

965965
return response
966966

967+
def abort_sync_job(self, instance_job_id: Optional[str] = None) -> Dict[str, Any]:
968+
"""Abort a synchronization job.
969+
970+
args:
971+
instance_job_id (str): The "Job ID" for the Custom Integration job to abort
972+
"""
973+
endpoint = f"/persister/synchronization/jobs/{instance_job_id}/abort"
974+
975+
data = {}
976+
977+
response = self._execute_syncapi_request(endpoint=endpoint, payload=data)
978+
979+
return response
980+
967981
def fetch_integration_jobs(self, instance_id: Optional[str] = None) -> List[Dict[str, Any]]:
968982
"""Fetch Integration Job details from defined integration instance.
969983

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="jupiterone",
8-
version="2.0.1",
8+
version="2.1.0",
99
description="A Python client for the JupiterOne API",
1010
license="MIT License",
1111
author="JupiterOne",

0 commit comments

Comments
 (0)