diff --git a/lib/services/graphManagement/lib/operations/applications.js b/lib/services/graphManagement/lib/operations/applications.js index 1f4f3bf4c7..a12af2d89c 100644 --- a/lib/services/graphManagement/lib/operations/applications.js +++ b/lib/services/graphManagement/lib/operations/applications.js @@ -1070,6 +1070,135 @@ function _addOwner(applicationObjectId, parameters, options, callback) { }); } +/** + * Remove a member from owners. + * + * @param {string} applicationObjectId The object ID of the application from + * which to remove the owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _removeOwner(applicationObjectId, ownerObjectId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (applicationObjectId === null || applicationObjectId === undefined || typeof applicationObjectId.valueOf() !== 'string') { + throw new Error('applicationObjectId cannot be null or undefined and it must be of type string.'); + } + if (ownerObjectId === null || ownerObjectId === undefined || typeof ownerObjectId.valueOf() !== 'string') { + throw new Error('ownerObjectId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/applications/{applicationObjectId}/$links/owners/{ownerObjectId}'; + requestUrl = requestUrl.replace('{applicationObjectId}', encodeURIComponent(applicationObjectId)); + requestUrl = requestUrl.replace('{ownerObjectId}', encodeURIComponent(ownerObjectId)); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + /** * Get the keyCredentials associated with an application. * @@ -1925,6 +2054,7 @@ class Applications { this._patch = _patch; this._listOwners = _listOwners; this._addOwner = _addOwner; + this._removeOwner = _removeOwner; this._listKeyCredentials = _listKeyCredentials; this._updateKeyCredentials = _updateKeyCredentials; this._listPasswordCredentials = _listPasswordCredentials; @@ -2663,6 +2793,93 @@ class Applications { } } + /** + * Remove a member from owners. + * + * @param {string} applicationObjectId The object ID of the application from + * which to remove the owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + removeOwnerWithHttpOperationResponse(applicationObjectId, ownerObjectId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._removeOwner(applicationObjectId, ownerObjectId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Remove a member from owners. + * + * @param {string} applicationObjectId The object ID of the application from + * which to remove the owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + removeOwner(applicationObjectId, ownerObjectId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._removeOwner(applicationObjectId, ownerObjectId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._removeOwner(applicationObjectId, ownerObjectId, options, optionalCallback); + } + } + /** * Get the keyCredentials associated with an application. * diff --git a/lib/services/graphManagement/lib/operations/groups.js b/lib/services/graphManagement/lib/operations/groups.js index 72975bf399..2fb9f9b75e 100644 --- a/lib/services/graphManagement/lib/operations/groups.js +++ b/lib/services/graphManagement/lib/operations/groups.js @@ -1620,6 +1620,135 @@ function _addOwner(objectId, parameters, options, callback) { }); } +/** + * Remove a member from owners. + * + * @param {string} objectId The object ID of the group from which to remove the + * owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _removeOwner(objectId, ownerObjectId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (objectId === null || objectId === undefined || typeof objectId.valueOf() !== 'string') { + throw new Error('objectId cannot be null or undefined and it must be of type string.'); + } + if (ownerObjectId === null || ownerObjectId === undefined || typeof ownerObjectId.valueOf() !== 'string') { + throw new Error('ownerObjectId cannot be null or undefined and it must be of type string.'); + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.tenantID === null || this.client.tenantID === undefined || typeof this.client.tenantID.valueOf() !== 'string') { + throw new Error('this.client.tenantID cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{tenantID}/groups/{objectId}/$links/owners/{ownerObjectId}'; + requestUrl = requestUrl.replace('{objectId}', encodeURIComponent(objectId)); + requestUrl = requestUrl.replace('{ownerObjectId}', encodeURIComponent(ownerObjectId)); + requestUrl = requestUrl.replace('{tenantID}', encodeURIComponent(this.client.tenantID)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['GraphError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + /** * Gets a list of groups for the current tenant. * @@ -2052,6 +2181,7 @@ class Groups { this._getMemberGroups = _getMemberGroups; this._listOwners = _listOwners; this._addOwner = _addOwner; + this._removeOwner = _removeOwner; this._listNext = _listNext; this._getGroupMembersNext = _getGroupMembersNext; this._listOwnersNext = _listOwnersNext; @@ -3051,6 +3181,93 @@ class Groups { } } + /** + * Remove a member from owners. + * + * @param {string} objectId The object ID of the group from which to remove the + * owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + removeOwnerWithHttpOperationResponse(objectId, ownerObjectId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._removeOwner(objectId, ownerObjectId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Remove a member from owners. + * + * @param {string} objectId The object ID of the group from which to remove the + * owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + removeOwner(objectId, ownerObjectId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._removeOwner(objectId, ownerObjectId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._removeOwner(objectId, ownerObjectId, options, optionalCallback); + } + } + /** * Gets a list of groups for the current tenant. * diff --git a/lib/services/graphManagement/lib/operations/index.d.ts b/lib/services/graphManagement/lib/operations/index.d.ts index 2a64f129c8..6c07de1e44 100644 --- a/lib/services/graphManagement/lib/operations/index.d.ts +++ b/lib/services/graphManagement/lib/operations/index.d.ts @@ -730,6 +730,66 @@ export interface Applications { addOwner(applicationObjectId: string, parameters: models.AddOwnerParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Remove a member from owners. + * + * @param {string} applicationObjectId The object ID of the application from + * which to remove the owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + removeOwnerWithHttpOperationResponse(applicationObjectId: string, ownerObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Remove a member from owners. + * + * @param {string} applicationObjectId The object ID of the application from + * which to remove the owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + removeOwner(applicationObjectId: string, ownerObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + removeOwner(applicationObjectId: string, ownerObjectId: string, callback: ServiceCallback): void; + removeOwner(applicationObjectId: string, ownerObjectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Get the keyCredentials associated with an application. * @@ -2011,6 +2071,66 @@ export interface Groups { addOwner(objectId: string, parameters: models.AddOwnerParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Remove a member from owners. + * + * @param {string} objectId The object ID of the group from which to remove the + * owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + removeOwnerWithHttpOperationResponse(objectId: string, ownerObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Remove a member from owners. + * + * @param {string} objectId The object ID of the group from which to remove the + * owner. + * + * @param {string} ownerObjectId Owner object id + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + removeOwner(objectId: string, ownerObjectId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + removeOwner(objectId: string, ownerObjectId: string, callback: ServiceCallback): void; + removeOwner(objectId: string, ownerObjectId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Gets a list of groups for the current tenant. *