/* jshint latedef:false */
/* jshint forin:false */
/* jshint noempty:false */

// 
// Copyright (c) Microsoft and contributors.  All rights reserved.
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//   http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 
// See the License for the specific language governing permissions and
// limitations under the License.
// 

// Warning: This code was generated by a tool.
// 
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

'use strict';

var util = require('util');
var azureCommon = require('azure-common');
var Service = azureCommon.Service;
var WebResource = azureCommon.WebResource;

var GraphRbacManagementClient = ( /** @lends GraphRbacManagementClient */ function() {
  /**
   * @class
   * Initializes a new instance of the GraphRbacManagementClient class.
   * @constructor
   * 
   * @param {string} tenantID Gets or sets the tenant Id.
   * 
   * @param {SubscriptionCloudCredentials} credentials Gets subscription
   * credentials which uniquely identify Microsoft Azure subscription. The
   * subscription ID forms part of the URI for every service call.
   * 
   * @param {string} [credentials.subscriptionId]
   * 
   * @param {string} [baseUri] Gets the URI used as the base for all cloud
   * service requests.
   * 
   * @param {Array} filters
   */
  function GraphRbacManagementClient(tenantID, credentials, baseUri, filters) {
    if (tenantID === null || tenantID === undefined) {
      throw new Error('tenantID cannot be null.');
    }
    if (credentials === null || credentials === undefined) {
      throw new Error('credentials cannot be null.');
    }
    
    GraphRbacManagementClient['super_'].call(this, credentials, filters);
    
    this.tenantID = tenantID;
    this.credentials = credentials;
    this.baseUri = baseUri;
    if (this.baseUri === null || this.baseUri === undefined) {
      this.baseUri = 'https://graph.windows.net/';
    }
    if (this.apiVersion === null || this.apiVersion === undefined) {
      this.apiVersion = '1.42-previewInternal';
    }
    if (this.longRunningOperationInitialTimeout === null || this.longRunningOperationInitialTimeout === undefined) {
      this.longRunningOperationInitialTimeout = -1;
    }
    if (this.longRunningOperationRetryTimeout === null || this.longRunningOperationRetryTimeout === undefined) {
      this.longRunningOperationRetryTimeout = -1;
    }
    /**
     * Provides an instance of the
     * [ApplicationOperations](-ApplicationOperations.html) object.
     * @type {object}
     */
    this.application = new ApplicationOperations(this);
    /**
     * Provides an instance of the [GroupOperations](-GroupOperations.html)
     * object.
     * @type {object}
     */
    this.group = new GroupOperations(this);
    /**
     * Provides an instance of the [ObjectOperations](-ObjectOperations.html)
     * object.
     * @type {object}
     */
    this.objects = new ObjectOperations(this);
    /**
     * Provides an instance of the
     * [ServicePrincipalOperations](-ServicePrincipalOperations.html) object.
     * @type {object}
     */
    this.servicePrincipal = new ServicePrincipalOperations(this);
    /**
     * Provides an instance of the [UserOperations](-UserOperations.html)
     * object.
     * @type {object}
     */
    this.user = new UserOperations(this);
  }
  
  util.inherits(GraphRbacManagementClient, Service);
  
  
  return GraphRbacManagementClient;
})();
exports.GraphRbacManagementClient = GraphRbacManagementClient;

