UNPKG

22.9 kBJavaScriptView Raw
1"use strict";
2/*
3 * ---------------------------------------------------------
4 * Copyright(C) Microsoft Corporation. All rights reserved.
5 * ---------------------------------------------------------
6 *
7 * ---------------------------------------------------------
8 * Generated file, DO NOT EDIT
9 * ---------------------------------------------------------
10 */
11var __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};
20Object.defineProperty(exports, "__esModule", { value: true });
21exports.ManagementApi = void 0;
22const basem = require("./ClientApiBases");
23const ManagementInterfaces = require("./interfaces/ManagementInterfaces");
24class ManagementApi extends basem.ClientApiBase {
25 constructor(baseUrl, handlers, options) {
26 super(baseUrl, handlers, 'node-Management-api', options);
27 }
28 /**
29 * Delete the billing info for an organization.
30 *
31 * @param {string} organizationId
32 */
33 deleteBillingInfo(organizationId) {
34 return __awaiter(this, void 0, void 0, function* () {
35 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
36 let routeValues = {
37 action: "Default",
38 organizationId: organizationId
39 };
40 try {
41 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "de45fbc6-60fd-46e2-95ef-490ad08d656a", routeValues);
42 let url = verData.requestUrl;
43 let options = this.createRequestOptions('application/json', verData.apiVersion);
44 let res;
45 res = yield this.rest.del(url, options);
46 let ret = this.formatResponse(res.result, null, false);
47 resolve(ret);
48 }
49 catch (err) {
50 reject(err);
51 }
52 }));
53 });
54 }
55 /**
56 * Delete the meter usage history from Primary SU for an organization.
57 *
58 * @param {string} organizationId
59 */
60 deleteMeterUsageHistory(organizationId) {
61 return __awaiter(this, void 0, void 0, function* () {
62 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
63 let routeValues = {
64 action: "MeterUsageHistory",
65 organizationId: organizationId
66 };
67 try {
68 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "de45fbc6-60fd-46e2-95ef-490ad08d656a", routeValues);
69 let url = verData.requestUrl;
70 let options = this.createRequestOptions('application/json', verData.apiVersion);
71 let res;
72 res = yield this.rest.del(url, options);
73 let ret = this.formatResponse(res.result, null, false);
74 resolve(ret);
75 }
76 catch (err) {
77 reject(err);
78 }
79 }));
80 });
81 }
82 /**
83 * Get the billing info for an organization.
84 *
85 * @param {string} organizationId - Organization ID to get billing info for.
86 */
87 getBillingInfo(organizationId) {
88 return __awaiter(this, void 0, void 0, function* () {
89 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
90 let routeValues = {
91 action: "Default",
92 organizationId: organizationId
93 };
94 try {
95 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "de45fbc6-60fd-46e2-95ef-490ad08d656a", routeValues);
96 let url = verData.requestUrl;
97 let options = this.createRequestOptions('application/json', verData.apiVersion);
98 let res;
99 res = yield this.rest.get(url, options);
100 let ret = this.formatResponse(res.result, ManagementInterfaces.TypeInfo.BillingInfo, false);
101 resolve(ret);
102 }
103 catch (err) {
104 reject(err);
105 }
106 }));
107 });
108 }
109 /**
110 * Save the billing info for an organization.
111 *
112 * @param {ManagementInterfaces.BillingInfo} billingInfo
113 * @param {string} organizationId
114 */
115 saveBillingInfo(billingInfo, organizationId) {
116 return __awaiter(this, void 0, void 0, function* () {
117 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
118 let routeValues = {
119 action: "Default",
120 organizationId: organizationId
121 };
122 try {
123 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "de45fbc6-60fd-46e2-95ef-490ad08d656a", routeValues);
124 let url = verData.requestUrl;
125 let options = this.createRequestOptions('application/json', verData.apiVersion);
126 let res;
127 res = yield this.rest.create(url, billingInfo, options);
128 let ret = this.formatResponse(res.result, null, false);
129 resolve(ret);
130 }
131 catch (err) {
132 reject(err);
133 }
134 }));
135 });
136 }
137 /**
138 * During multi-org billing computation in primary scale unit(EUS21), this API is used to create billing snapshot for a specific org. Primary scale unit will call this API for each org in different scsle units to create billing snapshot. Data will be stored in the org specific partition DB -> billing snapshot table. This is needed as customers will fetch billing data from their org specific partition DB.
139 *
140 * @param {ManagementInterfaces.MeterUsage} meterUsage
141 */
142 createBillingSnapshot(meterUsage) {
143 return __awaiter(this, void 0, void 0, function* () {
144 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
145 let routeValues = {
146 action: "Default",
147 };
148 try {
149 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "e58d8091-3d07-48b1-9527-7d6295fd4081", routeValues);
150 let url = verData.requestUrl;
151 let options = this.createRequestOptions('application/json', verData.apiVersion);
152 let res;
153 res = yield this.rest.create(url, meterUsage, options);
154 let ret = this.formatResponse(res.result, null, false);
155 resolve(ret);
156 }
157 catch (err) {
158 reject(err);
159 }
160 }));
161 });
162 }
163 /**
164 * Get all billable committers details, including those not matched with a VSID.
165 *
166 * @param {Date} billingDate - The date to query, or if not provided, today
167 */
168 getBillableCommitterDetails(billingDate) {
169 return __awaiter(this, void 0, void 0, function* () {
170 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
171 let routeValues = {
172 action: "Details",
173 };
174 let queryValues = {
175 billingDate: billingDate,
176 };
177 try {
178 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "e58d8091-3d07-48b1-9527-7d6295fd4081", routeValues, queryValues);
179 let url = verData.requestUrl;
180 let options = this.createRequestOptions('application/json', verData.apiVersion);
181 let res;
182 res = yield this.rest.get(url, options);
183 let ret = this.formatResponse(res.result, ManagementInterfaces.TypeInfo.BillableCommitterDetails, true);
184 resolve(ret);
185 }
186 catch (err) {
187 reject(err);
188 }
189 }));
190 });
191 }
192 /**
193 */
194 getLastMeterUsage() {
195 return __awaiter(this, void 0, void 0, function* () {
196 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
197 let routeValues = {
198 action: "Last",
199 };
200 try {
201 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "e58d8091-3d07-48b1-9527-7d6295fd4081", routeValues);
202 let url = verData.requestUrl;
203 let options = this.createRequestOptions('application/json', verData.apiVersion);
204 let res;
205 res = yield this.rest.get(url, options);
206 let ret = this.formatResponse(res.result, ManagementInterfaces.TypeInfo.MeterUsage, false);
207 resolve(ret);
208 }
209 catch (err) {
210 reject(err);
211 }
212 }));
213 });
214 }
215 /**
216 * Get commiters used when calculating billing information.
217 *
218 * @param {Date} billingDate - The date to query, or if not provided, today
219 */
220 getMeterUsage(billingDate) {
221 return __awaiter(this, void 0, void 0, function* () {
222 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
223 let routeValues = {
224 action: "Default",
225 };
226 let queryValues = {
227 billingDate: billingDate,
228 };
229 try {
230 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "e58d8091-3d07-48b1-9527-7d6295fd4081", routeValues, queryValues);
231 let url = verData.requestUrl;
232 let options = this.createRequestOptions('application/json', verData.apiVersion);
233 let res;
234 res = yield this.rest.get(url, options);
235 let ret = this.formatResponse(res.result, ManagementInterfaces.TypeInfo.MeterUsage, false);
236 resolve(ret);
237 }
238 catch (err) {
239 reject(err);
240 }
241 }));
242 });
243 }
244 /**
245 * Get the current status of Advanced Security for the organization
246 *
247 * @param {boolean} includeAllProperties - When true, also determine if pushes are blocked if they contain secrets
248 */
249 getOrgEnablementStatus(includeAllProperties) {
250 return __awaiter(this, void 0, void 0, function* () {
251 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
252 let routeValues = {};
253 let queryValues = {
254 includeAllProperties: includeAllProperties,
255 };
256 try {
257 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "d0c0450f-8882-46f4-a5a8-e48fea3095b0", routeValues, queryValues);
258 let url = verData.requestUrl;
259 let options = this.createRequestOptions('application/json', verData.apiVersion);
260 let res;
261 res = yield this.rest.get(url, options);
262 let ret = this.formatResponse(res.result, ManagementInterfaces.TypeInfo.AdvSecEnablementSettings, false);
263 resolve(ret);
264 }
265 catch (err) {
266 reject(err);
267 }
268 }));
269 });
270 }
271 /**
272 * Update the status of Advanced Security for the organization
273 *
274 * @param {ManagementInterfaces.AdvSecEnablementSettingsUpdate} savedAdvSecEnablementStatus - The new status
275 */
276 updateOrgEnablementStatus(savedAdvSecEnablementStatus) {
277 return __awaiter(this, void 0, void 0, function* () {
278 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
279 let routeValues = {};
280 try {
281 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "d0c0450f-8882-46f4-a5a8-e48fea3095b0", routeValues);
282 let url = verData.requestUrl;
283 let options = this.createRequestOptions('application/json', verData.apiVersion);
284 let res;
285 res = yield this.rest.update(url, savedAdvSecEnablementStatus, options);
286 let ret = this.formatResponse(res.result, null, false);
287 resolve(ret);
288 }
289 catch (err) {
290 reject(err);
291 }
292 }));
293 });
294 }
295 /**
296 * Estimate the committers that would be added to the customer's usage if Advanced Security was enabled for this organization.
297 *
298 */
299 getEstimatedOrgBillablePushers() {
300 return __awaiter(this, void 0, void 0, function* () {
301 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
302 let routeValues = {};
303 try {
304 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "10a9e9c3-89bf-4312-92ed-139ddbcd2e28", routeValues);
305 let url = verData.requestUrl;
306 let options = this.createRequestOptions('application/json', verData.apiVersion);
307 let res;
308 res = yield this.rest.get(url, options);
309 let ret = this.formatResponse(res.result, null, true);
310 resolve(ret);
311 }
312 catch (err) {
313 reject(err);
314 }
315 }));
316 });
317 }
318 /**
319 * Get the current status of Advanced Security for a project
320 *
321 * @param {string} project - Project ID or project name
322 * @param {boolean} includeAllProperties - When true, also determine if pushes are blocked if they contain secrets
323 */
324 getProjectEnablementStatus(project, includeAllProperties) {
325 return __awaiter(this, void 0, void 0, function* () {
326 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
327 let routeValues = {
328 project: project
329 };
330 let queryValues = {
331 includeAllProperties: includeAllProperties,
332 };
333 try {
334 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "6b9a4b47-5f2d-40f3-8286-b0152079074d", routeValues, queryValues);
335 let url = verData.requestUrl;
336 let options = this.createRequestOptions('application/json', verData.apiVersion);
337 let res;
338 res = yield this.rest.get(url, options);
339 let ret = this.formatResponse(res.result, ManagementInterfaces.TypeInfo.AdvSecEnablementSettings, false);
340 resolve(ret);
341 }
342 catch (err) {
343 reject(err);
344 }
345 }));
346 });
347 }
348 /**
349 * Update the status of Advanced Security for the project
350 *
351 * @param {ManagementInterfaces.AdvSecEnablementSettingsUpdate} savedAdvSecEnablementStatus - The new status
352 * @param {string} project - Project ID or project name
353 */
354 updateProjectEnablementStatus(savedAdvSecEnablementStatus, project) {
355 return __awaiter(this, void 0, void 0, function* () {
356 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
357 let routeValues = {
358 project: project
359 };
360 try {
361 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "6b9a4b47-5f2d-40f3-8286-b0152079074d", routeValues);
362 let url = verData.requestUrl;
363 let options = this.createRequestOptions('application/json', verData.apiVersion);
364 let res;
365 res = yield this.rest.update(url, savedAdvSecEnablementStatus, options);
366 let ret = this.formatResponse(res.result, null, false);
367 resolve(ret);
368 }
369 catch (err) {
370 reject(err);
371 }
372 }));
373 });
374 }
375 /**
376 * Estimate the number of committers that would be added to the customer's usage if Advanced Security was enabled for this project.
377 *
378 * @param {string} project - Project ID or project name
379 */
380 getEstimatedProjectBillablePushers(project) {
381 return __awaiter(this, void 0, void 0, function* () {
382 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
383 let routeValues = {
384 project: project
385 };
386 try {
387 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "bf09cb40-ecf4-4496-8cf7-9ec60c64fd3e", routeValues);
388 let url = verData.requestUrl;
389 let options = this.createRequestOptions('application/json', verData.apiVersion);
390 let res;
391 res = yield this.rest.get(url, options);
392 let ret = this.formatResponse(res.result, null, true);
393 resolve(ret);
394 }
395 catch (err) {
396 reject(err);
397 }
398 }));
399 });
400 }
401 /**
402 * Determine if Advanced Security is enabled for a repository
403 *
404 * @param {string} project - Project ID or project name
405 * @param {string} repository - The name or ID of the repository
406 * @param {boolean} includeAllProperties - When true, will also determine if pushes are blocked when secrets are detected
407 */
408 getRepoEnablementStatus(project, repository, includeAllProperties) {
409 return __awaiter(this, void 0, void 0, function* () {
410 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
411 let routeValues = {
412 project: project,
413 repository: repository
414 };
415 let queryValues = {
416 includeAllProperties: includeAllProperties,
417 };
418 try {
419 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "d11a1c2b-b904-43dc-b970-bf42486262db", routeValues, queryValues);
420 let url = verData.requestUrl;
421 let options = this.createRequestOptions('application/json', verData.apiVersion);
422 let res;
423 res = yield this.rest.get(url, options);
424 let ret = this.formatResponse(res.result, ManagementInterfaces.TypeInfo.AdvSecEnablementStatus, false);
425 resolve(ret);
426 }
427 catch (err) {
428 reject(err);
429 }
430 }));
431 });
432 }
433 /**
434 * Update the enablement of Advanced Security for a repository
435 *
436 * @param {ManagementInterfaces.AdvSecEnablementStatusUpdate} savedAdvSecEnablementStatus - new status
437 * @param {string} project - Project ID or project name
438 * @param {string} repository - Name or ID of the repository
439 */
440 updateRepoAdvSecEnablementStatus(savedAdvSecEnablementStatus, project, repository) {
441 return __awaiter(this, void 0, void 0, function* () {
442 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
443 let routeValues = {
444 project: project,
445 repository: repository
446 };
447 try {
448 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "d11a1c2b-b904-43dc-b970-bf42486262db", routeValues);
449 let url = verData.requestUrl;
450 let options = this.createRequestOptions('application/json', verData.apiVersion);
451 let res;
452 res = yield this.rest.update(url, savedAdvSecEnablementStatus, options);
453 let ret = this.formatResponse(res.result, null, false);
454 resolve(ret);
455 }
456 catch (err) {
457 reject(err);
458 }
459 }));
460 });
461 }
462 /**
463 * Estimate the committers that would be added to the customer's usage if Advanced Security was enabled for this repository.
464 *
465 * @param {string} project - Project ID or project name
466 * @param {string} repository - The name or ID of the repository
467 */
468 getEstimatedRepoBillableCommitters(project, repository) {
469 return __awaiter(this, void 0, void 0, function* () {
470 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
471 let routeValues = {
472 project: project,
473 repository: repository
474 };
475 try {
476 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "Management", "b60f1ebf-ae77-4557-bd7f-ae3d5598dd1f", routeValues);
477 let url = verData.requestUrl;
478 let options = this.createRequestOptions('application/json', verData.apiVersion);
479 let res;
480 res = yield this.rest.get(url, options);
481 let ret = this.formatResponse(res.result, null, true);
482 resolve(ret);
483 }
484 catch (err) {
485 reject(err);
486 }
487 }));
488 });
489 }
490}
491exports.ManagementApi = ManagementApi;