Skip to content

Commit

Permalink
FAI-13875 Wolken - fetch full incident details (#1893)
Browse files Browse the repository at this point in the history
  • Loading branch information
ypc-faros authored Jan 24, 2025
1 parent 2236fcb commit c5459e2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 4 deletions.
17 changes: 16 additions & 1 deletion faros-airbyte-common/src/wolken/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ export interface Incident {
subStatusId: number;
lastUpdatedByUser: string;
lastUpdatedByUserId: number;
flexData: any[];
plannedStartDate: string;
plannedEndDate: string;
closedByUserID: string;
closureTimeStamp: string;
resolvedByUserID: string;
resolvedByUserEmail: string;
resolvedByUserName: string;
resolutionTimeStamp: string;
description: string;
flexFields: FlexField[];
ciRequestList: CIRequest[];
}

export interface FlexField {
flexId: number;
flexName: string;
flexValue: string;
}
42 changes: 40 additions & 2 deletions sources/wolken-source/resources/schemas/incidents.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,48 @@
"lastUpdatedByUserId": {
"type": "integer"
},
"flexData": {
"plannedStartDate": {
"type": "string"
},
"plannedEndDate": {
"type": "string"
},
"closedByUserID": {
"type": "string"
},
"closureTimeStamp": {
"type": "string"
},
"resolvedByUserID": {
"type": "string"
},
"resolvedByUserEmail": {
"type": "string"
},
"resolvedByUserName": {
"type": "string"
},
"resolutionTimeStamp": {
"type": "string"
},
"description": {
"type": "string"
},
"flexFields": {
"type": "array",
"items": {
"type": "object"
"type": "object",
"properties": {
"flexId": {
"type": "integer"
},
"flexName": {
"type": "string"
},
"flexValue": {
"type": "string"
}
}
}
},
"ciRequestList": {
Expand Down
15 changes: 14 additions & 1 deletion sources/wolken-source/src/wolken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {AxiosInstance} from 'axios';
import {AirbyteLogger} from 'faros-airbyte-cdk';
import {Incident, User} from 'faros-airbyte-common/wolken';
import {makeAxiosInstanceWithRetry} from 'faros-js-client';
import {get} from 'lodash';
import {VError} from 'verror';

const DEFAULT_PAGE_SIZE = 100;
Expand Down Expand Up @@ -225,6 +226,18 @@ export class Wolken {
params['updatedTimeLT'] = endDate.getTime();
}

yield* this.paginate<Incident>('/api/incidents', params);
for await (const incident of this.paginate<Incident>('/api/incidents', params)) {
try {
const response = await this.httpClient.get(`/api/incidents/${incident.ticketId}`, {
headers: {Authorization: `Bearer ${await this.tokenManager.getAccessToken()}`}
});
const responseData = get(response, 'data.data');
if (Array.isArray(responseData) && responseData.length > 0) {
yield responseData[0];
}
} catch (error: any) {
throw new VError(error, `Failed to fetch incident details for ticket ${incident.ticketId}: ${error.message}`);
}
}
}
}

0 comments on commit c5459e2

Please sign in to comment.