/* 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 _ = require('underscore');
var azureCommon = require('azure-common');
var Service = azureCommon.Service;
var WebResource = azureCommon.WebResource;

var AuthorizationManagementClient = ( /** @lends AuthorizationManagementClient */ function() {
  /**
   * @class
   * Initializes a new instance of the AuthorizationManagementClient class.
   * @constructor
   * 
   * @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 AuthorizationManagementClient(credentials, baseUri, filters) {
    if (credentials === null || credentials === undefined) {
      throw new Error('credentials cannot be null.');
    }
    
    AuthorizationManagementClient['super_'].call(this, credentials, filters);
    
    this.credentials = credentials;
    this.baseUri = baseUri;
    if (this.baseUri === null || this.baseUri === undefined) {
      this.baseUri = 'https://management.azure.com/';
    }
    if (this.apiVersion === null || this.apiVersion === undefined) {
      this.apiVersion = '2015-07-01';
    }
    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
     * [ClassicAdministratorOperations](-ClassicAdministratorOperations.html)
     * object.
     * @type {object}
     */
    this.classicAdministrators = new ClassicAdministratorOperations(this);
    /**
     * Provides an instance of the
     * [PermissionOperations](-PermissionOperations.html) object.
     * @type {object}
     */
    this.permissions = new PermissionOperations(this);
    /**
     * Provides an instance of the
     * [RoleAssignmentOperations](-RoleAssignmentOperations.html) object.
     * @type {object}
     */
    this.roleAssignments = new RoleAssignmentOperations(this);
    /**
     * Provides an instance of the
     * [RoleDefinitionOperations](-RoleDefinitionOperations.html) object.
     * @type {object}
     */
    this.roleDefinitions = new RoleDefinitionOperations(this);
  }
  
  util.inherits(AuthorizationManagementClient, Service);
  
  
  return AuthorizationManagementClient;
})();
exports.AuthorizationManagementClient = AuthorizationManagementClient;

