< Summary

Class:Microsoft.Azure.Graph.RBAC.UsersOperations
Assembly:Microsoft.Azure.Graph.RBAC
File(s):C:\Git\azure-sdk-for-net\sdk\graphrbac\Microsoft.Azure.Graph.RBAC\src\Generated\UsersOperations.cs
Covered lines:268
Uncovered lines:344
Coverable lines:612
Total lines:1332
Line coverage:43.7% (268 of 612)
Covered branches:152
Total branches:374
Branch coverage:40.6% (152 of 374)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
CreateWithHttpMessagesAsync()-58.24%55.36%
ListWithHttpMessagesAsync()-57.47%55.56%
GetWithHttpMessagesAsync()-70.93%63.46%
UpdateWithHttpMessagesAsync()-0%0%
DeleteWithHttpMessagesAsync()-57.14%52.08%
GetMemberGroupsWithHttpMessagesAsync()-57.89%55.17%
ListNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\graphrbac\Microsoft.Azure.Graph.RBAC\src\Generated\UsersOperations.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.Graph.RBAC
 12{
 13    using Microsoft.Rest;
 14    using Microsoft.Rest.Azure;
 15    using Microsoft.Rest.Azure.OData;
 16    using Models;
 17    using Newtonsoft.Json;
 18    using System.Collections;
 19    using System.Collections.Generic;
 20    using System.Linq;
 21    using System.Net;
 22    using System.Net.Http;
 23    using System.Threading;
 24    using System.Threading.Tasks;
 25
 26    /// <summary>
 27    /// UsersOperations operations.
 28    /// </summary>
 29    internal partial class UsersOperations : IServiceOperations<GraphRbacManagementClient>, IUsersOperations
 30    {
 31        /// <summary>
 32        /// Initializes a new instance of the UsersOperations class.
 33        /// </summary>
 34        /// <param name='client'>
 35        /// Reference to the service client.
 36        /// </param>
 37        /// <exception cref="System.ArgumentNullException">
 38        /// Thrown when a required parameter is null
 39        /// </exception>
 4640        internal UsersOperations(GraphRbacManagementClient client)
 41        {
 4642            if (client == null)
 43            {
 044                throw new System.ArgumentNullException("client");
 45            }
 4646            Client = client;
 4647        }
 48
 49        /// <summary>
 50        /// Gets a reference to the GraphRbacManagementClient
 51        /// </summary>
 44452        public GraphRbacManagementClient Client { get; private set; }
 53
 54        /// <summary>
 55        /// Create a new user.
 56        /// </summary>
 57        /// <param name='parameters'>
 58        /// Parameters to create a user.
 59        /// </param>
 60        /// <param name='customHeaders'>
 61        /// Headers that will be added to request.
 62        /// </param>
 63        /// <param name='cancellationToken'>
 64        /// The cancellation token.
 65        /// </param>
 66        /// <exception cref="GraphErrorException">
 67        /// Thrown when the operation returned an invalid status code
 68        /// </exception>
 69        /// <exception cref="SerializationException">
 70        /// Thrown when unable to deserialize the response
 71        /// </exception>
 72        /// <exception cref="ValidationException">
 73        /// Thrown when a required parameter is null
 74        /// </exception>
 75        /// <exception cref="System.ArgumentNullException">
 76        /// Thrown when a required parameter is null
 77        /// </exception>
 78        /// <return>
 79        /// A response object containing the response body and response headers.
 80        /// </return>
 81        public async Task<AzureOperationResponse<User>> CreateWithHttpMessagesAsync(UserCreateParameters parameters, Dic
 82        {
 483            if (parameters == null)
 84            {
 085                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 86            }
 487            if (parameters != null)
 88            {
 489                parameters.Validate();
 90            }
 491            if (Client.ApiVersion == null)
 92            {
 093                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 94            }
 495            if (Client.TenantID == null)
 96            {
 097                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 98            }
 99            // Tracing
 4100            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 4101            string _invocationId = null;
 4102            if (_shouldTrace)
 103            {
 0104                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0105                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0106                tracingParameters.Add("parameters", parameters);
 0107                tracingParameters.Add("cancellationToken", cancellationToken);
 0108                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
 109            }
 110            // Construct URL
 4111            var _baseUrl = Client.BaseUri.AbsoluteUri;
 4112            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/users"
 4113            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 4114            List<string> _queryParameters = new List<string>();
 4115            if (Client.ApiVersion != null)
 116            {
 4117                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 118            }
 4119            if (_queryParameters.Count > 0)
 120            {
 4121                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 122            }
 123            // Create HTTP transport objects
 4124            var _httpRequest = new HttpRequestMessage();
 4125            HttpResponseMessage _httpResponse = null;
 4126            _httpRequest.Method = new HttpMethod("POST");
 4127            _httpRequest.RequestUri = new System.Uri(_url);
 128            // Set Headers
 4129            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 130            {
 4131                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 132            }
 4133            if (Client.AcceptLanguage != null)
 134            {
 4135                if (_httpRequest.Headers.Contains("accept-language"))
 136                {
 0137                    _httpRequest.Headers.Remove("accept-language");
 138                }
 4139                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 140            }
 141
 142
 4143            if (customHeaders != null)
 144            {
 0145                foreach(var _header in customHeaders)
 146                {
 0147                    if (_httpRequest.Headers.Contains(_header.Key))
 148                    {
 0149                        _httpRequest.Headers.Remove(_header.Key);
 150                    }
 0151                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 152                }
 153            }
 154
 155            // Serialize Request
 4156            string _requestContent = null;
 4157            if(parameters != null)
 158            {
 4159                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 4160                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 4161                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 162            }
 163            // Set Credentials
 4164            if (Client.Credentials != null)
 165            {
 4166                cancellationToken.ThrowIfCancellationRequested();
 4167                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 168            }
 169            // Send Request
 4170            if (_shouldTrace)
 171            {
 0172                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 173            }
 4174            cancellationToken.ThrowIfCancellationRequested();
 4175            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4176            if (_shouldTrace)
 177            {
 0178                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 179            }
 4180            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 4181            cancellationToken.ThrowIfCancellationRequested();
 4182            string _responseContent = null;
 4183            if ((int)_statusCode != 201)
 184            {
 0185                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 186                try
 187                {
 0188                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0189                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0190                    if (_errorBody != null)
 191                    {
 0192                        ex.Body = _errorBody;
 193                    }
 0194                }
 0195                catch (JsonException)
 196                {
 197                    // Ignore the exception
 0198                }
 0199                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0200                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0201                if (_shouldTrace)
 202                {
 0203                    ServiceClientTracing.Error(_invocationId, ex);
 204                }
 0205                _httpRequest.Dispose();
 0206                if (_httpResponse != null)
 207                {
 0208                    _httpResponse.Dispose();
 209                }
 0210                throw ex;
 211            }
 212            // Create Result
 4213            var _result = new AzureOperationResponse<User>();
 4214            _result.Request = _httpRequest;
 4215            _result.Response = _httpResponse;
 4216            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 217            {
 0218                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 219            }
 220            // Deserialize Response
 4221            if ((int)_statusCode == 201)
 222            {
 4223                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 224                try
 225                {
 4226                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<User>(_responseContent, Client.D
 4227                }
 0228                catch (JsonException ex)
 229                {
 0230                    _httpRequest.Dispose();
 0231                    if (_httpResponse != null)
 232                    {
 0233                        _httpResponse.Dispose();
 234                    }
 0235                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 236                }
 237            }
 4238            if (_shouldTrace)
 239            {
 0240                ServiceClientTracing.Exit(_invocationId, _result);
 241            }
 4242            return _result;
 4243        }
 244
 245        /// <summary>
 246        /// Gets list of users for the current tenant.
 247        /// </summary>
 248        /// <param name='odataQuery'>
 249        /// OData parameters to apply to the operation.
 250        /// </param>
 251        /// <param name='customHeaders'>
 252        /// Headers that will be added to request.
 253        /// </param>
 254        /// <param name='cancellationToken'>
 255        /// The cancellation token.
 256        /// </param>
 257        /// <exception cref="GraphErrorException">
 258        /// Thrown when the operation returned an invalid status code
 259        /// </exception>
 260        /// <exception cref="SerializationException">
 261        /// Thrown when unable to deserialize the response
 262        /// </exception>
 263        /// <exception cref="ValidationException">
 264        /// Thrown when a required parameter is null
 265        /// </exception>
 266        /// <exception cref="System.ArgumentNullException">
 267        /// Thrown when a required parameter is null
 268        /// </exception>
 269        /// <return>
 270        /// A response object containing the response body and response headers.
 271        /// </return>
 272        public async Task<AzureOperationResponse<IPage<User>>> ListWithHttpMessagesAsync(ODataQuery<User> odataQuery = d
 273        {
 10274            if (Client.ApiVersion == null)
 275            {
 0276                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 277            }
 10278            if (Client.TenantID == null)
 279            {
 0280                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 281            }
 282            // Tracing
 10283            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 10284            string _invocationId = null;
 10285            if (_shouldTrace)
 286            {
 0287                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0288                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0289                tracingParameters.Add("odataQuery", odataQuery);
 0290                tracingParameters.Add("cancellationToken", cancellationToken);
 0291                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 292            }
 293            // Construct URL
 10294            var _baseUrl = Client.BaseUri.AbsoluteUri;
 10295            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/users"
 10296            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 10297            List<string> _queryParameters = new List<string>();
 10298            if (odataQuery != null)
 299            {
 2300                var _odataFilter = odataQuery.ToString();
 2301                if (!string.IsNullOrEmpty(_odataFilter))
 302                {
 2303                    _queryParameters.Add(_odataFilter);
 304                }
 305            }
 10306            if (Client.ApiVersion != null)
 307            {
 10308                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 309            }
 10310            if (_queryParameters.Count > 0)
 311            {
 10312                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 313            }
 314            // Create HTTP transport objects
 10315            var _httpRequest = new HttpRequestMessage();
 10316            HttpResponseMessage _httpResponse = null;
 10317            _httpRequest.Method = new HttpMethod("GET");
 10318            _httpRequest.RequestUri = new System.Uri(_url);
 319            // Set Headers
 10320            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 321            {
 10322                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 323            }
 10324            if (Client.AcceptLanguage != null)
 325            {
 10326                if (_httpRequest.Headers.Contains("accept-language"))
 327                {
 0328                    _httpRequest.Headers.Remove("accept-language");
 329                }
 10330                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 331            }
 332
 333
 10334            if (customHeaders != null)
 335            {
 0336                foreach(var _header in customHeaders)
 337                {
 0338                    if (_httpRequest.Headers.Contains(_header.Key))
 339                    {
 0340                        _httpRequest.Headers.Remove(_header.Key);
 341                    }
 0342                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 343                }
 344            }
 345
 346            // Serialize Request
 10347            string _requestContent = null;
 348            // Set Credentials
 10349            if (Client.Credentials != null)
 350            {
 10351                cancellationToken.ThrowIfCancellationRequested();
 10352                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 353            }
 354            // Send Request
 10355            if (_shouldTrace)
 356            {
 0357                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 358            }
 10359            cancellationToken.ThrowIfCancellationRequested();
 10360            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 10361            if (_shouldTrace)
 362            {
 0363                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 364            }
 10365            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 10366            cancellationToken.ThrowIfCancellationRequested();
 10367            string _responseContent = null;
 10368            if ((int)_statusCode != 200)
 369            {
 0370                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 371                try
 372                {
 0373                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0374                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0375                    if (_errorBody != null)
 376                    {
 0377                        ex.Body = _errorBody;
 378                    }
 0379                }
 0380                catch (JsonException)
 381                {
 382                    // Ignore the exception
 0383                }
 0384                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0385                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0386                if (_shouldTrace)
 387                {
 0388                    ServiceClientTracing.Error(_invocationId, ex);
 389                }
 0390                _httpRequest.Dispose();
 0391                if (_httpResponse != null)
 392                {
 0393                    _httpResponse.Dispose();
 394                }
 0395                throw ex;
 396            }
 397            // Create Result
 10398            var _result = new AzureOperationResponse<IPage<User>>();
 10399            _result.Request = _httpRequest;
 10400            _result.Response = _httpResponse;
 10401            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 402            {
 0403                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 404            }
 405            // Deserialize Response
 10406            if ((int)_statusCode == 200)
 407            {
 10408                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 409                try
 410                {
 10411                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<User>>(_responseContent, Cl
 10412                }
 0413                catch (JsonException ex)
 414                {
 0415                    _httpRequest.Dispose();
 0416                    if (_httpResponse != null)
 417                    {
 0418                        _httpResponse.Dispose();
 419                    }
 0420                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 421                }
 422            }
 10423            if (_shouldTrace)
 424            {
 0425                ServiceClientTracing.Exit(_invocationId, _result);
 426            }
 10427            return _result;
 10428        }
 429
 430        /// <summary>
 431        /// Gets user information from the directory.
 432        /// </summary>
 433        /// <param name='upnOrObjectId'>
 434        /// The object ID or principal name of the user for which to get information.
 435        /// </param>
 436        /// <param name='customHeaders'>
 437        /// Headers that will be added to request.
 438        /// </param>
 439        /// <param name='cancellationToken'>
 440        /// The cancellation token.
 441        /// </param>
 442        /// <exception cref="GraphErrorException">
 443        /// Thrown when the operation returned an invalid status code
 444        /// </exception>
 445        /// <exception cref="SerializationException">
 446        /// Thrown when unable to deserialize the response
 447        /// </exception>
 448        /// <exception cref="ValidationException">
 449        /// Thrown when a required parameter is null
 450        /// </exception>
 451        /// <exception cref="System.ArgumentNullException">
 452        /// Thrown when a required parameter is null
 453        /// </exception>
 454        /// <return>
 455        /// A response object containing the response body and response headers.
 456        /// </return>
 457        public async Task<AzureOperationResponse<User>> GetWithHttpMessagesAsync(string upnOrObjectId, Dictionary<string
 458        {
 4459            if (upnOrObjectId == null)
 460            {
 0461                throw new ValidationException(ValidationRules.CannotBeNull, "upnOrObjectId");
 462            }
 4463            if (Client.ApiVersion == null)
 464            {
 0465                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 466            }
 4467            if (Client.TenantID == null)
 468            {
 0469                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 470            }
 471            // Tracing
 4472            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 4473            string _invocationId = null;
 4474            if (_shouldTrace)
 475            {
 0476                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0477                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0478                tracingParameters.Add("upnOrObjectId", upnOrObjectId);
 0479                tracingParameters.Add("cancellationToken", cancellationToken);
 0480                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 481            }
 482            // Construct URL
 4483            var _baseUrl = Client.BaseUri.AbsoluteUri;
 4484            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/users/
 4485            _url = _url.Replace("{upnOrObjectId}", System.Uri.EscapeDataString(upnOrObjectId));
 4486            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 4487            List<string> _queryParameters = new List<string>();
 4488            if (Client.ApiVersion != null)
 489            {
 4490                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 491            }
 4492            if (_queryParameters.Count > 0)
 493            {
 4494                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 495            }
 496            // Create HTTP transport objects
 4497            var _httpRequest = new HttpRequestMessage();
 4498            HttpResponseMessage _httpResponse = null;
 4499            _httpRequest.Method = new HttpMethod("GET");
 4500            _httpRequest.RequestUri = new System.Uri(_url);
 501            // Set Headers
 4502            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 503            {
 4504                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 505            }
 4506            if (Client.AcceptLanguage != null)
 507            {
 4508                if (_httpRequest.Headers.Contains("accept-language"))
 509                {
 0510                    _httpRequest.Headers.Remove("accept-language");
 511                }
 4512                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 513            }
 514
 515
 4516            if (customHeaders != null)
 517            {
 0518                foreach(var _header in customHeaders)
 519                {
 0520                    if (_httpRequest.Headers.Contains(_header.Key))
 521                    {
 0522                        _httpRequest.Headers.Remove(_header.Key);
 523                    }
 0524                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 525                }
 526            }
 527
 528            // Serialize Request
 4529            string _requestContent = null;
 530            // Set Credentials
 4531            if (Client.Credentials != null)
 532            {
 4533                cancellationToken.ThrowIfCancellationRequested();
 4534                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 535            }
 536            // Send Request
 4537            if (_shouldTrace)
 538            {
 0539                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 540            }
 4541            cancellationToken.ThrowIfCancellationRequested();
 4542            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4543            if (_shouldTrace)
 544            {
 0545                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 546            }
 4547            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 4548            cancellationToken.ThrowIfCancellationRequested();
 4549            string _responseContent = null;
 4550            if ((int)_statusCode != 200)
 551            {
 2552                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 553                try
 554                {
 2555                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2556                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 2557                    if (_errorBody != null)
 558                    {
 2559                        ex.Body = _errorBody;
 560                    }
 2561                }
 0562                catch (JsonException)
 563                {
 564                    // Ignore the exception
 0565                }
 2566                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 2567                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 2568                if (_shouldTrace)
 569                {
 0570                    ServiceClientTracing.Error(_invocationId, ex);
 571                }
 2572                _httpRequest.Dispose();
 2573                if (_httpResponse != null)
 574                {
 2575                    _httpResponse.Dispose();
 576                }
 2577                throw ex;
 578            }
 579            // Create Result
 2580            var _result = new AzureOperationResponse<User>();
 2581            _result.Request = _httpRequest;
 2582            _result.Response = _httpResponse;
 2583            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 584            {
 0585                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 586            }
 587            // Deserialize Response
 2588            if ((int)_statusCode == 200)
 589            {
 2590                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 591                try
 592                {
 2593                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<User>(_responseContent, Client.D
 2594                }
 0595                catch (JsonException ex)
 596                {
 0597                    _httpRequest.Dispose();
 0598                    if (_httpResponse != null)
 599                    {
 0600                        _httpResponse.Dispose();
 601                    }
 0602                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 603                }
 604            }
 2605            if (_shouldTrace)
 606            {
 0607                ServiceClientTracing.Exit(_invocationId, _result);
 608            }
 2609            return _result;
 2610        }
 611
 612        /// <summary>
 613        /// Updates a user.
 614        /// </summary>
 615        /// <param name='upnOrObjectId'>
 616        /// The object ID or principal name of the user to update.
 617        /// </param>
 618        /// <param name='parameters'>
 619        /// Parameters to update an existing user.
 620        /// </param>
 621        /// <param name='customHeaders'>
 622        /// Headers that will be added to request.
 623        /// </param>
 624        /// <param name='cancellationToken'>
 625        /// The cancellation token.
 626        /// </param>
 627        /// <exception cref="GraphErrorException">
 628        /// Thrown when the operation returned an invalid status code
 629        /// </exception>
 630        /// <exception cref="ValidationException">
 631        /// Thrown when a required parameter is null
 632        /// </exception>
 633        /// <exception cref="System.ArgumentNullException">
 634        /// Thrown when a required parameter is null
 635        /// </exception>
 636        /// <return>
 637        /// A response object containing the response body and response headers.
 638        /// </return>
 639        public async Task<AzureOperationResponse> UpdateWithHttpMessagesAsync(string upnOrObjectId, UserUpdateParameters
 640        {
 0641            if (upnOrObjectId == null)
 642            {
 0643                throw new ValidationException(ValidationRules.CannotBeNull, "upnOrObjectId");
 644            }
 0645            if (parameters == null)
 646            {
 0647                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 648            }
 0649            if (Client.ApiVersion == null)
 650            {
 0651                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 652            }
 0653            if (Client.TenantID == null)
 654            {
 0655                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 656            }
 657            // Tracing
 0658            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0659            string _invocationId = null;
 0660            if (_shouldTrace)
 661            {
 0662                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0663                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0664                tracingParameters.Add("upnOrObjectId", upnOrObjectId);
 0665                tracingParameters.Add("parameters", parameters);
 0666                tracingParameters.Add("cancellationToken", cancellationToken);
 0667                ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
 668            }
 669            // Construct URL
 0670            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0671            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/users/
 0672            _url = _url.Replace("{upnOrObjectId}", System.Uri.EscapeDataString(upnOrObjectId));
 0673            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 0674            List<string> _queryParameters = new List<string>();
 0675            if (Client.ApiVersion != null)
 676            {
 0677                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 678            }
 0679            if (_queryParameters.Count > 0)
 680            {
 0681                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 682            }
 683            // Create HTTP transport objects
 0684            var _httpRequest = new HttpRequestMessage();
 0685            HttpResponseMessage _httpResponse = null;
 0686            _httpRequest.Method = new HttpMethod("PATCH");
 0687            _httpRequest.RequestUri = new System.Uri(_url);
 688            // Set Headers
 0689            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 690            {
 0691                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 692            }
 0693            if (Client.AcceptLanguage != null)
 694            {
 0695                if (_httpRequest.Headers.Contains("accept-language"))
 696                {
 0697                    _httpRequest.Headers.Remove("accept-language");
 698                }
 0699                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 700            }
 701
 702
 0703            if (customHeaders != null)
 704            {
 0705                foreach(var _header in customHeaders)
 706                {
 0707                    if (_httpRequest.Headers.Contains(_header.Key))
 708                    {
 0709                        _httpRequest.Headers.Remove(_header.Key);
 710                    }
 0711                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 712                }
 713            }
 714
 715            // Serialize Request
 0716            string _requestContent = null;
 0717            if(parameters != null)
 718            {
 0719                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 0720                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0721                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 722            }
 723            // Set Credentials
 0724            if (Client.Credentials != null)
 725            {
 0726                cancellationToken.ThrowIfCancellationRequested();
 0727                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 728            }
 729            // Send Request
 0730            if (_shouldTrace)
 731            {
 0732                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 733            }
 0734            cancellationToken.ThrowIfCancellationRequested();
 0735            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0736            if (_shouldTrace)
 737            {
 0738                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 739            }
 0740            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0741            cancellationToken.ThrowIfCancellationRequested();
 0742            string _responseContent = null;
 0743            if ((int)_statusCode != 204)
 744            {
 0745                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 746                try
 747                {
 0748                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0749                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0750                    if (_errorBody != null)
 751                    {
 0752                        ex.Body = _errorBody;
 753                    }
 0754                }
 0755                catch (JsonException)
 756                {
 757                    // Ignore the exception
 0758                }
 0759                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0760                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0761                if (_shouldTrace)
 762                {
 0763                    ServiceClientTracing.Error(_invocationId, ex);
 764                }
 0765                _httpRequest.Dispose();
 0766                if (_httpResponse != null)
 767                {
 0768                    _httpResponse.Dispose();
 769                }
 0770                throw ex;
 771            }
 772            // Create Result
 0773            var _result = new AzureOperationResponse();
 0774            _result.Request = _httpRequest;
 0775            _result.Response = _httpResponse;
 0776            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 777            {
 0778                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 779            }
 0780            if (_shouldTrace)
 781            {
 0782                ServiceClientTracing.Exit(_invocationId, _result);
 783            }
 0784            return _result;
 0785        }
 786
 787        /// <summary>
 788        /// Delete a user.
 789        /// </summary>
 790        /// <param name='upnOrObjectId'>
 791        /// The object ID or principal name of the user to delete.
 792        /// </param>
 793        /// <param name='customHeaders'>
 794        /// Headers that will be added to request.
 795        /// </param>
 796        /// <param name='cancellationToken'>
 797        /// The cancellation token.
 798        /// </param>
 799        /// <exception cref="GraphErrorException">
 800        /// Thrown when the operation returned an invalid status code
 801        /// </exception>
 802        /// <exception cref="ValidationException">
 803        /// Thrown when a required parameter is null
 804        /// </exception>
 805        /// <exception cref="System.ArgumentNullException">
 806        /// Thrown when a required parameter is null
 807        /// </exception>
 808        /// <return>
 809        /// A response object containing the response body and response headers.
 810        /// </return>
 811        public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string upnOrObjectId, Dictionary<string, L
 812        {
 4813            if (upnOrObjectId == null)
 814            {
 0815                throw new ValidationException(ValidationRules.CannotBeNull, "upnOrObjectId");
 816            }
 4817            if (Client.ApiVersion == null)
 818            {
 0819                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 820            }
 4821            if (Client.TenantID == null)
 822            {
 0823                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 824            }
 825            // Tracing
 4826            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 4827            string _invocationId = null;
 4828            if (_shouldTrace)
 829            {
 0830                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0831                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0832                tracingParameters.Add("upnOrObjectId", upnOrObjectId);
 0833                tracingParameters.Add("cancellationToken", cancellationToken);
 0834                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 835            }
 836            // Construct URL
 4837            var _baseUrl = Client.BaseUri.AbsoluteUri;
 4838            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/users/
 4839            _url = _url.Replace("{upnOrObjectId}", System.Uri.EscapeDataString(upnOrObjectId));
 4840            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 4841            List<string> _queryParameters = new List<string>();
 4842            if (Client.ApiVersion != null)
 843            {
 4844                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 845            }
 4846            if (_queryParameters.Count > 0)
 847            {
 4848                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 849            }
 850            // Create HTTP transport objects
 4851            var _httpRequest = new HttpRequestMessage();
 4852            HttpResponseMessage _httpResponse = null;
 4853            _httpRequest.Method = new HttpMethod("DELETE");
 4854            _httpRequest.RequestUri = new System.Uri(_url);
 855            // Set Headers
 4856            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 857            {
 4858                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 859            }
 4860            if (Client.AcceptLanguage != null)
 861            {
 4862                if (_httpRequest.Headers.Contains("accept-language"))
 863                {
 0864                    _httpRequest.Headers.Remove("accept-language");
 865                }
 4866                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 867            }
 868
 869
 4870            if (customHeaders != null)
 871            {
 0872                foreach(var _header in customHeaders)
 873                {
 0874                    if (_httpRequest.Headers.Contains(_header.Key))
 875                    {
 0876                        _httpRequest.Headers.Remove(_header.Key);
 877                    }
 0878                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 879                }
 880            }
 881
 882            // Serialize Request
 4883            string _requestContent = null;
 884            // Set Credentials
 4885            if (Client.Credentials != null)
 886            {
 4887                cancellationToken.ThrowIfCancellationRequested();
 4888                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 889            }
 890            // Send Request
 4891            if (_shouldTrace)
 892            {
 0893                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 894            }
 4895            cancellationToken.ThrowIfCancellationRequested();
 4896            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4897            if (_shouldTrace)
 898            {
 0899                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 900            }
 4901            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 4902            cancellationToken.ThrowIfCancellationRequested();
 4903            string _responseContent = null;
 4904            if ((int)_statusCode != 204)
 905            {
 0906                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 907                try
 908                {
 0909                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0910                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0911                    if (_errorBody != null)
 912                    {
 0913                        ex.Body = _errorBody;
 914                    }
 0915                }
 0916                catch (JsonException)
 917                {
 918                    // Ignore the exception
 0919                }
 0920                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0921                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0922                if (_shouldTrace)
 923                {
 0924                    ServiceClientTracing.Error(_invocationId, ex);
 925                }
 0926                _httpRequest.Dispose();
 0927                if (_httpResponse != null)
 928                {
 0929                    _httpResponse.Dispose();
 930                }
 0931                throw ex;
 932            }
 933            // Create Result
 4934            var _result = new AzureOperationResponse();
 4935            _result.Request = _httpRequest;
 4936            _result.Response = _httpResponse;
 4937            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 938            {
 0939                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 940            }
 4941            if (_shouldTrace)
 942            {
 0943                ServiceClientTracing.Exit(_invocationId, _result);
 944            }
 4945            return _result;
 4946        }
 947
 948        /// <summary>
 949        /// Gets a collection that contains the object IDs of the groups of which the
 950        /// user is a member.
 951        /// </summary>
 952        /// <param name='objectId'>
 953        /// The object ID of the user for which to get group membership.
 954        /// </param>
 955        /// <param name='parameters'>
 956        /// User filtering parameters.
 957        /// </param>
 958        /// <param name='customHeaders'>
 959        /// Headers that will be added to request.
 960        /// </param>
 961        /// <param name='cancellationToken'>
 962        /// The cancellation token.
 963        /// </param>
 964        /// <exception cref="GraphErrorException">
 965        /// Thrown when the operation returned an invalid status code
 966        /// </exception>
 967        /// <exception cref="SerializationException">
 968        /// Thrown when unable to deserialize the response
 969        /// </exception>
 970        /// <exception cref="ValidationException">
 971        /// Thrown when a required parameter is null
 972        /// </exception>
 973        /// <exception cref="System.ArgumentNullException">
 974        /// Thrown when a required parameter is null
 975        /// </exception>
 976        /// <return>
 977        /// A response object containing the response body and response headers.
 978        /// </return>
 979        public async Task<AzureOperationResponse<IEnumerable<string>>> GetMemberGroupsWithHttpMessagesAsync(string objec
 980        {
 6981            if (objectId == null)
 982            {
 0983                throw new ValidationException(ValidationRules.CannotBeNull, "objectId");
 984            }
 6985            if (parameters == null)
 986            {
 0987                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 988            }
 6989            if (parameters != null)
 990            {
 6991                parameters.Validate();
 992            }
 6993            if (Client.ApiVersion == null)
 994            {
 0995                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 996            }
 6997            if (Client.TenantID == null)
 998            {
 0999                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1000            }
 1001            // Tracing
 61002            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 61003            string _invocationId = null;
 61004            if (_shouldTrace)
 1005            {
 01006                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01007                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01008                tracingParameters.Add("objectId", objectId);
 01009                tracingParameters.Add("parameters", parameters);
 01010                tracingParameters.Add("cancellationToken", cancellationToken);
 01011                ServiceClientTracing.Enter(_invocationId, this, "GetMemberGroups", tracingParameters);
 1012            }
 1013            // Construct URL
 61014            var _baseUrl = Client.BaseUri.AbsoluteUri;
 61015            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/users/
 61016            _url = _url.Replace("{objectId}", System.Uri.EscapeDataString(objectId));
 61017            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 61018            List<string> _queryParameters = new List<string>();
 61019            if (Client.ApiVersion != null)
 1020            {
 61021                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1022            }
 61023            if (_queryParameters.Count > 0)
 1024            {
 61025                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1026            }
 1027            // Create HTTP transport objects
 61028            var _httpRequest = new HttpRequestMessage();
 61029            HttpResponseMessage _httpResponse = null;
 61030            _httpRequest.Method = new HttpMethod("POST");
 61031            _httpRequest.RequestUri = new System.Uri(_url);
 1032            // Set Headers
 61033            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1034            {
 61035                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1036            }
 61037            if (Client.AcceptLanguage != null)
 1038            {
 61039                if (_httpRequest.Headers.Contains("accept-language"))
 1040                {
 01041                    _httpRequest.Headers.Remove("accept-language");
 1042                }
 61043                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1044            }
 1045
 1046
 61047            if (customHeaders != null)
 1048            {
 01049                foreach(var _header in customHeaders)
 1050                {
 01051                    if (_httpRequest.Headers.Contains(_header.Key))
 1052                    {
 01053                        _httpRequest.Headers.Remove(_header.Key);
 1054                    }
 01055                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1056                }
 1057            }
 1058
 1059            // Serialize Request
 61060            string _requestContent = null;
 61061            if(parameters != null)
 1062            {
 61063                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 61064                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 61065                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1066            }
 1067            // Set Credentials
 61068            if (Client.Credentials != null)
 1069            {
 61070                cancellationToken.ThrowIfCancellationRequested();
 61071                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1072            }
 1073            // Send Request
 61074            if (_shouldTrace)
 1075            {
 01076                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1077            }
 61078            cancellationToken.ThrowIfCancellationRequested();
 61079            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 61080            if (_shouldTrace)
 1081            {
 01082                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1083            }
 61084            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 61085            cancellationToken.ThrowIfCancellationRequested();
 61086            string _responseContent = null;
 61087            if ((int)_statusCode != 200)
 1088            {
 01089                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1090                try
 1091                {
 01092                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01093                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01094                    if (_errorBody != null)
 1095                    {
 01096                        ex.Body = _errorBody;
 1097                    }
 01098                }
 01099                catch (JsonException)
 1100                {
 1101                    // Ignore the exception
 01102                }
 01103                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01104                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01105                if (_shouldTrace)
 1106                {
 01107                    ServiceClientTracing.Error(_invocationId, ex);
 1108                }
 01109                _httpRequest.Dispose();
 01110                if (_httpResponse != null)
 1111                {
 01112                    _httpResponse.Dispose();
 1113                }
 01114                throw ex;
 1115            }
 1116            // Create Result
 61117            var _result = new AzureOperationResponse<IEnumerable<string>>();
 61118            _result.Request = _httpRequest;
 61119            _result.Response = _httpResponse;
 61120            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1121            {
 01122                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1123            }
 1124            // Deserialize Response
 61125            if ((int)_statusCode == 200)
 1126            {
 61127                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1128                try
 1129                {
 61130                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<string>>(_responseContent,
 61131                }
 01132                catch (JsonException ex)
 1133                {
 01134                    _httpRequest.Dispose();
 01135                    if (_httpResponse != null)
 1136                    {
 01137                        _httpResponse.Dispose();
 1138                    }
 01139                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1140                }
 1141            }
 61142            if (_shouldTrace)
 1143            {
 01144                ServiceClientTracing.Exit(_invocationId, _result);
 1145            }
 61146            return _result;
 61147        }
 1148
 1149        /// <summary>
 1150        /// Gets a list of users for the current tenant.
 1151        /// </summary>
 1152        /// <param name='nextLink'>
 1153        /// Next link for the list operation.
 1154        /// </param>
 1155        /// <param name='customHeaders'>
 1156        /// Headers that will be added to request.
 1157        /// </param>
 1158        /// <param name='cancellationToken'>
 1159        /// The cancellation token.
 1160        /// </param>
 1161        /// <exception cref="GraphErrorException">
 1162        /// Thrown when the operation returned an invalid status code
 1163        /// </exception>
 1164        /// <exception cref="SerializationException">
 1165        /// Thrown when unable to deserialize the response
 1166        /// </exception>
 1167        /// <exception cref="ValidationException">
 1168        /// Thrown when a required parameter is null
 1169        /// </exception>
 1170        /// <exception cref="System.ArgumentNullException">
 1171        /// Thrown when a required parameter is null
 1172        /// </exception>
 1173        /// <return>
 1174        /// A response object containing the response body and response headers.
 1175        /// </return>
 1176        public async Task<AzureOperationResponse<IPage<User>>> ListNextWithHttpMessagesAsync(string nextLink, Dictionary
 1177        {
 01178            if (nextLink == null)
 1179            {
 01180                throw new ValidationException(ValidationRules.CannotBeNull, "nextLink");
 1181            }
 01182            if (Client.ApiVersion == null)
 1183            {
 01184                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1185            }
 01186            if (Client.TenantID == null)
 1187            {
 01188                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1189            }
 1190            // Tracing
 01191            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01192            string _invocationId = null;
 01193            if (_shouldTrace)
 1194            {
 01195                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01196                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01197                tracingParameters.Add("nextLink", nextLink);
 01198                tracingParameters.Add("cancellationToken", cancellationToken);
 01199                ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
 1200            }
 1201            // Construct URL
 01202            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01203            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/{nextL
 01204            _url = _url.Replace("{nextLink}", nextLink);
 01205            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01206            List<string> _queryParameters = new List<string>();
 01207            if (Client.ApiVersion != null)
 1208            {
 01209                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1210            }
 01211            if (_queryParameters.Count > 0)
 1212            {
 01213                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1214            }
 1215            // Create HTTP transport objects
 01216            var _httpRequest = new HttpRequestMessage();
 01217            HttpResponseMessage _httpResponse = null;
 01218            _httpRequest.Method = new HttpMethod("GET");
 01219            _httpRequest.RequestUri = new System.Uri(_url);
 1220            // Set Headers
 01221            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1222            {
 01223                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1224            }
 01225            if (Client.AcceptLanguage != null)
 1226            {
 01227                if (_httpRequest.Headers.Contains("accept-language"))
 1228                {
 01229                    _httpRequest.Headers.Remove("accept-language");
 1230                }
 01231                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1232            }
 1233
 1234
 01235            if (customHeaders != null)
 1236            {
 01237                foreach(var _header in customHeaders)
 1238                {
 01239                    if (_httpRequest.Headers.Contains(_header.Key))
 1240                    {
 01241                        _httpRequest.Headers.Remove(_header.Key);
 1242                    }
 01243                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1244                }
 1245            }
 1246
 1247            // Serialize Request
 01248            string _requestContent = null;
 1249            // Set Credentials
 01250            if (Client.Credentials != null)
 1251            {
 01252                cancellationToken.ThrowIfCancellationRequested();
 01253                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1254            }
 1255            // Send Request
 01256            if (_shouldTrace)
 1257            {
 01258                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1259            }
 01260            cancellationToken.ThrowIfCancellationRequested();
 01261            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01262            if (_shouldTrace)
 1263            {
 01264                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1265            }
 01266            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01267            cancellationToken.ThrowIfCancellationRequested();
 01268            string _responseContent = null;
 01269            if ((int)_statusCode != 200)
 1270            {
 01271                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1272                try
 1273                {
 01274                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01275                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01276                    if (_errorBody != null)
 1277                    {
 01278                        ex.Body = _errorBody;
 1279                    }
 01280                }
 01281                catch (JsonException)
 1282                {
 1283                    // Ignore the exception
 01284                }
 01285                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01286                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01287                if (_shouldTrace)
 1288                {
 01289                    ServiceClientTracing.Error(_invocationId, ex);
 1290                }
 01291                _httpRequest.Dispose();
 01292                if (_httpResponse != null)
 1293                {
 01294                    _httpResponse.Dispose();
 1295                }
 01296                throw ex;
 1297            }
 1298            // Create Result
 01299            var _result = new AzureOperationResponse<IPage<User>>();
 01300            _result.Request = _httpRequest;
 01301            _result.Response = _httpResponse;
 01302            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1303            {
 01304                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1305            }
 1306            // Deserialize Response
 01307            if ((int)_statusCode == 200)
 1308            {
 01309                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1310                try
 1311                {
 01312                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<User>>(_responseContent, Cl
 01313                }
 01314                catch (JsonException ex)
 1315                {
 01316                    _httpRequest.Dispose();
 01317                    if (_httpResponse != null)
 1318                    {
 01319                        _httpResponse.Dispose();
 1320                    }
 01321                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1322                }
 1323            }
 01324            if (_shouldTrace)
 1325            {
 01326                ServiceClientTracing.Exit(_invocationId, _result);
 1327            }
 01328            return _result;
 01329        }
 1330
 1331    }
 1332}