UNPKG

14.8 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.FeatureManagementApi = void 0;
22const basem = require("./ClientApiBases");
23const FeatureManagementInterfaces = require("./interfaces/FeatureManagementInterfaces");
24class FeatureManagementApi extends basem.ClientApiBase {
25 constructor(baseUrl, handlers, options) {
26 super(baseUrl, handlers, 'node-FeatureManagement-api', options);
27 }
28 /**
29 * Get a specific feature by its id
30 *
31 * @param {string} featureId - The contribution id of the feature
32 */
33 getFeature(featureId) {
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 featureId: featureId
38 };
39 try {
40 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "FeatureManagement", "c4209f25-7a27-41dd-9f04-06080c7b6afd", routeValues);
41 let url = verData.requestUrl;
42 let options = this.createRequestOptions('application/json', verData.apiVersion);
43 let res;
44 res = yield this.rest.get(url, options);
45 let ret = this.formatResponse(res.result, null, false);
46 resolve(ret);
47 }
48 catch (err) {
49 reject(err);
50 }
51 }));
52 });
53 }
54 /**
55 * Get a list of all defined features
56 *
57 * @param {string} targetContributionId - Optional target contribution. If null/empty, return all features. If specified include the features that target the specified contribution.
58 */
59 getFeatures(targetContributionId) {
60 return __awaiter(this, void 0, void 0, function* () {
61 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
62 let routeValues = {};
63 let queryValues = {
64 targetContributionId: targetContributionId,
65 };
66 try {
67 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "FeatureManagement", "c4209f25-7a27-41dd-9f04-06080c7b6afd", routeValues, queryValues);
68 let url = verData.requestUrl;
69 let options = this.createRequestOptions('application/json', verData.apiVersion);
70 let res;
71 res = yield this.rest.get(url, options);
72 let ret = this.formatResponse(res.result, null, true);
73 resolve(ret);
74 }
75 catch (err) {
76 reject(err);
77 }
78 }));
79 });
80 }
81 /**
82 * Get the state of the specified feature for the given user/all-users scope
83 *
84 * @param {string} featureId - Contribution id of the feature
85 * @param {string} userScope - User-Scope at which to get the value. Should be "me" for the current user or "host" for all users.
86 */
87 getFeatureState(featureId, userScope) {
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 featureId: featureId,
92 userScope: userScope
93 };
94 try {
95 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "FeatureManagement", "98911314-3f9b-4eaf-80e8-83900d8e85d9", 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, FeatureManagementInterfaces.TypeInfo.ContributedFeatureState, false);
101 resolve(ret);
102 }
103 catch (err) {
104 reject(err);
105 }
106 }));
107 });
108 }
109 /**
110 * Set the state of a feature
111 *
112 * @param {FeatureManagementInterfaces.ContributedFeatureState} feature - Posted feature state object. Should specify the effective value.
113 * @param {string} featureId - Contribution id of the feature
114 * @param {string} userScope - User-Scope at which to set the value. Should be "me" for the current user or "host" for all users.
115 * @param {string} reason - Reason for changing the state
116 * @param {string} reasonCode - Short reason code
117 */
118 setFeatureState(feature, featureId, userScope, reason, reasonCode) {
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 featureId: featureId,
123 userScope: userScope
124 };
125 let queryValues = {
126 reason: reason,
127 reasonCode: reasonCode,
128 };
129 try {
130 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "FeatureManagement", "98911314-3f9b-4eaf-80e8-83900d8e85d9", routeValues, queryValues);
131 let url = verData.requestUrl;
132 let options = this.createRequestOptions('application/json', verData.apiVersion);
133 let res;
134 res = yield this.rest.update(url, feature, options);
135 let ret = this.formatResponse(res.result, FeatureManagementInterfaces.TypeInfo.ContributedFeatureState, false);
136 resolve(ret);
137 }
138 catch (err) {
139 reject(err);
140 }
141 }));
142 });
143 }
144 /**
145 * Get the state of the specified feature for the given named scope
146 *
147 * @param {string} featureId - Contribution id of the feature
148 * @param {string} userScope - User-Scope at which to get the value. Should be "me" for the current user or "host" for all users.
149 * @param {string} scopeName - Scope at which to get the feature setting for (e.g. "project" or "team")
150 * @param {string} scopeValue - Value of the scope (e.g. the project or team id)
151 */
152 getFeatureStateForScope(featureId, userScope, scopeName, scopeValue) {
153 return __awaiter(this, void 0, void 0, function* () {
154 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
155 let routeValues = {
156 featureId: featureId,
157 userScope: userScope,
158 scopeName: scopeName,
159 scopeValue: scopeValue
160 };
161 try {
162 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "FeatureManagement", "dd291e43-aa9f-4cee-8465-a93c78e414a4", routeValues);
163 let url = verData.requestUrl;
164 let options = this.createRequestOptions('application/json', verData.apiVersion);
165 let res;
166 res = yield this.rest.get(url, options);
167 let ret = this.formatResponse(res.result, FeatureManagementInterfaces.TypeInfo.ContributedFeatureState, false);
168 resolve(ret);
169 }
170 catch (err) {
171 reject(err);
172 }
173 }));
174 });
175 }
176 /**
177 * Set the state of a feature at a specific scope
178 *
179 * @param {FeatureManagementInterfaces.ContributedFeatureState} feature - Posted feature state object. Should specify the effective value.
180 * @param {string} featureId - Contribution id of the feature
181 * @param {string} userScope - User-Scope at which to set the value. Should be "me" for the current user or "host" for all users.
182 * @param {string} scopeName - Scope at which to get the feature setting for (e.g. "project" or "team")
183 * @param {string} scopeValue - Value of the scope (e.g. the project or team id)
184 * @param {string} reason - Reason for changing the state
185 * @param {string} reasonCode - Short reason code
186 */
187 setFeatureStateForScope(feature, featureId, userScope, scopeName, scopeValue, reason, reasonCode) {
188 return __awaiter(this, void 0, void 0, function* () {
189 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
190 let routeValues = {
191 featureId: featureId,
192 userScope: userScope,
193 scopeName: scopeName,
194 scopeValue: scopeValue
195 };
196 let queryValues = {
197 reason: reason,
198 reasonCode: reasonCode,
199 };
200 try {
201 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "FeatureManagement", "dd291e43-aa9f-4cee-8465-a93c78e414a4", routeValues, queryValues);
202 let url = verData.requestUrl;
203 let options = this.createRequestOptions('application/json', verData.apiVersion);
204 let res;
205 res = yield this.rest.update(url, feature, options);
206 let ret = this.formatResponse(res.result, FeatureManagementInterfaces.TypeInfo.ContributedFeatureState, false);
207 resolve(ret);
208 }
209 catch (err) {
210 reject(err);
211 }
212 }));
213 });
214 }
215 /**
216 * Get the effective state for a list of feature ids
217 *
218 * @param {FeatureManagementInterfaces.ContributedFeatureStateQuery} query - Features to query along with current scope values
219 */
220 queryFeatureStates(query) {
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 try {
225 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "FeatureManagement", "2b4486ad-122b-400c-ae65-17b6672c1f9d", routeValues);
226 let url = verData.requestUrl;
227 let options = this.createRequestOptions('application/json', verData.apiVersion);
228 let res;
229 res = yield this.rest.create(url, query, options);
230 let ret = this.formatResponse(res.result, FeatureManagementInterfaces.TypeInfo.ContributedFeatureStateQuery, false);
231 resolve(ret);
232 }
233 catch (err) {
234 reject(err);
235 }
236 }));
237 });
238 }
239 /**
240 * Get the states of the specified features for the default scope
241 *
242 * @param {FeatureManagementInterfaces.ContributedFeatureStateQuery} query - Query describing the features to query.
243 * @param {string} userScope
244 */
245 queryFeatureStatesForDefaultScope(query, userScope) {
246 return __awaiter(this, void 0, void 0, function* () {
247 return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
248 let routeValues = {
249 userScope: userScope
250 };
251 try {
252 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "FeatureManagement", "3f810f28-03e2-4239-b0bc-788add3005e5", routeValues);
253 let url = verData.requestUrl;
254 let options = this.createRequestOptions('application/json', verData.apiVersion);
255 let res;
256 res = yield this.rest.create(url, query, options);
257 let ret = this.formatResponse(res.result, FeatureManagementInterfaces.TypeInfo.ContributedFeatureStateQuery, false);
258 resolve(ret);
259 }
260 catch (err) {
261 reject(err);
262 }
263 }));
264 });
265 }
266 /**
267 * Get the states of the specified features for the specific named scope
268 *
269 * @param {FeatureManagementInterfaces.ContributedFeatureStateQuery} query - Query describing the features to query.
270 * @param {string} userScope
271 * @param {string} scopeName
272 * @param {string} scopeValue
273 */
274 queryFeatureStatesForNamedScope(query, userScope, scopeName, scopeValue) {
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 userScope: userScope,
279 scopeName: scopeName,
280 scopeValue: scopeValue
281 };
282 try {
283 let verData = yield this.vsoClient.getVersioningData("7.2-preview.1", "FeatureManagement", "f29e997b-c2da-4d15-8380-765788a1a74c", routeValues);
284 let url = verData.requestUrl;
285 let options = this.createRequestOptions('application/json', verData.apiVersion);
286 let res;
287 res = yield this.rest.create(url, query, options);
288 let ret = this.formatResponse(res.result, FeatureManagementInterfaces.TypeInfo.ContributedFeatureStateQuery, false);
289 resolve(ret);
290 }
291 catch (err) {
292 reject(err);
293 }
294 }));
295 });
296 }
297}
298exports.FeatureManagementApi = FeatureManagementApi;