var ClassicAdministratorOperations = ( /** @lends ClassicAdministratorOperations */ function() {
  /**
   * @class
   * Get classic administrator details  (see http://TBD for more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [AuthorizationManagementClient] {@link
   * AuthorizationManagementClient~AuthorizationManagementClient}.
   * See [classicAdministrators] {@link
   * AuthorizationManagementClient~AuthorizationManagementClient#classicAdministrators}.
   * Initializes a new instance of the ClassicAdministratorOperations class.
   * @constructor
   * 
   * @param {AuthorizationManagementClient} client Reference to the service
   * client.
   */
  function ClassicAdministratorOperations(client) {
    this.client = client;
  }
  
  /**
   * Gets a list of classic administrators for the subscription.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ClassicAdministratorOperations.prototype.list = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/Microsoft.Authorization/classicAdministrators';
    var queryParameters = [];
    queryParameters.push('api-version=2015-06-01');
    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 = { classicAdministrators: [] };
        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 classicAdministratorInstance = {};
              result.classicAdministrators.push(classicAdministratorInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                classicAdministratorInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                classicAdministratorInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                classicAdministratorInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                classicAdministratorInstance.properties = propertiesInstance;
                
                var emailAddressValue = propertiesValue['emailAddress'];
                if (emailAddressValue !== null && emailAddressValue !== undefined) {
                  var emailAddressInstance = emailAddressValue;
                  propertiesInstance.emailAddress = emailAddressInstance;
                }
                
                var roleValue = propertiesValue['role'];
                if (roleValue !== null && roleValue !== undefined) {
                  var roleInstance = roleValue;
                  propertiesInstance.role = roleInstance;
                }
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return ClassicAdministratorOperations;
})();

var PermissionOperations = ( /** @lends PermissionOperations */ function() {
  /**
   * @class
   * Get resource or resource group permissions  (see http://TBD for more
   * information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [AuthorizationManagementClient] {@link
   * AuthorizationManagementClient~AuthorizationManagementClient}.
   * See [permissions] {@link
   * AuthorizationManagementClient~AuthorizationManagementClient#permissions}.
   * Initializes a new instance of the PermissionOperations class.
   * @constructor
   * 
   * @param {AuthorizationManagementClient} client Reference to the service
   * client.
   */
  function PermissionOperations(client) {
    this.client = client;
  }
  
  /**
   * Gets a resource permissions.
   * 
   * @param {string} resourceGroupName The name of the resource group. The name
   * is case insensitive.
   * 
   * @param {ResourceIdentity} identity Resource
   * 
   * @param {string} identity.resourceName Gets or sets resource name.
   * 
   * @param {string} identity.resourceProviderNamespace Gets or sets namespace
   * of the resource provider.
   * 
   * @param {string} identity.resourceType Gets or sets resource type.
   * 
   * @param {string} [identity.parentResourcePath] Gets or sets parent resource
   * path (optional).
   * 
   * @param {string} [identity.resourceProviderApiVersion] Gets or sets API
   * version of the resource provider.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  PermissionOperations.prototype.listForResource = function(resourceGroupName, identity, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (identity === null || identity === undefined) {
      return callback(new Error('identity cannot be null.'));
    }
    if (identity.resourceName === null || identity.resourceName === undefined) {
      return callback(new Error('identity. cannot be null.'));
    }
    if (identity.resourceProviderNamespace === null || identity.resourceProviderNamespace === undefined) {
      return callback(new Error('identity. cannot be null.'));
    }
    if (identity.resourceType === null || identity.resourceType === undefined) {
      return callback(new Error('identity. cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourcegroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + encodeURIComponent(identity.resourceProviderNamespace);
    url2 = url2 + '/';
    if (identity.parentResourcePath !== null && identity.parentResourcePath !== undefined) {
      url2 = url2 + identity.parentResourcePath;
    }
    url2 = url2 + '/';
    url2 = url2 + identity.resourceType;
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(identity.resourceName);
    url2 = url2 + '/providers/Microsoft.Authorization/permissions';
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 = { permissions: [] };
        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 permissionInstance = { actions: [], notActions: [] };
              result.permissions.push(permissionInstance);
              
              var actionsArray = valueValue['actions'];
              if (actionsArray !== null && actionsArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < actionsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var actionsValue = actionsArray[loweredIndex2];
                  permissionInstance.actions.push(actionsValue);
                }
              }
              
              var notActionsArray = valueValue['notActions'];
              if (notActionsArray !== null && notActionsArray !== undefined) {
                for (var loweredIndex3 = 0; loweredIndex3 < notActionsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                  var notActionsValue = notActionsArray[loweredIndex3];
                  permissionInstance.notActions.push(notActionsValue);
                }
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a resource group permissions.
   * 
   * @param {string} resourceGroupName Name of the resource group to get the
   * permissions for.The name is case insensitive.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  PermissionOperations.prototype.listForResourceGroup = function(resourceGroupName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourcegroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/Microsoft.Authorization/permissions';
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 = { permissions: [] };
        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 permissionInstance = { actions: [], notActions: [] };
              result.permissions.push(permissionInstance);
              
              var actionsArray = valueValue['actions'];
              if (actionsArray !== null && actionsArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < actionsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var actionsValue = actionsArray[loweredIndex2];
                  permissionInstance.actions.push(actionsValue);
                }
              }
              
              var notActionsArray = valueValue['notActions'];
              if (notActionsArray !== null && notActionsArray !== undefined) {
                for (var loweredIndex3 = 0; loweredIndex3 < notActionsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                  var notActionsValue = notActionsArray[loweredIndex3];
                  permissionInstance.notActions.push(notActionsValue);
                }
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return PermissionOperations;
})();

var RoleAssignmentOperations = ( /** @lends RoleAssignmentOperations */ function() {
  /**
   * @class
   * TBD  (see http://TBD for more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [AuthorizationManagementClient] {@link
   * AuthorizationManagementClient~AuthorizationManagementClient}.
   * See [roleAssignments] {@link
   * AuthorizationManagementClient~AuthorizationManagementClient#roleAssignments}.
   * Initializes a new instance of the RoleAssignmentOperations class.
   * @constructor
   * 
   * @param {AuthorizationManagementClient} client Reference to the service
   * client.
   */
  function RoleAssignmentOperations(client) {
    this.client = client;
  }
  
  /**
   * Create role assignment.
   * 
   * @param {string} scope Scope.
   * 
   * @param {Guid} roleAssignmentName Role assignment name.
   * 
   * @param {RoleAssignmentCreateParameters} parameters Role assignment.
   * 
   * @param {RoleAssignmentProperties} [parameters.properties] Gets or sets
   * role assignment properties.
   * 
   * @param {string} [parameters.properties.roleDefinitionId] Gets or sets role
   * definition id.
   * 
   * @param {Guid} [parameters.properties.principalId] Gets or sets principal
   * Id.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.create = function(scope, roleAssignmentName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (scope === null || scope === undefined) {
      return callback(new Error('scope cannot be null.'));
    }
    if (roleAssignmentName === null || roleAssignmentName === undefined) {
      return callback(new Error('roleAssignmentName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + scope;
    url2 = url2 + '/providers/Microsoft.Authorization/roleAssignments/';
    url2 = url2 + encodeURIComponent(roleAssignmentName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 = 'PUT';
    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 propertiesValue = {};
    requestDoc = propertiesValue;
    
    if (parameters.properties !== null && parameters.properties !== undefined) {
      var propertiesValue2 = {};
      propertiesValue['properties'] = propertiesValue2;
      
      if (parameters.properties.roleDefinitionId !== null && parameters.properties.roleDefinitionId !== undefined) {
        propertiesValue2['roleDefinitionId'] = parameters.properties.roleDefinitionId;
      }
      
      if (parameters.properties.principalId !== null && parameters.properties.principalId !== undefined) {
        propertiesValue2['principalId'] = parameters.properties.principalId;
      }
    }
    
    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 roleAssignmentInstance = {};
          result.roleAssignment = roleAssignmentInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleAssignmentInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleAssignmentInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleAssignmentInstance.type = typeInstance;
          }
          
          var propertiesValue3 = responseDoc['properties'];
          if (propertiesValue3 !== null && propertiesValue3 !== undefined) {
            var propertiesInstance = {};
            roleAssignmentInstance.properties = propertiesInstance;
            
            var scopeValue = propertiesValue3['scope'];
            if (scopeValue !== null && scopeValue !== undefined) {
              var scopeInstance = scopeValue;
              propertiesInstance.scope = scopeInstance;
            }
            
            var roleDefinitionIdValue = propertiesValue3['roleDefinitionId'];
            if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
              var roleDefinitionIdInstance = roleDefinitionIdValue;
              propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
            }
            
            var principalIdValue = propertiesValue3['principalId'];
            if (principalIdValue !== null && principalIdValue !== undefined) {
              var principalIdInstance = principalIdValue;
              propertiesInstance.principalId = principalIdInstance;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Create role assignment by Id.
   * 
   * @param {string} roleAssignmentId Role assignment Id
   * 
   * @param {RoleAssignmentCreateParameters} parameters Role assignment.
   * 
   * @param {RoleAssignmentProperties} [parameters.properties] Gets or sets
   * role assignment properties.
   * 
   * @param {string} [parameters.properties.roleDefinitionId] Gets or sets role
   * definition id.
   * 
   * @param {Guid} [parameters.properties.principalId] Gets or sets principal
   * Id.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.createById = function(roleAssignmentId, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (roleAssignmentId === null || roleAssignmentId === undefined) {
      return callback(new Error('roleAssignmentId cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + roleAssignmentId;
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 = 'PUT';
    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 propertiesValue = {};
    requestDoc = propertiesValue;
    
    if (parameters.properties !== null && parameters.properties !== undefined) {
      var propertiesValue2 = {};
      propertiesValue['properties'] = propertiesValue2;
      
      if (parameters.properties.roleDefinitionId !== null && parameters.properties.roleDefinitionId !== undefined) {
        propertiesValue2['roleDefinitionId'] = parameters.properties.roleDefinitionId;
      }
      
      if (parameters.properties.principalId !== null && parameters.properties.principalId !== undefined) {
        propertiesValue2['principalId'] = parameters.properties.principalId;
      }
    }
    
    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 roleAssignmentInstance = {};
          result.roleAssignment = roleAssignmentInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleAssignmentInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleAssignmentInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleAssignmentInstance.type = typeInstance;
          }
          
          var propertiesValue3 = responseDoc['properties'];
          if (propertiesValue3 !== null && propertiesValue3 !== undefined) {
            var propertiesInstance = {};
            roleAssignmentInstance.properties = propertiesInstance;
            
            var scopeValue = propertiesValue3['scope'];
            if (scopeValue !== null && scopeValue !== undefined) {
              var scopeInstance = scopeValue;
              propertiesInstance.scope = scopeInstance;
            }
            
            var roleDefinitionIdValue = propertiesValue3['roleDefinitionId'];
            if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
              var roleDefinitionIdInstance = roleDefinitionIdValue;
              propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
            }
            
            var principalIdValue = propertiesValue3['principalId'];
            if (principalIdValue !== null && principalIdValue !== undefined) {
              var principalIdInstance = principalIdValue;
              propertiesInstance.principalId = principalIdInstance;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Delete role assignment.
   * 
   * @param {string} scope Scope.
   * 
   * @param {Guid} roleAssignmentName Role assignment name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.deleteMethod = function(scope, roleAssignmentName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (scope === null || scope === undefined) {
      return callback(new Error('scope cannot be null.'));
    }
    if (roleAssignmentName === null || roleAssignmentName === undefined) {
      return callback(new Error('roleAssignmentName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + scope;
    url2 = url2 + '/providers/Microsoft.Authorization/roleAssignments/';
    url2 = url2 + encodeURIComponent(roleAssignmentName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 !== 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 roleAssignmentInstance = {};
          result.roleAssignment = roleAssignmentInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleAssignmentInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleAssignmentInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleAssignmentInstance.type = typeInstance;
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = {};
            roleAssignmentInstance.properties = propertiesInstance;
            
            var scopeValue = propertiesValue['scope'];
            if (scopeValue !== null && scopeValue !== undefined) {
              var scopeInstance = scopeValue;
              propertiesInstance.scope = scopeInstance;
            }
            
            var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
            if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
              var roleDefinitionIdInstance = roleDefinitionIdValue;
              propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
            }
            
            var principalIdValue = propertiesValue['principalId'];
            if (principalIdValue !== null && principalIdValue !== undefined) {
              var principalIdInstance = principalIdValue;
              propertiesInstance.principalId = principalIdInstance;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Delete role assignment.
   * 
   * @param {string} roleAssignmentId Role assignment Id
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.deleteById = function(roleAssignmentId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (roleAssignmentId === null || roleAssignmentId === undefined) {
      return callback(new Error('roleAssignmentId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + roleAssignmentId;
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 !== 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 roleAssignmentInstance = {};
          result.roleAssignment = roleAssignmentInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleAssignmentInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleAssignmentInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleAssignmentInstance.type = typeInstance;
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = {};
            roleAssignmentInstance.properties = propertiesInstance;
            
            var scopeValue = propertiesValue['scope'];
            if (scopeValue !== null && scopeValue !== undefined) {
              var scopeInstance = scopeValue;
              propertiesInstance.scope = scopeInstance;
            }
            
            var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
            if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
              var roleDefinitionIdInstance = roleDefinitionIdValue;
              propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
            }
            
            var principalIdValue = propertiesValue['principalId'];
            if (principalIdValue !== null && principalIdValue !== undefined) {
              var principalIdInstance = principalIdValue;
              propertiesInstance.principalId = principalIdInstance;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get single role assignment.
   * 
   * @param {string} scope Scope.
   * 
   * @param {Guid} roleAssignmentName Role assignment name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.get = function(scope, roleAssignmentName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (scope === null || scope === undefined) {
      return callback(new Error('scope cannot be null.'));
    }
    if (roleAssignmentName === null || roleAssignmentName === undefined) {
      return callback(new Error('roleAssignmentName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + scope;
    url2 = url2 + '/providers/Microsoft.Authorization/roleAssignments/';
    url2 = url2 + encodeURIComponent(roleAssignmentName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 roleAssignmentInstance = {};
          result.roleAssignment = roleAssignmentInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleAssignmentInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleAssignmentInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleAssignmentInstance.type = typeInstance;
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = {};
            roleAssignmentInstance.properties = propertiesInstance;
            
            var scopeValue = propertiesValue['scope'];
            if (scopeValue !== null && scopeValue !== undefined) {
              var scopeInstance = scopeValue;
              propertiesInstance.scope = scopeInstance;
            }
            
            var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
            if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
              var roleDefinitionIdInstance = roleDefinitionIdValue;
              propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
            }
            
            var principalIdValue = propertiesValue['principalId'];
            if (principalIdValue !== null && principalIdValue !== undefined) {
              var principalIdInstance = principalIdValue;
              propertiesInstance.principalId = principalIdInstance;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get single role assignment.
   * 
   * @param {string} roleAssignmentId Role assignment Id
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.getById = function(roleAssignmentId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (roleAssignmentId === null || roleAssignmentId === undefined) {
      return callback(new Error('roleAssignmentId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + roleAssignmentId;
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 roleAssignmentInstance = {};
          result.roleAssignment = roleAssignmentInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleAssignmentInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleAssignmentInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleAssignmentInstance.type = typeInstance;
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = {};
            roleAssignmentInstance.properties = propertiesInstance;
            
            var scopeValue = propertiesValue['scope'];
            if (scopeValue !== null && scopeValue !== undefined) {
              var scopeInstance = scopeValue;
              propertiesInstance.scope = scopeInstance;
            }
            
            var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
            if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
              var roleDefinitionIdInstance = roleDefinitionIdValue;
              propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
            }
            
            var principalIdValue = propertiesValue['principalId'];
            if (principalIdValue !== null && principalIdValue !== undefined) {
              var principalIdInstance = principalIdValue;
              propertiesInstance.principalId = principalIdInstance;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets role assignments of the subscription.
   * 
   * @param {ListAssignmentsFilterParameters} [parametersOrCallback] List
   * operation filters. If null will return all role assignments at, above or
   * below the subscription.
   * 
   * @param {Guid} [parametersOrCallback.principalId] Returns role assignment
   * of the specific principal.
   * 
   * @param {boolean} [parametersOrCallback.atScope] This returns all role
   * assignments at or above.
   * 
   * @param {Guid} [parametersOrCallback.assignedToPrincipalId] Returns role
   * assignments directly assigned to the principal as well as assignments to
   * the principal's groups (transitive). Currenly supported only for User
   * Principals
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.list = function(parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/providers/Microsoft.Authorization/roleAssignments';
    var queryParameters = [];
    var odataFilter = [];
    if (parameters !== null && parameters !== undefined && parameters.atScope !== null && parameters.atScope !== undefined && parameters.atScope === true) {
      odataFilter.push('atScope()');
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    var odataFilter2 = [];
    if (parameters !== null && parameters !== undefined && parameters.principalId !== null && parameters.principalId !== undefined) {
      odataFilter2.push('principalId eq \'' + encodeURIComponent(parameters.principalId) + '\'');
    }
    if (odataFilter2.length > 0) {
      queryParameters.push('$filter=' + odataFilter2.join(null));
    }
    var odataFilter3 = [];
    if (parameters !== null && parameters !== undefined && parameters.assignedToPrincipalId !== null && parameters.assignedToPrincipalId !== undefined) {
      odataFilter3.push('assignedTo(\'' + encodeURIComponent(parameters.assignedToPrincipalId) + '\')');
    }
    if (odataFilter3.length > 0) {
      queryParameters.push('$filter=' + odataFilter3.join(null));
    }
    queryParameters.push('api-version=2015-07-01');
    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
    
    // 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 = { roleAssignments: [] };
        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 roleAssignmentInstance = {};
              result.roleAssignments.push(roleAssignmentInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                roleAssignmentInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                roleAssignmentInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                roleAssignmentInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                roleAssignmentInstance.properties = propertiesInstance;
                
                var scopeValue = propertiesValue['scope'];
                if (scopeValue !== null && scopeValue !== undefined) {
                  var scopeInstance = scopeValue;
                  propertiesInstance.scope = scopeInstance;
                }
                
                var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
                if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
                  var roleDefinitionIdInstance = roleDefinitionIdValue;
                  propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
                }
                
                var principalIdValue = propertiesValue['principalId'];
                if (principalIdValue !== null && principalIdValue !== undefined) {
                  var principalIdInstance = principalIdValue;
                  propertiesInstance.principalId = principalIdInstance;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets role assignments of the resource.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {ResourceIdentity} identity Resource identity.
   * 
   * @param {string} identity.resourceName Gets or sets resource name.
   * 
   * @param {string} identity.resourceProviderNamespace Gets or sets namespace
   * of the resource provider.
   * 
   * @param {string} identity.resourceType Gets or sets resource type.
   * 
   * @param {string} [identity.parentResourcePath] Gets or sets parent resource
   * path (optional).
   * 
   * @param {string} [identity.resourceProviderApiVersion] Gets or sets API
   * version of the resource provider.
   * 
   * @param {ListAssignmentsFilterParameters} [parametersOrCallback] List
   * operation filters. If null will return all role assignments at, above or
   * below the resource.
   * 
   * @param {Guid} [parametersOrCallback.principalId] Returns role assignment
   * of the specific principal.
   * 
   * @param {boolean} [parametersOrCallback.atScope] This returns all role
   * assignments at or above.
   * 
   * @param {Guid} [parametersOrCallback.assignedToPrincipalId] Returns role
   * assignments directly assigned to the principal as well as assignments to
   * the principal's groups (transitive). Currenly supported only for User
   * Principals
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.listForResource = function(resourceGroupName, identity, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (identity === null || identity === undefined) {
      return callback(new Error('identity cannot be null.'));
    }
    if (identity.resourceName === null || identity.resourceName === undefined) {
      return callback(new Error('identity. cannot be null.'));
    }
    if (identity.resourceProviderNamespace === null || identity.resourceProviderNamespace === undefined) {
      return callback(new Error('identity. cannot be null.'));
    }
    if (identity.resourceType === null || identity.resourceType === undefined) {
      return callback(new Error('identity. cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourcegroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + encodeURIComponent(identity.resourceProviderNamespace);
    url2 = url2 + '/';
    if (identity.parentResourcePath !== null && identity.parentResourcePath !== undefined) {
      url2 = url2 + identity.parentResourcePath;
    }
    url2 = url2 + '/';
    url2 = url2 + identity.resourceType;
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(identity.resourceName);
    url2 = url2 + 'providers/Microsoft.Authorization/roleAssignments';
    var queryParameters = [];
    var odataFilter = [];
    if (parameters !== null && parameters !== undefined && parameters.atScope !== null && parameters.atScope !== undefined && parameters.atScope === true) {
      odataFilter.push('atScope()');
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    var odataFilter2 = [];
    if (parameters !== null && parameters !== undefined && parameters.principalId !== null && parameters.principalId !== undefined) {
      odataFilter2.push('principalId eq \'' + encodeURIComponent(parameters.principalId) + '\'');
    }
    if (odataFilter2.length > 0) {
      queryParameters.push('$filter=' + odataFilter2.join(null));
    }
    var odataFilter3 = [];
    if (parameters !== null && parameters !== undefined && parameters.assignedToPrincipalId !== null && parameters.assignedToPrincipalId !== undefined) {
      odataFilter3.push('assignedTo(\'' + encodeURIComponent(parameters.assignedToPrincipalId) + '\')');
    }
    if (odataFilter3.length > 0) {
      queryParameters.push('$filter=' + odataFilter3.join(null));
    }
    queryParameters.push('api-version=2015-07-01');
    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
    
    // 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 = { roleAssignments: [] };
        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 roleAssignmentInstance = {};
              result.roleAssignments.push(roleAssignmentInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                roleAssignmentInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                roleAssignmentInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                roleAssignmentInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                roleAssignmentInstance.properties = propertiesInstance;
                
                var scopeValue = propertiesValue['scope'];
                if (scopeValue !== null && scopeValue !== undefined) {
                  var scopeInstance = scopeValue;
                  propertiesInstance.scope = scopeInstance;
                }
                
                var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
                if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
                  var roleDefinitionIdInstance = roleDefinitionIdValue;
                  propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
                }
                
                var principalIdValue = propertiesValue['principalId'];
                if (principalIdValue !== null && principalIdValue !== undefined) {
                  var principalIdInstance = principalIdValue;
                  propertiesInstance.principalId = principalIdInstance;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets role assignments of the resource group.
   * 
   * @param {string} [resourceGroupName] Resource group name.
   * 
   * @param {ListAssignmentsFilterParameters} [parametersOrCallback] List
   * operation filters. If null will return all role assignments at, above or
   * below the resource group.
   * 
   * @param {Guid} [parametersOrCallback.principalId] Returns role assignment
   * of the specific principal.
   * 
   * @param {boolean} [parametersOrCallback.atScope] This returns all role
   * assignments at or above.
   * 
   * @param {Guid} [parametersOrCallback.assignedToPrincipalId] Returns role
   * assignments directly assigned to the principal as well as assignments to
   * the principal's groups (transitive). Currenly supported only for User
   * Principals
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.listForResourceGroup = function(resourceGroupName, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      url2 = url2 + encodeURIComponent(resourceGroupName);
    }
    url2 = url2 + '/providers/Microsoft.Authorization/roleAssignments';
    var queryParameters = [];
    var odataFilter = [];
    if (parameters !== null && parameters !== undefined && parameters.atScope !== null && parameters.atScope !== undefined && parameters.atScope === true) {
      odataFilter.push('atScope()');
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    var odataFilter2 = [];
    if (parameters !== null && parameters !== undefined && parameters.principalId !== null && parameters.principalId !== undefined) {
      odataFilter2.push('principalId eq \'' + encodeURIComponent(parameters.principalId) + '\'');
    }
    if (odataFilter2.length > 0) {
      queryParameters.push('$filter=' + odataFilter2.join(null));
    }
    var odataFilter3 = [];
    if (parameters !== null && parameters !== undefined && parameters.assignedToPrincipalId !== null && parameters.assignedToPrincipalId !== undefined) {
      odataFilter3.push('assignedTo(\'' + encodeURIComponent(parameters.assignedToPrincipalId) + '\')');
    }
    if (odataFilter3.length > 0) {
      queryParameters.push('$filter=' + odataFilter3.join(null));
    }
    queryParameters.push('api-version=2015-07-01');
    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
    
    // 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 = { roleAssignments: [] };
        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 roleAssignmentInstance = {};
              result.roleAssignments.push(roleAssignmentInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                roleAssignmentInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                roleAssignmentInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                roleAssignmentInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                roleAssignmentInstance.properties = propertiesInstance;
                
                var scopeValue = propertiesValue['scope'];
                if (scopeValue !== null && scopeValue !== undefined) {
                  var scopeInstance = scopeValue;
                  propertiesInstance.scope = scopeInstance;
                }
                
                var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
                if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
                  var roleDefinitionIdInstance = roleDefinitionIdValue;
                  propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
                }
                
                var principalIdValue = propertiesValue['principalId'];
                if (principalIdValue !== null && principalIdValue !== undefined) {
                  var principalIdInstance = principalIdValue;
                  propertiesInstance.principalId = principalIdInstance;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets role assignments of the resource group.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * List operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.listForResourceGroupNext = 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 + nextLink;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    
    // 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 = { roleAssignments: [] };
        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 roleAssignmentInstance = {};
              result.roleAssignments.push(roleAssignmentInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                roleAssignmentInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                roleAssignmentInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                roleAssignmentInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                roleAssignmentInstance.properties = propertiesInstance;
                
                var scopeValue = propertiesValue['scope'];
                if (scopeValue !== null && scopeValue !== undefined) {
                  var scopeInstance = scopeValue;
                  propertiesInstance.scope = scopeInstance;
                }
                
                var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
                if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
                  var roleDefinitionIdInstance = roleDefinitionIdValue;
                  propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
                }
                
                var principalIdValue = propertiesValue['principalId'];
                if (principalIdValue !== null && principalIdValue !== undefined) {
                  var principalIdInstance = principalIdValue;
                  propertiesInstance.principalId = principalIdInstance;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets role assignments of the resource.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * List operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.listForResourceNext = 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 + nextLink;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    
    // 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 = { roleAssignments: [] };
        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 roleAssignmentInstance = {};
              result.roleAssignments.push(roleAssignmentInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                roleAssignmentInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                roleAssignmentInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                roleAssignmentInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                roleAssignmentInstance.properties = propertiesInstance;
                
                var scopeValue = propertiesValue['scope'];
                if (scopeValue !== null && scopeValue !== undefined) {
                  var scopeInstance = scopeValue;
                  propertiesInstance.scope = scopeInstance;
                }
                
                var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
                if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
                  var roleDefinitionIdInstance = roleDefinitionIdValue;
                  propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
                }
                
                var principalIdValue = propertiesValue['principalId'];
                if (principalIdValue !== null && principalIdValue !== undefined) {
                  var principalIdInstance = principalIdValue;
                  propertiesInstance.principalId = principalIdInstance;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets role assignments of the scope.
   * 
   * @param {string} scope Scope.
   * 
   * @param {ListAssignmentsFilterParameters} [parametersOrCallback] List
   * operation filters. If null will return all role assignments at, above or
   * below the subscription.
   * 
   * @param {Guid} [parametersOrCallback.principalId] Returns role assignment
   * of the specific principal.
   * 
   * @param {boolean} [parametersOrCallback.atScope] This returns all role
   * assignments at or above.
   * 
   * @param {Guid} [parametersOrCallback.assignedToPrincipalId] Returns role
   * assignments directly assigned to the principal as well as assignments to
   * the principal's groups (transitive). Currenly supported only for User
   * Principals
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.listForScope = function(scope, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (scope === null || scope === undefined) {
      return callback(new Error('scope cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + scope;
    url2 = url2 + '/providers/Microsoft.Authorization/roleAssignments';
    var queryParameters = [];
    var odataFilter = [];
    if (parameters !== null && parameters !== undefined && parameters.atScope !== null && parameters.atScope !== undefined && parameters.atScope === true) {
      odataFilter.push('atScope()');
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    var odataFilter2 = [];
    if (parameters !== null && parameters !== undefined && parameters.principalId !== null && parameters.principalId !== undefined) {
      odataFilter2.push('principalId eq \'' + encodeURIComponent(parameters.principalId) + '\'');
    }
    if (odataFilter2.length > 0) {
      queryParameters.push('$filter=' + odataFilter2.join(null));
    }
    var odataFilter3 = [];
    if (parameters !== null && parameters !== undefined && parameters.assignedToPrincipalId !== null && parameters.assignedToPrincipalId !== undefined) {
      odataFilter3.push('assignedTo(\'' + encodeURIComponent(parameters.assignedToPrincipalId) + '\')');
    }
    if (odataFilter3.length > 0) {
      queryParameters.push('$filter=' + odataFilter3.join(null));
    }
    queryParameters.push('api-version=2015-07-01');
    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 = { roleAssignments: [] };
        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 roleAssignmentInstance = {};
              result.roleAssignments.push(roleAssignmentInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                roleAssignmentInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                roleAssignmentInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                roleAssignmentInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                roleAssignmentInstance.properties = propertiesInstance;
                
                var scopeValue = propertiesValue['scope'];
                if (scopeValue !== null && scopeValue !== undefined) {
                  var scopeInstance = scopeValue;
                  propertiesInstance.scope = scopeInstance;
                }
                
                var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
                if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
                  var roleDefinitionIdInstance = roleDefinitionIdValue;
                  propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
                }
                
                var principalIdValue = propertiesValue['principalId'];
                if (principalIdValue !== null && principalIdValue !== undefined) {
                  var principalIdInstance = principalIdValue;
                  propertiesInstance.principalId = principalIdInstance;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets role assignments of the scope.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * List operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.prototype.listForScopeNext = 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 + nextLink;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    
    // 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 = { roleAssignments: [] };
        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 roleAssignmentInstance = {};
              result.roleAssignments.push(roleAssignmentInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                roleAssignmentInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                roleAssignmentInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                roleAssignmentInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                roleAssignmentInstance.properties = propertiesInstance;
                
                var scopeValue = propertiesValue['scope'];
                if (scopeValue !== null && scopeValue !== undefined) {
                  var scopeInstance = scopeValue;
                  propertiesInstance.scope = scopeInstance;
                }
                
                var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
                if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
                  var roleDefinitionIdInstance = roleDefinitionIdValue;
                  propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
                }
                
                var principalIdValue = propertiesValue['principalId'];
                if (principalIdValue !== null && principalIdValue !== undefined) {
                  var principalIdInstance = principalIdValue;
                  propertiesInstance.principalId = principalIdInstance;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets role assignments of the subscription.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * List operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleAssignmentOperations.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 + nextLink;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    
    // 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 = { roleAssignments: [] };
        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 roleAssignmentInstance = {};
              result.roleAssignments.push(roleAssignmentInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                roleAssignmentInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                roleAssignmentInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                roleAssignmentInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                roleAssignmentInstance.properties = propertiesInstance;
                
                var scopeValue = propertiesValue['scope'];
                if (scopeValue !== null && scopeValue !== undefined) {
                  var scopeInstance = scopeValue;
                  propertiesInstance.scope = scopeInstance;
                }
                
                var roleDefinitionIdValue = propertiesValue['roleDefinitionId'];
                if (roleDefinitionIdValue !== null && roleDefinitionIdValue !== undefined) {
                  var roleDefinitionIdInstance = roleDefinitionIdValue;
                  propertiesInstance.roleDefinitionId = roleDefinitionIdInstance;
                }
                
                var principalIdValue = propertiesValue['principalId'];
                if (principalIdValue !== null && principalIdValue !== undefined) {
                  var principalIdInstance = principalIdValue;
                  propertiesInstance.principalId = principalIdInstance;
                }
              }
            }
          }
          
          var nextLinkValue = responseDoc['nextLink'];
          if (nextLinkValue !== null && nextLinkValue !== undefined) {
            var nextLinkInstance = nextLinkValue;
            result.nextLink = nextLinkInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return RoleAssignmentOperations;
})();

var RoleDefinitionOperations = ( /** @lends RoleDefinitionOperations */ function() {
  /**
   * @class
   * TBD  (see http://TBD for more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [AuthorizationManagementClient] {@link
   * AuthorizationManagementClient~AuthorizationManagementClient}.
   * See [roleDefinitions] {@link
   * AuthorizationManagementClient~AuthorizationManagementClient#roleDefinitions}.
   * Initializes a new instance of the RoleDefinitionOperations class.
   * @constructor
   * 
   * @param {AuthorizationManagementClient} client Reference to the service
   * client.
   */
  function RoleDefinitionOperations(client) {
    this.client = client;
  }
  
  /**
   * Creates or updates a role definition.
   * 
   * @param {Guid} roleDefinitionId Role definition id.
   * 
   * @param {string} scope Scope
   * 
   * @param {RoleDefinitionCreateOrUpdateParameters} parameters Role definition.
   * 
   * @param {RoleDefinition} [parameters.roleDefinition] Gets or sets role
   * definition properties.
   * 
   * @param {string} [parameters.roleDefinition.id] Gets or sets role
   * definition id.
   * 
   * @param {Guid} [parameters.roleDefinition.name] Gets or sets role
   * definition name.
   * 
   * @param {string} [parameters.roleDefinition.type] Gets or sets role
   * definition type.
   * 
   * @param {RoleDefinitionProperties} [parameters.roleDefinition.properties]
   * Gets or sets role definition properties.
   * 
   * @param {string} [parameters.roleDefinition.properties.roleName] Gets or
   * sets role name.
   * 
   * @param {string} [parameters.roleDefinition.properties.description] Gets or
   * sets role definition description.
   * 
   * @param {string} [parameters.roleDefinition.properties.type] Gets or sets
   * role type.
   * 
   * @param {IEnumerable} [parameters.roleDefinition.properties.permissions]
   * Gets or sets role definition permissions.
   * 
   * @param {IEnumerable}
   * [parameters.roleDefinition.properties.assignableScopes] Gets or sets role
   * definition assignable scopes.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleDefinitionOperations.prototype.createOrUpdate = function(roleDefinitionId, scope, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (roleDefinitionId === null || roleDefinitionId === undefined) {
      return callback(new Error('roleDefinitionId cannot be null.'));
    }
    if (scope === null || scope === undefined) {
      return callback(new Error('scope cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + scope;
    url2 = url2 + '/providers/Microsoft.Authorization/roleDefinitions/';
    url2 = url2 + encodeURIComponent(roleDefinitionId);
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 = 'PUT';
    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 propertiesValue = {};
    requestDoc = propertiesValue;
    
    if (parameters.roleDefinition !== null && parameters.roleDefinition !== undefined) {
      if (parameters.roleDefinition.id !== null && parameters.roleDefinition.id !== undefined) {
        propertiesValue['id'] = parameters.roleDefinition.id;
      }
      
      if (parameters.roleDefinition.name !== null && parameters.roleDefinition.name !== undefined) {
        propertiesValue['name'] = parameters.roleDefinition.name;
      }
      
      if (parameters.roleDefinition.type !== null && parameters.roleDefinition.type !== undefined) {
        propertiesValue['type'] = parameters.roleDefinition.type;
      }
      
      if (parameters.roleDefinition.properties !== null && parameters.roleDefinition.properties !== undefined) {
        var propertiesValue2 = {};
        propertiesValue['properties'] = propertiesValue2;
        
        if (parameters.roleDefinition.properties.roleName !== null && parameters.roleDefinition.properties.roleName !== undefined) {
          propertiesValue2['roleName'] = parameters.roleDefinition.properties.roleName;
        }
        
        if (parameters.roleDefinition.properties.description !== null && parameters.roleDefinition.properties.description !== undefined) {
          propertiesValue2['description'] = parameters.roleDefinition.properties.description;
        }
        
        if (parameters.roleDefinition.properties.type !== null && parameters.roleDefinition.properties.type !== undefined) {
          propertiesValue2['type'] = parameters.roleDefinition.properties.type;
        }
        
        if (parameters.roleDefinition.properties.permissions !== null && parameters.roleDefinition.properties.permissions !== undefined) {
          var permissionsArray = [];
          for (var loweredIndex1 = 0; loweredIndex1 < parameters.roleDefinition.properties.permissions.length; loweredIndex1 = loweredIndex1 + 1) {
            var permissionsItem = parameters.roleDefinition.properties.permissions[loweredIndex1];
            var permissionValue = {};
            permissionsArray.push(permissionValue);
            
            if (permissionsItem.actions !== null && permissionsItem.actions !== undefined) {
              var actionsArray = [];
              for (var loweredIndex2 = 0; loweredIndex2 < permissionsItem.actions.length; loweredIndex2 = loweredIndex2 + 1) {
                var actionsItem = permissionsItem.actions[loweredIndex2];
                actionsArray.push(actionsItem);
              }
              permissionValue['actions'] = actionsArray;
            }
            
            if (permissionsItem.notActions !== null && permissionsItem.notActions !== undefined) {
              var notActionsArray = [];
              for (var loweredIndex3 = 0; loweredIndex3 < permissionsItem.notActions.length; loweredIndex3 = loweredIndex3 + 1) {
                var notActionsItem = permissionsItem.notActions[loweredIndex3];
                notActionsArray.push(notActionsItem);
              }
              permissionValue['notActions'] = notActionsArray;
            }
          }
          propertiesValue2['permissions'] = permissionsArray;
        }
        
        if (parameters.roleDefinition.properties.assignableScopes !== null && parameters.roleDefinition.properties.assignableScopes !== undefined) {
          var assignableScopesArray = [];
          for (var loweredIndex4 = 0; loweredIndex4 < parameters.roleDefinition.properties.assignableScopes.length; loweredIndex4 = loweredIndex4 + 1) {
            var assignableScopesItem = parameters.roleDefinition.properties.assignableScopes[loweredIndex4];
            assignableScopesArray.push(assignableScopesItem);
          }
          propertiesValue2['assignableScopes'] = assignableScopesArray;
        }
      }
    }
    
    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 roleDefinitionInstance = {};
          result.roleDefinition = roleDefinitionInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleDefinitionInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleDefinitionInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleDefinitionInstance.type = typeInstance;
          }
          
          var propertiesValue3 = responseDoc['properties'];
          if (propertiesValue3 !== null && propertiesValue3 !== undefined) {
            var propertiesInstance = { assignableScopes: [], permissions: [] };
            roleDefinitionInstance.properties = propertiesInstance;
            
            var roleNameValue = propertiesValue3['roleName'];
            if (roleNameValue !== null && roleNameValue !== undefined) {
              var roleNameInstance = roleNameValue;
              propertiesInstance.roleName = roleNameInstance;
            }
            
            var descriptionValue = propertiesValue3['description'];
            if (descriptionValue !== null && descriptionValue !== undefined) {
              var descriptionInstance = descriptionValue;
              propertiesInstance.description = descriptionInstance;
            }
            
            var typeValue2 = propertiesValue3['type'];
            if (typeValue2 !== null && typeValue2 !== undefined) {
              var typeInstance2 = typeValue2;
              propertiesInstance.type = typeInstance2;
            }
            
            var permissionsArray2 = propertiesValue3['permissions'];
            if (permissionsArray2 !== null && permissionsArray2 !== undefined) {
              for (var loweredIndex5 = 0; loweredIndex5 < permissionsArray2.length; loweredIndex5 = loweredIndex5 + 1) {
                var permissionsValue = permissionsArray2[loweredIndex5];
                var permissionInstance = { actions: [], notActions: [] };
                propertiesInstance.permissions.push(permissionInstance);
                
                var actionsArray2 = permissionsValue['actions'];
                if (actionsArray2 !== null && actionsArray2 !== undefined) {
                  for (var loweredIndex6 = 0; loweredIndex6 < actionsArray2.length; loweredIndex6 = loweredIndex6 + 1) {
                    var actionsValue = actionsArray2[loweredIndex6];
                    permissionInstance.actions.push(actionsValue);
                  }
                }
                
                var notActionsArray2 = permissionsValue['notActions'];
                if (notActionsArray2 !== null && notActionsArray2 !== undefined) {
                  for (var loweredIndex7 = 0; loweredIndex7 < notActionsArray2.length; loweredIndex7 = loweredIndex7 + 1) {
                    var notActionsValue = notActionsArray2[loweredIndex7];
                    permissionInstance.notActions.push(notActionsValue);
                  }
                }
              }
            }
            
            var assignableScopesArray2 = propertiesValue3['assignableScopes'];
            if (assignableScopesArray2 !== null && assignableScopesArray2 !== undefined) {
              for (var loweredIndex8 = 0; loweredIndex8 < assignableScopesArray2.length; loweredIndex8 = loweredIndex8 + 1) {
                var assignableScopesValue = assignableScopesArray2[loweredIndex8];
                propertiesInstance.assignableScopes.push(assignableScopesValue);
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Deletes the role definition.
   * 
   * @param {Guid} roleDefinitionId Role definition id.
   * 
   * @param {string} scope Scope
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleDefinitionOperations.prototype.deleteMethod = function(roleDefinitionId, scope, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (roleDefinitionId === null || roleDefinitionId === undefined) {
      return callback(new Error('roleDefinitionId cannot be null.'));
    }
    if (scope === null || scope === undefined) {
      return callback(new Error('scope cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + scope;
    url2 = url2 + '/providers/Microsoft.Authorization/roleDefinitions/';
    url2 = url2 + encodeURIComponent(roleDefinitionId);
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 !== 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 roleDefinitionInstance = {};
          result.roleDefinition = roleDefinitionInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleDefinitionInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleDefinitionInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleDefinitionInstance.type = typeInstance;
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = { assignableScopes: [], permissions: [] };
            roleDefinitionInstance.properties = propertiesInstance;
            
            var roleNameValue = propertiesValue['roleName'];
            if (roleNameValue !== null && roleNameValue !== undefined) {
              var roleNameInstance = roleNameValue;
              propertiesInstance.roleName = roleNameInstance;
            }
            
            var descriptionValue = propertiesValue['description'];
            if (descriptionValue !== null && descriptionValue !== undefined) {
              var descriptionInstance = descriptionValue;
              propertiesInstance.description = descriptionInstance;
            }
            
            var typeValue2 = propertiesValue['type'];
            if (typeValue2 !== null && typeValue2 !== undefined) {
              var typeInstance2 = typeValue2;
              propertiesInstance.type = typeInstance2;
            }
            
            var permissionsArray = propertiesValue['permissions'];
            if (permissionsArray !== null && permissionsArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < permissionsArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var permissionsValue = permissionsArray[loweredIndex1];
                var permissionInstance = { actions: [], notActions: [] };
                propertiesInstance.permissions.push(permissionInstance);
                
                var actionsArray = permissionsValue['actions'];
                if (actionsArray !== null && actionsArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < actionsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var actionsValue = actionsArray[loweredIndex2];
                    permissionInstance.actions.push(actionsValue);
                  }
                }
                
                var notActionsArray = permissionsValue['notActions'];
                if (notActionsArray !== null && notActionsArray !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < notActionsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                    var notActionsValue = notActionsArray[loweredIndex3];
                    permissionInstance.notActions.push(notActionsValue);
                  }
                }
              }
            }
            
            var assignableScopesArray = propertiesValue['assignableScopes'];
            if (assignableScopesArray !== null && assignableScopesArray !== undefined) {
              for (var loweredIndex4 = 0; loweredIndex4 < assignableScopesArray.length; loweredIndex4 = loweredIndex4 + 1) {
                var assignableScopesValue = assignableScopesArray[loweredIndex4];
                propertiesInstance.assignableScopes.push(assignableScopesValue);
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get role definition by name (GUID).
   * 
   * @param {Guid} roleDefinitionId Role definition Id
   * 
   * @param {string} scope Scope
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleDefinitionOperations.prototype.get = function(roleDefinitionId, scope, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (roleDefinitionId === null || roleDefinitionId === undefined) {
      return callback(new Error('roleDefinitionId cannot be null.'));
    }
    if (scope === null || scope === undefined) {
      return callback(new Error('scope cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + scope;
    url2 = url2 + '/providers/Microsoft.Authorization/roleDefinitions/';
    url2 = url2 + encodeURIComponent(roleDefinitionId);
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 roleDefinitionInstance = {};
          result.roleDefinition = roleDefinitionInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleDefinitionInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleDefinitionInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleDefinitionInstance.type = typeInstance;
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = { assignableScopes: [], permissions: [] };
            roleDefinitionInstance.properties = propertiesInstance;
            
            var roleNameValue = propertiesValue['roleName'];
            if (roleNameValue !== null && roleNameValue !== undefined) {
              var roleNameInstance = roleNameValue;
              propertiesInstance.roleName = roleNameInstance;
            }
            
            var descriptionValue = propertiesValue['description'];
            if (descriptionValue !== null && descriptionValue !== undefined) {
              var descriptionInstance = descriptionValue;
              propertiesInstance.description = descriptionInstance;
            }
            
            var typeValue2 = propertiesValue['type'];
            if (typeValue2 !== null && typeValue2 !== undefined) {
              var typeInstance2 = typeValue2;
              propertiesInstance.type = typeInstance2;
            }
            
            var permissionsArray = propertiesValue['permissions'];
            if (permissionsArray !== null && permissionsArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < permissionsArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var permissionsValue = permissionsArray[loweredIndex1];
                var permissionInstance = { actions: [], notActions: [] };
                propertiesInstance.permissions.push(permissionInstance);
                
                var actionsArray = permissionsValue['actions'];
                if (actionsArray !== null && actionsArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < actionsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var actionsValue = actionsArray[loweredIndex2];
                    permissionInstance.actions.push(actionsValue);
                  }
                }
                
                var notActionsArray = permissionsValue['notActions'];
                if (notActionsArray !== null && notActionsArray !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < notActionsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                    var notActionsValue = notActionsArray[loweredIndex3];
                    permissionInstance.notActions.push(notActionsValue);
                  }
                }
              }
            }
            
            var assignableScopesArray = propertiesValue['assignableScopes'];
            if (assignableScopesArray !== null && assignableScopesArray !== undefined) {
              for (var loweredIndex4 = 0; loweredIndex4 < assignableScopesArray.length; loweredIndex4 = loweredIndex4 + 1) {
                var assignableScopesValue = assignableScopesArray[loweredIndex4];
                propertiesInstance.assignableScopes.push(assignableScopesValue);
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get role definition by name (GUID).
   * 
   * @param {string} roleDefinitionId Fully qualified role definition Id
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleDefinitionOperations.prototype.getById = function(roleDefinitionId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (roleDefinitionId === null || roleDefinitionId === undefined) {
      return callback(new Error('roleDefinitionId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + roleDefinitionId;
    var queryParameters = [];
    queryParameters.push('api-version=2015-07-01');
    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 roleDefinitionInstance = {};
          result.roleDefinition = roleDefinitionInstance;
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            roleDefinitionInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            roleDefinitionInstance.name = nameInstance;
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            roleDefinitionInstance.type = typeInstance;
          }
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = { assignableScopes: [], permissions: [] };
            roleDefinitionInstance.properties = propertiesInstance;
            
            var roleNameValue = propertiesValue['roleName'];
            if (roleNameValue !== null && roleNameValue !== undefined) {
              var roleNameInstance = roleNameValue;
              propertiesInstance.roleName = roleNameInstance;
            }
            
            var descriptionValue = propertiesValue['description'];
            if (descriptionValue !== null && descriptionValue !== undefined) {
              var descriptionInstance = descriptionValue;
              propertiesInstance.description = descriptionInstance;
            }
            
            var typeValue2 = propertiesValue['type'];
            if (typeValue2 !== null && typeValue2 !== undefined) {
              var typeInstance2 = typeValue2;
              propertiesInstance.type = typeInstance2;
            }
            
            var permissionsArray = propertiesValue['permissions'];
            if (permissionsArray !== null && permissionsArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < permissionsArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var permissionsValue = permissionsArray[loweredIndex1];
                var permissionInstance = { actions: [], notActions: [] };
                propertiesInstance.permissions.push(permissionInstance);
                
                var actionsArray = permissionsValue['actions'];
                if (actionsArray !== null && actionsArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < actionsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var actionsValue = actionsArray[loweredIndex2];
                    permissionInstance.actions.push(actionsValue);
                  }
                }
                
                var notActionsArray = permissionsValue['notActions'];
                if (notActionsArray !== null && notActionsArray !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < notActionsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                    var notActionsValue = notActionsArray[loweredIndex3];
                    permissionInstance.notActions.push(notActionsValue);
                  }
                }
              }
            }
            
            var assignableScopesArray = propertiesValue['assignableScopes'];
            if (assignableScopesArray !== null && assignableScopesArray !== undefined) {
              for (var loweredIndex4 = 0; loweredIndex4 < assignableScopesArray.length; loweredIndex4 = loweredIndex4 + 1) {
                var assignableScopesValue = assignableScopesArray[loweredIndex4];
                propertiesInstance.assignableScopes.push(assignableScopesValue);
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get all role definitions that are applicable at scope and above. Use
   * atScopeAndBelow filter to search below the given scope as well
   * 
   * @param {string} scope Scope
   * 
   * @param {ListDefinitionFilterParameters} [parametersOrCallback] List role
   * definitions filters.
   * 
   * @param {string} [parametersOrCallback.roleName] Returns role definitions
   * with this name.
   * 
   * @param {boolean} [parametersOrCallback.atScopeAndBelow] If specified, also
   * returns all role definition at scope and below.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RoleDefinitionOperations.prototype.list = function(scope, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (scope === null || scope === undefined) {
      return callback(new Error('scope cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    url2 = url2 + scope;
    url2 = url2 + '/providers/Microsoft.Authorization/roleDefinitions';
    var queryParameters = [];
    var odataFilter = [];
    if (parameters !== null && parameters !== undefined && parameters.roleName !== null && parameters.roleName !== undefined) {
      odataFilter.push('roleName eq \'' + encodeURIComponent(parameters.roleName) + '\'');
    }
    if (parameters !== null && parameters !== undefined && parameters.atScopeAndBelow !== null && parameters.atScopeAndBelow !== undefined && parameters.atScopeAndBelow === true) {
      odataFilter.push('atScopeAndBelow()');
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(' and '));
    }
    queryParameters.push('api-version=2015-07-01');
    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 = { roleDefinitions: [] };
        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 roleDefinitionInstance = {};
              result.roleDefinitions.push(roleDefinitionInstance);
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                roleDefinitionInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                roleDefinitionInstance.name = nameInstance;
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                roleDefinitionInstance.type = typeInstance;
              }
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = { assignableScopes: [], permissions: [] };
                roleDefinitionInstance.properties = propertiesInstance;
                
                var roleNameValue = propertiesValue['roleName'];
                if (roleNameValue !== null && roleNameValue !== undefined) {
                  var roleNameInstance = roleNameValue;
                  propertiesInstance.roleName = roleNameInstance;
                }
                
                var descriptionValue = propertiesValue['description'];
                if (descriptionValue !== null && descriptionValue !== undefined) {
                  var descriptionInstance = descriptionValue;
                  propertiesInstance.description = descriptionInstance;
                }
                
                var typeValue2 = propertiesValue['type'];
                if (typeValue2 !== null && typeValue2 !== undefined) {
                  var typeInstance2 = typeValue2;
                  propertiesInstance.type = typeInstance2;
                }
                
                var permissionsArray = propertiesValue['permissions'];
                if (permissionsArray !== null && permissionsArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < permissionsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var permissionsValue = permissionsArray[loweredIndex2];
                    var permissionInstance = { actions: [], notActions: [] };
                    propertiesInstance.permissions.push(permissionInstance);
                    
                    var actionsArray = permissionsValue['actions'];
                    if (actionsArray !== null && actionsArray !== undefined) {
                      for (var loweredIndex3 = 0; loweredIndex3 < actionsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                        var actionsValue = actionsArray[loweredIndex3];
                        permissionInstance.actions.push(actionsValue);
                      }
                    }
                    
                    var notActionsArray = permissionsValue['notActions'];
                    if (notActionsArray !== null && notActionsArray !== undefined) {
                      for (var loweredIndex4 = 0; loweredIndex4 < notActionsArray.length; loweredIndex4 = loweredIndex4 + 1) {
                        var notActionsValue = notActionsArray[loweredIndex4];
                        permissionInstance.notActions.push(notActionsValue);
                      }
                    }
                  }
                }
                
                var assignableScopesArray = propertiesValue['assignableScopes'];
                if (assignableScopesArray !== null && assignableScopesArray !== undefined) {
                  for (var loweredIndex5 = 0; loweredIndex5 < assignableScopesArray.length; loweredIndex5 = loweredIndex5 + 1) {
                    var assignableScopesValue = assignableScopesArray[loweredIndex5];
                    propertiesInstance.assignableScopes.push(assignableScopesValue);
                  }
                }
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return RoleDefinitionOperations;
})();
