Skip to content

Commit

Permalink
add terminalStatus to abort syncJob api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dobregons committed Jul 3, 2024
1 parent 59a07be commit 32ec904
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/integration-sdk-core/src/types/synchronization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum SynchronizationJobStatus {
FINISHED = 'FINISHED',
UNKNOWN = 'UNKNOWN',
ERROR_BAD_DATA = 'ERROR_BAD_DATA',
ABORTED_DUE_TO_INVALID_CONFIGURATION = 'ABORTED_DUE_TO_INVALID_CONFIGURATION',
}

export interface SynchronizationJob {
Expand Down
10 changes: 8 additions & 2 deletions packages/integration-sdk-runtime/src/synchronization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
PartialDatasets,
Relationship,
SynchronizationJob,
SynchronizationJobStatus,
} from '@jupiterone/integration-sdk-core';

import { AxiosError } from 'axios';
Expand Down Expand Up @@ -569,6 +570,7 @@ export async function uploadData<T extends UploadDataLookup, K extends keyof T>(

interface AbortSynchronizationInput extends SynchronizationJobContext {
reason?: string;
terminalStatus?: SynchronizationJobStatus;
}
/**
* Aborts a synchronization job
Expand All @@ -578,15 +580,19 @@ export async function abortSynchronization({
apiClient,
job,
reason,
terminalStatus,
}: AbortSynchronizationInput) {
logger.info('Aborting synchronization job...');
logger.info(
{ integrationJobId: job.id, reason, terminalStatus },
'Aborting synchronization job...',
);

let abortedJob: SynchronizationJob;

try {
const response = await apiClient.post(
`/persister/synchronization/jobs/${job.id}/abort`,
{ reason },
{ reason, terminalStatus },
);
abortedJob = response.data.job;
} catch (err) {
Expand Down

0 comments on commit 32ec904

Please sign in to comment.