var ApplicationOperations = ( /** @lends ApplicationOperations */ function() {
  /**
   * @class
   * Operations for working with applications in Azure Active Directory Graph
   * API.  (see http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx
   * for more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [GraphRbacManagementClient] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient}.
   * See [application] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient#application}.
   * Initializes a new instance of the ApplicationOperations class.
   * @constructor
   * 
   * @param {GraphRbacManagementClient} client Reference to the service client.
   */
  function ApplicationOperations(client) {
    this.client = client;
  }
  
  /**
   * Create a new application.  (see
   * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more
   * information)
   * 
   * @param {ApplicationCreateParameters} parameters Parameters to create an
   * application.
   * 
   * @param {boolean} parameters.availableToOtherTenants Indicates if the
   * application will be available to other tenants
   * 
   * @param {string} parameters.displayName Application display name
   * 
   * @param {string} parameters.homepage Application homepage
   * 
   * @param {IEnumerable} parameters.identifierUris Application Uris
   * 
   * @param {IEnumerable} [parameters.replyUrls] Application reply Urls
   * 
   * @param {IEnumerable} [parameters.keyCredentials] Gets or sets the list of
   * KeyCredential objects
   * 
   * @param {IEnumerable} [parameters.passwordCredentials] Gets or sets the
   * list of PasswordCredential objects
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ApplicationOperations.prototype.create = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.availableToOtherTenants === null || parameters.availableToOtherTenants === undefined) {
      return callback(new Error('parameters.availableToOtherTenants cannot be null.'));
    }
    if (parameters.displayName === null || parameters.displayName === undefined) {
      return callback(new Error('parameters.displayName cannot be null.'));
    }
    if (parameters.homepage === null || parameters.homepage === undefined) {
      return callback(new Error('parameters.homepage cannot be null.'));
    }
    if (parameters.identifierUris === null || parameters.identifierUris === undefined) {
      return callback(new Error('parameters.identifierUris cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/applications';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var applicationCreateParametersValue = {};
    requestDoc = applicationCreateParametersValue;
    
    applicationCreateParametersValue['availableToOtherTenants'] = parameters.availableToOtherTenants;
    
    applicationCreateParametersValue['displayName'] = parameters.displayName;
    
    applicationCreateParametersValue['homepage'] = parameters.homepage;
    
    if (parameters.identifierUris !== null && parameters.identifierUris !== undefined) {
      var identifierUrisArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.identifierUris.length; loweredIndex1 = loweredIndex1 + 1) {
        var identifierUrisItem = parameters.identifierUris[loweredIndex1];
        identifierUrisArray.push(identifierUrisItem);
      }
      applicationCreateParametersValue['identifierUris'] = identifierUrisArray;
    }
    
    if (parameters.replyUrls !== null && parameters.replyUrls !== undefined) {
      var replyUrlsArray = [];
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.replyUrls.length; loweredIndex2 = loweredIndex2 + 1) {
        var replyUrlsItem = parameters.replyUrls[loweredIndex2];
        replyUrlsArray.push(replyUrlsItem);
      }
      applicationCreateParametersValue['replyUrls'] = replyUrlsArray;
    }
    
    if (parameters.keyCredentials !== null && parameters.keyCredentials !== undefined) {
      var keyCredentialsArray = [];
      for (var loweredIndex3 = 0; loweredIndex3 < parameters.keyCredentials.length; loweredIndex3 = loweredIndex3 + 1) {
        var keyCredentialsItem = parameters.keyCredentials[loweredIndex3];
        var keyCredentialValue = {};
        keyCredentialsArray.push(keyCredentialValue);
        
        if (keyCredentialsItem.startDate !== null && keyCredentialsItem.startDate !== undefined) {
          keyCredentialValue['startDate'] = keyCredentialsItem.startDate.toISOString();
        }
        
        if (keyCredentialsItem.endDate !== null && keyCredentialsItem.endDate !== undefined) {
          keyCredentialValue['endDate'] = keyCredentialsItem.endDate.toISOString();
        }
        
        if (keyCredentialsItem.value !== null && keyCredentialsItem.value !== undefined) {
          keyCredentialValue['value'] = keyCredentialsItem.value;
        }
        
        if (keyCredentialsItem.keyId !== null && keyCredentialsItem.keyId !== undefined) {
          keyCredentialValue['keyId'] = keyCredentialsItem.keyId;
        }
        
        if (keyCredentialsItem.usage !== null && keyCredentialsItem.usage !== undefined) {
          keyCredentialValue['usage'] = keyCredentialsItem.usage;
        }
        
        if (keyCredentialsItem.type !== null && keyCredentialsItem.type !== undefined) {
          keyCredentialValue['type'] = keyCredentialsItem.type;
        }
      }
      applicationCreateParametersValue['keyCredentials'] = keyCredentialsArray;
    }
    
    if (parameters.passwordCredentials !== null && parameters.passwordCredentials !== undefined) {
      var passwordCredentialsArray = [];
      for (var loweredIndex4 = 0; loweredIndex4 < parameters.passwordCredentials.length; loweredIndex4 = loweredIndex4 + 1) {
        var passwordCredentialsItem = parameters.passwordCredentials[loweredIndex4];
        var passwordCredentialValue = {};
        passwordCredentialsArray.push(passwordCredentialValue);
        
        if (passwordCredentialsItem.startDate !== null && passwordCredentialsItem.startDate !== undefined) {
          passwordCredentialValue['startDate'] = passwordCredentialsItem.startDate.toISOString();
        }
        
        if (passwordCredentialsItem.endDate !== null && passwordCredentialsItem.endDate !== undefined) {
          passwordCredentialValue['endDate'] = passwordCredentialsItem.endDate.toISOString();
        }
        
        if (passwordCredentialsItem.keyId !== null && passwordCredentialsItem.keyId !== undefined) {
          passwordCredentialValue['keyId'] = passwordCredentialsItem.keyId;
        }
        
        if (passwordCredentialsItem.value !== null && passwordCredentialsItem.value !== undefined) {
          passwordCredentialValue['value'] = passwordCredentialsItem.value;
        }
      }
      applicationCreateParametersValue['passwordCredentials'] = passwordCredentialsArray;
    }
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 201) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var applicationInstance = { appPermissions: [], identifierUris: [], replyUrls: [] };
          result.application = applicationInstance;
          
          var objectIdValue = responseDoc['objectId'];
          if (objectIdValue !== null && objectIdValue !== undefined) {
            var objectIdInstance = objectIdValue;
            applicationInstance.objectId = objectIdInstance;
          }
          
          var objectTypeValue = responseDoc['objectType'];
          if (objectTypeValue !== null && objectTypeValue !== undefined) {
            var objectTypeInstance = objectTypeValue;
            applicationInstance.objectType = objectTypeInstance;
          }
          
          var appIdValue = responseDoc['appId'];
          if (appIdValue !== null && appIdValue !== undefined) {
            var appIdInstance = appIdValue;
            applicationInstance.appId = appIdInstance;
          }
          
          var displayNameValue = responseDoc['displayName'];
          if (displayNameValue !== null && displayNameValue !== undefined) {
            var displayNameInstance = displayNameValue;
            applicationInstance.displayName = displayNameInstance;
          }
          
          var identifierUrisArray2 = responseDoc['identifierUris'];
          if (identifierUrisArray2 !== null && identifierUrisArray2 !== undefined) {
            for (var loweredIndex5 = 0; loweredIndex5 < identifierUrisArray2.length; loweredIndex5 = loweredIndex5 + 1) {
              var identifierUrisValue = identifierUrisArray2[loweredIndex5];
              applicationInstance.identifierUris.push(identifierUrisValue);
            }
          }
          
          var replyUrlsArray2 = responseDoc['replyUrls'];
          if (replyUrlsArray2 !== null && replyUrlsArray2 !== undefined) {
            for (var loweredIndex6 = 0; loweredIndex6 < replyUrlsArray2.length; loweredIndex6 = loweredIndex6 + 1) {
              var replyUrlsValue = replyUrlsArray2[loweredIndex6];
              applicationInstance.replyUrls.push(replyUrlsValue);
            }
          }
          
          var appPermissionsArray = responseDoc['appPermissions'];
          if (appPermissionsArray !== null && appPermissionsArray !== undefined) {
            for (var loweredIndex7 = 0; loweredIndex7 < appPermissionsArray.length; loweredIndex7 = loweredIndex7 + 1) {
              var appPermissionsValue = appPermissionsArray[loweredIndex7];
              applicationInstance.appPermissions.push(appPermissionsValue);
            }
          }
          
          var availableToOtherTenantsValue = responseDoc['availableToOtherTenants'];
          if (availableToOtherTenantsValue !== null && availableToOtherTenantsValue !== undefined) {
            var availableToOtherTenantsInstance = availableToOtherTenantsValue;
            applicationInstance.availableToOtherTenants = availableToOtherTenantsInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Delete an application.  (see
   * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more
   * information)
   * 
   * @param {string} applicationObjectId Application object id
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ApplicationOperations.prototype.deleteMethod = function(applicationObjectId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (applicationObjectId === null || applicationObjectId === undefined) {
      return callback(new Error('applicationObjectId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/applications/';
    url2 = url2 + applicationObjectId;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get an application by object Id.  (see
   * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more
   * information)
   * 
   * @param {string} applicationObjectId Application object id
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ApplicationOperations.prototype.get = function(applicationObjectId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (applicationObjectId === null || applicationObjectId === undefined) {
      return callback(new Error('applicationObjectId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/applications/';
    url2 = url2 + applicationObjectId;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var applicationInstance = { appPermissions: [], identifierUris: [], replyUrls: [] };
          result.application = applicationInstance;
          
          var objectIdValue = responseDoc['objectId'];
          if (objectIdValue !== null && objectIdValue !== undefined) {
            var objectIdInstance = objectIdValue;
            applicationInstance.objectId = objectIdInstance;
          }
          
          var objectTypeValue = responseDoc['objectType'];
          if (objectTypeValue !== null && objectTypeValue !== undefined) {
            var objectTypeInstance = objectTypeValue;
            applicationInstance.objectType = objectTypeInstance;
          }
          
          var appIdValue = responseDoc['appId'];
          if (appIdValue !== null && appIdValue !== undefined) {
            var appIdInstance = appIdValue;
            applicationInstance.appId = appIdInstance;
          }
          
          var displayNameValue = responseDoc['displayName'];
          if (displayNameValue !== null && displayNameValue !== undefined) {
            var displayNameInstance = displayNameValue;
            applicationInstance.displayName = displayNameInstance;
          }
          
          var identifierUrisArray = responseDoc['identifierUris'];
          if (identifierUrisArray !== null && identifierUrisArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < identifierUrisArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var identifierUrisValue = identifierUrisArray[loweredIndex1];
              applicationInstance.identifierUris.push(identifierUrisValue);
            }
          }
          
          var replyUrlsArray = responseDoc['replyUrls'];
          if (replyUrlsArray !== null && replyUrlsArray !== undefined) {
            for (var loweredIndex2 = 0; loweredIndex2 < replyUrlsArray.length; loweredIndex2 = loweredIndex2 + 1) {
              var replyUrlsValue = replyUrlsArray[loweredIndex2];
              applicationInstance.replyUrls.push(replyUrlsValue);
            }
          }
          
          var appPermissionsArray = responseDoc['appPermissions'];
          if (appPermissionsArray !== null && appPermissionsArray !== undefined) {
            for (var loweredIndex3 = 0; loweredIndex3 < appPermissionsArray.length; loweredIndex3 = loweredIndex3 + 1) {
              var appPermissionsValue = appPermissionsArray[loweredIndex3];
              applicationInstance.appPermissions.push(appPermissionsValue);
            }
          }
          
          var availableToOtherTenantsValue = responseDoc['availableToOtherTenants'];
          if (availableToOtherTenantsValue !== null && availableToOtherTenantsValue !== undefined) {
            var availableToOtherTenantsInstance = availableToOtherTenantsValue;
            applicationInstance.availableToOtherTenants = availableToOtherTenantsInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get applications by filters.  (see
   * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more
   * information)
   * 
   * @param {ApplicationFilterParameters} parameters Application filter
   * parameters
   * 
   * @param {Guid} [parameters.appId] Returns an application with a specific
   * appId.
   * 
   * @param {string} [parameters.displayNameStartsWith] Returns all
   * applications starting with this displayName.
   * 
   * @param {string} [parameters.identifierUri] Returns an application which
   * contains the mentioned identifierUri.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ApplicationOperations.prototype.list = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/applications';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    var odataFilter = [];
    if (parameters.appId !== null && parameters.appId !== undefined) {
      odataFilter.push('appId eq guid\'' + encodeURIComponent(parameters.appId) + '\'');
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    var odataFilter2 = [];
    if (parameters.displayNameStartsWith !== null && parameters.displayNameStartsWith !== undefined) {
      odataFilter2.push('startswith(displayName,\'' + encodeURIComponent(parameters.displayNameStartsWith) + '\')');
    }
    if (odataFilter2.length > 0) {
      queryParameters.push('$filter=' + odataFilter2.join(null));
    }
    var odataFilter3 = [];
    if (parameters.identifierUri !== null && parameters.identifierUri !== undefined) {
      odataFilter3.push('identifierUris/any(s:s eq \'' + encodeURIComponent(parameters.identifierUri) + '\')');
    }
    if (odataFilter3.length > 0) {
      queryParameters.push('$filter=' + odataFilter3.join(null));
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { applications: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var applicationInstance = { appPermissions: [], identifierUris: [], replyUrls: [] };
              result.applications.push(applicationInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                applicationInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                applicationInstance.objectType = objectTypeInstance;
              }
              
              var appIdValue = valueValue['appId'];
              if (appIdValue !== null && appIdValue !== undefined) {
                var appIdInstance = appIdValue;
                applicationInstance.appId = appIdInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                applicationInstance.displayName = displayNameInstance;
              }
              
              var identifierUrisArray = valueValue['identifierUris'];
              if (identifierUrisArray !== null && identifierUrisArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < identifierUrisArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var identifierUrisValue = identifierUrisArray[loweredIndex2];
                  applicationInstance.identifierUris.push(identifierUrisValue);
                }
              }
              
              var replyUrlsArray = valueValue['replyUrls'];
              if (replyUrlsArray !== null && replyUrlsArray !== undefined) {
                for (var loweredIndex3 = 0; loweredIndex3 < replyUrlsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                  var replyUrlsValue = replyUrlsArray[loweredIndex3];
                  applicationInstance.replyUrls.push(replyUrlsValue);
                }
              }
              
              var appPermissionsArray = valueValue['appPermissions'];
              if (appPermissionsArray !== null && appPermissionsArray !== undefined) {
                for (var loweredIndex4 = 0; loweredIndex4 < appPermissionsArray.length; loweredIndex4 = loweredIndex4 + 1) {
                  var appPermissionsValue = appPermissionsArray[loweredIndex4];
                  applicationInstance.appPermissions.push(appPermissionsValue);
                }
              }
              
              var availableToOtherTenantsValue = valueValue['availableToOtherTenants'];
              if (availableToOtherTenantsValue !== null && availableToOtherTenantsValue !== undefined) {
                var availableToOtherTenantsInstance = availableToOtherTenantsValue;
                applicationInstance.availableToOtherTenants = availableToOtherTenantsInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Update existing application.  (see
   * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more
   * information)
   * 
   * @param {string} applicationObjectId Application object id
   * 
   * @param {ApplicationCreateParameters} parameters Parameters to create an
   * application.
   * 
   * @param {boolean} parameters.availableToOtherTenants Indicates if the
   * application will be available to other tenants
   * 
   * @param {string} parameters.displayName Application display name
   * 
   * @param {string} parameters.homepage Application homepage
   * 
   * @param {IEnumerable} parameters.identifierUris Application Uris
   * 
   * @param {IEnumerable} [parameters.replyUrls] Application reply Urls
   * 
   * @param {IEnumerable} [parameters.keyCredentials] Gets or sets the list of
   * KeyCredential objects
   * 
   * @param {IEnumerable} [parameters.passwordCredentials] Gets or sets the
   * list of PasswordCredential objects
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ApplicationOperations.prototype.update = function(applicationObjectId, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (applicationObjectId === null || applicationObjectId === undefined) {
      return callback(new Error('applicationObjectId cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.availableToOtherTenants === null || parameters.availableToOtherTenants === undefined) {
      return callback(new Error('parameters.availableToOtherTenants cannot be null.'));
    }
    if (parameters.displayName === null || parameters.displayName === undefined) {
      return callback(new Error('parameters.displayName cannot be null.'));
    }
    if (parameters.homepage === null || parameters.homepage === undefined) {
      return callback(new Error('parameters.homepage cannot be null.'));
    }
    if (parameters.identifierUris === null || parameters.identifierUris === undefined) {
      return callback(new Error('parameters.identifierUris cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/applications/';
    url2 = url2 + applicationObjectId;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PATCH';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var applicationCreateParametersValue = {};
    requestDoc = applicationCreateParametersValue;
    
    applicationCreateParametersValue['availableToOtherTenants'] = parameters.availableToOtherTenants;
    
    applicationCreateParametersValue['displayName'] = parameters.displayName;
    
    applicationCreateParametersValue['homepage'] = parameters.homepage;
    
    if (parameters.identifierUris !== null && parameters.identifierUris !== undefined) {
      var identifierUrisArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.identifierUris.length; loweredIndex1 = loweredIndex1 + 1) {
        var identifierUrisItem = parameters.identifierUris[loweredIndex1];
        identifierUrisArray.push(identifierUrisItem);
      }
      applicationCreateParametersValue['identifierUris'] = identifierUrisArray;
    }
    
    if (parameters.replyUrls !== null && parameters.replyUrls !== undefined) {
      var replyUrlsArray = [];
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.replyUrls.length; loweredIndex2 = loweredIndex2 + 1) {
        var replyUrlsItem = parameters.replyUrls[loweredIndex2];
        replyUrlsArray.push(replyUrlsItem);
      }
      applicationCreateParametersValue['replyUrls'] = replyUrlsArray;
    }
    
    if (parameters.keyCredentials !== null && parameters.keyCredentials !== undefined) {
      var keyCredentialsArray = [];
      for (var loweredIndex3 = 0; loweredIndex3 < parameters.keyCredentials.length; loweredIndex3 = loweredIndex3 + 1) {
        var keyCredentialsItem = parameters.keyCredentials[loweredIndex3];
        var keyCredentialValue = {};
        keyCredentialsArray.push(keyCredentialValue);
        
        if (keyCredentialsItem.startDate !== null && keyCredentialsItem.startDate !== undefined) {
          keyCredentialValue['startDate'] = keyCredentialsItem.startDate.toISOString();
        }
        
        if (keyCredentialsItem.endDate !== null && keyCredentialsItem.endDate !== undefined) {
          keyCredentialValue['endDate'] = keyCredentialsItem.endDate.toISOString();
        }
        
        if (keyCredentialsItem.value !== null && keyCredentialsItem.value !== undefined) {
          keyCredentialValue['value'] = keyCredentialsItem.value;
        }
        
        if (keyCredentialsItem.keyId !== null && keyCredentialsItem.keyId !== undefined) {
          keyCredentialValue['keyId'] = keyCredentialsItem.keyId;
        }
        
        if (keyCredentialsItem.usage !== null && keyCredentialsItem.usage !== undefined) {
          keyCredentialValue['usage'] = keyCredentialsItem.usage;
        }
        
        if (keyCredentialsItem.type !== null && keyCredentialsItem.type !== undefined) {
          keyCredentialValue['type'] = keyCredentialsItem.type;
        }
      }
      applicationCreateParametersValue['keyCredentials'] = keyCredentialsArray;
    }
    
    if (parameters.passwordCredentials !== null && parameters.passwordCredentials !== undefined) {
      var passwordCredentialsArray = [];
      for (var loweredIndex4 = 0; loweredIndex4 < parameters.passwordCredentials.length; loweredIndex4 = loweredIndex4 + 1) {
        var passwordCredentialsItem = parameters.passwordCredentials[loweredIndex4];
        var passwordCredentialValue = {};
        passwordCredentialsArray.push(passwordCredentialValue);
        
        if (passwordCredentialsItem.startDate !== null && passwordCredentialsItem.startDate !== undefined) {
          passwordCredentialValue['startDate'] = passwordCredentialsItem.startDate.toISOString();
        }
        
        if (passwordCredentialsItem.endDate !== null && passwordCredentialsItem.endDate !== undefined) {
          passwordCredentialValue['endDate'] = passwordCredentialsItem.endDate.toISOString();
        }
        
        if (passwordCredentialsItem.keyId !== null && passwordCredentialsItem.keyId !== undefined) {
          passwordCredentialValue['keyId'] = passwordCredentialsItem.keyId;
        }
        
        if (passwordCredentialsItem.value !== null && passwordCredentialsItem.value !== undefined) {
          passwordCredentialValue['value'] = passwordCredentialsItem.value;
        }
      }
      applicationCreateParametersValue['passwordCredentials'] = passwordCredentialsArray;
    }
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  return ApplicationOperations;
})();

var GroupOperations = ( /** @lends GroupOperations */ function() {
  /**
   * @class
   * Operations for working with Groups in Azure Active Directory Graph API.
   * (see http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [GraphRbacManagementClient] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient}.
   * See [group] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient#group}.
   * Initializes a new instance of the GroupOperations class.
   * @constructor
   * 
   * @param {GraphRbacManagementClient} client Reference to the service client.
   */
  function GroupOperations(client) {
    this.client = client;
  }
  
  /**
   * Add a memeber to a group.   (see
   * http://msdn.microsoft.com/en-us/library/azure/dn151600.aspx for more
   * information)
   * 
   * @param {string} groupObjectId Group object id
   * 
   * @param {GroupAddMemberParameters} parameters Member Object Url as
   * https://graph.windows.net/contoso.onmicrosoft.com/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd
   * 
   * @param {string} parameters.memberUrl Group display name
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.addMember = function(groupObjectId, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (groupObjectId === null || groupObjectId === undefined) {
      return callback(new Error('groupObjectId cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.memberUrl === null || parameters.memberUrl === undefined) {
      return callback(new Error('parameters.memberUrl cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/groups/';
    url2 = url2 + groupObjectId;
    url2 = url2 + '/$links/members';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var groupAddMemberParametersValue = {};
    requestDoc = groupAddMemberParametersValue;
    
    groupAddMemberParametersValue['url'] = parameters.memberUrl;
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Create a group in the directory.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn151614.aspx for more
   * information)
   * 
   * @param {GroupCreateParameters} parameters Parameters to create a group
   * 
   * @param {string} parameters.displayName Group display name
   * 
   * @param {boolean} parameters.mailEnabled Mail
   * 
   * @param {string} parameters.mailNickname Mail nick name
   * 
   * @param {boolean} parameters.securityEnabled Is security enabled
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.create = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.displayName === null || parameters.displayName === undefined) {
      return callback(new Error('parameters.displayName cannot be null.'));
    }
    if (parameters.mailEnabled === null || parameters.mailEnabled === undefined) {
      return callback(new Error('parameters.mailEnabled cannot be null.'));
    }
    if (parameters.mailNickname === null || parameters.mailNickname === undefined) {
      return callback(new Error('parameters.mailNickname cannot be null.'));
    }
    if (parameters.securityEnabled === null || parameters.securityEnabled === undefined) {
      return callback(new Error('parameters.securityEnabled cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/groups';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var groupCreateParametersValue = {};
    requestDoc = groupCreateParametersValue;
    
    groupCreateParametersValue['displayName'] = parameters.displayName;
    
    groupCreateParametersValue['mailEnabled'] = parameters.mailEnabled;
    
    groupCreateParametersValue['mailNickname'] = parameters.mailNickname;
    
    groupCreateParametersValue['securityEnabled'] = parameters.securityEnabled;
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 201) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var groupInstance = {};
          result.group = groupInstance;
          
          var objectIdValue = responseDoc['objectId'];
          if (objectIdValue !== null && objectIdValue !== undefined) {
            var objectIdInstance = objectIdValue;
            groupInstance.objectId = objectIdInstance;
          }
          
          var objectTypeValue = responseDoc['objectType'];
          if (objectTypeValue !== null && objectTypeValue !== undefined) {
            var objectTypeInstance = objectTypeValue;
            groupInstance.objectType = objectTypeInstance;
          }
          
          var displayNameValue = responseDoc['displayName'];
          if (displayNameValue !== null && displayNameValue !== undefined) {
            var displayNameInstance = displayNameValue;
            groupInstance.displayName = displayNameInstance;
          }
          
          var securityEnabledValue = responseDoc['securityEnabled'];
          if (securityEnabledValue !== null && securityEnabledValue !== undefined) {
            var securityEnabledInstance = securityEnabledValue;
            groupInstance.securityEnabled = securityEnabledInstance;
          }
          
          var mailValue = responseDoc['mail'];
          if (mailValue !== null && mailValue !== undefined) {
            var mailInstance = mailValue;
            groupInstance.mail = mailInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Delete a group in the directory.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn151608.aspx for more
   * information)
   * 
   * @param {string} groupObjectId Object id
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.deleteMethod = function(groupObjectId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (groupObjectId === null || groupObjectId === undefined) {
      return callback(new Error('groupObjectId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/groups/';
    url2 = url2 + groupObjectId;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets group information from the directory.
   * 
   * @param {string} objectId User objectId to get group information.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.get = function(objectId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (objectId === null || objectId === undefined) {
      return callback(new Error('objectId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/groups/';
    url2 = url2 + objectId;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var groupInstance = {};
          result.group = groupInstance;
          
          var objectIdValue = responseDoc['objectId'];
          if (objectIdValue !== null && objectIdValue !== undefined) {
            var objectIdInstance = objectIdValue;
            groupInstance.objectId = objectIdInstance;
          }
          
          var objectTypeValue = responseDoc['objectType'];
          if (objectTypeValue !== null && objectTypeValue !== undefined) {
            var objectTypeInstance = objectTypeValue;
            groupInstance.objectType = objectTypeInstance;
          }
          
          var displayNameValue = responseDoc['displayName'];
          if (displayNameValue !== null && displayNameValue !== undefined) {
            var displayNameInstance = displayNameValue;
            groupInstance.displayName = displayNameInstance;
          }
          
          var securityEnabledValue = responseDoc['securityEnabled'];
          if (securityEnabledValue !== null && securityEnabledValue !== undefined) {
            var securityEnabledInstance = securityEnabledValue;
            groupInstance.securityEnabled = securityEnabledInstance;
          }
          
          var mailValue = responseDoc['mail'];
          if (mailValue !== null && mailValue !== undefined) {
            var mailInstance = mailValue;
            groupInstance.mail = mailInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets the members of a group.
   * 
   * @param {string} objectId Group object Id who's members should be retrieved.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.getGroupMembers = function(objectId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (objectId === null || objectId === undefined) {
      return callback(new Error('objectId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/groups/';
    url2 = url2 + objectId;
    url2 = url2 + '/members';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { aADObject: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var aADObjectInstance = { servicePrincipalNames: [] };
              result.aADObject.push(aADObjectInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                aADObjectInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                aADObjectInstance.objectType = objectTypeInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                aADObjectInstance.displayName = displayNameInstance;
              }
              
              var userPrincipalNameValue = valueValue['userPrincipalName'];
              if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {
                var userPrincipalNameInstance = userPrincipalNameValue;
                aADObjectInstance.userPrincipalName = userPrincipalNameInstance;
              }
              
              var mailValue = valueValue['mail'];
              if (mailValue !== null && mailValue !== undefined) {
                var mailInstance = mailValue;
                aADObjectInstance.mail = mailInstance;
              }
              
              var mailEnabledValue = valueValue['mailEnabled'];
              if (mailEnabledValue !== null && mailEnabledValue !== undefined) {
                var mailEnabledInstance = mailEnabledValue;
                aADObjectInstance.mailEnabled = mailEnabledInstance;
              }
              
              var securityEnabledValue = valueValue['securityEnabled'];
              if (securityEnabledValue !== null && securityEnabledValue !== undefined) {
                var securityEnabledInstance = securityEnabledValue;
                aADObjectInstance.securityEnabled = securityEnabledInstance;
              }
              
              var signInNameValue = valueValue['signInName'];
              if (signInNameValue !== null && signInNameValue !== undefined) {
                var signInNameInstance = signInNameValue;
                aADObjectInstance.signInName = signInNameInstance;
              }
              
              var servicePrincipalNamesArray = valueValue['servicePrincipalNames'];
              if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < servicePrincipalNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex2];
                  aADObjectInstance.servicePrincipalNames.push(servicePrincipalNamesValue);
                }
              }
              
              var userTypeValue = valueValue['userType'];
              if (userTypeValue !== null && userTypeValue !== undefined) {
                var userTypeInstance = userTypeValue;
                aADObjectInstance.userType = userTypeInstance;
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets next set of members of a group.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * GetGroupMembers or GetGroupMembersNext.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.getGroupMembersNext = function(nextLink, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (nextLink === null || nextLink === undefined) {
      return callback(new Error('nextLink cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/';
    url2 = url2 + nextLink;
    url2 = url2 + '&api-version=1.42-previewInternal';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { aADObject: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var aADObjectInstance = { servicePrincipalNames: [] };
              result.aADObject.push(aADObjectInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                aADObjectInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                aADObjectInstance.objectType = objectTypeInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                aADObjectInstance.displayName = displayNameInstance;
              }
              
              var userPrincipalNameValue = valueValue['userPrincipalName'];
              if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {
                var userPrincipalNameInstance = userPrincipalNameValue;
                aADObjectInstance.userPrincipalName = userPrincipalNameInstance;
              }
              
              var mailValue = valueValue['mail'];
              if (mailValue !== null && mailValue !== undefined) {
                var mailInstance = mailValue;
                aADObjectInstance.mail = mailInstance;
              }
              
              var mailEnabledValue = valueValue['mailEnabled'];
              if (mailEnabledValue !== null && mailEnabledValue !== undefined) {
                var mailEnabledInstance = mailEnabledValue;
                aADObjectInstance.mailEnabled = mailEnabledInstance;
              }
              
              var securityEnabledValue = valueValue['securityEnabled'];
              if (securityEnabledValue !== null && securityEnabledValue !== undefined) {
                var securityEnabledInstance = securityEnabledValue;
                aADObjectInstance.securityEnabled = securityEnabledInstance;
              }
              
              var signInNameValue = valueValue['signInName'];
              if (signInNameValue !== null && signInNameValue !== undefined) {
                var signInNameInstance = signInNameValue;
                aADObjectInstance.signInName = signInNameInstance;
              }
              
              var servicePrincipalNamesArray = valueValue['servicePrincipalNames'];
              if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < servicePrincipalNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex2];
                  aADObjectInstance.servicePrincipalNames.push(servicePrincipalNamesValue);
                }
              }
              
              var userTypeValue = valueValue['userType'];
              if (userTypeValue !== null && userTypeValue !== undefined) {
                var userTypeInstance = userTypeValue;
                aADObjectInstance.userType = userTypeInstance;
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a collection that contains the Object IDs of the groups of which the
   * group is a member.
   * 
   * @param {GroupGetMemberGroupsParameters} parameters Group filtering
   * parameters.
   * 
   * @param {string} parameters.objectId Group object Id
   * 
   * @param {boolean} parameters.securityEnabledOnly If true only membership in
   * security enabled groups should be checked. Otherwise membership in all
   * groups should be checked
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.getMemberGroups = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.objectId === null || parameters.objectId === undefined) {
      return callback(new Error('parameters.objectId cannot be null.'));
    }
    if (parameters.securityEnabledOnly === null || parameters.securityEnabledOnly === undefined) {
      return callback(new Error('parameters.securityEnabledOnly cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/groups/';
    url2 = url2 + parameters.objectId;
    url2 = url2 + '/getMemberGroups';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var groupGetMemberGroupsParametersValue = {};
    requestDoc = groupGetMemberGroupsParametersValue;
    
    groupGetMemberGroupsParametersValue['securityEnabledOnly'] = parameters.securityEnabledOnly;
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { objectIds: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              result.objectIds.push(valueValue);
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets list of groups for the current tenant.
   * 
   * @param {string} [mail] Email to filter results.
   * 
   * @param {string} [displayNameStartsWith] Display name to filter results.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.list = function(mail, displayNameStartsWith, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/groups';
    var queryParameters = [];
    var odataFilter = [];
    if (mail !== null && mail !== undefined) {
      odataFilter.push('mail eq \'' + encodeURIComponent(mail) + '\'');
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    var odataFilter2 = [];
    if (displayNameStartsWith !== null && displayNameStartsWith !== undefined) {
      odataFilter2.push('startswith(displayName,\'' + encodeURIComponent(displayNameStartsWith) + '\')');
    }
    if (odataFilter2.length > 0) {
      queryParameters.push('$filter=' + odataFilter2.join(null));
    }
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { groups: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var groupInstance = {};
              result.groups.push(groupInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                groupInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                groupInstance.objectType = objectTypeInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                groupInstance.displayName = displayNameInstance;
              }
              
              var securityEnabledValue = valueValue['securityEnabled'];
              if (securityEnabledValue !== null && securityEnabledValue !== undefined) {
                var securityEnabledInstance = securityEnabledValue;
                groupInstance.securityEnabled = securityEnabledInstance;
              }
              
              var mailValue = valueValue['mail'];
              if (mailValue !== null && mailValue !== undefined) {
                var mailInstance = mailValue;
                groupInstance.mail = mailInstance;
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets list of groups for the current tenant.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * List operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.listNext = function(nextLink, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (nextLink === null || nextLink === undefined) {
      return callback(new Error('nextLink cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/';
    url2 = url2 + nextLink;
    url2 = url2 + '&api-version=1.42-previewInternal';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { groups: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var groupInstance = {};
              result.groups.push(groupInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                groupInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                groupInstance.objectType = objectTypeInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                groupInstance.displayName = displayNameInstance;
              }
              
              var securityEnabledValue = valueValue['securityEnabled'];
              if (securityEnabledValue !== null && securityEnabledValue !== undefined) {
                var securityEnabledInstance = securityEnabledValue;
                groupInstance.securityEnabled = securityEnabledInstance;
              }
              
              var mailValue = valueValue['mail'];
              if (mailValue !== null && mailValue !== undefined) {
                var mailInstance = mailValue;
                groupInstance.mail = mailInstance;
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Remove a memeber from a group  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn151607.aspx for more
   * information)
   * 
   * @param {string} groupObjectId Group object id
   * 
   * @param {string} memberObjectId Member Object id
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  GroupOperations.prototype.removeMember = function(groupObjectId, memberObjectId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (groupObjectId === null || groupObjectId === undefined) {
      return callback(new Error('groupObjectId cannot be null.'));
    }
    if (memberObjectId === null || memberObjectId === undefined) {
      return callback(new Error('memberObjectId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/groups/';
    url2 = url2 + groupObjectId;
    url2 = url2 + '/$links/members/';
    url2 = url2 + memberObjectId;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  return GroupOperations;
})();

var ObjectOperations = ( /** @lends ObjectOperations */ function() {
  /**
   * @class
   * Operations for working with Objects in Azure AD Graph API.  (see
   * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more
   * information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [GraphRbacManagementClient] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient}.
   * See [objects] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient#objects}.
   * Initializes a new instance of the ObjectOperations class.
   * @constructor
   * 
   * @param {GraphRbacManagementClient} client Reference to the service client.
   */
  function ObjectOperations(client) {
    this.client = client;
  }
  
  /**
   * Gets the details for current logged in user
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ObjectOperations.prototype.getCurrentUser = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/me';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var aADObjectInstance = { servicePrincipalNames: [] };
          result.aADObject = aADObjectInstance;
          
          var objectIdValue = responseDoc['objectId'];
          if (objectIdValue !== null && objectIdValue !== undefined) {
            var objectIdInstance = objectIdValue;
            aADObjectInstance.objectId = objectIdInstance;
          }
          
          var objectTypeValue = responseDoc['objectType'];
          if (objectTypeValue !== null && objectTypeValue !== undefined) {
            var objectTypeInstance = objectTypeValue;
            aADObjectInstance.objectType = objectTypeInstance;
          }
          
          var displayNameValue = responseDoc['displayName'];
          if (displayNameValue !== null && displayNameValue !== undefined) {
            var displayNameInstance = displayNameValue;
            aADObjectInstance.displayName = displayNameInstance;
          }
          
          var userPrincipalNameValue = responseDoc['userPrincipalName'];
          if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {
            var userPrincipalNameInstance = userPrincipalNameValue;
            aADObjectInstance.userPrincipalName = userPrincipalNameInstance;
          }
          
          var mailValue = responseDoc['mail'];
          if (mailValue !== null && mailValue !== undefined) {
            var mailInstance = mailValue;
            aADObjectInstance.mail = mailInstance;
          }
          
          var mailEnabledValue = responseDoc['mailEnabled'];
          if (mailEnabledValue !== null && mailEnabledValue !== undefined) {
            var mailEnabledInstance = mailEnabledValue;
            aADObjectInstance.mailEnabled = mailEnabledInstance;
          }
          
          var securityEnabledValue = responseDoc['securityEnabled'];
          if (securityEnabledValue !== null && securityEnabledValue !== undefined) {
            var securityEnabledInstance = securityEnabledValue;
            aADObjectInstance.securityEnabled = securityEnabledInstance;
          }
          
          var signInNameValue = responseDoc['signInName'];
          if (signInNameValue !== null && signInNameValue !== undefined) {
            var signInNameInstance = signInNameValue;
            aADObjectInstance.signInName = signInNameInstance;
          }
          
          var servicePrincipalNamesArray = responseDoc['servicePrincipalNames'];
          if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < servicePrincipalNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex1];
              aADObjectInstance.servicePrincipalNames.push(servicePrincipalNamesValue);
            }
          }
          
          var userTypeValue = responseDoc['userType'];
          if (userTypeValue !== null && userTypeValue !== undefined) {
            var userTypeInstance = userTypeValue;
            aADObjectInstance.userType = userTypeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets AD group membership by provided AD object Ids
   * 
   * @param {GetObjectsParameters} parameters Objects filtering parameters.
   * 
   * @param {array} [parameters.ids] Requested object Ids
   * 
   * @param {array} [parameters.types] Requested object types
   * 
   * @param {boolean} parameters.includeDirectoryObjectReferences If true, also
   * searches for object ids in the partner tenant
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ObjectOperations.prototype.getObjectsByObjectIds = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.includeDirectoryObjectReferences === null || parameters.includeDirectoryObjectReferences === undefined) {
      return callback(new Error('parameters.includeDirectoryObjectReferences cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/getObjectsByObjectIds';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var getObjectsParametersValue = {};
    requestDoc = getObjectsParametersValue;
    
    if (parameters.ids !== null && parameters.ids !== undefined) {
      var objectIdsArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.ids.length; loweredIndex1 = loweredIndex1 + 1) {
        var objectIdsItem = parameters.ids[loweredIndex1];
        objectIdsArray.push(objectIdsItem);
      }
      getObjectsParametersValue['objectIds'] = objectIdsArray;
    }
    
    if (parameters.types !== null && parameters.types !== undefined) {
      var typesArray = [];
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.types.length; loweredIndex2 = loweredIndex2 + 1) {
        var typesItem = parameters.types[loweredIndex2];
        typesArray.push(typesItem);
      }
      getObjectsParametersValue['types'] = typesArray;
    }
    
    getObjectsParametersValue['includeDirectoryObjectReferences'] = parameters.includeDirectoryObjectReferences;
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { aADObject: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex3 = 0; loweredIndex3 < valueArray.length; loweredIndex3 = loweredIndex3 + 1) {
              var valueValue = valueArray[loweredIndex3];
              var aADObjectInstance = { servicePrincipalNames: [] };
              result.aADObject.push(aADObjectInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                aADObjectInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                aADObjectInstance.objectType = objectTypeInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                aADObjectInstance.displayName = displayNameInstance;
              }
              
              var userPrincipalNameValue = valueValue['userPrincipalName'];
              if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {
                var userPrincipalNameInstance = userPrincipalNameValue;
                aADObjectInstance.userPrincipalName = userPrincipalNameInstance;
              }
              
              var mailValue = valueValue['mail'];
              if (mailValue !== null && mailValue !== undefined) {
                var mailInstance = mailValue;
                aADObjectInstance.mail = mailInstance;
              }
              
              var mailEnabledValue = valueValue['mailEnabled'];
              if (mailEnabledValue !== null && mailEnabledValue !== undefined) {
                var mailEnabledInstance = mailEnabledValue;
                aADObjectInstance.mailEnabled = mailEnabledInstance;
              }
              
              var securityEnabledValue = valueValue['securityEnabled'];
              if (securityEnabledValue !== null && securityEnabledValue !== undefined) {
                var securityEnabledInstance = securityEnabledValue;
                aADObjectInstance.securityEnabled = securityEnabledInstance;
              }
              
              var signInNameValue = valueValue['signInName'];
              if (signInNameValue !== null && signInNameValue !== undefined) {
                var signInNameInstance = signInNameValue;
                aADObjectInstance.signInName = signInNameInstance;
              }
              
              var servicePrincipalNamesArray = valueValue['servicePrincipalNames'];
              if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {
                for (var loweredIndex4 = 0; loweredIndex4 < servicePrincipalNamesArray.length; loweredIndex4 = loweredIndex4 + 1) {
                  var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex4];
                  aADObjectInstance.servicePrincipalNames.push(servicePrincipalNamesValue);
                }
              }
              
              var userTypeValue = valueValue['userType'];
              if (userTypeValue !== null && userTypeValue !== undefined) {
                var userTypeInstance = userTypeValue;
                aADObjectInstance.userType = userTypeInstance;
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  return ObjectOperations;
})();

var ServicePrincipalOperations = ( /** @lends ServicePrincipalOperations */ function() {
  /**
   * @class
   * Operations for working with service principal in Azure Active Directory
   * Graph API.  (see
   * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more
   * information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [GraphRbacManagementClient] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient}.
   * See [servicePrincipal] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient#servicePrincipal}.
   * Initializes a new instance of the ServicePrincipalOperations class.
   * @constructor
   * 
   * @param {GraphRbacManagementClient} client Reference to the service client.
   */
  function ServicePrincipalOperations(client) {
    this.client = client;
  }
  
  /**
   * Creates a service principal in the  directory.
   * 
   * @param {ServicePrincipalCreateParameters} parameters Parameters to create
   * a service principal.
   * 
   * @param {string} parameters.appId Gets or sets application Id
   * 
   * @param {boolean} parameters.accountEnabled Specifies if the account is
   * enabled
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServicePrincipalOperations.prototype.create = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.accountEnabled === null || parameters.accountEnabled === undefined) {
      return callback(new Error('parameters.accountEnabled cannot be null.'));
    }
    if (parameters.appId === null || parameters.appId === undefined) {
      return callback(new Error('parameters.appId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/servicePrincipals';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var servicePrincipalCreateParametersValue = {};
    requestDoc = servicePrincipalCreateParametersValue;
    
    servicePrincipalCreateParametersValue['appId'] = parameters.appId;
    
    servicePrincipalCreateParametersValue['accountEnabled'] = parameters.accountEnabled;
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 201) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var servicePrincipalInstance = { servicePrincipalNames: [] };
          result.servicePrincipal = servicePrincipalInstance;
          
          var objectIdValue = responseDoc['objectId'];
          if (objectIdValue !== null && objectIdValue !== undefined) {
            var objectIdInstance = objectIdValue;
            servicePrincipalInstance.objectId = objectIdInstance;
          }
          
          var objectTypeValue = responseDoc['objectType'];
          if (objectTypeValue !== null && objectTypeValue !== undefined) {
            var objectTypeInstance = objectTypeValue;
            servicePrincipalInstance.objectType = objectTypeInstance;
          }
          
          var displayNameValue = responseDoc['displayName'];
          if (displayNameValue !== null && displayNameValue !== undefined) {
            var displayNameInstance = displayNameValue;
            servicePrincipalInstance.displayName = displayNameInstance;
          }
          
          var appIdValue = responseDoc['appId'];
          if (appIdValue !== null && appIdValue !== undefined) {
            var appIdInstance = appIdValue;
            servicePrincipalInstance.appId = appIdInstance;
          }
          
          var servicePrincipalNamesArray = responseDoc['servicePrincipalNames'];
          if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < servicePrincipalNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex1];
              servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Deletes service principal from the directory.
   * 
   * @param {string} objectId Object id to delete service principal information.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServicePrincipalOperations.prototype.deleteMethod = function(objectId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (objectId === null || objectId === undefined) {
      return callback(new Error('objectId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/servicePrincipals/';
    url2 = url2 + objectId;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets service principal information from the directory.
   * 
   * @param {string} objectId Object id to get service principal information.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServicePrincipalOperations.prototype.get = function(objectId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (objectId === null || objectId === undefined) {
      return callback(new Error('objectId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/servicePrincipals/';
    url2 = url2 + objectId;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var servicePrincipalInstance = { servicePrincipalNames: [] };
          result.servicePrincipal = servicePrincipalInstance;
          
          var objectIdValue = responseDoc['objectId'];
          if (objectIdValue !== null && objectIdValue !== undefined) {
            var objectIdInstance = objectIdValue;
            servicePrincipalInstance.objectId = objectIdInstance;
          }
          
          var objectTypeValue = responseDoc['objectType'];
          if (objectTypeValue !== null && objectTypeValue !== undefined) {
            var objectTypeInstance = objectTypeValue;
            servicePrincipalInstance.objectType = objectTypeInstance;
          }
          
          var displayNameValue = responseDoc['displayName'];
          if (displayNameValue !== null && displayNameValue !== undefined) {
            var displayNameInstance = displayNameValue;
            servicePrincipalInstance.displayName = displayNameInstance;
          }
          
          var appIdValue = responseDoc['appId'];
          if (appIdValue !== null && appIdValue !== undefined) {
            var appIdInstance = appIdValue;
            servicePrincipalInstance.appId = appIdInstance;
          }
          
          var servicePrincipalNamesArray = responseDoc['servicePrincipalNames'];
          if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < servicePrincipalNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex1];
              servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets service principal information from the directory.
   * 
   * @param {string} servicePrincipalName filter based on service principal name
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServicePrincipalOperations.prototype.getByServicePrincipalName = function(servicePrincipalName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (servicePrincipalName === null || servicePrincipalName === undefined) {
      return callback(new Error('servicePrincipalName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/servicePrincipals';
    var queryParameters = [];
    var odataFilter = [];
    odataFilter.push('servicePrincipalNames/any(c:c eq \'' + encodeURIComponent(servicePrincipalName) + '\')');
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { servicePrincipals: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var servicePrincipalInstance = { servicePrincipalNames: [] };
              result.servicePrincipals.push(servicePrincipalInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                servicePrincipalInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                servicePrincipalInstance.objectType = objectTypeInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                servicePrincipalInstance.displayName = displayNameInstance;
              }
              
              var appIdValue = valueValue['appId'];
              if (appIdValue !== null && appIdValue !== undefined) {
                var appIdInstance = appIdValue;
                servicePrincipalInstance.appId = appIdInstance;
              }
              
              var servicePrincipalNamesArray = valueValue['servicePrincipalNames'];
              if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < servicePrincipalNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex2];
                  servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);
                }
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets list of service principals from the current tenant.
   * 
   * @param {string} [displayNameStartsWith] Display name to filter results.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServicePrincipalOperations.prototype.list = function(displayNameStartsWith, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/servicePrincipals';
    var queryParameters = [];
    var odataFilter = [];
    if (displayNameStartsWith !== null && displayNameStartsWith !== undefined) {
      odataFilter.push('startswith(displayName,\'' + encodeURIComponent(displayNameStartsWith) + '\')');
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { servicePrincipals: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var servicePrincipalInstance = { servicePrincipalNames: [] };
              result.servicePrincipals.push(servicePrincipalInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                servicePrincipalInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                servicePrincipalInstance.objectType = objectTypeInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                servicePrincipalInstance.displayName = displayNameInstance;
              }
              
              var appIdValue = valueValue['appId'];
              if (appIdValue !== null && appIdValue !== undefined) {
                var appIdInstance = appIdValue;
                servicePrincipalInstance.appId = appIdInstance;
              }
              
              var servicePrincipalNamesArray = valueValue['servicePrincipalNames'];
              if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < servicePrincipalNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex2];
                  servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);
                }
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets list of service principals for the current tenant.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * List operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServicePrincipalOperations.prototype.listNext = function(nextLink, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (nextLink === null || nextLink === undefined) {
      return callback(new Error('nextLink cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/';
    url2 = url2 + nextLink;
    url2 = url2 + '&api-version=1.42-previewInternal';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { servicePrincipals: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var servicePrincipalInstance = { servicePrincipalNames: [] };
              result.servicePrincipals.push(servicePrincipalInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                servicePrincipalInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                servicePrincipalInstance.objectType = objectTypeInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                servicePrincipalInstance.displayName = displayNameInstance;
              }
              
              var appIdValue = valueValue['appId'];
              if (appIdValue !== null && appIdValue !== undefined) {
                var appIdInstance = appIdValue;
                servicePrincipalInstance.appId = appIdInstance;
              }
              
              var servicePrincipalNamesArray = valueValue['servicePrincipalNames'];
              if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < servicePrincipalNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex2];
                  servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);
                }
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  return ServicePrincipalOperations;
})();

var UserOperations = ( /** @lends UserOperations */ function() {
  /**
   * @class
   * Operations for working with Users in Azure Active Directory Graph API.
   * (see http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [GraphRbacManagementClient] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient}.
   * See [user] {@link
   * GraphRbacManagementClient~GraphRbacManagementClient#user}.
   * Initializes a new instance of the UserOperations class.
   * @constructor
   * 
   * @param {GraphRbacManagementClient} client Reference to the service client.
   */
  function UserOperations(client) {
    this.client = client;
  }
  
  /**
   * Create a new user.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn130117.aspx for more
   * information)
   * 
   * @param {UserCreateParameters} parameters Parameters to create a user.
   * 
   * @param {string} parameters.userPrincipalName User Principal Name
   * 
   * @param {boolean} parameters.accountEnabled Enable the account
   * 
   * @param {string} parameters.displayName User display name
   * 
   * @param {string} parameters.mailNickname Mail nick name
   * 
   * @param {PasswordProfile} parameters.passwordProfileSettings Password
   * Profile
   * 
   * @param {string} parameters.passwordProfileSettings.password Password
   * 
   * @param {boolean}
   * [parameters.passwordProfileSettings.forceChangePasswordNextLogin] Force
   * change password on next login
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  UserOperations.prototype.create = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.accountEnabled === null || parameters.accountEnabled === undefined) {
      return callback(new Error('parameters.accountEnabled cannot be null.'));
    }
    if (parameters.displayName === null || parameters.displayName === undefined) {
      return callback(new Error('parameters.displayName cannot be null.'));
    }
    if (parameters.mailNickname === null || parameters.mailNickname === undefined) {
      return callback(new Error('parameters.mailNickname cannot be null.'));
    }
    if (parameters.passwordProfileSettings === null || parameters.passwordProfileSettings === undefined) {
      return callback(new Error('parameters.passwordProfileSettings cannot be null.'));
    }
    if (parameters.passwordProfileSettings.password === null || parameters.passwordProfileSettings.password === undefined) {
      return callback(new Error('parameters.passwordProfileSettings. cannot be null.'));
    }
    if (parameters.userPrincipalName === null || parameters.userPrincipalName === undefined) {
      return callback(new Error('parameters.userPrincipalName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/users';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var userCreateParametersValue = {};
    requestDoc = userCreateParametersValue;
    
    userCreateParametersValue['userPrincipalName'] = parameters.userPrincipalName;
    
    userCreateParametersValue['accountEnabled'] = parameters.accountEnabled;
    
    userCreateParametersValue['displayName'] = parameters.displayName;
    
    userCreateParametersValue['mailNickname'] = parameters.mailNickname;
    
    var passwordProfileValue = {};
    userCreateParametersValue['passwordProfile'] = passwordProfileValue;
    
    passwordProfileValue['password'] = parameters.passwordProfileSettings.password;
    
    if (parameters.passwordProfileSettings.forceChangePasswordNextLogin !== null && parameters.passwordProfileSettings.forceChangePasswordNextLogin !== undefined) {
      passwordProfileValue['forceChangePasswordNextLogin'] = parameters.passwordProfileSettings.forceChangePasswordNextLogin;
    }
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 201) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var userInstance = {};
          result.user = userInstance;
          
          var objectIdValue = responseDoc['objectId'];
          if (objectIdValue !== null && objectIdValue !== undefined) {
            var objectIdInstance = objectIdValue;
            userInstance.objectId = objectIdInstance;
          }
          
          var objectTypeValue = responseDoc['objectType'];
          if (objectTypeValue !== null && objectTypeValue !== undefined) {
            var objectTypeInstance = objectTypeValue;
            userInstance.objectType = objectTypeInstance;
          }
          
          var userPrincipalNameValue = responseDoc['userPrincipalName'];
          if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {
            var userPrincipalNameInstance = userPrincipalNameValue;
            userInstance.userPrincipalName = userPrincipalNameInstance;
          }
          
          var displayNameValue = responseDoc['displayName'];
          if (displayNameValue !== null && displayNameValue !== undefined) {
            var displayNameInstance = displayNameValue;
            userInstance.displayName = displayNameInstance;
          }
          
          var signInNameValue = responseDoc['signInName'];
          if (signInNameValue !== null && signInNameValue !== undefined) {
            var signInNameInstance = signInNameValue;
            userInstance.signInName = signInNameInstance;
          }
          
          var mailValue = responseDoc['mail'];
          if (mailValue !== null && mailValue !== undefined) {
            var mailInstance = mailValue;
            userInstance.mail = mailInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Delete a user.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx for more
   * information)
   * 
   * @param {string} user user object id or user principal name
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  UserOperations.prototype.deleteMethod = function(user, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (user === null || user === undefined) {
      return callback(new Error('user cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/users/';
    url2 = url2 + user;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets user information from the directory.  (see
   * http://msdn.microsoft.com/en-us/library/azure/dn151678.aspx for more
   * information)
   * 
   * @param {string} upnOrObjectId User object Id or user principal name to get
   * user information.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  UserOperations.prototype.get = function(upnOrObjectId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (upnOrObjectId === null || upnOrObjectId === undefined) {
      return callback(new Error('upnOrObjectId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/users/';
    url2 = url2 + upnOrObjectId;
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var userInstance = {};
          result.user = userInstance;
          
          var objectIdValue = responseDoc['objectId'];
          if (objectIdValue !== null && objectIdValue !== undefined) {
            var objectIdInstance = objectIdValue;
            userInstance.objectId = objectIdInstance;
          }
          
          var objectTypeValue = responseDoc['objectType'];
          if (objectTypeValue !== null && objectTypeValue !== undefined) {
            var objectTypeInstance = objectTypeValue;
            userInstance.objectType = objectTypeInstance;
          }
          
          var userPrincipalNameValue = responseDoc['userPrincipalName'];
          if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {
            var userPrincipalNameInstance = userPrincipalNameValue;
            userInstance.userPrincipalName = userPrincipalNameInstance;
          }
          
          var displayNameValue = responseDoc['displayName'];
          if (displayNameValue !== null && displayNameValue !== undefined) {
            var displayNameInstance = displayNameValue;
            userInstance.displayName = displayNameInstance;
          }
          
          var signInNameValue = responseDoc['signInName'];
          if (signInNameValue !== null && signInNameValue !== undefined) {
            var signInNameInstance = signInNameValue;
            userInstance.signInName = signInNameInstance;
          }
          
          var mailValue = responseDoc['mail'];
          if (mailValue !== null && mailValue !== undefined) {
            var mailInstance = mailValue;
            userInstance.mail = mailInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets user information from the directory.
   * 
   * @param {string} signInName filter based on sign in name
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  UserOperations.prototype.getBySignInName = function(signInName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (signInName === null || signInName === undefined) {
      return callback(new Error('signInName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/users';
    var queryParameters = [];
    var odataFilter = [];
    odataFilter.push('signInName eq \'' + encodeURIComponent(signInName) + '\'');
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { users: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var userInstance = {};
              result.users.push(userInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                userInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                userInstance.objectType = objectTypeInstance;
              }
              
              var userPrincipalNameValue = valueValue['userPrincipalName'];
              if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {
                var userPrincipalNameInstance = userPrincipalNameValue;
                userInstance.userPrincipalName = userPrincipalNameInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                userInstance.displayName = displayNameInstance;
              }
              
              var signInNameValue = valueValue['signInName'];
              if (signInNameValue !== null && signInNameValue !== undefined) {
                var signInNameInstance = signInNameValue;
                userInstance.signInName = signInNameInstance;
              }
              
              var mailValue = valueValue['mail'];
              if (mailValue !== null && mailValue !== undefined) {
                var mailInstance = mailValue;
                userInstance.mail = mailInstance;
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a collection that contains the Object IDs of the groups of which the
   * user is a member.
   * 
   * @param {UserGetMemberGroupsParameters} parameters User filtering
   * parameters.
   * 
   * @param {string} parameters.objectId User object Id
   * 
   * @param {boolean} parameters.securityEnabledOnly If true only membership in
   * security enabled groups should be checked. Otherwise membership in all
   * groups should be checked
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  UserOperations.prototype.getMemberGroups = function(parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.objectId === null || parameters.objectId === undefined) {
      return callback(new Error('parameters.objectId cannot be null.'));
    }
    if (parameters.securityEnabledOnly === null || parameters.securityEnabledOnly === undefined) {
      return callback(new Error('parameters.securityEnabledOnly cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/users/';
    url2 = url2 + parameters.objectId;
    url2 = url2 + '/getMemberGroups';
    var queryParameters = [];
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var userGetMemberGroupsParametersValue = {};
    requestDoc = userGetMemberGroupsParametersValue;
    
    userGetMemberGroupsParametersValue['securityEnabledOnly'] = parameters.securityEnabledOnly;
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { objectIds: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              result.objectIds.push(valueValue);
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets list of users for the current tenant.
   * 
   * @param {string} [mail] Email to filter results.
   * 
   * @param {string} [displayNameStartsWith] Display name to filter results.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  UserOperations.prototype.list = function(mail, displayNameStartsWith, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/users';
    var queryParameters = [];
    var odataFilter = [];
    if (mail !== null && mail !== undefined) {
      odataFilter.push('mail eq \'' + encodeURIComponent(mail) + '\'');
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    var odataFilter2 = [];
    if (displayNameStartsWith !== null && displayNameStartsWith !== undefined) {
      odataFilter2.push('startswith(displayName,\'' + encodeURIComponent(displayNameStartsWith) + '\')');
    }
    if (odataFilter2.length > 0) {
      queryParameters.push('$filter=' + odataFilter2.join(null));
    }
    queryParameters.push('api-version=1.42-previewInternal');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { users: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var userInstance = {};
              result.users.push(userInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                userInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                userInstance.objectType = objectTypeInstance;
              }
              
              var userPrincipalNameValue = valueValue['userPrincipalName'];
              if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {
                var userPrincipalNameInstance = userPrincipalNameValue;
                userInstance.userPrincipalName = userPrincipalNameInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                userInstance.displayName = displayNameInstance;
              }
              
              var signInNameValue = valueValue['signInName'];
              if (signInNameValue !== null && signInNameValue !== undefined) {
                var signInNameInstance = signInNameValue;
                userInstance.signInName = signInNameInstance;
              }
              
              var mailValue = valueValue['mail'];
              if (mailValue !== null && mailValue !== undefined) {
                var mailInstance = mailValue;
                userInstance.mail = mailInstance;
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets list of users for the current tenant.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * List operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  UserOperations.prototype.listNext = function(nextLink, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (nextLink === null || nextLink === undefined) {
      return callback(new Error('nextLink cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(this.client.tenantID);
    url2 = url2 + '/';
    url2 = url2 + nextLink;
    url2 = url2 + '&api-version=1.42-previewInternal';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { users: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var userInstance = {};
              result.users.push(userInstance);
              
              var objectIdValue = valueValue['objectId'];
              if (objectIdValue !== null && objectIdValue !== undefined) {
                var objectIdInstance = objectIdValue;
                userInstance.objectId = objectIdInstance;
              }
              
              var objectTypeValue = valueValue['objectType'];
              if (objectTypeValue !== null && objectTypeValue !== undefined) {
                var objectTypeInstance = objectTypeValue;
                userInstance.objectType = objectTypeInstance;
              }
              
              var userPrincipalNameValue = valueValue['userPrincipalName'];
              if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {
                var userPrincipalNameInstance = userPrincipalNameValue;
                userInstance.userPrincipalName = userPrincipalNameInstance;
              }
              
              var displayNameValue = valueValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                userInstance.displayName = displayNameInstance;
              }
              
              var signInNameValue = valueValue['signInName'];
              if (signInNameValue !== null && signInNameValue !== undefined) {
                var signInNameInstance = signInNameValue;
                userInstance.signInName = signInNameInstance;
              }
              
              var mailValue = valueValue['mail'];
              if (mailValue !== null && mailValue !== undefined) {
                var mailInstance = mailValue;
                userInstance.mail = mailInstance;
              }
            }
          }
          
          var odatanextLinkValue = responseDoc['odata.nextLink'];
          if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {
            var odatanextLinkInstance = odatanextLinkValue;
            result.nextLink = odatanextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['request-id'];
      
      return callback(null, result);
    });
  };
  
  return UserOperations;
})();
