microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
lib/app-center-node-client/src/account/operations/apps.js
2744lines · modecode
| 1 | /* |
| 2 | * Code generated by Microsoft (R) AutoRest Code Generator. |
| 3 | * Changes may cause incorrect behavior and will be lost if the code is |
| 4 | * regenerated. |
| 5 | */ |
| 6 | |
| 7 | 'use strict'; |
| 8 | |
| 9 | const msRest = require('ms-rest'); |
| 10 | const WebResource = msRest.WebResource; |
| 11 | |
| 12 | /** |
| 13 | * Creates a new app and returns it to the caller |
| 14 | * |
| 15 | * @param {object} app The data for the app |
| 16 | * |
| 17 | * @param {string} [app.description] A short text describing the app |
| 18 | * |
| 19 | * @param {string} app.displayName The descriptive name of the app. This can |
| 20 | * contain any characters |
| 21 | * |
| 22 | * @param {string} [app.name] The name of the app used in URLs |
| 23 | * |
| 24 | * @param {string} app.os The OS the app will be running on. Possible values |
| 25 | * include: 'Android', 'iOS', 'macOS', 'Tizen', 'tvOS', 'Windows' |
| 26 | * |
| 27 | * @param {string} app.platform The platform of the app. Possible values |
| 28 | * include: 'Java', 'Objective-C-Swift', 'UWP', 'Cordova', 'React-Native', |
| 29 | * 'Xamarin' |
| 30 | * |
| 31 | * @param {object} [options] Optional Parameters. |
| 32 | * |
| 33 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 34 | * request |
| 35 | * |
| 36 | * @param {function} callback - The callback. |
| 37 | * |
| 38 | * @returns {function} callback(err, result, request, response) |
| 39 | * |
| 40 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 41 | * |
| 42 | * {object} [result] - The deserialized result object if an error did not occur. |
| 43 | * See {@link AppResponse} for more information. |
| 44 | * |
| 45 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 46 | * |
| 47 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 48 | */ |
| 49 | function _create(app, options, callback) { |
| 50 | /* jshint validthis: true */ |
| 51 | let client = this.client; |
| 52 | if(!callback && typeof options === 'function') { |
| 53 | callback = options; |
| 54 | options = null; |
| 55 | } |
| 56 | if (!callback) { |
| 57 | throw new Error('callback cannot be null.'); |
| 58 | } |
| 59 | // Validate |
| 60 | try { |
| 61 | if (app === null || app === undefined) { |
| 62 | throw new Error('app cannot be null or undefined.'); |
| 63 | } |
| 64 | } catch (error) { |
| 65 | return callback(error); |
| 66 | } |
| 67 | |
| 68 | // Construct URL |
| 69 | let baseUrl = this.client.baseUri; |
| 70 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps'; |
| 71 | |
| 72 | // Create HTTP transport objects |
| 73 | let httpRequest = new WebResource(); |
| 74 | httpRequest.method = 'POST'; |
| 75 | httpRequest.url = requestUrl; |
| 76 | httpRequest.headers = {}; |
| 77 | // Set Headers |
| 78 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 79 | if(options) { |
| 80 | for(let headerName in options['customHeaders']) { |
| 81 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 82 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | // Serialize Request |
| 87 | let requestContent = null; |
| 88 | let requestModel = null; |
| 89 | try { |
| 90 | if (app !== null && app !== undefined) { |
| 91 | let requestModelMapper = new client.models['AppRequest']().mapper(); |
| 92 | requestModel = client.serialize(requestModelMapper, app, 'app'); |
| 93 | requestContent = JSON.stringify(requestModel); |
| 94 | } |
| 95 | } catch (error) { |
| 96 | let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + |
| 97 | `payload - ${JSON.stringify(app, null, 2)}.`); |
| 98 | return callback(serializationError); |
| 99 | } |
| 100 | httpRequest.body = requestContent; |
| 101 | // Send Request |
| 102 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 103 | if (err) { |
| 104 | return callback(err); |
| 105 | } |
| 106 | let statusCode = response.statusCode; |
| 107 | if (statusCode !== 201) { |
| 108 | let error = new Error(responseBody); |
| 109 | error.statusCode = response.statusCode; |
| 110 | error.request = msRest.stripRequest(httpRequest); |
| 111 | error.response = msRest.stripResponse(response); |
| 112 | if (responseBody === '') responseBody = null; |
| 113 | let parsedErrorResponse; |
| 114 | try { |
| 115 | parsedErrorResponse = JSON.parse(responseBody); |
| 116 | if (parsedErrorResponse) { |
| 117 | let internalError = null; |
| 118 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 119 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 120 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 121 | } |
| 122 | } catch (defaultError) { |
| 123 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 124 | `- "${responseBody}" for the default response.`; |
| 125 | return callback(error); |
| 126 | } |
| 127 | return callback(error); |
| 128 | } |
| 129 | // Create Result |
| 130 | let result = null; |
| 131 | if (responseBody === '') responseBody = null; |
| 132 | // Deserialize Response |
| 133 | if (statusCode === 201) { |
| 134 | let parsedResponse = null; |
| 135 | try { |
| 136 | parsedResponse = JSON.parse(responseBody); |
| 137 | result = JSON.parse(responseBody); |
| 138 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 139 | let resultMapper = new client.models['AppResponse']().mapper(); |
| 140 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 141 | } |
| 142 | } catch (error) { |
| 143 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 144 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 145 | deserializationError.response = msRest.stripResponse(response); |
| 146 | return callback(deserializationError); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | return callback(null, result, httpRequest, response); |
| 151 | }); |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Returns a list of apps |
| 156 | * |
| 157 | * @param {object} [options] Optional Parameters. |
| 158 | * |
| 159 | * @param {string} [options.orderBy] The name of the attribute by which to |
| 160 | * order the response by. By default, apps are in order of creation. All |
| 161 | * results are ordered in ascending order. Possible values include: |
| 162 | * 'display_name', 'name' |
| 163 | * |
| 164 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 165 | * request |
| 166 | * |
| 167 | * @param {function} callback - The callback. |
| 168 | * |
| 169 | * @returns {function} callback(err, result, request, response) |
| 170 | * |
| 171 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 172 | * |
| 173 | * {array} [result] - The deserialized result object if an error did not occur. |
| 174 | * |
| 175 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 176 | * |
| 177 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 178 | */ |
| 179 | function _list(options, callback) { |
| 180 | /* jshint validthis: true */ |
| 181 | let client = this.client; |
| 182 | if(!callback && typeof options === 'function') { |
| 183 | callback = options; |
| 184 | options = null; |
| 185 | } |
| 186 | if (!callback) { |
| 187 | throw new Error('callback cannot be null.'); |
| 188 | } |
| 189 | let orderBy = (options && options.orderBy !== undefined) ? options.orderBy : undefined; |
| 190 | // Validate |
| 191 | try { |
| 192 | if (orderBy !== null && orderBy !== undefined && typeof orderBy.valueOf() !== 'string') { |
| 193 | throw new Error('orderBy must be of type string.'); |
| 194 | } |
| 195 | } catch (error) { |
| 196 | return callback(error); |
| 197 | } |
| 198 | |
| 199 | // Construct URL |
| 200 | let baseUrl = this.client.baseUri; |
| 201 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps'; |
| 202 | let queryParameters = []; |
| 203 | if (orderBy !== null && orderBy !== undefined) { |
| 204 | queryParameters.push('$orderBy=' + encodeURIComponent(orderBy)); |
| 205 | } |
| 206 | if (queryParameters.length > 0) { |
| 207 | requestUrl += '?' + queryParameters.join('&'); |
| 208 | } |
| 209 | |
| 210 | // Create HTTP transport objects |
| 211 | let httpRequest = new WebResource(); |
| 212 | httpRequest.method = 'GET'; |
| 213 | httpRequest.url = requestUrl; |
| 214 | httpRequest.headers = {}; |
| 215 | // Set Headers |
| 216 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 217 | if(options) { |
| 218 | for(let headerName in options['customHeaders']) { |
| 219 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 220 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | httpRequest.body = null; |
| 225 | // Send Request |
| 226 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 227 | if (err) { |
| 228 | return callback(err); |
| 229 | } |
| 230 | let statusCode = response.statusCode; |
| 231 | if (statusCode !== 200) { |
| 232 | let error = new Error(responseBody); |
| 233 | error.statusCode = response.statusCode; |
| 234 | error.request = msRest.stripRequest(httpRequest); |
| 235 | error.response = msRest.stripResponse(response); |
| 236 | if (responseBody === '') responseBody = null; |
| 237 | let parsedErrorResponse; |
| 238 | try { |
| 239 | parsedErrorResponse = JSON.parse(responseBody); |
| 240 | if (parsedErrorResponse) { |
| 241 | let internalError = null; |
| 242 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 243 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 244 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 245 | } |
| 246 | } catch (defaultError) { |
| 247 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 248 | `- "${responseBody}" for the default response.`; |
| 249 | return callback(error); |
| 250 | } |
| 251 | return callback(error); |
| 252 | } |
| 253 | // Create Result |
| 254 | let result = null; |
| 255 | if (responseBody === '') responseBody = null; |
| 256 | // Deserialize Response |
| 257 | if (statusCode === 200) { |
| 258 | let parsedResponse = null; |
| 259 | try { |
| 260 | parsedResponse = JSON.parse(responseBody); |
| 261 | result = JSON.parse(responseBody); |
| 262 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 263 | let resultMapper = { |
| 264 | required: false, |
| 265 | serializedName: 'parsedResponse', |
| 266 | type: { |
| 267 | name: 'Sequence', |
| 268 | element: { |
| 269 | required: false, |
| 270 | serializedName: 'AppResponseElementType', |
| 271 | type: { |
| 272 | name: 'Composite', |
| 273 | className: 'AppResponse' |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | }; |
| 278 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 279 | } |
| 280 | } catch (error) { |
| 281 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 282 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 283 | deserializationError.response = msRest.stripResponse(response); |
| 284 | return callback(deserializationError); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | return callback(null, result, httpRequest, response); |
| 289 | }); |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * Return a specific app with the given app name which belongs to the given |
| 294 | * owner. |
| 295 | * |
| 296 | * @param {string} appName The name of the application |
| 297 | * |
| 298 | * @param {string} ownerName The name of the owner |
| 299 | * |
| 300 | * @param {object} [options] Optional Parameters. |
| 301 | * |
| 302 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 303 | * request |
| 304 | * |
| 305 | * @param {function} callback - The callback. |
| 306 | * |
| 307 | * @returns {function} callback(err, result, request, response) |
| 308 | * |
| 309 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 310 | * |
| 311 | * {object} [result] - The deserialized result object if an error did not occur. |
| 312 | * See {@link AppResponse} for more information. |
| 313 | * |
| 314 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 315 | * |
| 316 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 317 | */ |
| 318 | function _get(appName, ownerName, options, callback) { |
| 319 | /* jshint validthis: true */ |
| 320 | let client = this.client; |
| 321 | if(!callback && typeof options === 'function') { |
| 322 | callback = options; |
| 323 | options = null; |
| 324 | } |
| 325 | if (!callback) { |
| 326 | throw new Error('callback cannot be null.'); |
| 327 | } |
| 328 | // Validate |
| 329 | try { |
| 330 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 331 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 332 | } |
| 333 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 334 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 335 | } |
| 336 | } catch (error) { |
| 337 | return callback(error); |
| 338 | } |
| 339 | |
| 340 | // Construct URL |
| 341 | let baseUrl = this.client.baseUri; |
| 342 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}'; |
| 343 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 344 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 345 | |
| 346 | // Create HTTP transport objects |
| 347 | let httpRequest = new WebResource(); |
| 348 | httpRequest.method = 'GET'; |
| 349 | httpRequest.url = requestUrl; |
| 350 | httpRequest.headers = {}; |
| 351 | // Set Headers |
| 352 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 353 | if(options) { |
| 354 | for(let headerName in options['customHeaders']) { |
| 355 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 356 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | httpRequest.body = null; |
| 361 | // Send Request |
| 362 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 363 | if (err) { |
| 364 | return callback(err); |
| 365 | } |
| 366 | let statusCode = response.statusCode; |
| 367 | if (statusCode !== 200) { |
| 368 | let error = new Error(responseBody); |
| 369 | error.statusCode = response.statusCode; |
| 370 | error.request = msRest.stripRequest(httpRequest); |
| 371 | error.response = msRest.stripResponse(response); |
| 372 | if (responseBody === '') responseBody = null; |
| 373 | let parsedErrorResponse; |
| 374 | try { |
| 375 | parsedErrorResponse = JSON.parse(responseBody); |
| 376 | if (parsedErrorResponse) { |
| 377 | let internalError = null; |
| 378 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 379 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 380 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 381 | } |
| 382 | } catch (defaultError) { |
| 383 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 384 | `- "${responseBody}" for the default response.`; |
| 385 | return callback(error); |
| 386 | } |
| 387 | return callback(error); |
| 388 | } |
| 389 | // Create Result |
| 390 | let result = null; |
| 391 | if (responseBody === '') responseBody = null; |
| 392 | // Deserialize Response |
| 393 | if (statusCode === 200) { |
| 394 | let parsedResponse = null; |
| 395 | try { |
| 396 | parsedResponse = JSON.parse(responseBody); |
| 397 | result = JSON.parse(responseBody); |
| 398 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 399 | let resultMapper = new client.models['AppResponse']().mapper(); |
| 400 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 401 | } |
| 402 | } catch (error) { |
| 403 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 404 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 405 | deserializationError.response = msRest.stripResponse(response); |
| 406 | return callback(deserializationError); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | return callback(null, result, httpRequest, response); |
| 411 | }); |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Partially updates a single app |
| 416 | * |
| 417 | * @param {string} appName The name of the application |
| 418 | * |
| 419 | * @param {string} ownerName The name of the owner |
| 420 | * |
| 421 | * @param {object} [options] Optional Parameters. |
| 422 | * |
| 423 | * @param {object} [options.app] The partial data for the app |
| 424 | * |
| 425 | * @param {string} [options.app.description] A short text describing the app |
| 426 | * |
| 427 | * @param {string} [options.app.displayName] The display name of the app |
| 428 | * |
| 429 | * @param {string} [options.app.name] The name of the app used in URLs |
| 430 | * |
| 431 | * @param {string} [options.app.iconUrl] The string representation of the URL |
| 432 | * pointing to the app's icon |
| 433 | * |
| 434 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 435 | * request |
| 436 | * |
| 437 | * @param {function} callback - The callback. |
| 438 | * |
| 439 | * @returns {function} callback(err, result, request, response) |
| 440 | * |
| 441 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 442 | * |
| 443 | * {object} [result] - The deserialized result object if an error did not occur. |
| 444 | * See {@link AppResponse} for more information. |
| 445 | * |
| 446 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 447 | * |
| 448 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 449 | */ |
| 450 | function _update(appName, ownerName, options, callback) { |
| 451 | /* jshint validthis: true */ |
| 452 | let client = this.client; |
| 453 | if(!callback && typeof options === 'function') { |
| 454 | callback = options; |
| 455 | options = null; |
| 456 | } |
| 457 | if (!callback) { |
| 458 | throw new Error('callback cannot be null.'); |
| 459 | } |
| 460 | let app = (options && options.app !== undefined) ? options.app : undefined; |
| 461 | // Validate |
| 462 | try { |
| 463 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 464 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 465 | } |
| 466 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 467 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 468 | } |
| 469 | } catch (error) { |
| 470 | return callback(error); |
| 471 | } |
| 472 | |
| 473 | // Construct URL |
| 474 | let baseUrl = this.client.baseUri; |
| 475 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}'; |
| 476 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 477 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 478 | |
| 479 | // Create HTTP transport objects |
| 480 | let httpRequest = new WebResource(); |
| 481 | httpRequest.method = 'PATCH'; |
| 482 | httpRequest.url = requestUrl; |
| 483 | httpRequest.headers = {}; |
| 484 | // Set Headers |
| 485 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 486 | if(options) { |
| 487 | for(let headerName in options['customHeaders']) { |
| 488 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 489 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | // Serialize Request |
| 494 | let requestContent = null; |
| 495 | let requestModel = null; |
| 496 | try { |
| 497 | if (app !== null && app !== undefined) { |
| 498 | let requestModelMapper = new client.models['AppPatchRequest']().mapper(); |
| 499 | requestModel = client.serialize(requestModelMapper, app, 'app'); |
| 500 | requestContent = JSON.stringify(requestModel); |
| 501 | } |
| 502 | } catch (error) { |
| 503 | let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + |
| 504 | `payload - ${JSON.stringify(app, null, 2)}.`); |
| 505 | return callback(serializationError); |
| 506 | } |
| 507 | httpRequest.body = requestContent; |
| 508 | // Send Request |
| 509 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 510 | if (err) { |
| 511 | return callback(err); |
| 512 | } |
| 513 | let statusCode = response.statusCode; |
| 514 | if (statusCode !== 200) { |
| 515 | let error = new Error(responseBody); |
| 516 | error.statusCode = response.statusCode; |
| 517 | error.request = msRest.stripRequest(httpRequest); |
| 518 | error.response = msRest.stripResponse(response); |
| 519 | if (responseBody === '') responseBody = null; |
| 520 | let parsedErrorResponse; |
| 521 | try { |
| 522 | parsedErrorResponse = JSON.parse(responseBody); |
| 523 | if (parsedErrorResponse) { |
| 524 | let internalError = null; |
| 525 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 526 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 527 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 528 | } |
| 529 | } catch (defaultError) { |
| 530 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 531 | `- "${responseBody}" for the default response.`; |
| 532 | return callback(error); |
| 533 | } |
| 534 | return callback(error); |
| 535 | } |
| 536 | // Create Result |
| 537 | let result = null; |
| 538 | if (responseBody === '') responseBody = null; |
| 539 | // Deserialize Response |
| 540 | if (statusCode === 200) { |
| 541 | let parsedResponse = null; |
| 542 | try { |
| 543 | parsedResponse = JSON.parse(responseBody); |
| 544 | result = JSON.parse(responseBody); |
| 545 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 546 | let resultMapper = new client.models['AppResponse']().mapper(); |
| 547 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 548 | } |
| 549 | } catch (error) { |
| 550 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 551 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 552 | deserializationError.response = msRest.stripResponse(response); |
| 553 | return callback(deserializationError); |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | return callback(null, result, httpRequest, response); |
| 558 | }); |
| 559 | } |
| 560 | |
| 561 | /** |
| 562 | * Delete an app |
| 563 | * |
| 564 | * @param {string} appName The name of the application |
| 565 | * |
| 566 | * @param {string} ownerName The name of the owner |
| 567 | * |
| 568 | * @param {object} [options] Optional Parameters. |
| 569 | * |
| 570 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 571 | * request |
| 572 | * |
| 573 | * @param {function} callback - The callback. |
| 574 | * |
| 575 | * @returns {function} callback(err, result, request, response) |
| 576 | * |
| 577 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 578 | * |
| 579 | * {null} [result] - The deserialized result object if an error did not occur. |
| 580 | * |
| 581 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 582 | * |
| 583 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 584 | */ |
| 585 | function _deleteMethod(appName, ownerName, options, callback) { |
| 586 | /* jshint validthis: true */ |
| 587 | let client = this.client; |
| 588 | if(!callback && typeof options === 'function') { |
| 589 | callback = options; |
| 590 | options = null; |
| 591 | } |
| 592 | if (!callback) { |
| 593 | throw new Error('callback cannot be null.'); |
| 594 | } |
| 595 | // Validate |
| 596 | try { |
| 597 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 598 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 599 | } |
| 600 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 601 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 602 | } |
| 603 | } catch (error) { |
| 604 | return callback(error); |
| 605 | } |
| 606 | |
| 607 | // Construct URL |
| 608 | let baseUrl = this.client.baseUri; |
| 609 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}'; |
| 610 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 611 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 612 | |
| 613 | // Create HTTP transport objects |
| 614 | let httpRequest = new WebResource(); |
| 615 | httpRequest.method = 'DELETE'; |
| 616 | httpRequest.url = requestUrl; |
| 617 | httpRequest.headers = {}; |
| 618 | // Set Headers |
| 619 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 620 | if(options) { |
| 621 | for(let headerName in options['customHeaders']) { |
| 622 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 623 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 624 | } |
| 625 | } |
| 626 | } |
| 627 | httpRequest.body = null; |
| 628 | // Send Request |
| 629 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 630 | if (err) { |
| 631 | return callback(err); |
| 632 | } |
| 633 | let statusCode = response.statusCode; |
| 634 | if (statusCode < 200 || statusCode >= 300) { |
| 635 | let error = new Error(responseBody); |
| 636 | error.statusCode = response.statusCode; |
| 637 | error.request = msRest.stripRequest(httpRequest); |
| 638 | error.response = msRest.stripResponse(response); |
| 639 | if (responseBody === '') responseBody = null; |
| 640 | let parsedErrorResponse; |
| 641 | try { |
| 642 | parsedErrorResponse = JSON.parse(responseBody); |
| 643 | if (parsedErrorResponse) { |
| 644 | let internalError = null; |
| 645 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 646 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 647 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 648 | } |
| 649 | } catch (defaultError) { |
| 650 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 651 | `- "${responseBody}" for the default response.`; |
| 652 | return callback(error); |
| 653 | } |
| 654 | return callback(error); |
| 655 | } |
| 656 | // Create Result |
| 657 | let result = null; |
| 658 | if (responseBody === '') responseBody = null; |
| 659 | |
| 660 | return callback(null, result, httpRequest, response); |
| 661 | }); |
| 662 | } |
| 663 | |
| 664 | /** |
| 665 | * Returns the details of all teams that have access to the app. |
| 666 | * |
| 667 | * @param {string} appName The name of the application |
| 668 | * |
| 669 | * @param {string} ownerName The name of the owner |
| 670 | * |
| 671 | * @param {object} [options] Optional Parameters. |
| 672 | * |
| 673 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 674 | * request |
| 675 | * |
| 676 | * @param {function} callback - The callback. |
| 677 | * |
| 678 | * @returns {function} callback(err, result, request, response) |
| 679 | * |
| 680 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 681 | * |
| 682 | * {array} [result] - The deserialized result object if an error did not occur. |
| 683 | * |
| 684 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 685 | * |
| 686 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 687 | */ |
| 688 | function _getTeams(appName, ownerName, options, callback) { |
| 689 | /* jshint validthis: true */ |
| 690 | let client = this.client; |
| 691 | if(!callback && typeof options === 'function') { |
| 692 | callback = options; |
| 693 | options = null; |
| 694 | } |
| 695 | if (!callback) { |
| 696 | throw new Error('callback cannot be null.'); |
| 697 | } |
| 698 | // Validate |
| 699 | try { |
| 700 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 701 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 702 | } |
| 703 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 704 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 705 | } |
| 706 | } catch (error) { |
| 707 | return callback(error); |
| 708 | } |
| 709 | |
| 710 | // Construct URL |
| 711 | let baseUrl = this.client.baseUri; |
| 712 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/teams'; |
| 713 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 714 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 715 | |
| 716 | // Create HTTP transport objects |
| 717 | let httpRequest = new WebResource(); |
| 718 | httpRequest.method = 'GET'; |
| 719 | httpRequest.url = requestUrl; |
| 720 | httpRequest.headers = {}; |
| 721 | // Set Headers |
| 722 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 723 | if(options) { |
| 724 | for(let headerName in options['customHeaders']) { |
| 725 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 726 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 727 | } |
| 728 | } |
| 729 | } |
| 730 | httpRequest.body = null; |
| 731 | // Send Request |
| 732 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 733 | if (err) { |
| 734 | return callback(err); |
| 735 | } |
| 736 | let statusCode = response.statusCode; |
| 737 | if (statusCode !== 200) { |
| 738 | let error = new Error(responseBody); |
| 739 | error.statusCode = response.statusCode; |
| 740 | error.request = msRest.stripRequest(httpRequest); |
| 741 | error.response = msRest.stripResponse(response); |
| 742 | if (responseBody === '') responseBody = null; |
| 743 | let parsedErrorResponse; |
| 744 | try { |
| 745 | parsedErrorResponse = JSON.parse(responseBody); |
| 746 | if (parsedErrorResponse) { |
| 747 | let internalError = null; |
| 748 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 749 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 750 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 751 | } |
| 752 | } catch (defaultError) { |
| 753 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 754 | `- "${responseBody}" for the default response.`; |
| 755 | return callback(error); |
| 756 | } |
| 757 | return callback(error); |
| 758 | } |
| 759 | // Create Result |
| 760 | let result = null; |
| 761 | if (responseBody === '') responseBody = null; |
| 762 | // Deserialize Response |
| 763 | if (statusCode === 200) { |
| 764 | let parsedResponse = null; |
| 765 | try { |
| 766 | parsedResponse = JSON.parse(responseBody); |
| 767 | result = JSON.parse(responseBody); |
| 768 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 769 | let resultMapper = { |
| 770 | required: false, |
| 771 | serializedName: 'parsedResponse', |
| 772 | type: { |
| 773 | name: 'Sequence', |
| 774 | element: { |
| 775 | required: false, |
| 776 | serializedName: 'TeamAppResponseElementType', |
| 777 | type: { |
| 778 | name: 'Composite', |
| 779 | className: 'TeamAppResponse' |
| 780 | } |
| 781 | } |
| 782 | } |
| 783 | }; |
| 784 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 785 | } |
| 786 | } catch (error) { |
| 787 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 788 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 789 | deserializationError.response = msRest.stripResponse(response); |
| 790 | return callback(deserializationError); |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | return callback(null, result, httpRequest, response); |
| 795 | }); |
| 796 | } |
| 797 | |
| 798 | /** |
| 799 | * Returns the testers associated with the app specified with the given app |
| 800 | * name which belongs to the given owner. |
| 801 | * |
| 802 | * @param {string} appName The name of the application |
| 803 | * |
| 804 | * @param {string} ownerName The name of the owner |
| 805 | * |
| 806 | * @param {object} [options] Optional Parameters. |
| 807 | * |
| 808 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 809 | * request |
| 810 | * |
| 811 | * @param {function} callback - The callback. |
| 812 | * |
| 813 | * @returns {function} callback(err, result, request, response) |
| 814 | * |
| 815 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 816 | * |
| 817 | * {array} [result] - The deserialized result object if an error did not occur. |
| 818 | * |
| 819 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 820 | * |
| 821 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 822 | */ |
| 823 | function _listTesters(appName, ownerName, options, callback) { |
| 824 | /* jshint validthis: true */ |
| 825 | let client = this.client; |
| 826 | if(!callback && typeof options === 'function') { |
| 827 | callback = options; |
| 828 | options = null; |
| 829 | } |
| 830 | if (!callback) { |
| 831 | throw new Error('callback cannot be null.'); |
| 832 | } |
| 833 | // Validate |
| 834 | try { |
| 835 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 836 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 837 | } |
| 838 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 839 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 840 | } |
| 841 | } catch (error) { |
| 842 | return callback(error); |
| 843 | } |
| 844 | |
| 845 | // Construct URL |
| 846 | let baseUrl = this.client.baseUri; |
| 847 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/testers'; |
| 848 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 849 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 850 | |
| 851 | // Create HTTP transport objects |
| 852 | let httpRequest = new WebResource(); |
| 853 | httpRequest.method = 'GET'; |
| 854 | httpRequest.url = requestUrl; |
| 855 | httpRequest.headers = {}; |
| 856 | // Set Headers |
| 857 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 858 | if(options) { |
| 859 | for(let headerName in options['customHeaders']) { |
| 860 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 861 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 862 | } |
| 863 | } |
| 864 | } |
| 865 | httpRequest.body = null; |
| 866 | // Send Request |
| 867 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 868 | if (err) { |
| 869 | return callback(err); |
| 870 | } |
| 871 | let statusCode = response.statusCode; |
| 872 | if (statusCode !== 200) { |
| 873 | let error = new Error(responseBody); |
| 874 | error.statusCode = response.statusCode; |
| 875 | error.request = msRest.stripRequest(httpRequest); |
| 876 | error.response = msRest.stripResponse(response); |
| 877 | if (responseBody === '') responseBody = null; |
| 878 | let parsedErrorResponse; |
| 879 | try { |
| 880 | parsedErrorResponse = JSON.parse(responseBody); |
| 881 | if (parsedErrorResponse) { |
| 882 | let internalError = null; |
| 883 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 884 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 885 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 886 | } |
| 887 | } catch (defaultError) { |
| 888 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 889 | `- "${responseBody}" for the default response.`; |
| 890 | return callback(error); |
| 891 | } |
| 892 | return callback(error); |
| 893 | } |
| 894 | // Create Result |
| 895 | let result = null; |
| 896 | if (responseBody === '') responseBody = null; |
| 897 | // Deserialize Response |
| 898 | if (statusCode === 200) { |
| 899 | let parsedResponse = null; |
| 900 | try { |
| 901 | parsedResponse = JSON.parse(responseBody); |
| 902 | result = JSON.parse(responseBody); |
| 903 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 904 | let resultMapper = { |
| 905 | required: false, |
| 906 | serializedName: 'parsedResponse', |
| 907 | type: { |
| 908 | name: 'Sequence', |
| 909 | element: { |
| 910 | required: false, |
| 911 | serializedName: 'UserProfileResponseElementType', |
| 912 | type: { |
| 913 | name: 'Composite', |
| 914 | className: 'UserProfileResponse' |
| 915 | } |
| 916 | } |
| 917 | } |
| 918 | }; |
| 919 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 920 | } |
| 921 | } catch (error) { |
| 922 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 923 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 924 | deserializationError.response = msRest.stripResponse(response); |
| 925 | return callback(deserializationError); |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | return callback(null, result, httpRequest, response); |
| 930 | }); |
| 931 | } |
| 932 | |
| 933 | /** |
| 934 | * Transfers ownership of an app to a different user or organization |
| 935 | * |
| 936 | * @param {string} appName The name of the application |
| 937 | * |
| 938 | * @param {string} destinationOwnerName The name of the owner (user or |
| 939 | * organization) to which the app is being transferred |
| 940 | * |
| 941 | * @param {string} ownerName The name of the owner |
| 942 | * |
| 943 | * @param {object} [options] Optional Parameters. |
| 944 | * |
| 945 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 946 | * request |
| 947 | * |
| 948 | * @param {function} callback - The callback. |
| 949 | * |
| 950 | * @returns {function} callback(err, result, request, response) |
| 951 | * |
| 952 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 953 | * |
| 954 | * {object} [result] - The deserialized result object if an error did not occur. |
| 955 | * See {@link AppResponse} for more information. |
| 956 | * |
| 957 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 958 | * |
| 959 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 960 | */ |
| 961 | function _transferOwnership(appName, destinationOwnerName, ownerName, options, callback) { |
| 962 | /* jshint validthis: true */ |
| 963 | let client = this.client; |
| 964 | if(!callback && typeof options === 'function') { |
| 965 | callback = options; |
| 966 | options = null; |
| 967 | } |
| 968 | if (!callback) { |
| 969 | throw new Error('callback cannot be null.'); |
| 970 | } |
| 971 | // Validate |
| 972 | try { |
| 973 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 974 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 975 | } |
| 976 | if (destinationOwnerName === null || destinationOwnerName === undefined || typeof destinationOwnerName.valueOf() !== 'string') { |
| 977 | throw new Error('destinationOwnerName cannot be null or undefined and it must be of type string.'); |
| 978 | } |
| 979 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 980 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 981 | } |
| 982 | } catch (error) { |
| 983 | return callback(error); |
| 984 | } |
| 985 | |
| 986 | // Construct URL |
| 987 | let baseUrl = this.client.baseUri; |
| 988 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/transfer/{destination_owner_name}'; |
| 989 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 990 | requestUrl = requestUrl.replace('{destination_owner_name}', encodeURIComponent(destinationOwnerName)); |
| 991 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 992 | |
| 993 | // Create HTTP transport objects |
| 994 | let httpRequest = new WebResource(); |
| 995 | httpRequest.method = 'POST'; |
| 996 | httpRequest.url = requestUrl; |
| 997 | httpRequest.headers = {}; |
| 998 | // Set Headers |
| 999 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 1000 | if(options) { |
| 1001 | for(let headerName in options['customHeaders']) { |
| 1002 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 1003 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 1004 | } |
| 1005 | } |
| 1006 | } |
| 1007 | httpRequest.body = null; |
| 1008 | // Send Request |
| 1009 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 1010 | if (err) { |
| 1011 | return callback(err); |
| 1012 | } |
| 1013 | let statusCode = response.statusCode; |
| 1014 | if (statusCode !== 200) { |
| 1015 | let error = new Error(responseBody); |
| 1016 | error.statusCode = response.statusCode; |
| 1017 | error.request = msRest.stripRequest(httpRequest); |
| 1018 | error.response = msRest.stripResponse(response); |
| 1019 | if (responseBody === '') responseBody = null; |
| 1020 | let parsedErrorResponse; |
| 1021 | try { |
| 1022 | parsedErrorResponse = JSON.parse(responseBody); |
| 1023 | if (parsedErrorResponse) { |
| 1024 | let internalError = null; |
| 1025 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 1026 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 1027 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 1028 | } |
| 1029 | } catch (defaultError) { |
| 1030 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 1031 | `- "${responseBody}" for the default response.`; |
| 1032 | return callback(error); |
| 1033 | } |
| 1034 | return callback(error); |
| 1035 | } |
| 1036 | // Create Result |
| 1037 | let result = null; |
| 1038 | if (responseBody === '') responseBody = null; |
| 1039 | // Deserialize Response |
| 1040 | if (statusCode === 200) { |
| 1041 | let parsedResponse = null; |
| 1042 | try { |
| 1043 | parsedResponse = JSON.parse(responseBody); |
| 1044 | result = JSON.parse(responseBody); |
| 1045 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 1046 | let resultMapper = new client.models['AppResponse']().mapper(); |
| 1047 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 1048 | } |
| 1049 | } catch (error) { |
| 1050 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 1051 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 1052 | deserializationError.response = msRest.stripResponse(response); |
| 1053 | return callback(deserializationError); |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | return callback(null, result, httpRequest, response); |
| 1058 | }); |
| 1059 | } |
| 1060 | |
| 1061 | /** |
| 1062 | * Removes the user from the app |
| 1063 | * |
| 1064 | * @param {string} appName The name of the application |
| 1065 | * |
| 1066 | * @param {string} ownerName The name of the owner |
| 1067 | * |
| 1068 | * @param {string} userEmail The user email of the user to delete |
| 1069 | * |
| 1070 | * @param {object} [options] Optional Parameters. |
| 1071 | * |
| 1072 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1073 | * request |
| 1074 | * |
| 1075 | * @param {function} callback - The callback. |
| 1076 | * |
| 1077 | * @returns {function} callback(err, result, request, response) |
| 1078 | * |
| 1079 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1080 | * |
| 1081 | * {null} [result] - The deserialized result object if an error did not occur. |
| 1082 | * |
| 1083 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1084 | * |
| 1085 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1086 | */ |
| 1087 | function _removeUser(appName, ownerName, userEmail, options, callback) { |
| 1088 | /* jshint validthis: true */ |
| 1089 | let client = this.client; |
| 1090 | if(!callback && typeof options === 'function') { |
| 1091 | callback = options; |
| 1092 | options = null; |
| 1093 | } |
| 1094 | if (!callback) { |
| 1095 | throw new Error('callback cannot be null.'); |
| 1096 | } |
| 1097 | // Validate |
| 1098 | try { |
| 1099 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 1100 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 1101 | } |
| 1102 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 1103 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 1104 | } |
| 1105 | if (userEmail === null || userEmail === undefined || typeof userEmail.valueOf() !== 'string') { |
| 1106 | throw new Error('userEmail cannot be null or undefined and it must be of type string.'); |
| 1107 | } |
| 1108 | } catch (error) { |
| 1109 | return callback(error); |
| 1110 | } |
| 1111 | |
| 1112 | // Construct URL |
| 1113 | let baseUrl = this.client.baseUri; |
| 1114 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/users/{user_email}'; |
| 1115 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 1116 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 1117 | requestUrl = requestUrl.replace('{user_email}', encodeURIComponent(userEmail)); |
| 1118 | |
| 1119 | // Create HTTP transport objects |
| 1120 | let httpRequest = new WebResource(); |
| 1121 | httpRequest.method = 'DELETE'; |
| 1122 | httpRequest.url = requestUrl; |
| 1123 | httpRequest.headers = {}; |
| 1124 | // Set Headers |
| 1125 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 1126 | if(options) { |
| 1127 | for(let headerName in options['customHeaders']) { |
| 1128 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 1129 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 1130 | } |
| 1131 | } |
| 1132 | } |
| 1133 | httpRequest.body = null; |
| 1134 | // Send Request |
| 1135 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 1136 | if (err) { |
| 1137 | return callback(err); |
| 1138 | } |
| 1139 | let statusCode = response.statusCode; |
| 1140 | if (statusCode < 200 || statusCode >= 300) { |
| 1141 | let error = new Error(responseBody); |
| 1142 | error.statusCode = response.statusCode; |
| 1143 | error.request = msRest.stripRequest(httpRequest); |
| 1144 | error.response = msRest.stripResponse(response); |
| 1145 | if (responseBody === '') responseBody = null; |
| 1146 | let parsedErrorResponse; |
| 1147 | try { |
| 1148 | parsedErrorResponse = JSON.parse(responseBody); |
| 1149 | if (parsedErrorResponse) { |
| 1150 | let internalError = null; |
| 1151 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 1152 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 1153 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 1154 | } |
| 1155 | } catch (defaultError) { |
| 1156 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 1157 | `- "${responseBody}" for the default response.`; |
| 1158 | return callback(error); |
| 1159 | } |
| 1160 | return callback(error); |
| 1161 | } |
| 1162 | // Create Result |
| 1163 | let result = null; |
| 1164 | if (responseBody === '') responseBody = null; |
| 1165 | |
| 1166 | return callback(null, result, httpRequest, response); |
| 1167 | }); |
| 1168 | } |
| 1169 | |
| 1170 | /** |
| 1171 | * Update user permission for the app |
| 1172 | * |
| 1173 | * @param {string} appName The name of the application |
| 1174 | * |
| 1175 | * @param {string} ownerName The name of the owner |
| 1176 | * |
| 1177 | * @param {string} userEmail The user email of the user to patch |
| 1178 | * |
| 1179 | * @param {object} [options] Optional Parameters. |
| 1180 | * |
| 1181 | * @param {object} [options.userAppPermissionsData] The value to update the |
| 1182 | * user permission for the app. |
| 1183 | * |
| 1184 | * @param {array} options.userAppPermissionsData.permissions The permissions |
| 1185 | * the user has for the app |
| 1186 | * |
| 1187 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1188 | * request |
| 1189 | * |
| 1190 | * @param {function} callback - The callback. |
| 1191 | * |
| 1192 | * @returns {function} callback(err, result, request, response) |
| 1193 | * |
| 1194 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1195 | * |
| 1196 | * {null} [result] - The deserialized result object if an error did not occur. |
| 1197 | * |
| 1198 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1199 | * |
| 1200 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1201 | */ |
| 1202 | function _updateUserPermissions(appName, ownerName, userEmail, options, callback) { |
| 1203 | /* jshint validthis: true */ |
| 1204 | let client = this.client; |
| 1205 | if(!callback && typeof options === 'function') { |
| 1206 | callback = options; |
| 1207 | options = null; |
| 1208 | } |
| 1209 | if (!callback) { |
| 1210 | throw new Error('callback cannot be null.'); |
| 1211 | } |
| 1212 | let userAppPermissionsData = (options && options.userAppPermissionsData !== undefined) ? options.userAppPermissionsData : undefined; |
| 1213 | // Validate |
| 1214 | try { |
| 1215 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 1216 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 1217 | } |
| 1218 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 1219 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 1220 | } |
| 1221 | if (userEmail === null || userEmail === undefined || typeof userEmail.valueOf() !== 'string') { |
| 1222 | throw new Error('userEmail cannot be null or undefined and it must be of type string.'); |
| 1223 | } |
| 1224 | } catch (error) { |
| 1225 | return callback(error); |
| 1226 | } |
| 1227 | |
| 1228 | // Construct URL |
| 1229 | let baseUrl = this.client.baseUri; |
| 1230 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/users/{user_email}'; |
| 1231 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 1232 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 1233 | requestUrl = requestUrl.replace('{user_email}', encodeURIComponent(userEmail)); |
| 1234 | |
| 1235 | // Create HTTP transport objects |
| 1236 | let httpRequest = new WebResource(); |
| 1237 | httpRequest.method = 'PATCH'; |
| 1238 | httpRequest.url = requestUrl; |
| 1239 | httpRequest.headers = {}; |
| 1240 | // Set Headers |
| 1241 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 1242 | if(options) { |
| 1243 | for(let headerName in options['customHeaders']) { |
| 1244 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 1245 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 1246 | } |
| 1247 | } |
| 1248 | } |
| 1249 | // Serialize Request |
| 1250 | let requestContent = null; |
| 1251 | let requestModel = null; |
| 1252 | try { |
| 1253 | if (userAppPermissionsData !== null && userAppPermissionsData !== undefined) { |
| 1254 | let requestModelMapper = new client.models['UserAppPermissionsUpdateRequest']().mapper(); |
| 1255 | requestModel = client.serialize(requestModelMapper, userAppPermissionsData, 'userAppPermissionsData'); |
| 1256 | requestContent = JSON.stringify(requestModel); |
| 1257 | } |
| 1258 | } catch (error) { |
| 1259 | let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + |
| 1260 | `payload - ${JSON.stringify(userAppPermissionsData, null, 2)}.`); |
| 1261 | return callback(serializationError); |
| 1262 | } |
| 1263 | httpRequest.body = requestContent; |
| 1264 | // Send Request |
| 1265 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 1266 | if (err) { |
| 1267 | return callback(err); |
| 1268 | } |
| 1269 | let statusCode = response.statusCode; |
| 1270 | if (statusCode < 200 || statusCode >= 300) { |
| 1271 | let error = new Error(responseBody); |
| 1272 | error.statusCode = response.statusCode; |
| 1273 | error.request = msRest.stripRequest(httpRequest); |
| 1274 | error.response = msRest.stripResponse(response); |
| 1275 | if (responseBody === '') responseBody = null; |
| 1276 | let parsedErrorResponse; |
| 1277 | try { |
| 1278 | parsedErrorResponse = JSON.parse(responseBody); |
| 1279 | if (parsedErrorResponse) { |
| 1280 | let internalError = null; |
| 1281 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 1282 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 1283 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 1284 | } |
| 1285 | } catch (defaultError) { |
| 1286 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 1287 | `- "${responseBody}" for the default response.`; |
| 1288 | return callback(error); |
| 1289 | } |
| 1290 | return callback(error); |
| 1291 | } |
| 1292 | // Create Result |
| 1293 | let result = null; |
| 1294 | if (responseBody === '') responseBody = null; |
| 1295 | |
| 1296 | return callback(null, result, httpRequest, response); |
| 1297 | }); |
| 1298 | } |
| 1299 | |
| 1300 | /** |
| 1301 | * Creates a new app for the organization and returns it to the caller |
| 1302 | * |
| 1303 | * @param {object} app The data for the app |
| 1304 | * |
| 1305 | * @param {string} [app.description] A short text describing the app |
| 1306 | * |
| 1307 | * @param {string} app.displayName The descriptive name of the app. This can |
| 1308 | * contain any characters |
| 1309 | * |
| 1310 | * @param {string} [app.name] The name of the app used in URLs |
| 1311 | * |
| 1312 | * @param {string} app.os The OS the app will be running on. Possible values |
| 1313 | * include: 'Android', 'iOS', 'macOS', 'Tizen', 'tvOS', 'Windows' |
| 1314 | * |
| 1315 | * @param {string} app.platform The platform of the app. Possible values |
| 1316 | * include: 'Java', 'Objective-C-Swift', 'UWP', 'Cordova', 'React-Native', |
| 1317 | * 'Xamarin' |
| 1318 | * |
| 1319 | * @param {string} orgName The organization's name |
| 1320 | * |
| 1321 | * @param {object} [options] Optional Parameters. |
| 1322 | * |
| 1323 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1324 | * request |
| 1325 | * |
| 1326 | * @param {function} callback - The callback. |
| 1327 | * |
| 1328 | * @returns {function} callback(err, result, request, response) |
| 1329 | * |
| 1330 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1331 | * |
| 1332 | * {object} [result] - The deserialized result object if an error did not occur. |
| 1333 | * See {@link AppResponse} for more information. |
| 1334 | * |
| 1335 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1336 | * |
| 1337 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1338 | */ |
| 1339 | function _createForOrg(app, orgName, options, callback) { |
| 1340 | /* jshint validthis: true */ |
| 1341 | let client = this.client; |
| 1342 | if(!callback && typeof options === 'function') { |
| 1343 | callback = options; |
| 1344 | options = null; |
| 1345 | } |
| 1346 | if (!callback) { |
| 1347 | throw new Error('callback cannot be null.'); |
| 1348 | } |
| 1349 | // Validate |
| 1350 | try { |
| 1351 | if (app === null || app === undefined) { |
| 1352 | throw new Error('app cannot be null or undefined.'); |
| 1353 | } |
| 1354 | if (orgName === null || orgName === undefined || typeof orgName.valueOf() !== 'string') { |
| 1355 | throw new Error('orgName cannot be null or undefined and it must be of type string.'); |
| 1356 | } |
| 1357 | } catch (error) { |
| 1358 | return callback(error); |
| 1359 | } |
| 1360 | |
| 1361 | // Construct URL |
| 1362 | let baseUrl = this.client.baseUri; |
| 1363 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/orgs/{org_name}/apps'; |
| 1364 | requestUrl = requestUrl.replace('{org_name}', encodeURIComponent(orgName)); |
| 1365 | |
| 1366 | // Create HTTP transport objects |
| 1367 | let httpRequest = new WebResource(); |
| 1368 | httpRequest.method = 'POST'; |
| 1369 | httpRequest.url = requestUrl; |
| 1370 | httpRequest.headers = {}; |
| 1371 | // Set Headers |
| 1372 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 1373 | if(options) { |
| 1374 | for(let headerName in options['customHeaders']) { |
| 1375 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 1376 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 1377 | } |
| 1378 | } |
| 1379 | } |
| 1380 | // Serialize Request |
| 1381 | let requestContent = null; |
| 1382 | let requestModel = null; |
| 1383 | try { |
| 1384 | if (app !== null && app !== undefined) { |
| 1385 | let requestModelMapper = new client.models['AppRequest']().mapper(); |
| 1386 | requestModel = client.serialize(requestModelMapper, app, 'app'); |
| 1387 | requestContent = JSON.stringify(requestModel); |
| 1388 | } |
| 1389 | } catch (error) { |
| 1390 | let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + |
| 1391 | `payload - ${JSON.stringify(app, null, 2)}.`); |
| 1392 | return callback(serializationError); |
| 1393 | } |
| 1394 | httpRequest.body = requestContent; |
| 1395 | // Send Request |
| 1396 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 1397 | if (err) { |
| 1398 | return callback(err); |
| 1399 | } |
| 1400 | let statusCode = response.statusCode; |
| 1401 | if (statusCode !== 200 && statusCode !== 201) { |
| 1402 | let error = new Error(responseBody); |
| 1403 | error.statusCode = response.statusCode; |
| 1404 | error.request = msRest.stripRequest(httpRequest); |
| 1405 | error.response = msRest.stripResponse(response); |
| 1406 | if (responseBody === '') responseBody = null; |
| 1407 | let parsedErrorResponse; |
| 1408 | try { |
| 1409 | parsedErrorResponse = JSON.parse(responseBody); |
| 1410 | if (parsedErrorResponse) { |
| 1411 | let internalError = null; |
| 1412 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 1413 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 1414 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 1415 | } |
| 1416 | } catch (defaultError) { |
| 1417 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 1418 | `- "${responseBody}" for the default response.`; |
| 1419 | return callback(error); |
| 1420 | } |
| 1421 | return callback(error); |
| 1422 | } |
| 1423 | // Create Result |
| 1424 | let result = null; |
| 1425 | if (responseBody === '') responseBody = null; |
| 1426 | // Deserialize Response |
| 1427 | if (statusCode === 200) { |
| 1428 | let parsedResponse = null; |
| 1429 | try { |
| 1430 | parsedResponse = JSON.parse(responseBody); |
| 1431 | result = JSON.parse(responseBody); |
| 1432 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 1433 | let resultMapper = new client.models['AppResponse']().mapper(); |
| 1434 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 1435 | } |
| 1436 | } catch (error) { |
| 1437 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 1438 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 1439 | deserializationError.response = msRest.stripResponse(response); |
| 1440 | return callback(deserializationError); |
| 1441 | } |
| 1442 | } |
| 1443 | // Deserialize Response |
| 1444 | if (statusCode === 201) { |
| 1445 | let parsedResponse = null; |
| 1446 | try { |
| 1447 | parsedResponse = JSON.parse(responseBody); |
| 1448 | result = JSON.parse(responseBody); |
| 1449 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 1450 | let resultMapper = new client.models['AppResponse']().mapper(); |
| 1451 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 1452 | } |
| 1453 | } catch (error) { |
| 1454 | let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 1455 | deserializationError1.request = msRest.stripRequest(httpRequest); |
| 1456 | deserializationError1.response = msRest.stripResponse(response); |
| 1457 | return callback(deserializationError1); |
| 1458 | } |
| 1459 | } |
| 1460 | |
| 1461 | return callback(null, result, httpRequest, response); |
| 1462 | }); |
| 1463 | } |
| 1464 | |
| 1465 | /** |
| 1466 | * Returns a list of apps for the organization |
| 1467 | * |
| 1468 | * @param {string} orgName The organization's name |
| 1469 | * |
| 1470 | * @param {object} [options] Optional Parameters. |
| 1471 | * |
| 1472 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1473 | * request |
| 1474 | * |
| 1475 | * @param {function} callback - The callback. |
| 1476 | * |
| 1477 | * @returns {function} callback(err, result, request, response) |
| 1478 | * |
| 1479 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1480 | * |
| 1481 | * {array} [result] - The deserialized result object if an error did not occur. |
| 1482 | * |
| 1483 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1484 | * |
| 1485 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1486 | */ |
| 1487 | function _listForOrg(orgName, options, callback) { |
| 1488 | /* jshint validthis: true */ |
| 1489 | let client = this.client; |
| 1490 | if(!callback && typeof options === 'function') { |
| 1491 | callback = options; |
| 1492 | options = null; |
| 1493 | } |
| 1494 | if (!callback) { |
| 1495 | throw new Error('callback cannot be null.'); |
| 1496 | } |
| 1497 | // Validate |
| 1498 | try { |
| 1499 | if (orgName === null || orgName === undefined || typeof orgName.valueOf() !== 'string') { |
| 1500 | throw new Error('orgName cannot be null or undefined and it must be of type string.'); |
| 1501 | } |
| 1502 | } catch (error) { |
| 1503 | return callback(error); |
| 1504 | } |
| 1505 | |
| 1506 | // Construct URL |
| 1507 | let baseUrl = this.client.baseUri; |
| 1508 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/orgs/{org_name}/apps'; |
| 1509 | requestUrl = requestUrl.replace('{org_name}', encodeURIComponent(orgName)); |
| 1510 | |
| 1511 | // Create HTTP transport objects |
| 1512 | let httpRequest = new WebResource(); |
| 1513 | httpRequest.method = 'GET'; |
| 1514 | httpRequest.url = requestUrl; |
| 1515 | httpRequest.headers = {}; |
| 1516 | // Set Headers |
| 1517 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 1518 | if(options) { |
| 1519 | for(let headerName in options['customHeaders']) { |
| 1520 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 1521 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 1522 | } |
| 1523 | } |
| 1524 | } |
| 1525 | httpRequest.body = null; |
| 1526 | // Send Request |
| 1527 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 1528 | if (err) { |
| 1529 | return callback(err); |
| 1530 | } |
| 1531 | let statusCode = response.statusCode; |
| 1532 | if (statusCode !== 200) { |
| 1533 | let error = new Error(responseBody); |
| 1534 | error.statusCode = response.statusCode; |
| 1535 | error.request = msRest.stripRequest(httpRequest); |
| 1536 | error.response = msRest.stripResponse(response); |
| 1537 | if (responseBody === '') responseBody = null; |
| 1538 | let parsedErrorResponse; |
| 1539 | try { |
| 1540 | parsedErrorResponse = JSON.parse(responseBody); |
| 1541 | if (parsedErrorResponse) { |
| 1542 | let internalError = null; |
| 1543 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 1544 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 1545 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 1546 | } |
| 1547 | } catch (defaultError) { |
| 1548 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 1549 | `- "${responseBody}" for the default response.`; |
| 1550 | return callback(error); |
| 1551 | } |
| 1552 | return callback(error); |
| 1553 | } |
| 1554 | // Create Result |
| 1555 | let result = null; |
| 1556 | if (responseBody === '') responseBody = null; |
| 1557 | // Deserialize Response |
| 1558 | if (statusCode === 200) { |
| 1559 | let parsedResponse = null; |
| 1560 | try { |
| 1561 | parsedResponse = JSON.parse(responseBody); |
| 1562 | result = JSON.parse(responseBody); |
| 1563 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 1564 | let resultMapper = { |
| 1565 | required: false, |
| 1566 | serializedName: 'parsedResponse', |
| 1567 | type: { |
| 1568 | name: 'Sequence', |
| 1569 | element: { |
| 1570 | required: false, |
| 1571 | serializedName: 'AppResponseElementType', |
| 1572 | type: { |
| 1573 | name: 'Composite', |
| 1574 | className: 'AppResponse' |
| 1575 | } |
| 1576 | } |
| 1577 | } |
| 1578 | }; |
| 1579 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 1580 | } |
| 1581 | } catch (error) { |
| 1582 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 1583 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 1584 | deserializationError.response = msRest.stripResponse(response); |
| 1585 | return callback(deserializationError); |
| 1586 | } |
| 1587 | } |
| 1588 | |
| 1589 | return callback(null, result, httpRequest, response); |
| 1590 | }); |
| 1591 | } |
| 1592 | |
| 1593 | /** Class representing a Apps. */ |
| 1594 | class Apps { |
| 1595 | /** |
| 1596 | * Create a Apps. |
| 1597 | * @param {AccountClient} client Reference to the service client. |
| 1598 | */ |
| 1599 | constructor(client) { |
| 1600 | this.client = client; |
| 1601 | this._create = _create; |
| 1602 | this._list = _list; |
| 1603 | this._get = _get; |
| 1604 | this._update = _update; |
| 1605 | this._deleteMethod = _deleteMethod; |
| 1606 | this._getTeams = _getTeams; |
| 1607 | this._listTesters = _listTesters; |
| 1608 | this._transferOwnership = _transferOwnership; |
| 1609 | this._removeUser = _removeUser; |
| 1610 | this._updateUserPermissions = _updateUserPermissions; |
| 1611 | this._createForOrg = _createForOrg; |
| 1612 | this._listForOrg = _listForOrg; |
| 1613 | } |
| 1614 | |
| 1615 | /** |
| 1616 | * Creates a new app and returns it to the caller |
| 1617 | * |
| 1618 | * @param {object} app The data for the app |
| 1619 | * |
| 1620 | * @param {string} [app.description] A short text describing the app |
| 1621 | * |
| 1622 | * @param {string} app.displayName The descriptive name of the app. This can |
| 1623 | * contain any characters |
| 1624 | * |
| 1625 | * @param {string} [app.name] The name of the app used in URLs |
| 1626 | * |
| 1627 | * @param {string} app.os The OS the app will be running on. Possible values |
| 1628 | * include: 'Android', 'iOS', 'macOS', 'Tizen', 'tvOS', 'Windows' |
| 1629 | * |
| 1630 | * @param {string} app.platform The platform of the app. Possible values |
| 1631 | * include: 'Java', 'Objective-C-Swift', 'UWP', 'Cordova', 'React-Native', |
| 1632 | * 'Xamarin' |
| 1633 | * |
| 1634 | * @param {object} [options] Optional Parameters. |
| 1635 | * |
| 1636 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1637 | * request |
| 1638 | * |
| 1639 | * @returns {Promise} A promise is returned |
| 1640 | * |
| 1641 | * @resolve {HttpOperationResponse<AppResponse>} - The deserialized result object. |
| 1642 | * |
| 1643 | * @reject {Error} - The error object. |
| 1644 | */ |
| 1645 | createWithHttpOperationResponse(app, options) { |
| 1646 | let client = this.client; |
| 1647 | let self = this; |
| 1648 | return new Promise((resolve, reject) => { |
| 1649 | self._create(app, options, (err, result, request, response) => { |
| 1650 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 1651 | httpOperationResponse.body = result; |
| 1652 | if (err) { reject(err); } |
| 1653 | else { resolve(httpOperationResponse); } |
| 1654 | return; |
| 1655 | }); |
| 1656 | }); |
| 1657 | } |
| 1658 | |
| 1659 | /** |
| 1660 | * Creates a new app and returns it to the caller |
| 1661 | * |
| 1662 | * @param {object} app The data for the app |
| 1663 | * |
| 1664 | * @param {string} [app.description] A short text describing the app |
| 1665 | * |
| 1666 | * @param {string} app.displayName The descriptive name of the app. This can |
| 1667 | * contain any characters |
| 1668 | * |
| 1669 | * @param {string} [app.name] The name of the app used in URLs |
| 1670 | * |
| 1671 | * @param {string} app.os The OS the app will be running on. Possible values |
| 1672 | * include: 'Android', 'iOS', 'macOS', 'Tizen', 'tvOS', 'Windows' |
| 1673 | * |
| 1674 | * @param {string} app.platform The platform of the app. Possible values |
| 1675 | * include: 'Java', 'Objective-C-Swift', 'UWP', 'Cordova', 'React-Native', |
| 1676 | * 'Xamarin' |
| 1677 | * |
| 1678 | * @param {object} [options] Optional Parameters. |
| 1679 | * |
| 1680 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1681 | * request |
| 1682 | * |
| 1683 | * @param {function} [optionalCallback] - The optional callback. |
| 1684 | * |
| 1685 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 1686 | * then it returns the callback else returns a Promise. |
| 1687 | * |
| 1688 | * {Promise} A promise is returned |
| 1689 | * |
| 1690 | * @resolve {AppResponse} - The deserialized result object. |
| 1691 | * |
| 1692 | * @reject {Error} - The error object. |
| 1693 | * |
| 1694 | * {function} optionalCallback(err, result, request, response) |
| 1695 | * |
| 1696 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1697 | * |
| 1698 | * {object} [result] - The deserialized result object if an error did not occur. |
| 1699 | * See {@link AppResponse} for more information. |
| 1700 | * |
| 1701 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1702 | * |
| 1703 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1704 | */ |
| 1705 | create(app, options, optionalCallback) { |
| 1706 | let client = this.client; |
| 1707 | let self = this; |
| 1708 | if (!optionalCallback && typeof options === 'function') { |
| 1709 | optionalCallback = options; |
| 1710 | options = null; |
| 1711 | } |
| 1712 | if (!optionalCallback) { |
| 1713 | return new Promise((resolve, reject) => { |
| 1714 | self._create(app, options, (err, result, request, response) => { |
| 1715 | if (err) { reject(err); } |
| 1716 | else { resolve(result); } |
| 1717 | return; |
| 1718 | }); |
| 1719 | }); |
| 1720 | } else { |
| 1721 | return self._create(app, options, optionalCallback); |
| 1722 | } |
| 1723 | } |
| 1724 | |
| 1725 | /** |
| 1726 | * Returns a list of apps |
| 1727 | * |
| 1728 | * @param {object} [options] Optional Parameters. |
| 1729 | * |
| 1730 | * @param {string} [options.orderBy] The name of the attribute by which to |
| 1731 | * order the response by. By default, apps are in order of creation. All |
| 1732 | * results are ordered in ascending order. Possible values include: |
| 1733 | * 'display_name', 'name' |
| 1734 | * |
| 1735 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1736 | * request |
| 1737 | * |
| 1738 | * @returns {Promise} A promise is returned |
| 1739 | * |
| 1740 | * @resolve {HttpOperationResponse<Array>} - The deserialized result object. |
| 1741 | * |
| 1742 | * @reject {Error} - The error object. |
| 1743 | */ |
| 1744 | listWithHttpOperationResponse(options) { |
| 1745 | let client = this.client; |
| 1746 | let self = this; |
| 1747 | return new Promise((resolve, reject) => { |
| 1748 | self._list(options, (err, result, request, response) => { |
| 1749 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 1750 | httpOperationResponse.body = result; |
| 1751 | if (err) { reject(err); } |
| 1752 | else { resolve(httpOperationResponse); } |
| 1753 | return; |
| 1754 | }); |
| 1755 | }); |
| 1756 | } |
| 1757 | |
| 1758 | /** |
| 1759 | * Returns a list of apps |
| 1760 | * |
| 1761 | * @param {object} [options] Optional Parameters. |
| 1762 | * |
| 1763 | * @param {string} [options.orderBy] The name of the attribute by which to |
| 1764 | * order the response by. By default, apps are in order of creation. All |
| 1765 | * results are ordered in ascending order. Possible values include: |
| 1766 | * 'display_name', 'name' |
| 1767 | * |
| 1768 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1769 | * request |
| 1770 | * |
| 1771 | * @param {function} [optionalCallback] - The optional callback. |
| 1772 | * |
| 1773 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 1774 | * then it returns the callback else returns a Promise. |
| 1775 | * |
| 1776 | * {Promise} A promise is returned |
| 1777 | * |
| 1778 | * @resolve {Array} - The deserialized result object. |
| 1779 | * |
| 1780 | * @reject {Error} - The error object. |
| 1781 | * |
| 1782 | * {function} optionalCallback(err, result, request, response) |
| 1783 | * |
| 1784 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1785 | * |
| 1786 | * {array} [result] - The deserialized result object if an error did not occur. |
| 1787 | * |
| 1788 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1789 | * |
| 1790 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1791 | */ |
| 1792 | list(options, optionalCallback) { |
| 1793 | let client = this.client; |
| 1794 | let self = this; |
| 1795 | if (!optionalCallback && typeof options === 'function') { |
| 1796 | optionalCallback = options; |
| 1797 | options = null; |
| 1798 | } |
| 1799 | if (!optionalCallback) { |
| 1800 | return new Promise((resolve, reject) => { |
| 1801 | self._list(options, (err, result, request, response) => { |
| 1802 | if (err) { reject(err); } |
| 1803 | else { resolve(result); } |
| 1804 | return; |
| 1805 | }); |
| 1806 | }); |
| 1807 | } else { |
| 1808 | return self._list(options, optionalCallback); |
| 1809 | } |
| 1810 | } |
| 1811 | |
| 1812 | /** |
| 1813 | * Return a specific app with the given app name which belongs to the given |
| 1814 | * owner. |
| 1815 | * |
| 1816 | * @param {string} appName The name of the application |
| 1817 | * |
| 1818 | * @param {string} ownerName The name of the owner |
| 1819 | * |
| 1820 | * @param {object} [options] Optional Parameters. |
| 1821 | * |
| 1822 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1823 | * request |
| 1824 | * |
| 1825 | * @returns {Promise} A promise is returned |
| 1826 | * |
| 1827 | * @resolve {HttpOperationResponse<AppResponse>} - The deserialized result object. |
| 1828 | * |
| 1829 | * @reject {Error} - The error object. |
| 1830 | */ |
| 1831 | getWithHttpOperationResponse(appName, ownerName, options) { |
| 1832 | let client = this.client; |
| 1833 | let self = this; |
| 1834 | return new Promise((resolve, reject) => { |
| 1835 | self._get(appName, ownerName, options, (err, result, request, response) => { |
| 1836 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 1837 | httpOperationResponse.body = result; |
| 1838 | if (err) { reject(err); } |
| 1839 | else { resolve(httpOperationResponse); } |
| 1840 | return; |
| 1841 | }); |
| 1842 | }); |
| 1843 | } |
| 1844 | |
| 1845 | /** |
| 1846 | * Return a specific app with the given app name which belongs to the given |
| 1847 | * owner. |
| 1848 | * |
| 1849 | * @param {string} appName The name of the application |
| 1850 | * |
| 1851 | * @param {string} ownerName The name of the owner |
| 1852 | * |
| 1853 | * @param {object} [options] Optional Parameters. |
| 1854 | * |
| 1855 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1856 | * request |
| 1857 | * |
| 1858 | * @param {function} [optionalCallback] - The optional callback. |
| 1859 | * |
| 1860 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 1861 | * then it returns the callback else returns a Promise. |
| 1862 | * |
| 1863 | * {Promise} A promise is returned |
| 1864 | * |
| 1865 | * @resolve {AppResponse} - The deserialized result object. |
| 1866 | * |
| 1867 | * @reject {Error} - The error object. |
| 1868 | * |
| 1869 | * {function} optionalCallback(err, result, request, response) |
| 1870 | * |
| 1871 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1872 | * |
| 1873 | * {object} [result] - The deserialized result object if an error did not occur. |
| 1874 | * See {@link AppResponse} for more information. |
| 1875 | * |
| 1876 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1877 | * |
| 1878 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1879 | */ |
| 1880 | get(appName, ownerName, options, optionalCallback) { |
| 1881 | let client = this.client; |
| 1882 | let self = this; |
| 1883 | if (!optionalCallback && typeof options === 'function') { |
| 1884 | optionalCallback = options; |
| 1885 | options = null; |
| 1886 | } |
| 1887 | if (!optionalCallback) { |
| 1888 | return new Promise((resolve, reject) => { |
| 1889 | self._get(appName, ownerName, options, (err, result, request, response) => { |
| 1890 | if (err) { reject(err); } |
| 1891 | else { resolve(result); } |
| 1892 | return; |
| 1893 | }); |
| 1894 | }); |
| 1895 | } else { |
| 1896 | return self._get(appName, ownerName, options, optionalCallback); |
| 1897 | } |
| 1898 | } |
| 1899 | |
| 1900 | /** |
| 1901 | * Partially updates a single app |
| 1902 | * |
| 1903 | * @param {string} appName The name of the application |
| 1904 | * |
| 1905 | * @param {string} ownerName The name of the owner |
| 1906 | * |
| 1907 | * @param {object} [options] Optional Parameters. |
| 1908 | * |
| 1909 | * @param {object} [options.app] The partial data for the app |
| 1910 | * |
| 1911 | * @param {string} [options.app.description] A short text describing the app |
| 1912 | * |
| 1913 | * @param {string} [options.app.displayName] The display name of the app |
| 1914 | * |
| 1915 | * @param {string} [options.app.name] The name of the app used in URLs |
| 1916 | * |
| 1917 | * @param {string} [options.app.iconUrl] The string representation of the URL |
| 1918 | * pointing to the app's icon |
| 1919 | * |
| 1920 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1921 | * request |
| 1922 | * |
| 1923 | * @returns {Promise} A promise is returned |
| 1924 | * |
| 1925 | * @resolve {HttpOperationResponse<AppResponse>} - The deserialized result object. |
| 1926 | * |
| 1927 | * @reject {Error} - The error object. |
| 1928 | */ |
| 1929 | updateWithHttpOperationResponse(appName, ownerName, options) { |
| 1930 | let client = this.client; |
| 1931 | let self = this; |
| 1932 | return new Promise((resolve, reject) => { |
| 1933 | self._update(appName, ownerName, options, (err, result, request, response) => { |
| 1934 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 1935 | httpOperationResponse.body = result; |
| 1936 | if (err) { reject(err); } |
| 1937 | else { resolve(httpOperationResponse); } |
| 1938 | return; |
| 1939 | }); |
| 1940 | }); |
| 1941 | } |
| 1942 | |
| 1943 | /** |
| 1944 | * Partially updates a single app |
| 1945 | * |
| 1946 | * @param {string} appName The name of the application |
| 1947 | * |
| 1948 | * @param {string} ownerName The name of the owner |
| 1949 | * |
| 1950 | * @param {object} [options] Optional Parameters. |
| 1951 | * |
| 1952 | * @param {object} [options.app] The partial data for the app |
| 1953 | * |
| 1954 | * @param {string} [options.app.description] A short text describing the app |
| 1955 | * |
| 1956 | * @param {string} [options.app.displayName] The display name of the app |
| 1957 | * |
| 1958 | * @param {string} [options.app.name] The name of the app used in URLs |
| 1959 | * |
| 1960 | * @param {string} [options.app.iconUrl] The string representation of the URL |
| 1961 | * pointing to the app's icon |
| 1962 | * |
| 1963 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 1964 | * request |
| 1965 | * |
| 1966 | * @param {function} [optionalCallback] - The optional callback. |
| 1967 | * |
| 1968 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 1969 | * then it returns the callback else returns a Promise. |
| 1970 | * |
| 1971 | * {Promise} A promise is returned |
| 1972 | * |
| 1973 | * @resolve {AppResponse} - The deserialized result object. |
| 1974 | * |
| 1975 | * @reject {Error} - The error object. |
| 1976 | * |
| 1977 | * {function} optionalCallback(err, result, request, response) |
| 1978 | * |
| 1979 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 1980 | * |
| 1981 | * {object} [result] - The deserialized result object if an error did not occur. |
| 1982 | * See {@link AppResponse} for more information. |
| 1983 | * |
| 1984 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 1985 | * |
| 1986 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 1987 | */ |
| 1988 | update(appName, ownerName, options, optionalCallback) { |
| 1989 | let client = this.client; |
| 1990 | let self = this; |
| 1991 | if (!optionalCallback && typeof options === 'function') { |
| 1992 | optionalCallback = options; |
| 1993 | options = null; |
| 1994 | } |
| 1995 | if (!optionalCallback) { |
| 1996 | return new Promise((resolve, reject) => { |
| 1997 | self._update(appName, ownerName, options, (err, result, request, response) => { |
| 1998 | if (err) { reject(err); } |
| 1999 | else { resolve(result); } |
| 2000 | return; |
| 2001 | }); |
| 2002 | }); |
| 2003 | } else { |
| 2004 | return self._update(appName, ownerName, options, optionalCallback); |
| 2005 | } |
| 2006 | } |
| 2007 | |
| 2008 | /** |
| 2009 | * Delete an app |
| 2010 | * |
| 2011 | * @param {string} appName The name of the application |
| 2012 | * |
| 2013 | * @param {string} ownerName The name of the owner |
| 2014 | * |
| 2015 | * @param {object} [options] Optional Parameters. |
| 2016 | * |
| 2017 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2018 | * request |
| 2019 | * |
| 2020 | * @returns {Promise} A promise is returned |
| 2021 | * |
| 2022 | * @resolve {HttpOperationResponse<null>} - The deserialized result object. |
| 2023 | * |
| 2024 | * @reject {Error} - The error object. |
| 2025 | */ |
| 2026 | deleteMethodWithHttpOperationResponse(appName, ownerName, options) { |
| 2027 | let client = this.client; |
| 2028 | let self = this; |
| 2029 | return new Promise((resolve, reject) => { |
| 2030 | self._deleteMethod(appName, ownerName, options, (err, result, request, response) => { |
| 2031 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 2032 | httpOperationResponse.body = result; |
| 2033 | if (err) { reject(err); } |
| 2034 | else { resolve(httpOperationResponse); } |
| 2035 | return; |
| 2036 | }); |
| 2037 | }); |
| 2038 | } |
| 2039 | |
| 2040 | /** |
| 2041 | * Delete an app |
| 2042 | * |
| 2043 | * @param {string} appName The name of the application |
| 2044 | * |
| 2045 | * @param {string} ownerName The name of the owner |
| 2046 | * |
| 2047 | * @param {object} [options] Optional Parameters. |
| 2048 | * |
| 2049 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2050 | * request |
| 2051 | * |
| 2052 | * @param {function} [optionalCallback] - The optional callback. |
| 2053 | * |
| 2054 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 2055 | * then it returns the callback else returns a Promise. |
| 2056 | * |
| 2057 | * {Promise} A promise is returned |
| 2058 | * |
| 2059 | * @resolve {null} - The deserialized result object. |
| 2060 | * |
| 2061 | * @reject {Error} - The error object. |
| 2062 | * |
| 2063 | * {function} optionalCallback(err, result, request, response) |
| 2064 | * |
| 2065 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 2066 | * |
| 2067 | * {null} [result] - The deserialized result object if an error did not occur. |
| 2068 | * |
| 2069 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 2070 | * |
| 2071 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 2072 | */ |
| 2073 | deleteMethod(appName, ownerName, options, optionalCallback) { |
| 2074 | let client = this.client; |
| 2075 | let self = this; |
| 2076 | if (!optionalCallback && typeof options === 'function') { |
| 2077 | optionalCallback = options; |
| 2078 | options = null; |
| 2079 | } |
| 2080 | if (!optionalCallback) { |
| 2081 | return new Promise((resolve, reject) => { |
| 2082 | self._deleteMethod(appName, ownerName, options, (err, result, request, response) => { |
| 2083 | if (err) { reject(err); } |
| 2084 | else { resolve(result); } |
| 2085 | return; |
| 2086 | }); |
| 2087 | }); |
| 2088 | } else { |
| 2089 | return self._deleteMethod(appName, ownerName, options, optionalCallback); |
| 2090 | } |
| 2091 | } |
| 2092 | |
| 2093 | /** |
| 2094 | * Returns the details of all teams that have access to the app. |
| 2095 | * |
| 2096 | * @param {string} appName The name of the application |
| 2097 | * |
| 2098 | * @param {string} ownerName The name of the owner |
| 2099 | * |
| 2100 | * @param {object} [options] Optional Parameters. |
| 2101 | * |
| 2102 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2103 | * request |
| 2104 | * |
| 2105 | * @returns {Promise} A promise is returned |
| 2106 | * |
| 2107 | * @resolve {HttpOperationResponse<Array>} - The deserialized result object. |
| 2108 | * |
| 2109 | * @reject {Error} - The error object. |
| 2110 | */ |
| 2111 | getTeamsWithHttpOperationResponse(appName, ownerName, options) { |
| 2112 | let client = this.client; |
| 2113 | let self = this; |
| 2114 | return new Promise((resolve, reject) => { |
| 2115 | self._getTeams(appName, ownerName, options, (err, result, request, response) => { |
| 2116 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 2117 | httpOperationResponse.body = result; |
| 2118 | if (err) { reject(err); } |
| 2119 | else { resolve(httpOperationResponse); } |
| 2120 | return; |
| 2121 | }); |
| 2122 | }); |
| 2123 | } |
| 2124 | |
| 2125 | /** |
| 2126 | * Returns the details of all teams that have access to the app. |
| 2127 | * |
| 2128 | * @param {string} appName The name of the application |
| 2129 | * |
| 2130 | * @param {string} ownerName The name of the owner |
| 2131 | * |
| 2132 | * @param {object} [options] Optional Parameters. |
| 2133 | * |
| 2134 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2135 | * request |
| 2136 | * |
| 2137 | * @param {function} [optionalCallback] - The optional callback. |
| 2138 | * |
| 2139 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 2140 | * then it returns the callback else returns a Promise. |
| 2141 | * |
| 2142 | * {Promise} A promise is returned |
| 2143 | * |
| 2144 | * @resolve {Array} - The deserialized result object. |
| 2145 | * |
| 2146 | * @reject {Error} - The error object. |
| 2147 | * |
| 2148 | * {function} optionalCallback(err, result, request, response) |
| 2149 | * |
| 2150 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 2151 | * |
| 2152 | * {array} [result] - The deserialized result object if an error did not occur. |
| 2153 | * |
| 2154 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 2155 | * |
| 2156 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 2157 | */ |
| 2158 | getTeams(appName, ownerName, options, optionalCallback) { |
| 2159 | let client = this.client; |
| 2160 | let self = this; |
| 2161 | if (!optionalCallback && typeof options === 'function') { |
| 2162 | optionalCallback = options; |
| 2163 | options = null; |
| 2164 | } |
| 2165 | if (!optionalCallback) { |
| 2166 | return new Promise((resolve, reject) => { |
| 2167 | self._getTeams(appName, ownerName, options, (err, result, request, response) => { |
| 2168 | if (err) { reject(err); } |
| 2169 | else { resolve(result); } |
| 2170 | return; |
| 2171 | }); |
| 2172 | }); |
| 2173 | } else { |
| 2174 | return self._getTeams(appName, ownerName, options, optionalCallback); |
| 2175 | } |
| 2176 | } |
| 2177 | |
| 2178 | /** |
| 2179 | * Returns the testers associated with the app specified with the given app |
| 2180 | * name which belongs to the given owner. |
| 2181 | * |
| 2182 | * @param {string} appName The name of the application |
| 2183 | * |
| 2184 | * @param {string} ownerName The name of the owner |
| 2185 | * |
| 2186 | * @param {object} [options] Optional Parameters. |
| 2187 | * |
| 2188 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2189 | * request |
| 2190 | * |
| 2191 | * @returns {Promise} A promise is returned |
| 2192 | * |
| 2193 | * @resolve {HttpOperationResponse<Array>} - The deserialized result object. |
| 2194 | * |
| 2195 | * @reject {Error} - The error object. |
| 2196 | */ |
| 2197 | listTestersWithHttpOperationResponse(appName, ownerName, options) { |
| 2198 | let client = this.client; |
| 2199 | let self = this; |
| 2200 | return new Promise((resolve, reject) => { |
| 2201 | self._listTesters(appName, ownerName, options, (err, result, request, response) => { |
| 2202 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 2203 | httpOperationResponse.body = result; |
| 2204 | if (err) { reject(err); } |
| 2205 | else { resolve(httpOperationResponse); } |
| 2206 | return; |
| 2207 | }); |
| 2208 | }); |
| 2209 | } |
| 2210 | |
| 2211 | /** |
| 2212 | * Returns the testers associated with the app specified with the given app |
| 2213 | * name which belongs to the given owner. |
| 2214 | * |
| 2215 | * @param {string} appName The name of the application |
| 2216 | * |
| 2217 | * @param {string} ownerName The name of the owner |
| 2218 | * |
| 2219 | * @param {object} [options] Optional Parameters. |
| 2220 | * |
| 2221 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2222 | * request |
| 2223 | * |
| 2224 | * @param {function} [optionalCallback] - The optional callback. |
| 2225 | * |
| 2226 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 2227 | * then it returns the callback else returns a Promise. |
| 2228 | * |
| 2229 | * {Promise} A promise is returned |
| 2230 | * |
| 2231 | * @resolve {Array} - The deserialized result object. |
| 2232 | * |
| 2233 | * @reject {Error} - The error object. |
| 2234 | * |
| 2235 | * {function} optionalCallback(err, result, request, response) |
| 2236 | * |
| 2237 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 2238 | * |
| 2239 | * {array} [result] - The deserialized result object if an error did not occur. |
| 2240 | * |
| 2241 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 2242 | * |
| 2243 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 2244 | */ |
| 2245 | listTesters(appName, ownerName, options, optionalCallback) { |
| 2246 | let client = this.client; |
| 2247 | let self = this; |
| 2248 | if (!optionalCallback && typeof options === 'function') { |
| 2249 | optionalCallback = options; |
| 2250 | options = null; |
| 2251 | } |
| 2252 | if (!optionalCallback) { |
| 2253 | return new Promise((resolve, reject) => { |
| 2254 | self._listTesters(appName, ownerName, options, (err, result, request, response) => { |
| 2255 | if (err) { reject(err); } |
| 2256 | else { resolve(result); } |
| 2257 | return; |
| 2258 | }); |
| 2259 | }); |
| 2260 | } else { |
| 2261 | return self._listTesters(appName, ownerName, options, optionalCallback); |
| 2262 | } |
| 2263 | } |
| 2264 | |
| 2265 | /** |
| 2266 | * Transfers ownership of an app to a different user or organization |
| 2267 | * |
| 2268 | * @param {string} appName The name of the application |
| 2269 | * |
| 2270 | * @param {string} destinationOwnerName The name of the owner (user or |
| 2271 | * organization) to which the app is being transferred |
| 2272 | * |
| 2273 | * @param {string} ownerName The name of the owner |
| 2274 | * |
| 2275 | * @param {object} [options] Optional Parameters. |
| 2276 | * |
| 2277 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2278 | * request |
| 2279 | * |
| 2280 | * @returns {Promise} A promise is returned |
| 2281 | * |
| 2282 | * @resolve {HttpOperationResponse<AppResponse>} - The deserialized result object. |
| 2283 | * |
| 2284 | * @reject {Error} - The error object. |
| 2285 | */ |
| 2286 | transferOwnershipWithHttpOperationResponse(appName, destinationOwnerName, ownerName, options) { |
| 2287 | let client = this.client; |
| 2288 | let self = this; |
| 2289 | return new Promise((resolve, reject) => { |
| 2290 | self._transferOwnership(appName, destinationOwnerName, ownerName, options, (err, result, request, response) => { |
| 2291 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 2292 | httpOperationResponse.body = result; |
| 2293 | if (err) { reject(err); } |
| 2294 | else { resolve(httpOperationResponse); } |
| 2295 | return; |
| 2296 | }); |
| 2297 | }); |
| 2298 | } |
| 2299 | |
| 2300 | /** |
| 2301 | * Transfers ownership of an app to a different user or organization |
| 2302 | * |
| 2303 | * @param {string} appName The name of the application |
| 2304 | * |
| 2305 | * @param {string} destinationOwnerName The name of the owner (user or |
| 2306 | * organization) to which the app is being transferred |
| 2307 | * |
| 2308 | * @param {string} ownerName The name of the owner |
| 2309 | * |
| 2310 | * @param {object} [options] Optional Parameters. |
| 2311 | * |
| 2312 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2313 | * request |
| 2314 | * |
| 2315 | * @param {function} [optionalCallback] - The optional callback. |
| 2316 | * |
| 2317 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 2318 | * then it returns the callback else returns a Promise. |
| 2319 | * |
| 2320 | * {Promise} A promise is returned |
| 2321 | * |
| 2322 | * @resolve {AppResponse} - The deserialized result object. |
| 2323 | * |
| 2324 | * @reject {Error} - The error object. |
| 2325 | * |
| 2326 | * {function} optionalCallback(err, result, request, response) |
| 2327 | * |
| 2328 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 2329 | * |
| 2330 | * {object} [result] - The deserialized result object if an error did not occur. |
| 2331 | * See {@link AppResponse} for more information. |
| 2332 | * |
| 2333 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 2334 | * |
| 2335 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 2336 | */ |
| 2337 | transferOwnership(appName, destinationOwnerName, ownerName, options, optionalCallback) { |
| 2338 | let client = this.client; |
| 2339 | let self = this; |
| 2340 | if (!optionalCallback && typeof options === 'function') { |
| 2341 | optionalCallback = options; |
| 2342 | options = null; |
| 2343 | } |
| 2344 | if (!optionalCallback) { |
| 2345 | return new Promise((resolve, reject) => { |
| 2346 | self._transferOwnership(appName, destinationOwnerName, ownerName, options, (err, result, request, response) => { |
| 2347 | if (err) { reject(err); } |
| 2348 | else { resolve(result); } |
| 2349 | return; |
| 2350 | }); |
| 2351 | }); |
| 2352 | } else { |
| 2353 | return self._transferOwnership(appName, destinationOwnerName, ownerName, options, optionalCallback); |
| 2354 | } |
| 2355 | } |
| 2356 | |
| 2357 | /** |
| 2358 | * Removes the user from the app |
| 2359 | * |
| 2360 | * @param {string} appName The name of the application |
| 2361 | * |
| 2362 | * @param {string} ownerName The name of the owner |
| 2363 | * |
| 2364 | * @param {string} userEmail The user email of the user to delete |
| 2365 | * |
| 2366 | * @param {object} [options] Optional Parameters. |
| 2367 | * |
| 2368 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2369 | * request |
| 2370 | * |
| 2371 | * @returns {Promise} A promise is returned |
| 2372 | * |
| 2373 | * @resolve {HttpOperationResponse<null>} - The deserialized result object. |
| 2374 | * |
| 2375 | * @reject {Error} - The error object. |
| 2376 | */ |
| 2377 | removeUserWithHttpOperationResponse(appName, ownerName, userEmail, options) { |
| 2378 | let client = this.client; |
| 2379 | let self = this; |
| 2380 | return new Promise((resolve, reject) => { |
| 2381 | self._removeUser(appName, ownerName, userEmail, options, (err, result, request, response) => { |
| 2382 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 2383 | httpOperationResponse.body = result; |
| 2384 | if (err) { reject(err); } |
| 2385 | else { resolve(httpOperationResponse); } |
| 2386 | return; |
| 2387 | }); |
| 2388 | }); |
| 2389 | } |
| 2390 | |
| 2391 | /** |
| 2392 | * Removes the user from the app |
| 2393 | * |
| 2394 | * @param {string} appName The name of the application |
| 2395 | * |
| 2396 | * @param {string} ownerName The name of the owner |
| 2397 | * |
| 2398 | * @param {string} userEmail The user email of the user to delete |
| 2399 | * |
| 2400 | * @param {object} [options] Optional Parameters. |
| 2401 | * |
| 2402 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2403 | * request |
| 2404 | * |
| 2405 | * @param {function} [optionalCallback] - The optional callback. |
| 2406 | * |
| 2407 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 2408 | * then it returns the callback else returns a Promise. |
| 2409 | * |
| 2410 | * {Promise} A promise is returned |
| 2411 | * |
| 2412 | * @resolve {null} - The deserialized result object. |
| 2413 | * |
| 2414 | * @reject {Error} - The error object. |
| 2415 | * |
| 2416 | * {function} optionalCallback(err, result, request, response) |
| 2417 | * |
| 2418 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 2419 | * |
| 2420 | * {null} [result] - The deserialized result object if an error did not occur. |
| 2421 | * |
| 2422 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 2423 | * |
| 2424 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 2425 | */ |
| 2426 | removeUser(appName, ownerName, userEmail, options, optionalCallback) { |
| 2427 | let client = this.client; |
| 2428 | let self = this; |
| 2429 | if (!optionalCallback && typeof options === 'function') { |
| 2430 | optionalCallback = options; |
| 2431 | options = null; |
| 2432 | } |
| 2433 | if (!optionalCallback) { |
| 2434 | return new Promise((resolve, reject) => { |
| 2435 | self._removeUser(appName, ownerName, userEmail, options, (err, result, request, response) => { |
| 2436 | if (err) { reject(err); } |
| 2437 | else { resolve(result); } |
| 2438 | return; |
| 2439 | }); |
| 2440 | }); |
| 2441 | } else { |
| 2442 | return self._removeUser(appName, ownerName, userEmail, options, optionalCallback); |
| 2443 | } |
| 2444 | } |
| 2445 | |
| 2446 | /** |
| 2447 | * Update user permission for the app |
| 2448 | * |
| 2449 | * @param {string} appName The name of the application |
| 2450 | * |
| 2451 | * @param {string} ownerName The name of the owner |
| 2452 | * |
| 2453 | * @param {string} userEmail The user email of the user to patch |
| 2454 | * |
| 2455 | * @param {object} [options] Optional Parameters. |
| 2456 | * |
| 2457 | * @param {object} [options.userAppPermissionsData] The value to update the |
| 2458 | * user permission for the app. |
| 2459 | * |
| 2460 | * @param {array} options.userAppPermissionsData.permissions The permissions |
| 2461 | * the user has for the app |
| 2462 | * |
| 2463 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2464 | * request |
| 2465 | * |
| 2466 | * @returns {Promise} A promise is returned |
| 2467 | * |
| 2468 | * @resolve {HttpOperationResponse<null>} - The deserialized result object. |
| 2469 | * |
| 2470 | * @reject {Error} - The error object. |
| 2471 | */ |
| 2472 | updateUserPermissionsWithHttpOperationResponse(appName, ownerName, userEmail, options) { |
| 2473 | let client = this.client; |
| 2474 | let self = this; |
| 2475 | return new Promise((resolve, reject) => { |
| 2476 | self._updateUserPermissions(appName, ownerName, userEmail, options, (err, result, request, response) => { |
| 2477 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 2478 | httpOperationResponse.body = result; |
| 2479 | if (err) { reject(err); } |
| 2480 | else { resolve(httpOperationResponse); } |
| 2481 | return; |
| 2482 | }); |
| 2483 | }); |
| 2484 | } |
| 2485 | |
| 2486 | /** |
| 2487 | * Update user permission for the app |
| 2488 | * |
| 2489 | * @param {string} appName The name of the application |
| 2490 | * |
| 2491 | * @param {string} ownerName The name of the owner |
| 2492 | * |
| 2493 | * @param {string} userEmail The user email of the user to patch |
| 2494 | * |
| 2495 | * @param {object} [options] Optional Parameters. |
| 2496 | * |
| 2497 | * @param {object} [options.userAppPermissionsData] The value to update the |
| 2498 | * user permission for the app. |
| 2499 | * |
| 2500 | * @param {array} options.userAppPermissionsData.permissions The permissions |
| 2501 | * the user has for the app |
| 2502 | * |
| 2503 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2504 | * request |
| 2505 | * |
| 2506 | * @param {function} [optionalCallback] - The optional callback. |
| 2507 | * |
| 2508 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 2509 | * then it returns the callback else returns a Promise. |
| 2510 | * |
| 2511 | * {Promise} A promise is returned |
| 2512 | * |
| 2513 | * @resolve {null} - The deserialized result object. |
| 2514 | * |
| 2515 | * @reject {Error} - The error object. |
| 2516 | * |
| 2517 | * {function} optionalCallback(err, result, request, response) |
| 2518 | * |
| 2519 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 2520 | * |
| 2521 | * {null} [result] - The deserialized result object if an error did not occur. |
| 2522 | * |
| 2523 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 2524 | * |
| 2525 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 2526 | */ |
| 2527 | updateUserPermissions(appName, ownerName, userEmail, options, optionalCallback) { |
| 2528 | let client = this.client; |
| 2529 | let self = this; |
| 2530 | if (!optionalCallback && typeof options === 'function') { |
| 2531 | optionalCallback = options; |
| 2532 | options = null; |
| 2533 | } |
| 2534 | if (!optionalCallback) { |
| 2535 | return new Promise((resolve, reject) => { |
| 2536 | self._updateUserPermissions(appName, ownerName, userEmail, options, (err, result, request, response) => { |
| 2537 | if (err) { reject(err); } |
| 2538 | else { resolve(result); } |
| 2539 | return; |
| 2540 | }); |
| 2541 | }); |
| 2542 | } else { |
| 2543 | return self._updateUserPermissions(appName, ownerName, userEmail, options, optionalCallback); |
| 2544 | } |
| 2545 | } |
| 2546 | |
| 2547 | /** |
| 2548 | * Creates a new app for the organization and returns it to the caller |
| 2549 | * |
| 2550 | * @param {object} app The data for the app |
| 2551 | * |
| 2552 | * @param {string} [app.description] A short text describing the app |
| 2553 | * |
| 2554 | * @param {string} app.displayName The descriptive name of the app. This can |
| 2555 | * contain any characters |
| 2556 | * |
| 2557 | * @param {string} [app.name] The name of the app used in URLs |
| 2558 | * |
| 2559 | * @param {string} app.os The OS the app will be running on. Possible values |
| 2560 | * include: 'Android', 'iOS', 'macOS', 'Tizen', 'tvOS', 'Windows' |
| 2561 | * |
| 2562 | * @param {string} app.platform The platform of the app. Possible values |
| 2563 | * include: 'Java', 'Objective-C-Swift', 'UWP', 'Cordova', 'React-Native', |
| 2564 | * 'Xamarin' |
| 2565 | * |
| 2566 | * @param {string} orgName The organization's name |
| 2567 | * |
| 2568 | * @param {object} [options] Optional Parameters. |
| 2569 | * |
| 2570 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2571 | * request |
| 2572 | * |
| 2573 | * @returns {Promise} A promise is returned |
| 2574 | * |
| 2575 | * @resolve {HttpOperationResponse<AppResponse>} - The deserialized result object. |
| 2576 | * |
| 2577 | * @reject {Error} - The error object. |
| 2578 | */ |
| 2579 | createForOrgWithHttpOperationResponse(app, orgName, options) { |
| 2580 | let client = this.client; |
| 2581 | let self = this; |
| 2582 | return new Promise((resolve, reject) => { |
| 2583 | self._createForOrg(app, orgName, options, (err, result, request, response) => { |
| 2584 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 2585 | httpOperationResponse.body = result; |
| 2586 | if (err) { reject(err); } |
| 2587 | else { resolve(httpOperationResponse); } |
| 2588 | return; |
| 2589 | }); |
| 2590 | }); |
| 2591 | } |
| 2592 | |
| 2593 | /** |
| 2594 | * Creates a new app for the organization and returns it to the caller |
| 2595 | * |
| 2596 | * @param {object} app The data for the app |
| 2597 | * |
| 2598 | * @param {string} [app.description] A short text describing the app |
| 2599 | * |
| 2600 | * @param {string} app.displayName The descriptive name of the app. This can |
| 2601 | * contain any characters |
| 2602 | * |
| 2603 | * @param {string} [app.name] The name of the app used in URLs |
| 2604 | * |
| 2605 | * @param {string} app.os The OS the app will be running on. Possible values |
| 2606 | * include: 'Android', 'iOS', 'macOS', 'Tizen', 'tvOS', 'Windows' |
| 2607 | * |
| 2608 | * @param {string} app.platform The platform of the app. Possible values |
| 2609 | * include: 'Java', 'Objective-C-Swift', 'UWP', 'Cordova', 'React-Native', |
| 2610 | * 'Xamarin' |
| 2611 | * |
| 2612 | * @param {string} orgName The organization's name |
| 2613 | * |
| 2614 | * @param {object} [options] Optional Parameters. |
| 2615 | * |
| 2616 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2617 | * request |
| 2618 | * |
| 2619 | * @param {function} [optionalCallback] - The optional callback. |
| 2620 | * |
| 2621 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 2622 | * then it returns the callback else returns a Promise. |
| 2623 | * |
| 2624 | * {Promise} A promise is returned |
| 2625 | * |
| 2626 | * @resolve {AppResponse} - The deserialized result object. |
| 2627 | * |
| 2628 | * @reject {Error} - The error object. |
| 2629 | * |
| 2630 | * {function} optionalCallback(err, result, request, response) |
| 2631 | * |
| 2632 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 2633 | * |
| 2634 | * {object} [result] - The deserialized result object if an error did not occur. |
| 2635 | * See {@link AppResponse} for more information. |
| 2636 | * |
| 2637 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 2638 | * |
| 2639 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 2640 | */ |
| 2641 | createForOrg(app, orgName, options, optionalCallback) { |
| 2642 | let client = this.client; |
| 2643 | let self = this; |
| 2644 | if (!optionalCallback && typeof options === 'function') { |
| 2645 | optionalCallback = options; |
| 2646 | options = null; |
| 2647 | } |
| 2648 | if (!optionalCallback) { |
| 2649 | return new Promise((resolve, reject) => { |
| 2650 | self._createForOrg(app, orgName, options, (err, result, request, response) => { |
| 2651 | if (err) { reject(err); } |
| 2652 | else { resolve(result); } |
| 2653 | return; |
| 2654 | }); |
| 2655 | }); |
| 2656 | } else { |
| 2657 | return self._createForOrg(app, orgName, options, optionalCallback); |
| 2658 | } |
| 2659 | } |
| 2660 | |
| 2661 | /** |
| 2662 | * Returns a list of apps for the organization |
| 2663 | * |
| 2664 | * @param {string} orgName The organization's name |
| 2665 | * |
| 2666 | * @param {object} [options] Optional Parameters. |
| 2667 | * |
| 2668 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2669 | * request |
| 2670 | * |
| 2671 | * @returns {Promise} A promise is returned |
| 2672 | * |
| 2673 | * @resolve {HttpOperationResponse<Array>} - The deserialized result object. |
| 2674 | * |
| 2675 | * @reject {Error} - The error object. |
| 2676 | */ |
| 2677 | listForOrgWithHttpOperationResponse(orgName, options) { |
| 2678 | let client = this.client; |
| 2679 | let self = this; |
| 2680 | return new Promise((resolve, reject) => { |
| 2681 | self._listForOrg(orgName, options, (err, result, request, response) => { |
| 2682 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 2683 | httpOperationResponse.body = result; |
| 2684 | if (err) { reject(err); } |
| 2685 | else { resolve(httpOperationResponse); } |
| 2686 | return; |
| 2687 | }); |
| 2688 | }); |
| 2689 | } |
| 2690 | |
| 2691 | /** |
| 2692 | * Returns a list of apps for the organization |
| 2693 | * |
| 2694 | * @param {string} orgName The organization's name |
| 2695 | * |
| 2696 | * @param {object} [options] Optional Parameters. |
| 2697 | * |
| 2698 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 2699 | * request |
| 2700 | * |
| 2701 | * @param {function} [optionalCallback] - The optional callback. |
| 2702 | * |
| 2703 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 2704 | * then it returns the callback else returns a Promise. |
| 2705 | * |
| 2706 | * {Promise} A promise is returned |
| 2707 | * |
| 2708 | * @resolve {Array} - The deserialized result object. |
| 2709 | * |
| 2710 | * @reject {Error} - The error object. |
| 2711 | * |
| 2712 | * {function} optionalCallback(err, result, request, response) |
| 2713 | * |
| 2714 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 2715 | * |
| 2716 | * {array} [result] - The deserialized result object if an error did not occur. |
| 2717 | * |
| 2718 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 2719 | * |
| 2720 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 2721 | */ |
| 2722 | listForOrg(orgName, options, optionalCallback) { |
| 2723 | let client = this.client; |
| 2724 | let self = this; |
| 2725 | if (!optionalCallback && typeof options === 'function') { |
| 2726 | optionalCallback = options; |
| 2727 | options = null; |
| 2728 | } |
| 2729 | if (!optionalCallback) { |
| 2730 | return new Promise((resolve, reject) => { |
| 2731 | self._listForOrg(orgName, options, (err, result, request, response) => { |
| 2732 | if (err) { reject(err); } |
| 2733 | else { resolve(result); } |
| 2734 | return; |
| 2735 | }); |
| 2736 | }); |
| 2737 | } else { |
| 2738 | return self._listForOrg(orgName, options, optionalCallback); |
| 2739 | } |
| 2740 | } |
| 2741 | |
| 2742 | } |
| 2743 | |
| 2744 | module.exports = Apps; |