Skip to content

Commit

Permalink
Merge pull request #1097 from JupiterOne/DP-287-add-terminal-status-t…
Browse files Browse the repository at this point in the history
…o-abort-endpoint

[DP-287] - Add terminalStatus to abort syncJob api endpoint
  • Loading branch information
dobregons committed Jul 5, 2024
2 parents 832afaa + 32ec904 commit f33ba16
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 f33ba16

Please sign in to comment.