< Summary

Class:Microsoft.Azure.Graph.RBAC.GroupsOperations
Assembly:Microsoft.Azure.Graph.RBAC
File(s):C:\Git\azure-sdk-for-net\sdk\graphrbac\Microsoft.Azure.Graph.RBAC\src\Generated\GroupsOperations.cs
Covered lines:299
Uncovered lines:990
Coverable lines:1289
Total lines:2771
Line coverage:23.1% (299 of 1289)
Covered branches:171
Total branches:786
Branch coverage:21.7% (171 of 786)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
IsMemberOfWithHttpMessagesAsync()-0%0%
RemoveMemberWithHttpMessagesAsync()-56.79%52%
AddMemberWithHttpMessagesAsync()-59.3%55.56%
CreateWithHttpMessagesAsync()-58.24%55.36%
ListWithHttpMessagesAsync()-57.47%55.56%
GetGroupMembersWithHttpMessagesAsync()-0%0%
GetWithHttpMessagesAsync()-58.14%53.85%
DeleteWithHttpMessagesAsync()-57.14%52.08%
GetMemberGroupsWithHttpMessagesAsync()-0%0%
ListOwnersWithHttpMessagesAsync()-0%0%
AddOwnerWithHttpMessagesAsync()-0%0%
RemoveOwnerWithHttpMessagesAsync()-0%0%
ListNextWithHttpMessagesAsync()-0%0%
GetGroupMembersNextWithHttpMessagesAsync()-0%0%
ListOwnersNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\graphrbac\Microsoft.Azure.Graph.RBAC\src\Generated\GroupsOperations.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    /// GroupsOperations operations.
 28    /// </summary>
 29    internal partial class GroupsOperations : IServiceOperations<GraphRbacManagementClient>, IGroupsOperations
 30    {
 31        /// <summary>
 32        /// Initializes a new instance of the GroupsOperations 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 GroupsOperations(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>
 35252        public GraphRbacManagementClient Client { get; private set; }
 53
 54        /// <summary>
 55        /// Checks whether the specified user, group, contact, or service principal is
 56        /// a direct or transitive member of the specified group.
 57        /// </summary>
 58        /// <param name='parameters'>
 59        /// The check group membership parameters.
 60        /// </param>
 61        /// <param name='customHeaders'>
 62        /// Headers that will be added to request.
 63        /// </param>
 64        /// <param name='cancellationToken'>
 65        /// The cancellation token.
 66        /// </param>
 67        /// <exception cref="GraphErrorException">
 68        /// Thrown when the operation returned an invalid status code
 69        /// </exception>
 70        /// <exception cref="SerializationException">
 71        /// Thrown when unable to deserialize the response
 72        /// </exception>
 73        /// <exception cref="ValidationException">
 74        /// Thrown when a required parameter is null
 75        /// </exception>
 76        /// <exception cref="System.ArgumentNullException">
 77        /// Thrown when a required parameter is null
 78        /// </exception>
 79        /// <return>
 80        /// A response object containing the response body and response headers.
 81        /// </return>
 82        public async Task<AzureOperationResponse<CheckGroupMembershipResult>> IsMemberOfWithHttpMessagesAsync(CheckGroup
 83        {
 084            if (parameters == null)
 85            {
 086                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 87            }
 088            if (parameters != null)
 89            {
 090                parameters.Validate();
 91            }
 092            if (Client.ApiVersion == null)
 93            {
 094                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 95            }
 096            if (Client.TenantID == null)
 97            {
 098                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 99            }
 100            // Tracing
 0101            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0102            string _invocationId = null;
 0103            if (_shouldTrace)
 104            {
 0105                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0106                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0107                tracingParameters.Add("parameters", parameters);
 0108                tracingParameters.Add("cancellationToken", cancellationToken);
 0109                ServiceClientTracing.Enter(_invocationId, this, "IsMemberOf", tracingParameters);
 110            }
 111            // Construct URL
 0112            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0113            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/isMemb
 0114            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 0115            List<string> _queryParameters = new List<string>();
 0116            if (Client.ApiVersion != null)
 117            {
 0118                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 119            }
 0120            if (_queryParameters.Count > 0)
 121            {
 0122                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 123            }
 124            // Create HTTP transport objects
 0125            var _httpRequest = new HttpRequestMessage();
 0126            HttpResponseMessage _httpResponse = null;
 0127            _httpRequest.Method = new HttpMethod("POST");
 0128            _httpRequest.RequestUri = new System.Uri(_url);
 129            // Set Headers
 0130            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 131            {
 0132                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 133            }
 0134            if (Client.AcceptLanguage != null)
 135            {
 0136                if (_httpRequest.Headers.Contains("accept-language"))
 137                {
 0138                    _httpRequest.Headers.Remove("accept-language");
 139                }
 0140                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 141            }
 142
 143
 0144            if (customHeaders != null)
 145            {
 0146                foreach(var _header in customHeaders)
 147                {
 0148                    if (_httpRequest.Headers.Contains(_header.Key))
 149                    {
 0150                        _httpRequest.Headers.Remove(_header.Key);
 151                    }
 0152                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 153                }
 154            }
 155
 156            // Serialize Request
 0157            string _requestContent = null;
 0158            if(parameters != null)
 159            {
 0160                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 0161                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0162                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 163            }
 164            // Set Credentials
 0165            if (Client.Credentials != null)
 166            {
 0167                cancellationToken.ThrowIfCancellationRequested();
 0168                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 169            }
 170            // Send Request
 0171            if (_shouldTrace)
 172            {
 0173                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 174            }
 0175            cancellationToken.ThrowIfCancellationRequested();
 0176            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0177            if (_shouldTrace)
 178            {
 0179                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 180            }
 0181            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0182            cancellationToken.ThrowIfCancellationRequested();
 0183            string _responseContent = null;
 0184            if ((int)_statusCode != 200)
 185            {
 0186                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 187                try
 188                {
 0189                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0190                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0191                    if (_errorBody != null)
 192                    {
 0193                        ex.Body = _errorBody;
 194                    }
 0195                }
 0196                catch (JsonException)
 197                {
 198                    // Ignore the exception
 0199                }
 0200                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0201                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0202                if (_shouldTrace)
 203                {
 0204                    ServiceClientTracing.Error(_invocationId, ex);
 205                }
 0206                _httpRequest.Dispose();
 0207                if (_httpResponse != null)
 208                {
 0209                    _httpResponse.Dispose();
 210                }
 0211                throw ex;
 212            }
 213            // Create Result
 0214            var _result = new AzureOperationResponse<CheckGroupMembershipResult>();
 0215            _result.Request = _httpRequest;
 0216            _result.Response = _httpResponse;
 0217            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 218            {
 0219                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 220            }
 221            // Deserialize Response
 0222            if ((int)_statusCode == 200)
 223            {
 0224                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 225                try
 226                {
 0227                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<CheckGroupMembershipResult>(_res
 0228                }
 0229                catch (JsonException ex)
 230                {
 0231                    _httpRequest.Dispose();
 0232                    if (_httpResponse != null)
 233                    {
 0234                        _httpResponse.Dispose();
 235                    }
 0236                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 237                }
 238            }
 0239            if (_shouldTrace)
 240            {
 0241                ServiceClientTracing.Exit(_invocationId, _result);
 242            }
 0243            return _result;
 0244        }
 245
 246        /// <summary>
 247        /// Remove a member from a group.
 248        /// </summary>
 249        /// <param name='groupObjectId'>
 250        /// The object ID of the group from which to remove the member.
 251        /// </param>
 252        /// <param name='memberObjectId'>
 253        /// Member object id
 254        /// </param>
 255        /// <param name='customHeaders'>
 256        /// Headers that will be added to request.
 257        /// </param>
 258        /// <param name='cancellationToken'>
 259        /// The cancellation token.
 260        /// </param>
 261        /// <exception cref="GraphErrorException">
 262        /// Thrown when the operation returned an invalid status code
 263        /// </exception>
 264        /// <exception cref="ValidationException">
 265        /// Thrown when a required parameter is null
 266        /// </exception>
 267        /// <exception cref="System.ArgumentNullException">
 268        /// Thrown when a required parameter is null
 269        /// </exception>
 270        /// <return>
 271        /// A response object containing the response body and response headers.
 272        /// </return>
 273        public async Task<AzureOperationResponse> RemoveMemberWithHttpMessagesAsync(string groupObjectId, string memberO
 274        {
 2275            if (groupObjectId == null)
 276            {
 0277                throw new ValidationException(ValidationRules.CannotBeNull, "groupObjectId");
 278            }
 2279            if (memberObjectId == null)
 280            {
 0281                throw new ValidationException(ValidationRules.CannotBeNull, "memberObjectId");
 282            }
 2283            if (Client.ApiVersion == null)
 284            {
 0285                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 286            }
 2287            if (Client.TenantID == null)
 288            {
 0289                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 290            }
 291            // Tracing
 2292            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2293            string _invocationId = null;
 2294            if (_shouldTrace)
 295            {
 0296                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0297                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0298                tracingParameters.Add("groupObjectId", groupObjectId);
 0299                tracingParameters.Add("memberObjectId", memberObjectId);
 0300                tracingParameters.Add("cancellationToken", cancellationToken);
 0301                ServiceClientTracing.Enter(_invocationId, this, "RemoveMember", tracingParameters);
 302            }
 303            // Construct URL
 2304            var _baseUrl = Client.BaseUri.AbsoluteUri;
 2305            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 2306            _url = _url.Replace("{groupObjectId}", System.Uri.EscapeDataString(groupObjectId));
 2307            _url = _url.Replace("{memberObjectId}", System.Uri.EscapeDataString(memberObjectId));
 2308            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 2309            List<string> _queryParameters = new List<string>();
 2310            if (Client.ApiVersion != null)
 311            {
 2312                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 313            }
 2314            if (_queryParameters.Count > 0)
 315            {
 2316                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 317            }
 318            // Create HTTP transport objects
 2319            var _httpRequest = new HttpRequestMessage();
 2320            HttpResponseMessage _httpResponse = null;
 2321            _httpRequest.Method = new HttpMethod("DELETE");
 2322            _httpRequest.RequestUri = new System.Uri(_url);
 323            // Set Headers
 2324            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 325            {
 2326                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 327            }
 2328            if (Client.AcceptLanguage != null)
 329            {
 2330                if (_httpRequest.Headers.Contains("accept-language"))
 331                {
 0332                    _httpRequest.Headers.Remove("accept-language");
 333                }
 2334                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 335            }
 336
 337
 2338            if (customHeaders != null)
 339            {
 0340                foreach(var _header in customHeaders)
 341                {
 0342                    if (_httpRequest.Headers.Contains(_header.Key))
 343                    {
 0344                        _httpRequest.Headers.Remove(_header.Key);
 345                    }
 0346                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 347                }
 348            }
 349
 350            // Serialize Request
 2351            string _requestContent = null;
 352            // Set Credentials
 2353            if (Client.Credentials != null)
 354            {
 2355                cancellationToken.ThrowIfCancellationRequested();
 2356                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 357            }
 358            // Send Request
 2359            if (_shouldTrace)
 360            {
 0361                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 362            }
 2363            cancellationToken.ThrowIfCancellationRequested();
 2364            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2365            if (_shouldTrace)
 366            {
 0367                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 368            }
 2369            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2370            cancellationToken.ThrowIfCancellationRequested();
 2371            string _responseContent = null;
 2372            if ((int)_statusCode != 204)
 373            {
 0374                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 375                try
 376                {
 0377                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0378                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0379                    if (_errorBody != null)
 380                    {
 0381                        ex.Body = _errorBody;
 382                    }
 0383                }
 0384                catch (JsonException)
 385                {
 386                    // Ignore the exception
 0387                }
 0388                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0389                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0390                if (_shouldTrace)
 391                {
 0392                    ServiceClientTracing.Error(_invocationId, ex);
 393                }
 0394                _httpRequest.Dispose();
 0395                if (_httpResponse != null)
 396                {
 0397                    _httpResponse.Dispose();
 398                }
 0399                throw ex;
 400            }
 401            // Create Result
 2402            var _result = new AzureOperationResponse();
 2403            _result.Request = _httpRequest;
 2404            _result.Response = _httpResponse;
 2405            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 406            {
 0407                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 408            }
 2409            if (_shouldTrace)
 410            {
 0411                ServiceClientTracing.Exit(_invocationId, _result);
 412            }
 2413            return _result;
 2414        }
 415
 416        /// <summary>
 417        /// Add a member to a group.
 418        /// </summary>
 419        /// <param name='groupObjectId'>
 420        /// The object ID of the group to which to add the member.
 421        /// </param>
 422        /// <param name='parameters'>
 423        /// The URL of the member object, such as
 424        /// https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b
 425        /// </param>
 426        /// <param name='customHeaders'>
 427        /// Headers that will be added to request.
 428        /// </param>
 429        /// <param name='cancellationToken'>
 430        /// The cancellation token.
 431        /// </param>
 432        /// <exception cref="GraphErrorException">
 433        /// Thrown when the operation returned an invalid status code
 434        /// </exception>
 435        /// <exception cref="ValidationException">
 436        /// Thrown when a required parameter is null
 437        /// </exception>
 438        /// <exception cref="System.ArgumentNullException">
 439        /// Thrown when a required parameter is null
 440        /// </exception>
 441        /// <return>
 442        /// A response object containing the response body and response headers.
 443        /// </return>
 444        public async Task<AzureOperationResponse> AddMemberWithHttpMessagesAsync(string groupObjectId, GroupAddMemberPar
 445        {
 2446            if (groupObjectId == null)
 447            {
 0448                throw new ValidationException(ValidationRules.CannotBeNull, "groupObjectId");
 449            }
 2450            if (parameters == null)
 451            {
 0452                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 453            }
 2454            if (parameters != null)
 455            {
 2456                parameters.Validate();
 457            }
 2458            if (Client.ApiVersion == null)
 459            {
 0460                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 461            }
 2462            if (Client.TenantID == null)
 463            {
 0464                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 465            }
 466            // Tracing
 2467            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2468            string _invocationId = null;
 2469            if (_shouldTrace)
 470            {
 0471                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0472                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0473                tracingParameters.Add("groupObjectId", groupObjectId);
 0474                tracingParameters.Add("parameters", parameters);
 0475                tracingParameters.Add("cancellationToken", cancellationToken);
 0476                ServiceClientTracing.Enter(_invocationId, this, "AddMember", tracingParameters);
 477            }
 478            // Construct URL
 2479            var _baseUrl = Client.BaseUri.AbsoluteUri;
 2480            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 2481            _url = _url.Replace("{groupObjectId}", System.Uri.EscapeDataString(groupObjectId));
 2482            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 2483            List<string> _queryParameters = new List<string>();
 2484            if (Client.ApiVersion != null)
 485            {
 2486                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 487            }
 2488            if (_queryParameters.Count > 0)
 489            {
 2490                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 491            }
 492            // Create HTTP transport objects
 2493            var _httpRequest = new HttpRequestMessage();
 2494            HttpResponseMessage _httpResponse = null;
 2495            _httpRequest.Method = new HttpMethod("POST");
 2496            _httpRequest.RequestUri = new System.Uri(_url);
 497            // Set Headers
 2498            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 499            {
 2500                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 501            }
 2502            if (Client.AcceptLanguage != null)
 503            {
 2504                if (_httpRequest.Headers.Contains("accept-language"))
 505                {
 0506                    _httpRequest.Headers.Remove("accept-language");
 507                }
 2508                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 509            }
 510
 511
 2512            if (customHeaders != null)
 513            {
 0514                foreach(var _header in customHeaders)
 515                {
 0516                    if (_httpRequest.Headers.Contains(_header.Key))
 517                    {
 0518                        _httpRequest.Headers.Remove(_header.Key);
 519                    }
 0520                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 521                }
 522            }
 523
 524            // Serialize Request
 2525            string _requestContent = null;
 2526            if(parameters != null)
 527            {
 2528                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 2529                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 2530                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 531            }
 532            // Set Credentials
 2533            if (Client.Credentials != null)
 534            {
 2535                cancellationToken.ThrowIfCancellationRequested();
 2536                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 537            }
 538            // Send Request
 2539            if (_shouldTrace)
 540            {
 0541                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 542            }
 2543            cancellationToken.ThrowIfCancellationRequested();
 2544            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2545            if (_shouldTrace)
 546            {
 0547                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 548            }
 2549            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2550            cancellationToken.ThrowIfCancellationRequested();
 2551            string _responseContent = null;
 2552            if ((int)_statusCode != 204)
 553            {
 0554                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 555                try
 556                {
 0557                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0558                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0559                    if (_errorBody != null)
 560                    {
 0561                        ex.Body = _errorBody;
 562                    }
 0563                }
 0564                catch (JsonException)
 565                {
 566                    // Ignore the exception
 0567                }
 0568                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0569                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0570                if (_shouldTrace)
 571                {
 0572                    ServiceClientTracing.Error(_invocationId, ex);
 573                }
 0574                _httpRequest.Dispose();
 0575                if (_httpResponse != null)
 576                {
 0577                    _httpResponse.Dispose();
 578                }
 0579                throw ex;
 580            }
 581            // Create Result
 2582            var _result = new AzureOperationResponse();
 2583            _result.Request = _httpRequest;
 2584            _result.Response = _httpResponse;
 2585            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 586            {
 0587                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 588            }
 2589            if (_shouldTrace)
 590            {
 0591                ServiceClientTracing.Exit(_invocationId, _result);
 592            }
 2593            return _result;
 2594        }
 595
 596        /// <summary>
 597        /// Create a group in the directory.
 598        /// </summary>
 599        /// <param name='parameters'>
 600        /// The parameters for the group to create.
 601        /// </param>
 602        /// <param name='customHeaders'>
 603        /// Headers that will be added to request.
 604        /// </param>
 605        /// <param name='cancellationToken'>
 606        /// The cancellation token.
 607        /// </param>
 608        /// <exception cref="GraphErrorException">
 609        /// Thrown when the operation returned an invalid status code
 610        /// </exception>
 611        /// <exception cref="SerializationException">
 612        /// Thrown when unable to deserialize the response
 613        /// </exception>
 614        /// <exception cref="ValidationException">
 615        /// Thrown when a required parameter is null
 616        /// </exception>
 617        /// <exception cref="System.ArgumentNullException">
 618        /// Thrown when a required parameter is null
 619        /// </exception>
 620        /// <return>
 621        /// A response object containing the response body and response headers.
 622        /// </return>
 623        public async Task<AzureOperationResponse<ADGroup>> CreateWithHttpMessagesAsync(GroupCreateParameters parameters,
 624        {
 4625            if (parameters == null)
 626            {
 0627                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 628            }
 4629            if (parameters != null)
 630            {
 4631                parameters.Validate();
 632            }
 4633            if (Client.ApiVersion == null)
 634            {
 0635                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 636            }
 4637            if (Client.TenantID == null)
 638            {
 0639                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 640            }
 641            // Tracing
 4642            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 4643            string _invocationId = null;
 4644            if (_shouldTrace)
 645            {
 0646                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0647                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0648                tracingParameters.Add("parameters", parameters);
 0649                tracingParameters.Add("cancellationToken", cancellationToken);
 0650                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
 651            }
 652            // Construct URL
 4653            var _baseUrl = Client.BaseUri.AbsoluteUri;
 4654            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 4655            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 4656            List<string> _queryParameters = new List<string>();
 4657            if (Client.ApiVersion != null)
 658            {
 4659                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 660            }
 4661            if (_queryParameters.Count > 0)
 662            {
 4663                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 664            }
 665            // Create HTTP transport objects
 4666            var _httpRequest = new HttpRequestMessage();
 4667            HttpResponseMessage _httpResponse = null;
 4668            _httpRequest.Method = new HttpMethod("POST");
 4669            _httpRequest.RequestUri = new System.Uri(_url);
 670            // Set Headers
 4671            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 672            {
 4673                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 674            }
 4675            if (Client.AcceptLanguage != null)
 676            {
 4677                if (_httpRequest.Headers.Contains("accept-language"))
 678                {
 0679                    _httpRequest.Headers.Remove("accept-language");
 680                }
 4681                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 682            }
 683
 684
 4685            if (customHeaders != null)
 686            {
 0687                foreach(var _header in customHeaders)
 688                {
 0689                    if (_httpRequest.Headers.Contains(_header.Key))
 690                    {
 0691                        _httpRequest.Headers.Remove(_header.Key);
 692                    }
 0693                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 694                }
 695            }
 696
 697            // Serialize Request
 4698            string _requestContent = null;
 4699            if(parameters != null)
 700            {
 4701                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 4702                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 4703                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 704            }
 705            // Set Credentials
 4706            if (Client.Credentials != null)
 707            {
 4708                cancellationToken.ThrowIfCancellationRequested();
 4709                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 710            }
 711            // Send Request
 4712            if (_shouldTrace)
 713            {
 0714                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 715            }
 4716            cancellationToken.ThrowIfCancellationRequested();
 4717            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4718            if (_shouldTrace)
 719            {
 0720                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 721            }
 4722            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 4723            cancellationToken.ThrowIfCancellationRequested();
 4724            string _responseContent = null;
 4725            if ((int)_statusCode != 201)
 726            {
 0727                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 728                try
 729                {
 0730                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0731                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0732                    if (_errorBody != null)
 733                    {
 0734                        ex.Body = _errorBody;
 735                    }
 0736                }
 0737                catch (JsonException)
 738                {
 739                    // Ignore the exception
 0740                }
 0741                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0742                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0743                if (_shouldTrace)
 744                {
 0745                    ServiceClientTracing.Error(_invocationId, ex);
 746                }
 0747                _httpRequest.Dispose();
 0748                if (_httpResponse != null)
 749                {
 0750                    _httpResponse.Dispose();
 751                }
 0752                throw ex;
 753            }
 754            // Create Result
 4755            var _result = new AzureOperationResponse<ADGroup>();
 4756            _result.Request = _httpRequest;
 4757            _result.Response = _httpResponse;
 4758            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 759            {
 0760                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 761            }
 762            // Deserialize Response
 4763            if ((int)_statusCode == 201)
 764            {
 4765                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 766                try
 767                {
 4768                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ADGroup>(_responseContent, Clien
 4769                }
 0770                catch (JsonException ex)
 771                {
 0772                    _httpRequest.Dispose();
 0773                    if (_httpResponse != null)
 774                    {
 0775                        _httpResponse.Dispose();
 776                    }
 0777                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 778                }
 779            }
 4780            if (_shouldTrace)
 781            {
 0782                ServiceClientTracing.Exit(_invocationId, _result);
 783            }
 4784            return _result;
 4785        }
 786
 787        /// <summary>
 788        /// Gets list of groups for the current tenant.
 789        /// </summary>
 790        /// <param name='odataQuery'>
 791        /// OData parameters to apply to the operation.
 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="SerializationException">
 803        /// Thrown when unable to deserialize the response
 804        /// </exception>
 805        /// <exception cref="ValidationException">
 806        /// Thrown when a required parameter is null
 807        /// </exception>
 808        /// <exception cref="System.ArgumentNullException">
 809        /// Thrown when a required parameter is null
 810        /// </exception>
 811        /// <return>
 812        /// A response object containing the response body and response headers.
 813        /// </return>
 814        public async Task<AzureOperationResponse<IPage<ADGroup>>> ListWithHttpMessagesAsync(ODataQuery<ADGroup> odataQue
 815        {
 8816            if (Client.ApiVersion == null)
 817            {
 0818                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 819            }
 8820            if (Client.TenantID == null)
 821            {
 0822                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 823            }
 824            // Tracing
 8825            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 8826            string _invocationId = null;
 8827            if (_shouldTrace)
 828            {
 0829                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0830                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0831                tracingParameters.Add("odataQuery", odataQuery);
 0832                tracingParameters.Add("cancellationToken", cancellationToken);
 0833                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 834            }
 835            // Construct URL
 8836            var _baseUrl = Client.BaseUri.AbsoluteUri;
 8837            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 8838            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 8839            List<string> _queryParameters = new List<string>();
 8840            if (odataQuery != null)
 841            {
 2842                var _odataFilter = odataQuery.ToString();
 2843                if (!string.IsNullOrEmpty(_odataFilter))
 844                {
 2845                    _queryParameters.Add(_odataFilter);
 846                }
 847            }
 8848            if (Client.ApiVersion != null)
 849            {
 8850                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 851            }
 8852            if (_queryParameters.Count > 0)
 853            {
 8854                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 855            }
 856            // Create HTTP transport objects
 8857            var _httpRequest = new HttpRequestMessage();
 8858            HttpResponseMessage _httpResponse = null;
 8859            _httpRequest.Method = new HttpMethod("GET");
 8860            _httpRequest.RequestUri = new System.Uri(_url);
 861            // Set Headers
 8862            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 863            {
 8864                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 865            }
 8866            if (Client.AcceptLanguage != null)
 867            {
 8868                if (_httpRequest.Headers.Contains("accept-language"))
 869                {
 0870                    _httpRequest.Headers.Remove("accept-language");
 871                }
 8872                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 873            }
 874
 875
 8876            if (customHeaders != null)
 877            {
 0878                foreach(var _header in customHeaders)
 879                {
 0880                    if (_httpRequest.Headers.Contains(_header.Key))
 881                    {
 0882                        _httpRequest.Headers.Remove(_header.Key);
 883                    }
 0884                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 885                }
 886            }
 887
 888            // Serialize Request
 8889            string _requestContent = null;
 890            // Set Credentials
 8891            if (Client.Credentials != null)
 892            {
 8893                cancellationToken.ThrowIfCancellationRequested();
 8894                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 895            }
 896            // Send Request
 8897            if (_shouldTrace)
 898            {
 0899                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 900            }
 8901            cancellationToken.ThrowIfCancellationRequested();
 8902            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8903            if (_shouldTrace)
 904            {
 0905                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 906            }
 8907            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 8908            cancellationToken.ThrowIfCancellationRequested();
 8909            string _responseContent = null;
 8910            if ((int)_statusCode != 200)
 911            {
 0912                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 913                try
 914                {
 0915                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0916                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0917                    if (_errorBody != null)
 918                    {
 0919                        ex.Body = _errorBody;
 920                    }
 0921                }
 0922                catch (JsonException)
 923                {
 924                    // Ignore the exception
 0925                }
 0926                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0927                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0928                if (_shouldTrace)
 929                {
 0930                    ServiceClientTracing.Error(_invocationId, ex);
 931                }
 0932                _httpRequest.Dispose();
 0933                if (_httpResponse != null)
 934                {
 0935                    _httpResponse.Dispose();
 936                }
 0937                throw ex;
 938            }
 939            // Create Result
 8940            var _result = new AzureOperationResponse<IPage<ADGroup>>();
 8941            _result.Request = _httpRequest;
 8942            _result.Response = _httpResponse;
 8943            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 944            {
 0945                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 946            }
 947            // Deserialize Response
 8948            if ((int)_statusCode == 200)
 949            {
 8950                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 951                try
 952                {
 8953                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ADGroup>>(_responseContent,
 8954                }
 0955                catch (JsonException ex)
 956                {
 0957                    _httpRequest.Dispose();
 0958                    if (_httpResponse != null)
 959                    {
 0960                        _httpResponse.Dispose();
 961                    }
 0962                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 963                }
 964            }
 8965            if (_shouldTrace)
 966            {
 0967                ServiceClientTracing.Exit(_invocationId, _result);
 968            }
 8969            return _result;
 8970        }
 971
 972        /// <summary>
 973        /// Gets the members of a group.
 974        /// </summary>
 975        /// <param name='objectId'>
 976        /// The object ID of the group whose members should be retrieved.
 977        /// </param>
 978        /// <param name='customHeaders'>
 979        /// Headers that will be added to request.
 980        /// </param>
 981        /// <param name='cancellationToken'>
 982        /// The cancellation token.
 983        /// </param>
 984        /// <exception cref="GraphErrorException">
 985        /// Thrown when the operation returned an invalid status code
 986        /// </exception>
 987        /// <exception cref="SerializationException">
 988        /// Thrown when unable to deserialize the response
 989        /// </exception>
 990        /// <exception cref="ValidationException">
 991        /// Thrown when a required parameter is null
 992        /// </exception>
 993        /// <exception cref="System.ArgumentNullException">
 994        /// Thrown when a required parameter is null
 995        /// </exception>
 996        /// <return>
 997        /// A response object containing the response body and response headers.
 998        /// </return>
 999        public async Task<AzureOperationResponse<IPage<DirectoryObject>>> GetGroupMembersWithHttpMessagesAsync(string ob
 1000        {
 01001            if (objectId == null)
 1002            {
 01003                throw new ValidationException(ValidationRules.CannotBeNull, "objectId");
 1004            }
 01005            if (Client.ApiVersion == null)
 1006            {
 01007                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1008            }
 01009            if (Client.TenantID == null)
 1010            {
 01011                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1012            }
 1013            // Tracing
 01014            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01015            string _invocationId = null;
 01016            if (_shouldTrace)
 1017            {
 01018                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01019                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01020                tracingParameters.Add("objectId", objectId);
 01021                tracingParameters.Add("cancellationToken", cancellationToken);
 01022                ServiceClientTracing.Enter(_invocationId, this, "GetGroupMembers", tracingParameters);
 1023            }
 1024            // Construct URL
 01025            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01026            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 01027            _url = _url.Replace("{objectId}", System.Uri.EscapeDataString(objectId));
 01028            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01029            List<string> _queryParameters = new List<string>();
 01030            if (Client.ApiVersion != null)
 1031            {
 01032                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1033            }
 01034            if (_queryParameters.Count > 0)
 1035            {
 01036                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1037            }
 1038            // Create HTTP transport objects
 01039            var _httpRequest = new HttpRequestMessage();
 01040            HttpResponseMessage _httpResponse = null;
 01041            _httpRequest.Method = new HttpMethod("GET");
 01042            _httpRequest.RequestUri = new System.Uri(_url);
 1043            // Set Headers
 01044            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1045            {
 01046                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1047            }
 01048            if (Client.AcceptLanguage != null)
 1049            {
 01050                if (_httpRequest.Headers.Contains("accept-language"))
 1051                {
 01052                    _httpRequest.Headers.Remove("accept-language");
 1053                }
 01054                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1055            }
 1056
 1057
 01058            if (customHeaders != null)
 1059            {
 01060                foreach(var _header in customHeaders)
 1061                {
 01062                    if (_httpRequest.Headers.Contains(_header.Key))
 1063                    {
 01064                        _httpRequest.Headers.Remove(_header.Key);
 1065                    }
 01066                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1067                }
 1068            }
 1069
 1070            // Serialize Request
 01071            string _requestContent = null;
 1072            // Set Credentials
 01073            if (Client.Credentials != null)
 1074            {
 01075                cancellationToken.ThrowIfCancellationRequested();
 01076                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1077            }
 1078            // Send Request
 01079            if (_shouldTrace)
 1080            {
 01081                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1082            }
 01083            cancellationToken.ThrowIfCancellationRequested();
 01084            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01085            if (_shouldTrace)
 1086            {
 01087                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1088            }
 01089            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01090            cancellationToken.ThrowIfCancellationRequested();
 01091            string _responseContent = null;
 01092            if ((int)_statusCode != 200)
 1093            {
 01094                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1095                try
 1096                {
 01097                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01098                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01099                    if (_errorBody != null)
 1100                    {
 01101                        ex.Body = _errorBody;
 1102                    }
 01103                }
 01104                catch (JsonException)
 1105                {
 1106                    // Ignore the exception
 01107                }
 01108                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01109                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01110                if (_shouldTrace)
 1111                {
 01112                    ServiceClientTracing.Error(_invocationId, ex);
 1113                }
 01114                _httpRequest.Dispose();
 01115                if (_httpResponse != null)
 1116                {
 01117                    _httpResponse.Dispose();
 1118                }
 01119                throw ex;
 1120            }
 1121            // Create Result
 01122            var _result = new AzureOperationResponse<IPage<DirectoryObject>>();
 01123            _result.Request = _httpRequest;
 01124            _result.Response = _httpResponse;
 01125            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1126            {
 01127                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1128            }
 1129            // Deserialize Response
 01130            if ((int)_statusCode == 200)
 1131            {
 01132                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1133                try
 1134                {
 01135                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response
 01136                }
 01137                catch (JsonException ex)
 1138                {
 01139                    _httpRequest.Dispose();
 01140                    if (_httpResponse != null)
 1141                    {
 01142                        _httpResponse.Dispose();
 1143                    }
 01144                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1145                }
 1146            }
 01147            if (_shouldTrace)
 1148            {
 01149                ServiceClientTracing.Exit(_invocationId, _result);
 1150            }
 01151            return _result;
 01152        }
 1153
 1154        /// <summary>
 1155        /// Gets group information from the directory.
 1156        /// </summary>
 1157        /// <param name='objectId'>
 1158        /// The object ID of the user for which to get group information.
 1159        /// </param>
 1160        /// <param name='customHeaders'>
 1161        /// Headers that will be added to request.
 1162        /// </param>
 1163        /// <param name='cancellationToken'>
 1164        /// The cancellation token.
 1165        /// </param>
 1166        /// <exception cref="GraphErrorException">
 1167        /// Thrown when the operation returned an invalid status code
 1168        /// </exception>
 1169        /// <exception cref="SerializationException">
 1170        /// Thrown when unable to deserialize the response
 1171        /// </exception>
 1172        /// <exception cref="ValidationException">
 1173        /// Thrown when a required parameter is null
 1174        /// </exception>
 1175        /// <exception cref="System.ArgumentNullException">
 1176        /// Thrown when a required parameter is null
 1177        /// </exception>
 1178        /// <return>
 1179        /// A response object containing the response body and response headers.
 1180        /// </return>
 1181        public async Task<AzureOperationResponse<ADGroup>> GetWithHttpMessagesAsync(string objectId, Dictionary<string, 
 1182        {
 21183            if (objectId == null)
 1184            {
 01185                throw new ValidationException(ValidationRules.CannotBeNull, "objectId");
 1186            }
 21187            if (Client.ApiVersion == null)
 1188            {
 01189                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1190            }
 21191            if (Client.TenantID == null)
 1192            {
 01193                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1194            }
 1195            // Tracing
 21196            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 21197            string _invocationId = null;
 21198            if (_shouldTrace)
 1199            {
 01200                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01201                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01202                tracingParameters.Add("objectId", objectId);
 01203                tracingParameters.Add("cancellationToken", cancellationToken);
 01204                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 1205            }
 1206            // Construct URL
 21207            var _baseUrl = Client.BaseUri.AbsoluteUri;
 21208            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 21209            _url = _url.Replace("{objectId}", System.Uri.EscapeDataString(objectId));
 21210            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 21211            List<string> _queryParameters = new List<string>();
 21212            if (Client.ApiVersion != null)
 1213            {
 21214                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1215            }
 21216            if (_queryParameters.Count > 0)
 1217            {
 21218                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1219            }
 1220            // Create HTTP transport objects
 21221            var _httpRequest = new HttpRequestMessage();
 21222            HttpResponseMessage _httpResponse = null;
 21223            _httpRequest.Method = new HttpMethod("GET");
 21224            _httpRequest.RequestUri = new System.Uri(_url);
 1225            // Set Headers
 21226            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1227            {
 21228                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1229            }
 21230            if (Client.AcceptLanguage != null)
 1231            {
 21232                if (_httpRequest.Headers.Contains("accept-language"))
 1233                {
 01234                    _httpRequest.Headers.Remove("accept-language");
 1235                }
 21236                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1237            }
 1238
 1239
 21240            if (customHeaders != null)
 1241            {
 01242                foreach(var _header in customHeaders)
 1243                {
 01244                    if (_httpRequest.Headers.Contains(_header.Key))
 1245                    {
 01246                        _httpRequest.Headers.Remove(_header.Key);
 1247                    }
 01248                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1249                }
 1250            }
 1251
 1252            // Serialize Request
 21253            string _requestContent = null;
 1254            // Set Credentials
 21255            if (Client.Credentials != null)
 1256            {
 21257                cancellationToken.ThrowIfCancellationRequested();
 21258                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1259            }
 1260            // Send Request
 21261            if (_shouldTrace)
 1262            {
 01263                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1264            }
 21265            cancellationToken.ThrowIfCancellationRequested();
 21266            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 21267            if (_shouldTrace)
 1268            {
 01269                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1270            }
 21271            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 21272            cancellationToken.ThrowIfCancellationRequested();
 21273            string _responseContent = null;
 21274            if ((int)_statusCode != 200)
 1275            {
 21276                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1277                try
 1278                {
 21279                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 21280                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 21281                    if (_errorBody != null)
 1282                    {
 21283                        ex.Body = _errorBody;
 1284                    }
 21285                }
 01286                catch (JsonException)
 1287                {
 1288                    // Ignore the exception
 01289                }
 21290                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 21291                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 21292                if (_shouldTrace)
 1293                {
 01294                    ServiceClientTracing.Error(_invocationId, ex);
 1295                }
 21296                _httpRequest.Dispose();
 21297                if (_httpResponse != null)
 1298                {
 21299                    _httpResponse.Dispose();
 1300                }
 21301                throw ex;
 1302            }
 1303            // Create Result
 01304            var _result = new AzureOperationResponse<ADGroup>();
 01305            _result.Request = _httpRequest;
 01306            _result.Response = _httpResponse;
 01307            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1308            {
 01309                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1310            }
 1311            // Deserialize Response
 01312            if ((int)_statusCode == 200)
 1313            {
 01314                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1315                try
 1316                {
 01317                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ADGroup>(_responseContent, Clien
 01318                }
 01319                catch (JsonException ex)
 1320                {
 01321                    _httpRequest.Dispose();
 01322                    if (_httpResponse != null)
 1323                    {
 01324                        _httpResponse.Dispose();
 1325                    }
 01326                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1327                }
 1328            }
 01329            if (_shouldTrace)
 1330            {
 01331                ServiceClientTracing.Exit(_invocationId, _result);
 1332            }
 01333            return _result;
 01334        }
 1335
 1336        /// <summary>
 1337        /// Delete a group from the directory.
 1338        /// </summary>
 1339        /// <param name='objectId'>
 1340        /// The object ID of the group to delete.
 1341        /// </param>
 1342        /// <param name='customHeaders'>
 1343        /// Headers that will be added to request.
 1344        /// </param>
 1345        /// <param name='cancellationToken'>
 1346        /// The cancellation token.
 1347        /// </param>
 1348        /// <exception cref="GraphErrorException">
 1349        /// Thrown when the operation returned an invalid status code
 1350        /// </exception>
 1351        /// <exception cref="ValidationException">
 1352        /// Thrown when a required parameter is null
 1353        /// </exception>
 1354        /// <exception cref="System.ArgumentNullException">
 1355        /// Thrown when a required parameter is null
 1356        /// </exception>
 1357        /// <return>
 1358        /// A response object containing the response body and response headers.
 1359        /// </return>
 1360        public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string objectId, Dictionary<string, List<s
 1361        {
 41362            if (objectId == null)
 1363            {
 01364                throw new ValidationException(ValidationRules.CannotBeNull, "objectId");
 1365            }
 41366            if (Client.ApiVersion == null)
 1367            {
 01368                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1369            }
 41370            if (Client.TenantID == null)
 1371            {
 01372                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1373            }
 1374            // Tracing
 41375            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 41376            string _invocationId = null;
 41377            if (_shouldTrace)
 1378            {
 01379                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01380                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01381                tracingParameters.Add("objectId", objectId);
 01382                tracingParameters.Add("cancellationToken", cancellationToken);
 01383                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 1384            }
 1385            // Construct URL
 41386            var _baseUrl = Client.BaseUri.AbsoluteUri;
 41387            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 41388            _url = _url.Replace("{objectId}", System.Uri.EscapeDataString(objectId));
 41389            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 41390            List<string> _queryParameters = new List<string>();
 41391            if (Client.ApiVersion != null)
 1392            {
 41393                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1394            }
 41395            if (_queryParameters.Count > 0)
 1396            {
 41397                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1398            }
 1399            // Create HTTP transport objects
 41400            var _httpRequest = new HttpRequestMessage();
 41401            HttpResponseMessage _httpResponse = null;
 41402            _httpRequest.Method = new HttpMethod("DELETE");
 41403            _httpRequest.RequestUri = new System.Uri(_url);
 1404            // Set Headers
 41405            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1406            {
 41407                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1408            }
 41409            if (Client.AcceptLanguage != null)
 1410            {
 41411                if (_httpRequest.Headers.Contains("accept-language"))
 1412                {
 01413                    _httpRequest.Headers.Remove("accept-language");
 1414                }
 41415                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1416            }
 1417
 1418
 41419            if (customHeaders != null)
 1420            {
 01421                foreach(var _header in customHeaders)
 1422                {
 01423                    if (_httpRequest.Headers.Contains(_header.Key))
 1424                    {
 01425                        _httpRequest.Headers.Remove(_header.Key);
 1426                    }
 01427                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1428                }
 1429            }
 1430
 1431            // Serialize Request
 41432            string _requestContent = null;
 1433            // Set Credentials
 41434            if (Client.Credentials != null)
 1435            {
 41436                cancellationToken.ThrowIfCancellationRequested();
 41437                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1438            }
 1439            // Send Request
 41440            if (_shouldTrace)
 1441            {
 01442                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1443            }
 41444            cancellationToken.ThrowIfCancellationRequested();
 41445            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 41446            if (_shouldTrace)
 1447            {
 01448                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1449            }
 41450            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 41451            cancellationToken.ThrowIfCancellationRequested();
 41452            string _responseContent = null;
 41453            if ((int)_statusCode != 204)
 1454            {
 01455                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1456                try
 1457                {
 01458                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01459                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01460                    if (_errorBody != null)
 1461                    {
 01462                        ex.Body = _errorBody;
 1463                    }
 01464                }
 01465                catch (JsonException)
 1466                {
 1467                    // Ignore the exception
 01468                }
 01469                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01470                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01471                if (_shouldTrace)
 1472                {
 01473                    ServiceClientTracing.Error(_invocationId, ex);
 1474                }
 01475                _httpRequest.Dispose();
 01476                if (_httpResponse != null)
 1477                {
 01478                    _httpResponse.Dispose();
 1479                }
 01480                throw ex;
 1481            }
 1482            // Create Result
 41483            var _result = new AzureOperationResponse();
 41484            _result.Request = _httpRequest;
 41485            _result.Response = _httpResponse;
 41486            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1487            {
 01488                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1489            }
 41490            if (_shouldTrace)
 1491            {
 01492                ServiceClientTracing.Exit(_invocationId, _result);
 1493            }
 41494            return _result;
 41495        }
 1496
 1497        /// <summary>
 1498        /// Gets a collection of object IDs of groups of which the specified group is a
 1499        /// member.
 1500        /// </summary>
 1501        /// <param name='objectId'>
 1502        /// The object ID of the group for which to get group membership.
 1503        /// </param>
 1504        /// <param name='parameters'>
 1505        /// Group filtering parameters.
 1506        /// </param>
 1507        /// <param name='customHeaders'>
 1508        /// Headers that will be added to request.
 1509        /// </param>
 1510        /// <param name='cancellationToken'>
 1511        /// The cancellation token.
 1512        /// </param>
 1513        /// <exception cref="GraphErrorException">
 1514        /// Thrown when the operation returned an invalid status code
 1515        /// </exception>
 1516        /// <exception cref="SerializationException">
 1517        /// Thrown when unable to deserialize the response
 1518        /// </exception>
 1519        /// <exception cref="ValidationException">
 1520        /// Thrown when a required parameter is null
 1521        /// </exception>
 1522        /// <exception cref="System.ArgumentNullException">
 1523        /// Thrown when a required parameter is null
 1524        /// </exception>
 1525        /// <return>
 1526        /// A response object containing the response body and response headers.
 1527        /// </return>
 1528        public async Task<AzureOperationResponse<IEnumerable<string>>> GetMemberGroupsWithHttpMessagesAsync(string objec
 1529        {
 01530            if (objectId == null)
 1531            {
 01532                throw new ValidationException(ValidationRules.CannotBeNull, "objectId");
 1533            }
 01534            if (parameters == null)
 1535            {
 01536                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 1537            }
 01538            if (parameters != null)
 1539            {
 01540                parameters.Validate();
 1541            }
 01542            if (Client.ApiVersion == null)
 1543            {
 01544                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1545            }
 01546            if (Client.TenantID == null)
 1547            {
 01548                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1549            }
 1550            // Tracing
 01551            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01552            string _invocationId = null;
 01553            if (_shouldTrace)
 1554            {
 01555                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01556                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01557                tracingParameters.Add("objectId", objectId);
 01558                tracingParameters.Add("parameters", parameters);
 01559                tracingParameters.Add("cancellationToken", cancellationToken);
 01560                ServiceClientTracing.Enter(_invocationId, this, "GetMemberGroups", tracingParameters);
 1561            }
 1562            // Construct URL
 01563            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01564            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 01565            _url = _url.Replace("{objectId}", System.Uri.EscapeDataString(objectId));
 01566            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01567            List<string> _queryParameters = new List<string>();
 01568            if (Client.ApiVersion != null)
 1569            {
 01570                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1571            }
 01572            if (_queryParameters.Count > 0)
 1573            {
 01574                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1575            }
 1576            // Create HTTP transport objects
 01577            var _httpRequest = new HttpRequestMessage();
 01578            HttpResponseMessage _httpResponse = null;
 01579            _httpRequest.Method = new HttpMethod("POST");
 01580            _httpRequest.RequestUri = new System.Uri(_url);
 1581            // Set Headers
 01582            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1583            {
 01584                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1585            }
 01586            if (Client.AcceptLanguage != null)
 1587            {
 01588                if (_httpRequest.Headers.Contains("accept-language"))
 1589                {
 01590                    _httpRequest.Headers.Remove("accept-language");
 1591                }
 01592                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1593            }
 1594
 1595
 01596            if (customHeaders != null)
 1597            {
 01598                foreach(var _header in customHeaders)
 1599                {
 01600                    if (_httpRequest.Headers.Contains(_header.Key))
 1601                    {
 01602                        _httpRequest.Headers.Remove(_header.Key);
 1603                    }
 01604                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1605                }
 1606            }
 1607
 1608            // Serialize Request
 01609            string _requestContent = null;
 01610            if(parameters != null)
 1611            {
 01612                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 01613                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01614                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1615            }
 1616            // Set Credentials
 01617            if (Client.Credentials != null)
 1618            {
 01619                cancellationToken.ThrowIfCancellationRequested();
 01620                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1621            }
 1622            // Send Request
 01623            if (_shouldTrace)
 1624            {
 01625                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1626            }
 01627            cancellationToken.ThrowIfCancellationRequested();
 01628            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01629            if (_shouldTrace)
 1630            {
 01631                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1632            }
 01633            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01634            cancellationToken.ThrowIfCancellationRequested();
 01635            string _responseContent = null;
 01636            if ((int)_statusCode != 200)
 1637            {
 01638                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1639                try
 1640                {
 01641                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01642                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01643                    if (_errorBody != null)
 1644                    {
 01645                        ex.Body = _errorBody;
 1646                    }
 01647                }
 01648                catch (JsonException)
 1649                {
 1650                    // Ignore the exception
 01651                }
 01652                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01653                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01654                if (_shouldTrace)
 1655                {
 01656                    ServiceClientTracing.Error(_invocationId, ex);
 1657                }
 01658                _httpRequest.Dispose();
 01659                if (_httpResponse != null)
 1660                {
 01661                    _httpResponse.Dispose();
 1662                }
 01663                throw ex;
 1664            }
 1665            // Create Result
 01666            var _result = new AzureOperationResponse<IEnumerable<string>>();
 01667            _result.Request = _httpRequest;
 01668            _result.Response = _httpResponse;
 01669            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1670            {
 01671                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1672            }
 1673            // Deserialize Response
 01674            if ((int)_statusCode == 200)
 1675            {
 01676                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1677                try
 1678                {
 01679                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<string>>(_responseContent,
 01680                }
 01681                catch (JsonException ex)
 1682                {
 01683                    _httpRequest.Dispose();
 01684                    if (_httpResponse != null)
 1685                    {
 01686                        _httpResponse.Dispose();
 1687                    }
 01688                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1689                }
 1690            }
 01691            if (_shouldTrace)
 1692            {
 01693                ServiceClientTracing.Exit(_invocationId, _result);
 1694            }
 01695            return _result;
 01696        }
 1697
 1698        /// <summary>
 1699        /// Directory objects that are owners of the group.
 1700        /// </summary>
 1701        /// <remarks>
 1702        /// The owners are a set of non-admin users who are allowed to modify this
 1703        /// object.
 1704        /// </remarks>
 1705        /// <param name='objectId'>
 1706        /// The object ID of the group for which to get owners.
 1707        /// </param>
 1708        /// <param name='customHeaders'>
 1709        /// Headers that will be added to request.
 1710        /// </param>
 1711        /// <param name='cancellationToken'>
 1712        /// The cancellation token.
 1713        /// </param>
 1714        /// <exception cref="GraphErrorException">
 1715        /// Thrown when the operation returned an invalid status code
 1716        /// </exception>
 1717        /// <exception cref="SerializationException">
 1718        /// Thrown when unable to deserialize the response
 1719        /// </exception>
 1720        /// <exception cref="ValidationException">
 1721        /// Thrown when a required parameter is null
 1722        /// </exception>
 1723        /// <exception cref="System.ArgumentNullException">
 1724        /// Thrown when a required parameter is null
 1725        /// </exception>
 1726        /// <return>
 1727        /// A response object containing the response body and response headers.
 1728        /// </return>
 1729        public async Task<AzureOperationResponse<IPage<DirectoryObject>>> ListOwnersWithHttpMessagesAsync(string objectI
 1730        {
 01731            if (objectId == null)
 1732            {
 01733                throw new ValidationException(ValidationRules.CannotBeNull, "objectId");
 1734            }
 01735            if (Client.ApiVersion == null)
 1736            {
 01737                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1738            }
 01739            if (Client.TenantID == null)
 1740            {
 01741                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1742            }
 1743            // Tracing
 01744            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01745            string _invocationId = null;
 01746            if (_shouldTrace)
 1747            {
 01748                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01749                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01750                tracingParameters.Add("objectId", objectId);
 01751                tracingParameters.Add("cancellationToken", cancellationToken);
 01752                ServiceClientTracing.Enter(_invocationId, this, "ListOwners", tracingParameters);
 1753            }
 1754            // Construct URL
 01755            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01756            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 01757            _url = _url.Replace("{objectId}", System.Uri.EscapeDataString(objectId));
 01758            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01759            List<string> _queryParameters = new List<string>();
 01760            if (Client.ApiVersion != null)
 1761            {
 01762                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1763            }
 01764            if (_queryParameters.Count > 0)
 1765            {
 01766                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1767            }
 1768            // Create HTTP transport objects
 01769            var _httpRequest = new HttpRequestMessage();
 01770            HttpResponseMessage _httpResponse = null;
 01771            _httpRequest.Method = new HttpMethod("GET");
 01772            _httpRequest.RequestUri = new System.Uri(_url);
 1773            // Set Headers
 01774            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1775            {
 01776                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1777            }
 01778            if (Client.AcceptLanguage != null)
 1779            {
 01780                if (_httpRequest.Headers.Contains("accept-language"))
 1781                {
 01782                    _httpRequest.Headers.Remove("accept-language");
 1783                }
 01784                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1785            }
 1786
 1787
 01788            if (customHeaders != null)
 1789            {
 01790                foreach(var _header in customHeaders)
 1791                {
 01792                    if (_httpRequest.Headers.Contains(_header.Key))
 1793                    {
 01794                        _httpRequest.Headers.Remove(_header.Key);
 1795                    }
 01796                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1797                }
 1798            }
 1799
 1800            // Serialize Request
 01801            string _requestContent = null;
 1802            // Set Credentials
 01803            if (Client.Credentials != null)
 1804            {
 01805                cancellationToken.ThrowIfCancellationRequested();
 01806                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1807            }
 1808            // Send Request
 01809            if (_shouldTrace)
 1810            {
 01811                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1812            }
 01813            cancellationToken.ThrowIfCancellationRequested();
 01814            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01815            if (_shouldTrace)
 1816            {
 01817                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1818            }
 01819            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01820            cancellationToken.ThrowIfCancellationRequested();
 01821            string _responseContent = null;
 01822            if ((int)_statusCode != 200)
 1823            {
 01824                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1825                try
 1826                {
 01827                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01828                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01829                    if (_errorBody != null)
 1830                    {
 01831                        ex.Body = _errorBody;
 1832                    }
 01833                }
 01834                catch (JsonException)
 1835                {
 1836                    // Ignore the exception
 01837                }
 01838                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01839                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01840                if (_shouldTrace)
 1841                {
 01842                    ServiceClientTracing.Error(_invocationId, ex);
 1843                }
 01844                _httpRequest.Dispose();
 01845                if (_httpResponse != null)
 1846                {
 01847                    _httpResponse.Dispose();
 1848                }
 01849                throw ex;
 1850            }
 1851            // Create Result
 01852            var _result = new AzureOperationResponse<IPage<DirectoryObject>>();
 01853            _result.Request = _httpRequest;
 01854            _result.Response = _httpResponse;
 01855            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1856            {
 01857                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1858            }
 1859            // Deserialize Response
 01860            if ((int)_statusCode == 200)
 1861            {
 01862                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1863                try
 1864                {
 01865                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response
 01866                }
 01867                catch (JsonException ex)
 1868                {
 01869                    _httpRequest.Dispose();
 01870                    if (_httpResponse != null)
 1871                    {
 01872                        _httpResponse.Dispose();
 1873                    }
 01874                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1875                }
 1876            }
 01877            if (_shouldTrace)
 1878            {
 01879                ServiceClientTracing.Exit(_invocationId, _result);
 1880            }
 01881            return _result;
 01882        }
 1883
 1884        /// <summary>
 1885        /// Add an owner to a group.
 1886        /// </summary>
 1887        /// <param name='objectId'>
 1888        /// The object ID of the application to which to add the owner.
 1889        /// </param>
 1890        /// <param name='parameters'>
 1891        /// The URL of the owner object, such as
 1892        /// https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b
 1893        /// </param>
 1894        /// <param name='customHeaders'>
 1895        /// Headers that will be added to request.
 1896        /// </param>
 1897        /// <param name='cancellationToken'>
 1898        /// The cancellation token.
 1899        /// </param>
 1900        /// <exception cref="GraphErrorException">
 1901        /// Thrown when the operation returned an invalid status code
 1902        /// </exception>
 1903        /// <exception cref="ValidationException">
 1904        /// Thrown when a required parameter is null
 1905        /// </exception>
 1906        /// <exception cref="System.ArgumentNullException">
 1907        /// Thrown when a required parameter is null
 1908        /// </exception>
 1909        /// <return>
 1910        /// A response object containing the response body and response headers.
 1911        /// </return>
 1912        public async Task<AzureOperationResponse> AddOwnerWithHttpMessagesAsync(string objectId, AddOwnerParameters para
 1913        {
 01914            if (objectId == null)
 1915            {
 01916                throw new ValidationException(ValidationRules.CannotBeNull, "objectId");
 1917            }
 01918            if (parameters == null)
 1919            {
 01920                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 1921            }
 01922            if (parameters != null)
 1923            {
 01924                parameters.Validate();
 1925            }
 01926            if (Client.ApiVersion == null)
 1927            {
 01928                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1929            }
 01930            if (Client.TenantID == null)
 1931            {
 01932                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1933            }
 1934            // Tracing
 01935            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01936            string _invocationId = null;
 01937            if (_shouldTrace)
 1938            {
 01939                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01940                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01941                tracingParameters.Add("objectId", objectId);
 01942                tracingParameters.Add("parameters", parameters);
 01943                tracingParameters.Add("cancellationToken", cancellationToken);
 01944                ServiceClientTracing.Enter(_invocationId, this, "AddOwner", tracingParameters);
 1945            }
 1946            // Construct URL
 01947            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01948            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 01949            _url = _url.Replace("{objectId}", System.Uri.EscapeDataString(objectId));
 01950            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01951            List<string> _queryParameters = new List<string>();
 01952            if (Client.ApiVersion != null)
 1953            {
 01954                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1955            }
 01956            if (_queryParameters.Count > 0)
 1957            {
 01958                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1959            }
 1960            // Create HTTP transport objects
 01961            var _httpRequest = new HttpRequestMessage();
 01962            HttpResponseMessage _httpResponse = null;
 01963            _httpRequest.Method = new HttpMethod("POST");
 01964            _httpRequest.RequestUri = new System.Uri(_url);
 1965            // Set Headers
 01966            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1967            {
 01968                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1969            }
 01970            if (Client.AcceptLanguage != null)
 1971            {
 01972                if (_httpRequest.Headers.Contains("accept-language"))
 1973                {
 01974                    _httpRequest.Headers.Remove("accept-language");
 1975                }
 01976                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1977            }
 1978
 1979
 01980            if (customHeaders != null)
 1981            {
 01982                foreach(var _header in customHeaders)
 1983                {
 01984                    if (_httpRequest.Headers.Contains(_header.Key))
 1985                    {
 01986                        _httpRequest.Headers.Remove(_header.Key);
 1987                    }
 01988                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1989                }
 1990            }
 1991
 1992            // Serialize Request
 01993            string _requestContent = null;
 01994            if(parameters != null)
 1995            {
 01996                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 01997                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01998                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1999            }
 2000            // Set Credentials
 02001            if (Client.Credentials != null)
 2002            {
 02003                cancellationToken.ThrowIfCancellationRequested();
 02004                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2005            }
 2006            // Send Request
 02007            if (_shouldTrace)
 2008            {
 02009                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2010            }
 02011            cancellationToken.ThrowIfCancellationRequested();
 02012            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02013            if (_shouldTrace)
 2014            {
 02015                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2016            }
 02017            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02018            cancellationToken.ThrowIfCancellationRequested();
 02019            string _responseContent = null;
 02020            if ((int)_statusCode != 204)
 2021            {
 02022                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2023                try
 2024                {
 02025                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02026                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 02027                    if (_errorBody != null)
 2028                    {
 02029                        ex.Body = _errorBody;
 2030                    }
 02031                }
 02032                catch (JsonException)
 2033                {
 2034                    // Ignore the exception
 02035                }
 02036                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02037                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02038                if (_shouldTrace)
 2039                {
 02040                    ServiceClientTracing.Error(_invocationId, ex);
 2041                }
 02042                _httpRequest.Dispose();
 02043                if (_httpResponse != null)
 2044                {
 02045                    _httpResponse.Dispose();
 2046                }
 02047                throw ex;
 2048            }
 2049            // Create Result
 02050            var _result = new AzureOperationResponse();
 02051            _result.Request = _httpRequest;
 02052            _result.Response = _httpResponse;
 02053            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 2054            {
 02055                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 2056            }
 02057            if (_shouldTrace)
 2058            {
 02059                ServiceClientTracing.Exit(_invocationId, _result);
 2060            }
 02061            return _result;
 02062        }
 2063
 2064        /// <summary>
 2065        /// Remove a member from owners.
 2066        /// </summary>
 2067        /// <param name='objectId'>
 2068        /// The object ID of the group from which to remove the owner.
 2069        /// </param>
 2070        /// <param name='ownerObjectId'>
 2071        /// Owner object id
 2072        /// </param>
 2073        /// <param name='customHeaders'>
 2074        /// Headers that will be added to request.
 2075        /// </param>
 2076        /// <param name='cancellationToken'>
 2077        /// The cancellation token.
 2078        /// </param>
 2079        /// <exception cref="GraphErrorException">
 2080        /// Thrown when the operation returned an invalid status code
 2081        /// </exception>
 2082        /// <exception cref="ValidationException">
 2083        /// Thrown when a required parameter is null
 2084        /// </exception>
 2085        /// <exception cref="System.ArgumentNullException">
 2086        /// Thrown when a required parameter is null
 2087        /// </exception>
 2088        /// <return>
 2089        /// A response object containing the response body and response headers.
 2090        /// </return>
 2091        public async Task<AzureOperationResponse> RemoveOwnerWithHttpMessagesAsync(string objectId, string ownerObjectId
 2092        {
 02093            if (objectId == null)
 2094            {
 02095                throw new ValidationException(ValidationRules.CannotBeNull, "objectId");
 2096            }
 02097            if (ownerObjectId == null)
 2098            {
 02099                throw new ValidationException(ValidationRules.CannotBeNull, "ownerObjectId");
 2100            }
 02101            if (Client.ApiVersion == null)
 2102            {
 02103                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2104            }
 02105            if (Client.TenantID == null)
 2106            {
 02107                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 2108            }
 2109            // Tracing
 02110            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02111            string _invocationId = null;
 02112            if (_shouldTrace)
 2113            {
 02114                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02115                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02116                tracingParameters.Add("objectId", objectId);
 02117                tracingParameters.Add("ownerObjectId", ownerObjectId);
 02118                tracingParameters.Add("cancellationToken", cancellationToken);
 02119                ServiceClientTracing.Enter(_invocationId, this, "RemoveOwner", tracingParameters);
 2120            }
 2121            // Construct URL
 02122            var _baseUrl = Client.BaseUri.AbsoluteUri;
 02123            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/groups
 02124            _url = _url.Replace("{objectId}", System.Uri.EscapeDataString(objectId));
 02125            _url = _url.Replace("{ownerObjectId}", System.Uri.EscapeDataString(ownerObjectId));
 02126            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 02127            List<string> _queryParameters = new List<string>();
 02128            if (Client.ApiVersion != null)
 2129            {
 02130                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2131            }
 02132            if (_queryParameters.Count > 0)
 2133            {
 02134                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2135            }
 2136            // Create HTTP transport objects
 02137            var _httpRequest = new HttpRequestMessage();
 02138            HttpResponseMessage _httpResponse = null;
 02139            _httpRequest.Method = new HttpMethod("DELETE");
 02140            _httpRequest.RequestUri = new System.Uri(_url);
 2141            // Set Headers
 02142            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2143            {
 02144                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 2145            }
 02146            if (Client.AcceptLanguage != null)
 2147            {
 02148                if (_httpRequest.Headers.Contains("accept-language"))
 2149                {
 02150                    _httpRequest.Headers.Remove("accept-language");
 2151                }
 02152                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2153            }
 2154
 2155
 02156            if (customHeaders != null)
 2157            {
 02158                foreach(var _header in customHeaders)
 2159                {
 02160                    if (_httpRequest.Headers.Contains(_header.Key))
 2161                    {
 02162                        _httpRequest.Headers.Remove(_header.Key);
 2163                    }
 02164                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2165                }
 2166            }
 2167
 2168            // Serialize Request
 02169            string _requestContent = null;
 2170            // Set Credentials
 02171            if (Client.Credentials != null)
 2172            {
 02173                cancellationToken.ThrowIfCancellationRequested();
 02174                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2175            }
 2176            // Send Request
 02177            if (_shouldTrace)
 2178            {
 02179                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2180            }
 02181            cancellationToken.ThrowIfCancellationRequested();
 02182            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02183            if (_shouldTrace)
 2184            {
 02185                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2186            }
 02187            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02188            cancellationToken.ThrowIfCancellationRequested();
 02189            string _responseContent = null;
 02190            if ((int)_statusCode != 204)
 2191            {
 02192                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2193                try
 2194                {
 02195                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02196                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 02197                    if (_errorBody != null)
 2198                    {
 02199                        ex.Body = _errorBody;
 2200                    }
 02201                }
 02202                catch (JsonException)
 2203                {
 2204                    // Ignore the exception
 02205                }
 02206                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02207                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02208                if (_shouldTrace)
 2209                {
 02210                    ServiceClientTracing.Error(_invocationId, ex);
 2211                }
 02212                _httpRequest.Dispose();
 02213                if (_httpResponse != null)
 2214                {
 02215                    _httpResponse.Dispose();
 2216                }
 02217                throw ex;
 2218            }
 2219            // Create Result
 02220            var _result = new AzureOperationResponse();
 02221            _result.Request = _httpRequest;
 02222            _result.Response = _httpResponse;
 02223            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 2224            {
 02225                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 2226            }
 02227            if (_shouldTrace)
 2228            {
 02229                ServiceClientTracing.Exit(_invocationId, _result);
 2230            }
 02231            return _result;
 02232        }
 2233
 2234        /// <summary>
 2235        /// Gets a list of groups for the current tenant.
 2236        /// </summary>
 2237        /// <param name='nextLink'>
 2238        /// Next link for the list operation.
 2239        /// </param>
 2240        /// <param name='customHeaders'>
 2241        /// Headers that will be added to request.
 2242        /// </param>
 2243        /// <param name='cancellationToken'>
 2244        /// The cancellation token.
 2245        /// </param>
 2246        /// <exception cref="GraphErrorException">
 2247        /// Thrown when the operation returned an invalid status code
 2248        /// </exception>
 2249        /// <exception cref="SerializationException">
 2250        /// Thrown when unable to deserialize the response
 2251        /// </exception>
 2252        /// <exception cref="ValidationException">
 2253        /// Thrown when a required parameter is null
 2254        /// </exception>
 2255        /// <exception cref="System.ArgumentNullException">
 2256        /// Thrown when a required parameter is null
 2257        /// </exception>
 2258        /// <return>
 2259        /// A response object containing the response body and response headers.
 2260        /// </return>
 2261        public async Task<AzureOperationResponse<IPage<ADGroup>>> ListNextWithHttpMessagesAsync(string nextLink, Diction
 2262        {
 02263            if (nextLink == null)
 2264            {
 02265                throw new ValidationException(ValidationRules.CannotBeNull, "nextLink");
 2266            }
 02267            if (Client.ApiVersion == null)
 2268            {
 02269                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2270            }
 02271            if (Client.TenantID == null)
 2272            {
 02273                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 2274            }
 2275            // Tracing
 02276            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02277            string _invocationId = null;
 02278            if (_shouldTrace)
 2279            {
 02280                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02281                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02282                tracingParameters.Add("nextLink", nextLink);
 02283                tracingParameters.Add("cancellationToken", cancellationToken);
 02284                ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
 2285            }
 2286            // Construct URL
 02287            var _baseUrl = Client.BaseUri.AbsoluteUri;
 02288            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/{nextL
 02289            _url = _url.Replace("{nextLink}", nextLink);
 02290            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 02291            List<string> _queryParameters = new List<string>();
 02292            if (Client.ApiVersion != null)
 2293            {
 02294                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2295            }
 02296            if (_queryParameters.Count > 0)
 2297            {
 02298                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2299            }
 2300            // Create HTTP transport objects
 02301            var _httpRequest = new HttpRequestMessage();
 02302            HttpResponseMessage _httpResponse = null;
 02303            _httpRequest.Method = new HttpMethod("GET");
 02304            _httpRequest.RequestUri = new System.Uri(_url);
 2305            // Set Headers
 02306            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2307            {
 02308                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 2309            }
 02310            if (Client.AcceptLanguage != null)
 2311            {
 02312                if (_httpRequest.Headers.Contains("accept-language"))
 2313                {
 02314                    _httpRequest.Headers.Remove("accept-language");
 2315                }
 02316                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2317            }
 2318
 2319
 02320            if (customHeaders != null)
 2321            {
 02322                foreach(var _header in customHeaders)
 2323                {
 02324                    if (_httpRequest.Headers.Contains(_header.Key))
 2325                    {
 02326                        _httpRequest.Headers.Remove(_header.Key);
 2327                    }
 02328                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2329                }
 2330            }
 2331
 2332            // Serialize Request
 02333            string _requestContent = null;
 2334            // Set Credentials
 02335            if (Client.Credentials != null)
 2336            {
 02337                cancellationToken.ThrowIfCancellationRequested();
 02338                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2339            }
 2340            // Send Request
 02341            if (_shouldTrace)
 2342            {
 02343                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2344            }
 02345            cancellationToken.ThrowIfCancellationRequested();
 02346            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02347            if (_shouldTrace)
 2348            {
 02349                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2350            }
 02351            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02352            cancellationToken.ThrowIfCancellationRequested();
 02353            string _responseContent = null;
 02354            if ((int)_statusCode != 200)
 2355            {
 02356                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2357                try
 2358                {
 02359                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02360                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 02361                    if (_errorBody != null)
 2362                    {
 02363                        ex.Body = _errorBody;
 2364                    }
 02365                }
 02366                catch (JsonException)
 2367                {
 2368                    // Ignore the exception
 02369                }
 02370                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02371                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02372                if (_shouldTrace)
 2373                {
 02374                    ServiceClientTracing.Error(_invocationId, ex);
 2375                }
 02376                _httpRequest.Dispose();
 02377                if (_httpResponse != null)
 2378                {
 02379                    _httpResponse.Dispose();
 2380                }
 02381                throw ex;
 2382            }
 2383            // Create Result
 02384            var _result = new AzureOperationResponse<IPage<ADGroup>>();
 02385            _result.Request = _httpRequest;
 02386            _result.Response = _httpResponse;
 02387            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 2388            {
 02389                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 2390            }
 2391            // Deserialize Response
 02392            if ((int)_statusCode == 200)
 2393            {
 02394                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2395                try
 2396                {
 02397                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ADGroup>>(_responseContent,
 02398                }
 02399                catch (JsonException ex)
 2400                {
 02401                    _httpRequest.Dispose();
 02402                    if (_httpResponse != null)
 2403                    {
 02404                        _httpResponse.Dispose();
 2405                    }
 02406                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2407                }
 2408            }
 02409            if (_shouldTrace)
 2410            {
 02411                ServiceClientTracing.Exit(_invocationId, _result);
 2412            }
 02413            return _result;
 02414        }
 2415
 2416        /// <summary>
 2417        /// Gets the members of a group.
 2418        /// </summary>
 2419        /// <param name='nextLink'>
 2420        /// Next link for the list operation.
 2421        /// </param>
 2422        /// <param name='customHeaders'>
 2423        /// Headers that will be added to request.
 2424        /// </param>
 2425        /// <param name='cancellationToken'>
 2426        /// The cancellation token.
 2427        /// </param>
 2428        /// <exception cref="GraphErrorException">
 2429        /// Thrown when the operation returned an invalid status code
 2430        /// </exception>
 2431        /// <exception cref="SerializationException">
 2432        /// Thrown when unable to deserialize the response
 2433        /// </exception>
 2434        /// <exception cref="ValidationException">
 2435        /// Thrown when a required parameter is null
 2436        /// </exception>
 2437        /// <exception cref="System.ArgumentNullException">
 2438        /// Thrown when a required parameter is null
 2439        /// </exception>
 2440        /// <return>
 2441        /// A response object containing the response body and response headers.
 2442        /// </return>
 2443        public async Task<AzureOperationResponse<IPage<DirectoryObject>>> GetGroupMembersNextWithHttpMessagesAsync(strin
 2444        {
 02445            if (nextLink == null)
 2446            {
 02447                throw new ValidationException(ValidationRules.CannotBeNull, "nextLink");
 2448            }
 02449            if (Client.ApiVersion == null)
 2450            {
 02451                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2452            }
 02453            if (Client.TenantID == null)
 2454            {
 02455                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 2456            }
 2457            // Tracing
 02458            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02459            string _invocationId = null;
 02460            if (_shouldTrace)
 2461            {
 02462                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02463                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02464                tracingParameters.Add("nextLink", nextLink);
 02465                tracingParameters.Add("cancellationToken", cancellationToken);
 02466                ServiceClientTracing.Enter(_invocationId, this, "GetGroupMembersNext", tracingParameters);
 2467            }
 2468            // Construct URL
 02469            var _baseUrl = Client.BaseUri.AbsoluteUri;
 02470            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/{nextL
 02471            _url = _url.Replace("{nextLink}", nextLink);
 02472            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 02473            List<string> _queryParameters = new List<string>();
 02474            if (Client.ApiVersion != null)
 2475            {
 02476                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2477            }
 02478            if (_queryParameters.Count > 0)
 2479            {
 02480                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2481            }
 2482            // Create HTTP transport objects
 02483            var _httpRequest = new HttpRequestMessage();
 02484            HttpResponseMessage _httpResponse = null;
 02485            _httpRequest.Method = new HttpMethod("GET");
 02486            _httpRequest.RequestUri = new System.Uri(_url);
 2487            // Set Headers
 02488            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2489            {
 02490                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 2491            }
 02492            if (Client.AcceptLanguage != null)
 2493            {
 02494                if (_httpRequest.Headers.Contains("accept-language"))
 2495                {
 02496                    _httpRequest.Headers.Remove("accept-language");
 2497                }
 02498                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2499            }
 2500
 2501
 02502            if (customHeaders != null)
 2503            {
 02504                foreach(var _header in customHeaders)
 2505                {
 02506                    if (_httpRequest.Headers.Contains(_header.Key))
 2507                    {
 02508                        _httpRequest.Headers.Remove(_header.Key);
 2509                    }
 02510                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2511                }
 2512            }
 2513
 2514            // Serialize Request
 02515            string _requestContent = null;
 2516            // Set Credentials
 02517            if (Client.Credentials != null)
 2518            {
 02519                cancellationToken.ThrowIfCancellationRequested();
 02520                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2521            }
 2522            // Send Request
 02523            if (_shouldTrace)
 2524            {
 02525                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2526            }
 02527            cancellationToken.ThrowIfCancellationRequested();
 02528            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02529            if (_shouldTrace)
 2530            {
 02531                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2532            }
 02533            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02534            cancellationToken.ThrowIfCancellationRequested();
 02535            string _responseContent = null;
 02536            if ((int)_statusCode != 200)
 2537            {
 02538                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2539                try
 2540                {
 02541                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02542                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 02543                    if (_errorBody != null)
 2544                    {
 02545                        ex.Body = _errorBody;
 2546                    }
 02547                }
 02548                catch (JsonException)
 2549                {
 2550                    // Ignore the exception
 02551                }
 02552                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02553                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02554                if (_shouldTrace)
 2555                {
 02556                    ServiceClientTracing.Error(_invocationId, ex);
 2557                }
 02558                _httpRequest.Dispose();
 02559                if (_httpResponse != null)
 2560                {
 02561                    _httpResponse.Dispose();
 2562                }
 02563                throw ex;
 2564            }
 2565            // Create Result
 02566            var _result = new AzureOperationResponse<IPage<DirectoryObject>>();
 02567            _result.Request = _httpRequest;
 02568            _result.Response = _httpResponse;
 02569            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 2570            {
 02571                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 2572            }
 2573            // Deserialize Response
 02574            if ((int)_statusCode == 200)
 2575            {
 02576                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2577                try
 2578                {
 02579                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response
 02580                }
 02581                catch (JsonException ex)
 2582                {
 02583                    _httpRequest.Dispose();
 02584                    if (_httpResponse != null)
 2585                    {
 02586                        _httpResponse.Dispose();
 2587                    }
 02588                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2589                }
 2590            }
 02591            if (_shouldTrace)
 2592            {
 02593                ServiceClientTracing.Exit(_invocationId, _result);
 2594            }
 02595            return _result;
 02596        }
 2597
 2598        /// <summary>
 2599        /// Directory objects that are owners of the group.
 2600        /// </summary>
 2601        /// <remarks>
 2602        /// The owners are a set of non-admin users who are allowed to modify this
 2603        /// object.
 2604        /// </remarks>
 2605        /// <param name='nextPageLink'>
 2606        /// The NextLink from the previous successful call to List operation.
 2607        /// </param>
 2608        /// <param name='customHeaders'>
 2609        /// Headers that will be added to request.
 2610        /// </param>
 2611        /// <param name='cancellationToken'>
 2612        /// The cancellation token.
 2613        /// </param>
 2614        /// <exception cref="GraphErrorException">
 2615        /// Thrown when the operation returned an invalid status code
 2616        /// </exception>
 2617        /// <exception cref="SerializationException">
 2618        /// Thrown when unable to deserialize the response
 2619        /// </exception>
 2620        /// <exception cref="ValidationException">
 2621        /// Thrown when a required parameter is null
 2622        /// </exception>
 2623        /// <exception cref="System.ArgumentNullException">
 2624        /// Thrown when a required parameter is null
 2625        /// </exception>
 2626        /// <return>
 2627        /// A response object containing the response body and response headers.
 2628        /// </return>
 2629        public async Task<AzureOperationResponse<IPage<DirectoryObject>>> ListOwnersNextWithHttpMessagesAsync(string nex
 2630        {
 02631            if (nextPageLink == null)
 2632            {
 02633                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 2634            }
 2635            // Tracing
 02636            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02637            string _invocationId = null;
 02638            if (_shouldTrace)
 2639            {
 02640                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02641                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02642                tracingParameters.Add("nextPageLink", nextPageLink);
 02643                tracingParameters.Add("cancellationToken", cancellationToken);
 02644                ServiceClientTracing.Enter(_invocationId, this, "ListOwnersNext", tracingParameters);
 2645            }
 2646            // Construct URL
 02647            string _url = "{nextLink}";
 02648            _url = _url.Replace("{nextLink}", nextPageLink);
 02649            List<string> _queryParameters = new List<string>();
 02650            if (_queryParameters.Count > 0)
 2651            {
 02652                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2653            }
 2654            // Create HTTP transport objects
 02655            var _httpRequest = new HttpRequestMessage();
 02656            HttpResponseMessage _httpResponse = null;
 02657            _httpRequest.Method = new HttpMethod("GET");
 02658            _httpRequest.RequestUri = new System.Uri(_url);
 2659            // Set Headers
 02660            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2661            {
 02662                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 2663            }
 02664            if (Client.AcceptLanguage != null)
 2665            {
 02666                if (_httpRequest.Headers.Contains("accept-language"))
 2667                {
 02668                    _httpRequest.Headers.Remove("accept-language");
 2669                }
 02670                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2671            }
 2672
 2673
 02674            if (customHeaders != null)
 2675            {
 02676                foreach(var _header in customHeaders)
 2677                {
 02678                    if (_httpRequest.Headers.Contains(_header.Key))
 2679                    {
 02680                        _httpRequest.Headers.Remove(_header.Key);
 2681                    }
 02682                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2683                }
 2684            }
 2685
 2686            // Serialize Request
 02687            string _requestContent = null;
 2688            // Set Credentials
 02689            if (Client.Credentials != null)
 2690            {
 02691                cancellationToken.ThrowIfCancellationRequested();
 02692                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2693            }
 2694            // Send Request
 02695            if (_shouldTrace)
 2696            {
 02697                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2698            }
 02699            cancellationToken.ThrowIfCancellationRequested();
 02700            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02701            if (_shouldTrace)
 2702            {
 02703                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2704            }
 02705            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02706            cancellationToken.ThrowIfCancellationRequested();
 02707            string _responseContent = null;
 02708            if ((int)_statusCode != 200)
 2709            {
 02710                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2711                try
 2712                {
 02713                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02714                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 02715                    if (_errorBody != null)
 2716                    {
 02717                        ex.Body = _errorBody;
 2718                    }
 02719                }
 02720                catch (JsonException)
 2721                {
 2722                    // Ignore the exception
 02723                }
 02724                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02725                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02726                if (_shouldTrace)
 2727                {
 02728                    ServiceClientTracing.Error(_invocationId, ex);
 2729                }
 02730                _httpRequest.Dispose();
 02731                if (_httpResponse != null)
 2732                {
 02733                    _httpResponse.Dispose();
 2734                }
 02735                throw ex;
 2736            }
 2737            // Create Result
 02738            var _result = new AzureOperationResponse<IPage<DirectoryObject>>();
 02739            _result.Request = _httpRequest;
 02740            _result.Response = _httpResponse;
 02741            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 2742            {
 02743                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 2744            }
 2745            // Deserialize Response
 02746            if ((int)_statusCode == 200)
 2747            {
 02748                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2749                try
 2750                {
 02751                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response
 02752                }
 02753                catch (JsonException ex)
 2754                {
 02755                    _httpRequest.Dispose();
 02756                    if (_httpResponse != null)
 2757                    {
 02758                        _httpResponse.Dispose();
 2759                    }
 02760                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2761                }
 2762            }
 02763            if (_shouldTrace)
 2764            {
 02765                ServiceClientTracing.Exit(_invocationId, _result);
 2766            }
 02767            return _result;
 02768        }
 2769
 2770    }
 2771}