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.PolicyApi = void 0;
|
22 | const basem = require("./ClientApiBases");
|
23 | const PolicyInterfaces = require("./interfaces/PolicyInterfaces");
|
24 | class PolicyApi extends basem.ClientApiBase {
|
25 | constructor(baseUrl, handlers, options) {
|
26 | super(baseUrl, handlers, 'node-Policy-api', options);
|
27 | }
|
28 | |
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | createPolicyConfiguration(configuration, project) {
|
35 | return __awaiter(this, void 0, void 0, function* () {
|
36 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
37 | let routeValues = {
|
38 | project: project
|
39 | };
|
40 | try {
|
41 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "dad91cbe-d183-45f8-9c6e-9c1164472121", routeValues);
|
42 | let url = verData.requestUrl;
|
43 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
44 | let res;
|
45 | res = yield this.rest.create(url, configuration, options);
|
46 | let ret = this.formatResponse(res.result, PolicyInterfaces.TypeInfo.PolicyConfiguration, false);
|
47 | resolve(ret);
|
48 | }
|
49 | catch (err) {
|
50 | reject(err);
|
51 | }
|
52 | }));
|
53 | });
|
54 | }
|
55 | |
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | deletePolicyConfiguration(project, configurationId) {
|
62 | return __awaiter(this, void 0, void 0, function* () {
|
63 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
64 | let routeValues = {
|
65 | project: project,
|
66 | configurationId: configurationId
|
67 | };
|
68 | try {
|
69 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "dad91cbe-d183-45f8-9c6e-9c1164472121", routeValues);
|
70 | let url = verData.requestUrl;
|
71 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
72 | let res;
|
73 | res = yield this.rest.del(url, options);
|
74 | let ret = this.formatResponse(res.result, null, false);
|
75 | resolve(ret);
|
76 | }
|
77 | catch (err) {
|
78 | reject(err);
|
79 | }
|
80 | }));
|
81 | });
|
82 | }
|
83 | |
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | getPolicyConfiguration(project, configurationId) {
|
90 | return __awaiter(this, void 0, void 0, function* () {
|
91 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
92 | let routeValues = {
|
93 | project: project,
|
94 | configurationId: configurationId
|
95 | };
|
96 | try {
|
97 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "dad91cbe-d183-45f8-9c6e-9c1164472121", routeValues);
|
98 | let url = verData.requestUrl;
|
99 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
100 | let res;
|
101 | res = yield this.rest.get(url, options);
|
102 | let ret = this.formatResponse(res.result, PolicyInterfaces.TypeInfo.PolicyConfiguration, false);
|
103 | resolve(ret);
|
104 | }
|
105 | catch (err) {
|
106 | reject(err);
|
107 | }
|
108 | }));
|
109 | });
|
110 | }
|
111 | |
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | getPolicyConfigurations(project, scope, policyType) {
|
119 | return __awaiter(this, void 0, void 0, function* () {
|
120 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
121 | let routeValues = {
|
122 | project: project
|
123 | };
|
124 | let queryValues = {
|
125 | scope: scope,
|
126 | policyType: policyType,
|
127 | };
|
128 | try {
|
129 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "dad91cbe-d183-45f8-9c6e-9c1164472121", routeValues, queryValues);
|
130 | let url = verData.requestUrl;
|
131 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
132 | let res;
|
133 | res = yield this.rest.get(url, options);
|
134 | let ret = this.formatResponse(res.result, PolicyInterfaces.TypeInfo.PolicyConfiguration, true);
|
135 | resolve(ret);
|
136 | }
|
137 | catch (err) {
|
138 | reject(err);
|
139 | }
|
140 | }));
|
141 | });
|
142 | }
|
143 | |
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | updatePolicyConfiguration(configuration, project, configurationId) {
|
151 | return __awaiter(this, void 0, void 0, function* () {
|
152 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
153 | let routeValues = {
|
154 | project: project,
|
155 | configurationId: configurationId
|
156 | };
|
157 | try {
|
158 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "dad91cbe-d183-45f8-9c6e-9c1164472121", routeValues);
|
159 | let url = verData.requestUrl;
|
160 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
161 | let res;
|
162 | res = yield this.rest.replace(url, configuration, options);
|
163 | let ret = this.formatResponse(res.result, PolicyInterfaces.TypeInfo.PolicyConfiguration, false);
|
164 | resolve(ret);
|
165 | }
|
166 | catch (err) {
|
167 | reject(err);
|
168 | }
|
169 | }));
|
170 | });
|
171 | }
|
172 | |
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 | getPolicyEvaluation(project, evaluationId) {
|
179 | return __awaiter(this, void 0, void 0, function* () {
|
180 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
181 | let routeValues = {
|
182 | project: project,
|
183 | evaluationId: evaluationId
|
184 | };
|
185 | try {
|
186 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "46aecb7a-5d2c-4647-897b-0209505a9fe4", routeValues);
|
187 | let url = verData.requestUrl;
|
188 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
189 | let res;
|
190 | res = yield this.rest.get(url, options);
|
191 | let ret = this.formatResponse(res.result, PolicyInterfaces.TypeInfo.PolicyEvaluationRecord, false);
|
192 | resolve(ret);
|
193 | }
|
194 | catch (err) {
|
195 | reject(err);
|
196 | }
|
197 | }));
|
198 | });
|
199 | }
|
200 | |
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 | requeuePolicyEvaluation(project, evaluationId) {
|
207 | return __awaiter(this, void 0, void 0, function* () {
|
208 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
209 | let routeValues = {
|
210 | project: project,
|
211 | evaluationId: evaluationId
|
212 | };
|
213 | try {
|
214 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "46aecb7a-5d2c-4647-897b-0209505a9fe4", routeValues);
|
215 | let url = verData.requestUrl;
|
216 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
217 | let res;
|
218 | res = yield this.rest.update(url, null, options);
|
219 | let ret = this.formatResponse(res.result, PolicyInterfaces.TypeInfo.PolicyEvaluationRecord, false);
|
220 | resolve(ret);
|
221 | }
|
222 | catch (err) {
|
223 | reject(err);
|
224 | }
|
225 | }));
|
226 | });
|
227 | }
|
228 | |
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 | getPolicyEvaluations(project, artifactId, includeNotApplicable, top, skip) {
|
238 | return __awaiter(this, void 0, void 0, function* () {
|
239 | if (artifactId == null) {
|
240 | throw new TypeError('artifactId can not be null or undefined');
|
241 | }
|
242 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
243 | let routeValues = {
|
244 | project: project
|
245 | };
|
246 | let queryValues = {
|
247 | artifactId: artifactId,
|
248 | includeNotApplicable: includeNotApplicable,
|
249 | '$top': top,
|
250 | '$skip': skip,
|
251 | };
|
252 | try {
|
253 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "c23ddff5-229c-4d04-a80b-0fdce9f360c8", routeValues, queryValues);
|
254 | let url = verData.requestUrl;
|
255 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
256 | let res;
|
257 | res = yield this.rest.get(url, options);
|
258 | let ret = this.formatResponse(res.result, PolicyInterfaces.TypeInfo.PolicyEvaluationRecord, true);
|
259 | resolve(ret);
|
260 | }
|
261 | catch (err) {
|
262 | reject(err);
|
263 | }
|
264 | }));
|
265 | });
|
266 | }
|
267 | |
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 | getPolicyConfigurationRevision(project, configurationId, revisionId) {
|
275 | return __awaiter(this, void 0, void 0, function* () {
|
276 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
277 | let routeValues = {
|
278 | project: project,
|
279 | configurationId: configurationId,
|
280 | revisionId: revisionId
|
281 | };
|
282 | try {
|
283 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "fe1e68a2-60d3-43cb-855b-85e41ae97c95", routeValues);
|
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, PolicyInterfaces.TypeInfo.PolicyConfiguration, false);
|
289 | resolve(ret);
|
290 | }
|
291 | catch (err) {
|
292 | reject(err);
|
293 | }
|
294 | }));
|
295 | });
|
296 | }
|
297 | |
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 | getPolicyConfigurationRevisions(project, configurationId, top, skip) {
|
306 | return __awaiter(this, void 0, void 0, function* () {
|
307 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
308 | let routeValues = {
|
309 | project: project,
|
310 | configurationId: configurationId
|
311 | };
|
312 | let queryValues = {
|
313 | '$top': top,
|
314 | '$skip': skip,
|
315 | };
|
316 | try {
|
317 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "fe1e68a2-60d3-43cb-855b-85e41ae97c95", routeValues, queryValues);
|
318 | let url = verData.requestUrl;
|
319 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
320 | let res;
|
321 | res = yield this.rest.get(url, options);
|
322 | let ret = this.formatResponse(res.result, PolicyInterfaces.TypeInfo.PolicyConfiguration, true);
|
323 | resolve(ret);
|
324 | }
|
325 | catch (err) {
|
326 | reject(err);
|
327 | }
|
328 | }));
|
329 | });
|
330 | }
|
331 | |
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 | getPolicyType(project, typeId) {
|
338 | return __awaiter(this, void 0, void 0, function* () {
|
339 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
340 | let routeValues = {
|
341 | project: project,
|
342 | typeId: typeId
|
343 | };
|
344 | try {
|
345 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "44096322-2d3d-466a-bb30-d1b7de69f61f", routeValues);
|
346 | let url = verData.requestUrl;
|
347 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
348 | let res;
|
349 | res = yield this.rest.get(url, options);
|
350 | let ret = this.formatResponse(res.result, null, false);
|
351 | resolve(ret);
|
352 | }
|
353 | catch (err) {
|
354 | reject(err);
|
355 | }
|
356 | }));
|
357 | });
|
358 | }
|
359 | |
360 |
|
361 |
|
362 |
|
363 |
|
364 | getPolicyTypes(project) {
|
365 | return __awaiter(this, void 0, void 0, function* () {
|
366 | return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
367 | let routeValues = {
|
368 | project: project
|
369 | };
|
370 | try {
|
371 | let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "policy", "44096322-2d3d-466a-bb30-d1b7de69f61f", routeValues);
|
372 | let url = verData.requestUrl;
|
373 | let options = this.createRequestOptions('application/json', verData.apiVersion);
|
374 | let res;
|
375 | res = yield this.rest.get(url, options);
|
376 | let ret = this.formatResponse(res.result, null, true);
|
377 | resolve(ret);
|
378 | }
|
379 | catch (err) {
|
380 | reject(err);
|
381 | }
|
382 | }));
|
383 | });
|
384 | }
|
385 | }
|
386 | exports.PolicyApi = PolicyApi;
|
387 | PolicyApi.RESOURCE_AREA_ID = "fb13a388-40dd-4a04-b530-013a739c72ef";
|