1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
12 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
13 | return new (P || (P = Promise))(function (resolve, reject) {
|
14 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
15 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
16 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
17 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
18 | });
|
19 | };
|
20 | Object.defineProperty(exports, "__esModule", { value: true });
|
21 | exports.AlertApi = void 0;
|
22 | const basem = require("./ClientApiBases");
|
23 | const AlertInterfaces = require("./interfaces/AlertInterfaces");
|
24 | class AlertApi extends basem.ClientApiBase {
|
25 | constructor(baseUrl, handlers, options) {
|
26 | super(baseUrl, handlers, 'node-Alert-api', options);
|
27 | }
|
28 | |
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | getAlert(project, alertId, repository, ref, expand) {
|
38 | return __awaiter(this, void 0, void 0, function* () {
|
39 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
40 | let routeValues = {
|
41 | project: project,
|
42 | alertId: alertId,
|
43 | repository: repository
|
44 | };
|
45 | let queryValues = {
|
46 | ref: ref,
|
47 | expand: expand,
|
48 | };
|
49 | try {
|
50 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Alert", "e21b4630-b7d2-4031-99e3-3ad328cc4a7f", routeValues, queryValues);
|
51 | let url = verData.requestUrl;
|
52 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
53 | let res;
|
54 | res = yield this.rest.get(url, options);
|
55 | let ret = this.formatResponse(res.result, AlertInterfaces.TypeInfo.Alert, false);
|
56 | resolve(ret);
|
57 | }
|
58 | catch (err) {
|
59 | reject(err);
|
60 | }
|
61 | }));
|
62 | });
|
63 | }
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | getAlerts(project, repository, top, orderBy, criteria, continuationToken) {
|
75 | return __awaiter(this, void 0, void 0, function* () {
|
76 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
77 | let routeValues = {
|
78 | project: project,
|
79 | repository: repository
|
80 | };
|
81 | let queryValues = {
|
82 | top: top,
|
83 | orderBy: orderBy,
|
84 | criteria: criteria,
|
85 | continuationToken: continuationToken,
|
86 | };
|
87 | try {
|
88 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Alert", "e21b4630-b7d2-4031-99e3-3ad328cc4a7f", routeValues, queryValues);
|
89 | let url = verData.requestUrl;
|
90 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
91 | let res;
|
92 | res = yield this.rest.get(url, options);
|
93 | let ret = this.formatResponse(res.result, AlertInterfaces.TypeInfo.Alert, true);
|
94 | resolve(ret);
|
95 | }
|
96 | catch (err) {
|
97 | reject(err);
|
98 | }
|
99 | }));
|
100 | });
|
101 | }
|
102 | |
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | getAlertSarif(project, alertId, repository, ref, expand) {
|
112 | return __awaiter(this, void 0, void 0, function* () {
|
113 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
114 | let routeValues = {
|
115 | project: project,
|
116 | alertId: alertId,
|
117 | repository: repository
|
118 | };
|
119 | let queryValues = {
|
120 | ref: ref,
|
121 | expand: expand,
|
122 | };
|
123 | try {
|
124 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Alert", "e21b4630-b7d2-4031-99e3-3ad328cc4a7f", routeValues, queryValues);
|
125 | let url = verData.requestUrl;
|
126 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
127 | let res;
|
128 | res = yield this.rest.get(url, options);
|
129 | let ret = this.formatResponse(res.result, null, false);
|
130 | resolve(ret);
|
131 | }
|
132 | catch (err) {
|
133 | reject(err);
|
134 | }
|
135 | }));
|
136 | });
|
137 | }
|
138 | |
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 | updateAlert(stateUpdate, project, alertId, repository) {
|
147 | return __awaiter(this, void 0, void 0, function* () {
|
148 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
149 | let routeValues = {
|
150 | project: project,
|
151 | alertId: alertId,
|
152 | repository: repository
|
153 | };
|
154 | try {
|
155 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Alert", "e21b4630-b7d2-4031-99e3-3ad328cc4a7f", routeValues);
|
156 | let url = verData.requestUrl;
|
157 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
158 | let res;
|
159 | res = yield this.rest.update(url, stateUpdate, options);
|
160 | let ret = this.formatResponse(res.result, AlertInterfaces.TypeInfo.Alert, false);
|
161 | resolve(ret);
|
162 | }
|
163 | catch (err) {
|
164 | reject(err);
|
165 | }
|
166 | }));
|
167 | });
|
168 | }
|
169 | |
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | getAlertInstances(project, alertId, repository, ref) {
|
178 | return __awaiter(this, void 0, void 0, function* () {
|
179 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
180 | let routeValues = {
|
181 | project: project,
|
182 | alertId: alertId,
|
183 | repository: repository
|
184 | };
|
185 | let queryValues = {
|
186 | ref: ref,
|
187 | };
|
188 | try {
|
189 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Alert", "f451ba96-0e95-458a-8dd5-3df894770a49", routeValues, queryValues);
|
190 | let url = verData.requestUrl;
|
191 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
192 | let res;
|
193 | res = yield this.rest.get(url, options);
|
194 | let ret = this.formatResponse(res.result, AlertInterfaces.TypeInfo.AlertAnalysisInstance, true);
|
195 | resolve(ret);
|
196 | }
|
197 | catch (err) {
|
198 | reject(err);
|
199 | }
|
200 | }));
|
201 | });
|
202 | }
|
203 | |
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 | updateAlertsMetadata(alertsMetadata, project, repository) {
|
211 | return __awaiter(this, void 0, void 0, function* () {
|
212 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
213 | let routeValues = {
|
214 | project: project,
|
215 | repository: repository
|
216 | };
|
217 | try {
|
218 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Alert", "65de4b84-7519-4ae8-8623-175f79b49b80", routeValues);
|
219 | let url = verData.requestUrl;
|
220 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
221 | let res;
|
222 | res = yield this.rest.update(url, alertsMetadata, options);
|
223 | let ret = this.formatResponse(res.result, AlertInterfaces.TypeInfo.AlertMetadataChange, true);
|
224 | resolve(ret);
|
225 | }
|
226 | catch (err) {
|
227 | reject(err);
|
228 | }
|
229 | }));
|
230 | });
|
231 | }
|
232 | |
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 | uploadSarif(customHeaders, contentStream, project, repository) {
|
240 | return __awaiter(this, void 0, void 0, function* () {
|
241 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
242 | let routeValues = {
|
243 | project: project,
|
244 | repository: repository
|
245 | };
|
246 | customHeaders = customHeaders || {};
|
247 | customHeaders["Content-Type"] = "application/octet-stream";
|
248 | try {
|
249 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Alert", "2a141cae-a50d-4c22-b41b-13f77748d035", routeValues);
|
250 | let url = verData.requestUrl;
|
251 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
252 | options.additionalHeaders = customHeaders;
|
253 | let res;
|
254 | res = yield this.rest.uploadStream("POST", url, contentStream, options);
|
255 | let ret = this.formatResponse(res.result, null, false);
|
256 | resolve(ret);
|
257 | }
|
258 | catch (err) {
|
259 | reject(err);
|
260 | }
|
261 | }));
|
262 | });
|
263 | }
|
264 | |
265 |
|
266 |
|
267 |
|
268 |
|
269 | getUxFilters(project, repository, alertType) {
|
270 | return __awaiter(this, void 0, void 0, function* () {
|
271 | if (alertType == null) {
|
272 | throw new TypeError('alertType can not be null or undefined');
|
273 | }
|
274 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
275 | let routeValues = {
|
276 | project: project,
|
277 | repository: repository
|
278 | };
|
279 | let queryValues = {
|
280 | alertType: alertType,
|
281 | };
|
282 | try {
|
283 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Alert", "8f90675b-f794-434d-8f2c-cfae0a11c02a", routeValues, queryValues);
|
284 | let url = verData.requestUrl;
|
285 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
286 | let res;
|
287 | res = yield this.rest.get(url, options);
|
288 | let ret = this.formatResponse(res.result, AlertInterfaces.TypeInfo.UxFilters, false);
|
289 | resolve(ret);
|
290 | }
|
291 | catch (err) {
|
292 | reject(err);
|
293 | }
|
294 | }));
|
295 | });
|
296 | }
|
297 | |
298 |
|
299 |
|
300 |
|
301 |
|
302 | getSarif(sarifId) {
|
303 | return __awaiter(this, void 0, void 0, function* () {
|
304 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
305 | let routeValues = {
|
306 | sarifId: sarifId
|
307 | };
|
308 | try {
|
309 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.2", "Alert", "a04689e7-0f81-48a2-8d18-40654c47494c", routeValues);
|
310 | let url = verData.requestUrl;
|
311 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
312 | let res;
|
313 | res = yield this.rest.get(url, options);
|
314 | let ret = this.formatResponse(res.result, AlertInterfaces.TypeInfo.SarifUploadStatus, false);
|
315 | resolve(ret);
|
316 | }
|
317 | catch (err) {
|
318 | reject(err);
|
319 | }
|
320 | }));
|
321 | });
|
322 | }
|
323 | }
|
324 | exports.AlertApi = AlertApi;
|