microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
6a465861663d7c6f9433e89c6f6619df320dcef3

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

lib/app-center-node-client/src/account/operations/organizations.js

1061lines · 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
9const msRest = require('ms-rest');
10const WebResource = msRest.WebResource;
11
12/**
13 * Creates a new organization and returns it to the caller
14 *
15 * @param {object} organization The organization data
16 *
17 * @param {string} [organization.displayName] The display name of the
18 * organization
19 *
20 * @param {string} [organization.name] The name of the organization used in
21 * URLs
22 *
23 * @param {object} [options] Optional Parameters.
24 *
25 * @param {object} [options.customHeaders] Headers that will be added to the
26 * request
27 *
28 * @param {function} callback - The callback.
29 *
30 * @returns {function} callback(err, result, request, response)
31 *
32 * {Error} err - The Error object if an error occurred, null otherwise.
33 *
34 * {object} [result] - The deserialized result object if an error did not occur.
35 * See {@link OrganizationResponse} for more information.
36 *
37 * {object} [request] - The HTTP Request object if an error did not occur.
38 *
39 * {stream} [response] - The HTTP Response stream if an error did not occur.
40 */
41function _createOrUpdate(organization, options, callback) {
42 /* jshint validthis: true */
43 let client = this.client;
44 if(!callback && typeof options === 'function') {
45 callback = options;
46 options = null;
47 }
48 if (!callback) {
49 throw new Error('callback cannot be null.');
50 }
51 // Validate
52 try {
53 if (organization === null || organization === undefined) {
54 throw new Error('organization cannot be null or undefined.');
55 }
56 } catch (error) {
57 return callback(error);
58 }
59
60 // Construct URL
61 let baseUrl = this.client.baseUri;
62 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/orgs';
63
64 // Create HTTP transport objects
65 let httpRequest = new WebResource();
66 httpRequest.method = 'POST';
67 httpRequest.url = requestUrl;
68 httpRequest.headers = {};
69 // Set Headers
70 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
71 if(options) {
72 for(let headerName in options['customHeaders']) {
73 if (options['customHeaders'].hasOwnProperty(headerName)) {
74 httpRequest.headers[headerName] = options['customHeaders'][headerName];
75 }
76 }
77 }
78 // Serialize Request
79 let requestContent = null;
80 let requestModel = null;
81 try {
82 if (organization !== null && organization !== undefined) {
83 let requestModelMapper = new client.models['OrganizationRequest']().mapper();
84 requestModel = client.serialize(requestModelMapper, organization, 'organization');
85 requestContent = JSON.stringify(requestModel);
86 }
87 } catch (error) {
88 let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
89 `payload - ${JSON.stringify(organization, null, 2)}.`);
90 return callback(serializationError);
91 }
92 httpRequest.body = requestContent;
93 // Send Request
94 return client.pipeline(httpRequest, (err, response, responseBody) => {
95 if (err) {
96 return callback(err);
97 }
98 let statusCode = response.statusCode;
99 if (statusCode !== 201) {
100 let error = new Error(responseBody);
101 error.statusCode = response.statusCode;
102 error.request = msRest.stripRequest(httpRequest);
103 error.response = msRest.stripResponse(response);
104 if (responseBody === '') responseBody = null;
105 let parsedErrorResponse;
106 try {
107 parsedErrorResponse = JSON.parse(responseBody);
108 if (parsedErrorResponse) {
109 let internalError = null;
110 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
111 error.code = internalError ? internalError.code : parsedErrorResponse.code;
112 error.message = internalError ? internalError.message : parsedErrorResponse.message;
113 }
114 } catch (defaultError) {
115 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
116 `- "${responseBody}" for the default response.`;
117 return callback(error);
118 }
119 return callback(error);
120 }
121 // Create Result
122 let result = null;
123 if (responseBody === '') responseBody = null;
124 // Deserialize Response
125 if (statusCode === 201) {
126 let parsedResponse = null;
127 try {
128 parsedResponse = JSON.parse(responseBody);
129 result = JSON.parse(responseBody);
130 if (parsedResponse !== null && parsedResponse !== undefined) {
131 let resultMapper = new client.models['OrganizationResponse']().mapper();
132 result = client.deserialize(resultMapper, parsedResponse, 'result');
133 }
134 } catch (error) {
135 let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
136 deserializationError.request = msRest.stripRequest(httpRequest);
137 deserializationError.response = msRest.stripResponse(response);
138 return callback(deserializationError);
139 }
140 }
141
142 return callback(null, result, httpRequest, response);
143 });
144}
145
146/**
147 * Returns a list of organizations the requesting user has access to
148 *
149 * @param {object} [options] Optional Parameters.
150 *
151 * @param {object} [options.customHeaders] Headers that will be added to the
152 * request
153 *
154 * @param {function} callback - The callback.
155 *
156 * @returns {function} callback(err, result, request, response)
157 *
158 * {Error} err - The Error object if an error occurred, null otherwise.
159 *
160 * {array} [result] - The deserialized result object if an error did not occur.
161 *
162 * {object} [request] - The HTTP Request object if an error did not occur.
163 *
164 * {stream} [response] - The HTTP Response stream if an error did not occur.
165 */
166function _list(options, callback) {
167 /* jshint validthis: true */
168 let client = this.client;
169 if(!callback && typeof options === 'function') {
170 callback = options;
171 options = null;
172 }
173 if (!callback) {
174 throw new Error('callback cannot be null.');
175 }
176
177 // Construct URL
178 let baseUrl = this.client.baseUri;
179 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/orgs';
180
181 // Create HTTP transport objects
182 let httpRequest = new WebResource();
183 httpRequest.method = 'GET';
184 httpRequest.url = requestUrl;
185 httpRequest.headers = {};
186 // Set Headers
187 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
188 if(options) {
189 for(let headerName in options['customHeaders']) {
190 if (options['customHeaders'].hasOwnProperty(headerName)) {
191 httpRequest.headers[headerName] = options['customHeaders'][headerName];
192 }
193 }
194 }
195 httpRequest.body = null;
196 // Send Request
197 return client.pipeline(httpRequest, (err, response, responseBody) => {
198 if (err) {
199 return callback(err);
200 }
201 let statusCode = response.statusCode;
202 if (statusCode !== 200) {
203 let error = new Error(responseBody);
204 error.statusCode = response.statusCode;
205 error.request = msRest.stripRequest(httpRequest);
206 error.response = msRest.stripResponse(response);
207 if (responseBody === '') responseBody = null;
208 let parsedErrorResponse;
209 try {
210 parsedErrorResponse = JSON.parse(responseBody);
211 if (parsedErrorResponse) {
212 let internalError = null;
213 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
214 error.code = internalError ? internalError.code : parsedErrorResponse.code;
215 error.message = internalError ? internalError.message : parsedErrorResponse.message;
216 }
217 } catch (defaultError) {
218 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
219 `- "${responseBody}" for the default response.`;
220 return callback(error);
221 }
222 return callback(error);
223 }
224 // Create Result
225 let result = null;
226 if (responseBody === '') responseBody = null;
227 // Deserialize Response
228 if (statusCode === 200) {
229 let parsedResponse = null;
230 try {
231 parsedResponse = JSON.parse(responseBody);
232 result = JSON.parse(responseBody);
233 if (parsedResponse !== null && parsedResponse !== undefined) {
234 let resultMapper = {
235 required: false,
236 serializedName: 'parsedResponse',
237 type: {
238 name: 'Sequence',
239 element: {
240 required: false,
241 serializedName: 'ListOKResponseItemElementType',
242 type: {
243 name: 'Composite',
244 className: 'ListOKResponseItem'
245 }
246 }
247 }
248 };
249 result = client.deserialize(resultMapper, parsedResponse, 'result');
250 }
251 } catch (error) {
252 let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
253 deserializationError.request = msRest.stripRequest(httpRequest);
254 deserializationError.response = msRest.stripResponse(response);
255 return callback(deserializationError);
256 }
257 }
258
259 return callback(null, result, httpRequest, response);
260 });
261}
262
263/**
264 * Returns the details of a single organization
265 *
266 * @param {string} orgName The organization's name
267 *
268 * @param {object} [options] Optional Parameters.
269 *
270 * @param {object} [options.customHeaders] Headers that will be added to the
271 * request
272 *
273 * @param {function} callback - The callback.
274 *
275 * @returns {function} callback(err, result, request, response)
276 *
277 * {Error} err - The Error object if an error occurred, null otherwise.
278 *
279 * {object} [result] - The deserialized result object if an error did not occur.
280 * See {@link OrganizationResponse} for more information.
281 *
282 * {object} [request] - The HTTP Request object if an error did not occur.
283 *
284 * {stream} [response] - The HTTP Response stream if an error did not occur.
285 */
286function _get(orgName, options, callback) {
287 /* jshint validthis: true */
288 let client = this.client;
289 if(!callback && typeof options === 'function') {
290 callback = options;
291 options = null;
292 }
293 if (!callback) {
294 throw new Error('callback cannot be null.');
295 }
296 // Validate
297 try {
298 if (orgName === null || orgName === undefined || typeof orgName.valueOf() !== 'string') {
299 throw new Error('orgName cannot be null or undefined and it must be of type string.');
300 }
301 } catch (error) {
302 return callback(error);
303 }
304
305 // Construct URL
306 let baseUrl = this.client.baseUri;
307 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/orgs/{org_name}';
308 requestUrl = requestUrl.replace('{org_name}', encodeURIComponent(orgName));
309
310 // Create HTTP transport objects
311 let httpRequest = new WebResource();
312 httpRequest.method = 'GET';
313 httpRequest.url = requestUrl;
314 httpRequest.headers = {};
315 // Set Headers
316 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
317 if(options) {
318 for(let headerName in options['customHeaders']) {
319 if (options['customHeaders'].hasOwnProperty(headerName)) {
320 httpRequest.headers[headerName] = options['customHeaders'][headerName];
321 }
322 }
323 }
324 httpRequest.body = null;
325 // Send Request
326 return client.pipeline(httpRequest, (err, response, responseBody) => {
327 if (err) {
328 return callback(err);
329 }
330 let statusCode = response.statusCode;
331 if (statusCode !== 200) {
332 let error = new Error(responseBody);
333 error.statusCode = response.statusCode;
334 error.request = msRest.stripRequest(httpRequest);
335 error.response = msRest.stripResponse(response);
336 if (responseBody === '') responseBody = null;
337 let parsedErrorResponse;
338 try {
339 parsedErrorResponse = JSON.parse(responseBody);
340 if (parsedErrorResponse) {
341 let internalError = null;
342 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
343 error.code = internalError ? internalError.code : parsedErrorResponse.code;
344 error.message = internalError ? internalError.message : parsedErrorResponse.message;
345 }
346 } catch (defaultError) {
347 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
348 `- "${responseBody}" for the default response.`;
349 return callback(error);
350 }
351 return callback(error);
352 }
353 // Create Result
354 let result = null;
355 if (responseBody === '') responseBody = null;
356 // Deserialize Response
357 if (statusCode === 200) {
358 let parsedResponse = null;
359 try {
360 parsedResponse = JSON.parse(responseBody);
361 result = JSON.parse(responseBody);
362 if (parsedResponse !== null && parsedResponse !== undefined) {
363 let resultMapper = new client.models['OrganizationResponse']().mapper();
364 result = client.deserialize(resultMapper, parsedResponse, 'result');
365 }
366 } catch (error) {
367 let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
368 deserializationError.request = msRest.stripRequest(httpRequest);
369 deserializationError.response = msRest.stripResponse(response);
370 return callback(deserializationError);
371 }
372 }
373
374 return callback(null, result, httpRequest, response);
375 });
376}
377
378/**
379 * Returns a list of organizations the requesting user has access to
380 *
381 * @param {object} org The data for the org
382 *
383 * @param {string} [org.displayName] The full (friendly) name of the
384 * organization.
385 *
386 * @param {string} [org.name] The name of the organization used in URLs
387 *
388 * @param {string} orgName The organization's name
389 *
390 * @param {object} [options] Optional Parameters.
391 *
392 * @param {object} [options.customHeaders] Headers that will be added to the
393 * request
394 *
395 * @param {function} callback - The callback.
396 *
397 * @returns {function} callback(err, result, request, response)
398 *
399 * {Error} err - The Error object if an error occurred, null otherwise.
400 *
401 * {object} [result] - The deserialized result object if an error did not occur.
402 * See {@link OrganizationResponse} for more information.
403 *
404 * {object} [request] - The HTTP Request object if an error did not occur.
405 *
406 * {stream} [response] - The HTTP Response stream if an error did not occur.
407 */
408function _update(org, orgName, options, callback) {
409 /* jshint validthis: true */
410 let client = this.client;
411 if(!callback && typeof options === 'function') {
412 callback = options;
413 options = null;
414 }
415 if (!callback) {
416 throw new Error('callback cannot be null.');
417 }
418 // Validate
419 try {
420 if (org === null || org === undefined) {
421 throw new Error('org cannot be null or undefined.');
422 }
423 if (orgName === null || orgName === undefined || typeof orgName.valueOf() !== 'string') {
424 throw new Error('orgName cannot be null or undefined and it must be of type string.');
425 }
426 } catch (error) {
427 return callback(error);
428 }
429
430 // Construct URL
431 let baseUrl = this.client.baseUri;
432 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/orgs/{org_name}';
433 requestUrl = requestUrl.replace('{org_name}', encodeURIComponent(orgName));
434
435 // Create HTTP transport objects
436 let httpRequest = new WebResource();
437 httpRequest.method = 'PATCH';
438 httpRequest.url = requestUrl;
439 httpRequest.headers = {};
440 // Set Headers
441 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
442 if(options) {
443 for(let headerName in options['customHeaders']) {
444 if (options['customHeaders'].hasOwnProperty(headerName)) {
445 httpRequest.headers[headerName] = options['customHeaders'][headerName];
446 }
447 }
448 }
449 // Serialize Request
450 let requestContent = null;
451 let requestModel = null;
452 try {
453 if (org !== null && org !== undefined) {
454 let requestModelMapper = new client.models['OrganizationPatchRequest']().mapper();
455 requestModel = client.serialize(requestModelMapper, org, 'org');
456 requestContent = JSON.stringify(requestModel);
457 }
458 } catch (error) {
459 let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
460 `payload - ${JSON.stringify(org, null, 2)}.`);
461 return callback(serializationError);
462 }
463 httpRequest.body = requestContent;
464 // Send Request
465 return client.pipeline(httpRequest, (err, response, responseBody) => {
466 if (err) {
467 return callback(err);
468 }
469 let statusCode = response.statusCode;
470 if (statusCode !== 200) {
471 let error = new Error(responseBody);
472 error.statusCode = response.statusCode;
473 error.request = msRest.stripRequest(httpRequest);
474 error.response = msRest.stripResponse(response);
475 if (responseBody === '') responseBody = null;
476 let parsedErrorResponse;
477 try {
478 parsedErrorResponse = JSON.parse(responseBody);
479 if (parsedErrorResponse) {
480 let internalError = null;
481 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
482 error.code = internalError ? internalError.code : parsedErrorResponse.code;
483 error.message = internalError ? internalError.message : parsedErrorResponse.message;
484 }
485 } catch (defaultError) {
486 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
487 `- "${responseBody}" for the default response.`;
488 return callback(error);
489 }
490 return callback(error);
491 }
492 // Create Result
493 let result = null;
494 if (responseBody === '') responseBody = null;
495 // Deserialize Response
496 if (statusCode === 200) {
497 let parsedResponse = null;
498 try {
499 parsedResponse = JSON.parse(responseBody);
500 result = JSON.parse(responseBody);
501 if (parsedResponse !== null && parsedResponse !== undefined) {
502 let resultMapper = new client.models['OrganizationResponse']().mapper();
503 result = client.deserialize(resultMapper, parsedResponse, 'result');
504 }
505 } catch (error) {
506 let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
507 deserializationError.request = msRest.stripRequest(httpRequest);
508 deserializationError.response = msRest.stripResponse(response);
509 return callback(deserializationError);
510 }
511 }
512
513 return callback(null, result, httpRequest, response);
514 });
515}
516
517/**
518 * Deletes a single organization
519 *
520 * @param {string} orgName The organization's name
521 *
522 * @param {object} [options] Optional Parameters.
523 *
524 * @param {object} [options.customHeaders] Headers that will be added to the
525 * request
526 *
527 * @param {function} callback - The callback.
528 *
529 * @returns {function} callback(err, result, request, response)
530 *
531 * {Error} err - The Error object if an error occurred, null otherwise.
532 *
533 * {null} [result] - The deserialized result object if an error did not occur.
534 *
535 * {object} [request] - The HTTP Request object if an error did not occur.
536 *
537 * {stream} [response] - The HTTP Response stream if an error did not occur.
538 */
539function _deleteMethod(orgName, options, callback) {
540 /* jshint validthis: true */
541 let client = this.client;
542 if(!callback && typeof options === 'function') {
543 callback = options;
544 options = null;
545 }
546 if (!callback) {
547 throw new Error('callback cannot be null.');
548 }
549 // Validate
550 try {
551 if (orgName === null || orgName === undefined || typeof orgName.valueOf() !== 'string') {
552 throw new Error('orgName cannot be null or undefined and it must be of type string.');
553 }
554 } catch (error) {
555 return callback(error);
556 }
557
558 // Construct URL
559 let baseUrl = this.client.baseUri;
560 let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/orgs/{org_name}';
561 requestUrl = requestUrl.replace('{org_name}', encodeURIComponent(orgName));
562
563 // Create HTTP transport objects
564 let httpRequest = new WebResource();
565 httpRequest.method = 'DELETE';
566 httpRequest.url = requestUrl;
567 httpRequest.headers = {};
568 // Set Headers
569 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
570 if(options) {
571 for(let headerName in options['customHeaders']) {
572 if (options['customHeaders'].hasOwnProperty(headerName)) {
573 httpRequest.headers[headerName] = options['customHeaders'][headerName];
574 }
575 }
576 }
577 httpRequest.body = null;
578 // Send Request
579 return client.pipeline(httpRequest, (err, response, responseBody) => {
580 if (err) {
581 return callback(err);
582 }
583 let statusCode = response.statusCode;
584 if (statusCode < 200 || statusCode >= 300) {
585 let error = new Error(responseBody);
586 error.statusCode = response.statusCode;
587 error.request = msRest.stripRequest(httpRequest);
588 error.response = msRest.stripResponse(response);
589 if (responseBody === '') responseBody = null;
590 let parsedErrorResponse;
591 try {
592 parsedErrorResponse = JSON.parse(responseBody);
593 if (parsedErrorResponse) {
594 let internalError = null;
595 if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
596 error.code = internalError ? internalError.code : parsedErrorResponse.code;
597 error.message = internalError ? internalError.message : parsedErrorResponse.message;
598 }
599 } catch (defaultError) {
600 error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
601 `- "${responseBody}" for the default response.`;
602 return callback(error);
603 }
604 return callback(error);
605 }
606 // Create Result
607 let result = null;
608 if (responseBody === '') responseBody = null;
609
610 return callback(null, result, httpRequest, response);
611 });
612}
613
614/** Class representing a Organizations. */
615class Organizations {
616 /**
617 * Create a Organizations.
618 * @param {AccountClient} client Reference to the service client.
619 */
620 constructor(client) {
621 this.client = client;
622 this._createOrUpdate = _createOrUpdate;
623 this._list = _list;
624 this._get = _get;
625 this._update = _update;
626 this._deleteMethod = _deleteMethod;
627 }
628
629 /**
630 * Creates a new organization and returns it to the caller
631 *
632 * @param {object} organization The organization data
633 *
634 * @param {string} [organization.displayName] The display name of the
635 * organization
636 *
637 * @param {string} [organization.name] The name of the organization used in
638 * URLs
639 *
640 * @param {object} [options] Optional Parameters.
641 *
642 * @param {object} [options.customHeaders] Headers that will be added to the
643 * request
644 *
645 * @returns {Promise} A promise is returned
646 *
647 * @resolve {HttpOperationResponse<OrganizationResponse>} - The deserialized result object.
648 *
649 * @reject {Error} - The error object.
650 */
651 createOrUpdateWithHttpOperationResponse(organization, options) {
652 let client = this.client;
653 let self = this;
654 return new Promise((resolve, reject) => {
655 self._createOrUpdate(organization, options, (err, result, request, response) => {
656 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
657 httpOperationResponse.body = result;
658 if (err) { reject(err); }
659 else { resolve(httpOperationResponse); }
660 return;
661 });
662 });
663 }
664
665 /**
666 * Creates a new organization and returns it to the caller
667 *
668 * @param {object} organization The organization data
669 *
670 * @param {string} [organization.displayName] The display name of the
671 * organization
672 *
673 * @param {string} [organization.name] The name of the organization used in
674 * URLs
675 *
676 * @param {object} [options] Optional Parameters.
677 *
678 * @param {object} [options.customHeaders] Headers that will be added to the
679 * request
680 *
681 * @param {function} [optionalCallback] - The optional callback.
682 *
683 * @returns {function|Promise} If a callback was passed as the last parameter
684 * then it returns the callback else returns a Promise.
685 *
686 * {Promise} A promise is returned
687 *
688 * @resolve {OrganizationResponse} - The deserialized result object.
689 *
690 * @reject {Error} - The error object.
691 *
692 * {function} optionalCallback(err, result, request, response)
693 *
694 * {Error} err - The Error object if an error occurred, null otherwise.
695 *
696 * {object} [result] - The deserialized result object if an error did not occur.
697 * See {@link OrganizationResponse} for more information.
698 *
699 * {object} [request] - The HTTP Request object if an error did not occur.
700 *
701 * {stream} [response] - The HTTP Response stream if an error did not occur.
702 */
703 createOrUpdate(organization, options, optionalCallback) {
704 let client = this.client;
705 let self = this;
706 if (!optionalCallback && typeof options === 'function') {
707 optionalCallback = options;
708 options = null;
709 }
710 if (!optionalCallback) {
711 return new Promise((resolve, reject) => {
712 self._createOrUpdate(organization, options, (err, result, request, response) => {
713 if (err) { reject(err); }
714 else { resolve(result); }
715 return;
716 });
717 });
718 } else {
719 return self._createOrUpdate(organization, options, optionalCallback);
720 }
721 }
722
723 /**
724 * Returns a list of organizations the requesting user has access to
725 *
726 * @param {object} [options] Optional Parameters.
727 *
728 * @param {object} [options.customHeaders] Headers that will be added to the
729 * request
730 *
731 * @returns {Promise} A promise is returned
732 *
733 * @resolve {HttpOperationResponse<Array>} - The deserialized result object.
734 *
735 * @reject {Error} - The error object.
736 */
737 listWithHttpOperationResponse(options) {
738 let client = this.client;
739 let self = this;
740 return new Promise((resolve, reject) => {
741 self._list(options, (err, result, request, response) => {
742 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
743 httpOperationResponse.body = result;
744 if (err) { reject(err); }
745 else { resolve(httpOperationResponse); }
746 return;
747 });
748 });
749 }
750
751 /**
752 * Returns a list of organizations the requesting user has access to
753 *
754 * @param {object} [options] Optional Parameters.
755 *
756 * @param {object} [options.customHeaders] Headers that will be added to the
757 * request
758 *
759 * @param {function} [optionalCallback] - The optional callback.
760 *
761 * @returns {function|Promise} If a callback was passed as the last parameter
762 * then it returns the callback else returns a Promise.
763 *
764 * {Promise} A promise is returned
765 *
766 * @resolve {Array} - The deserialized result object.
767 *
768 * @reject {Error} - The error object.
769 *
770 * {function} optionalCallback(err, result, request, response)
771 *
772 * {Error} err - The Error object if an error occurred, null otherwise.
773 *
774 * {array} [result] - The deserialized result object if an error did not occur.
775 *
776 * {object} [request] - The HTTP Request object if an error did not occur.
777 *
778 * {stream} [response] - The HTTP Response stream if an error did not occur.
779 */
780 list(options, optionalCallback) {
781 let client = this.client;
782 let self = this;
783 if (!optionalCallback && typeof options === 'function') {
784 optionalCallback = options;
785 options = null;
786 }
787 if (!optionalCallback) {
788 return new Promise((resolve, reject) => {
789 self._list(options, (err, result, request, response) => {
790 if (err) { reject(err); }
791 else { resolve(result); }
792 return;
793 });
794 });
795 } else {
796 return self._list(options, optionalCallback);
797 }
798 }
799
800 /**
801 * Returns the details of a single organization
802 *
803 * @param {string} orgName The organization's name
804 *
805 * @param {object} [options] Optional Parameters.
806 *
807 * @param {object} [options.customHeaders] Headers that will be added to the
808 * request
809 *
810 * @returns {Promise} A promise is returned
811 *
812 * @resolve {HttpOperationResponse<OrganizationResponse>} - The deserialized result object.
813 *
814 * @reject {Error} - The error object.
815 */
816 getWithHttpOperationResponse(orgName, options) {
817 let client = this.client;
818 let self = this;
819 return new Promise((resolve, reject) => {
820 self._get(orgName, options, (err, result, request, response) => {
821 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
822 httpOperationResponse.body = result;
823 if (err) { reject(err); }
824 else { resolve(httpOperationResponse); }
825 return;
826 });
827 });
828 }
829
830 /**
831 * Returns the details of a single organization
832 *
833 * @param {string} orgName The organization's name
834 *
835 * @param {object} [options] Optional Parameters.
836 *
837 * @param {object} [options.customHeaders] Headers that will be added to the
838 * request
839 *
840 * @param {function} [optionalCallback] - The optional callback.
841 *
842 * @returns {function|Promise} If a callback was passed as the last parameter
843 * then it returns the callback else returns a Promise.
844 *
845 * {Promise} A promise is returned
846 *
847 * @resolve {OrganizationResponse} - The deserialized result object.
848 *
849 * @reject {Error} - The error object.
850 *
851 * {function} optionalCallback(err, result, request, response)
852 *
853 * {Error} err - The Error object if an error occurred, null otherwise.
854 *
855 * {object} [result] - The deserialized result object if an error did not occur.
856 * See {@link OrganizationResponse} for more information.
857 *
858 * {object} [request] - The HTTP Request object if an error did not occur.
859 *
860 * {stream} [response] - The HTTP Response stream if an error did not occur.
861 */
862 get(orgName, options, optionalCallback) {
863 let client = this.client;
864 let self = this;
865 if (!optionalCallback && typeof options === 'function') {
866 optionalCallback = options;
867 options = null;
868 }
869 if (!optionalCallback) {
870 return new Promise((resolve, reject) => {
871 self._get(orgName, options, (err, result, request, response) => {
872 if (err) { reject(err); }
873 else { resolve(result); }
874 return;
875 });
876 });
877 } else {
878 return self._get(orgName, options, optionalCallback);
879 }
880 }
881
882 /**
883 * Returns a list of organizations the requesting user has access to
884 *
885 * @param {object} org The data for the org
886 *
887 * @param {string} [org.displayName] The full (friendly) name of the
888 * organization.
889 *
890 * @param {string} [org.name] The name of the organization used in URLs
891 *
892 * @param {string} orgName The organization's name
893 *
894 * @param {object} [options] Optional Parameters.
895 *
896 * @param {object} [options.customHeaders] Headers that will be added to the
897 * request
898 *
899 * @returns {Promise} A promise is returned
900 *
901 * @resolve {HttpOperationResponse<OrganizationResponse>} - The deserialized result object.
902 *
903 * @reject {Error} - The error object.
904 */
905 updateWithHttpOperationResponse(org, orgName, options) {
906 let client = this.client;
907 let self = this;
908 return new Promise((resolve, reject) => {
909 self._update(org, orgName, options, (err, result, request, response) => {
910 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
911 httpOperationResponse.body = result;
912 if (err) { reject(err); }
913 else { resolve(httpOperationResponse); }
914 return;
915 });
916 });
917 }
918
919 /**
920 * Returns a list of organizations the requesting user has access to
921 *
922 * @param {object} org The data for the org
923 *
924 * @param {string} [org.displayName] The full (friendly) name of the
925 * organization.
926 *
927 * @param {string} [org.name] The name of the organization used in URLs
928 *
929 * @param {string} orgName The organization's name
930 *
931 * @param {object} [options] Optional Parameters.
932 *
933 * @param {object} [options.customHeaders] Headers that will be added to the
934 * request
935 *
936 * @param {function} [optionalCallback] - The optional callback.
937 *
938 * @returns {function|Promise} If a callback was passed as the last parameter
939 * then it returns the callback else returns a Promise.
940 *
941 * {Promise} A promise is returned
942 *
943 * @resolve {OrganizationResponse} - The deserialized result object.
944 *
945 * @reject {Error} - The error object.
946 *
947 * {function} optionalCallback(err, result, request, response)
948 *
949 * {Error} err - The Error object if an error occurred, null otherwise.
950 *
951 * {object} [result] - The deserialized result object if an error did not occur.
952 * See {@link OrganizationResponse} for more information.
953 *
954 * {object} [request] - The HTTP Request object if an error did not occur.
955 *
956 * {stream} [response] - The HTTP Response stream if an error did not occur.
957 */
958 update(org, orgName, options, optionalCallback) {
959 let client = this.client;
960 let self = this;
961 if (!optionalCallback && typeof options === 'function') {
962 optionalCallback = options;
963 options = null;
964 }
965 if (!optionalCallback) {
966 return new Promise((resolve, reject) => {
967 self._update(org, orgName, options, (err, result, request, response) => {
968 if (err) { reject(err); }
969 else { resolve(result); }
970 return;
971 });
972 });
973 } else {
974 return self._update(org, orgName, options, optionalCallback);
975 }
976 }
977
978 /**
979 * Deletes a single organization
980 *
981 * @param {string} orgName The organization's name
982 *
983 * @param {object} [options] Optional Parameters.
984 *
985 * @param {object} [options.customHeaders] Headers that will be added to the
986 * request
987 *
988 * @returns {Promise} A promise is returned
989 *
990 * @resolve {HttpOperationResponse<null>} - The deserialized result object.
991 *
992 * @reject {Error} - The error object.
993 */
994 deleteMethodWithHttpOperationResponse(orgName, options) {
995 let client = this.client;
996 let self = this;
997 return new Promise((resolve, reject) => {
998 self._deleteMethod(orgName, options, (err, result, request, response) => {
999 let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
1000 httpOperationResponse.body = result;
1001 if (err) { reject(err); }
1002 else { resolve(httpOperationResponse); }
1003 return;
1004 });
1005 });
1006 }
1007
1008 /**
1009 * Deletes a single organization
1010 *
1011 * @param {string} orgName The organization's name
1012 *
1013 * @param {object} [options] Optional Parameters.
1014 *
1015 * @param {object} [options.customHeaders] Headers that will be added to the
1016 * request
1017 *
1018 * @param {function} [optionalCallback] - The optional callback.
1019 *
1020 * @returns {function|Promise} If a callback was passed as the last parameter
1021 * then it returns the callback else returns a Promise.
1022 *
1023 * {Promise} A promise is returned
1024 *
1025 * @resolve {null} - The deserialized result object.
1026 *
1027 * @reject {Error} - The error object.
1028 *
1029 * {function} optionalCallback(err, result, request, response)
1030 *
1031 * {Error} err - The Error object if an error occurred, null otherwise.
1032 *
1033 * {null} [result] - The deserialized result object if an error did not occur.
1034 *
1035 * {object} [request] - The HTTP Request object if an error did not occur.
1036 *
1037 * {stream} [response] - The HTTP Response stream if an error did not occur.
1038 */
1039 deleteMethod(orgName, options, optionalCallback) {
1040 let client = this.client;
1041 let self = this;
1042 if (!optionalCallback && typeof options === 'function') {
1043 optionalCallback = options;
1044 options = null;
1045 }
1046 if (!optionalCallback) {
1047 return new Promise((resolve, reject) => {
1048 self._deleteMethod(orgName, options, (err, result, request, response) => {
1049 if (err) { reject(err); }
1050 else { resolve(result); }
1051 return;
1052 });
1053 });
1054 } else {
1055 return self._deleteMethod(orgName, options, optionalCallback);
1056 }
1057 }
1058
1059}
1060
1061module.exports = Organizations;
1062