< Summary

Class:Microsoft.Azure.Graph.RBAC.ApplicationsOperations
Assembly:Microsoft.Azure.Graph.RBAC
File(s):C:\Git\azure-sdk-for-net\sdk\graphrbac\Microsoft.Azure.Graph.RBAC\src\Generated\ApplicationsOperations.cs
Covered lines:4
Uncovered lines:1270
Coverable lines:1274
Total lines:2735
Line coverage:0.3% (4 of 1274)
Covered branches:1
Total branches:776
Branch coverage:0.1% (1 of 776)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-0%100%
CreateWithHttpMessagesAsync()-0%0%
ListWithHttpMessagesAsync()-0%0%
DeleteWithHttpMessagesAsync()-0%0%
GetWithHttpMessagesAsync()-0%0%
PatchWithHttpMessagesAsync()-0%0%
ListOwnersWithHttpMessagesAsync()-0%0%
AddOwnerWithHttpMessagesAsync()-0%0%
RemoveOwnerWithHttpMessagesAsync()-0%0%
ListKeyCredentialsWithHttpMessagesAsync()-0%0%
UpdateKeyCredentialsWithHttpMessagesAsync()-0%0%
ListPasswordCredentialsWithHttpMessagesAsync()-0%0%
UpdatePasswordCredentialsWithHttpMessagesAsync()-0%0%
GetServicePrincipalsIdByAppIdWithHttpMessagesAsync()-0%0%
ListNextWithHttpMessagesAsync()-0%0%
ListOwnersNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\graphrbac\Microsoft.Azure.Graph.RBAC\src\Generated\ApplicationsOperations.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    /// ApplicationsOperations operations.
 28    /// </summary>
 29    internal partial class ApplicationsOperations : IServiceOperations<GraphRbacManagementClient>, IApplicationsOperatio
 30    {
 31        /// <summary>
 32        /// Initializes a new instance of the ApplicationsOperations 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 ApplicationsOperations(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>
 052        public GraphRbacManagementClient Client { get; private set; }
 53
 54        /// <summary>
 55        /// Create a new application.
 56        /// </summary>
 57        /// <param name='parameters'>
 58        /// The parameters for creating an application.
 59        /// </param>
 60        /// <param name='customHeaders'>
 61        /// Headers that will be added to request.
 62        /// </param>
 63        /// <param name='cancellationToken'>
 64        /// The cancellation token.
 65        /// </param>
 66        /// <exception cref="GraphErrorException">
 67        /// Thrown when the operation returned an invalid status code
 68        /// </exception>
 69        /// <exception cref="SerializationException">
 70        /// Thrown when unable to deserialize the response
 71        /// </exception>
 72        /// <exception cref="ValidationException">
 73        /// Thrown when a required parameter is null
 74        /// </exception>
 75        /// <exception cref="System.ArgumentNullException">
 76        /// Thrown when a required parameter is null
 77        /// </exception>
 78        /// <return>
 79        /// A response object containing the response body and response headers.
 80        /// </return>
 81        public async Task<AzureOperationResponse<Application>> CreateWithHttpMessagesAsync(ApplicationCreateParameters p
 82        {
 083            if (parameters == null)
 84            {
 085                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 86            }
 087            if (parameters != null)
 88            {
 089                parameters.Validate();
 90            }
 091            if (Client.ApiVersion == null)
 92            {
 093                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 94            }
 095            if (Client.TenantID == null)
 96            {
 097                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 98            }
 99            // Tracing
 0100            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0101            string _invocationId = null;
 0102            if (_shouldTrace)
 103            {
 0104                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0105                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0106                tracingParameters.Add("parameters", parameters);
 0107                tracingParameters.Add("cancellationToken", cancellationToken);
 0108                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
 109            }
 110            // Construct URL
 0111            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0112            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 0113            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 0114            List<string> _queryParameters = new List<string>();
 0115            if (Client.ApiVersion != null)
 116            {
 0117                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 118            }
 0119            if (_queryParameters.Count > 0)
 120            {
 0121                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 122            }
 123            // Create HTTP transport objects
 0124            var _httpRequest = new HttpRequestMessage();
 0125            HttpResponseMessage _httpResponse = null;
 0126            _httpRequest.Method = new HttpMethod("POST");
 0127            _httpRequest.RequestUri = new System.Uri(_url);
 128            // Set Headers
 0129            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 130            {
 0131                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 132            }
 0133            if (Client.AcceptLanguage != null)
 134            {
 0135                if (_httpRequest.Headers.Contains("accept-language"))
 136                {
 0137                    _httpRequest.Headers.Remove("accept-language");
 138                }
 0139                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 140            }
 141
 142
 0143            if (customHeaders != null)
 144            {
 0145                foreach(var _header in customHeaders)
 146                {
 0147                    if (_httpRequest.Headers.Contains(_header.Key))
 148                    {
 0149                        _httpRequest.Headers.Remove(_header.Key);
 150                    }
 0151                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 152                }
 153            }
 154
 155            // Serialize Request
 0156            string _requestContent = null;
 0157            if(parameters != null)
 158            {
 0159                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 0160                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0161                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 162            }
 163            // Set Credentials
 0164            if (Client.Credentials != null)
 165            {
 0166                cancellationToken.ThrowIfCancellationRequested();
 0167                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 168            }
 169            // Send Request
 0170            if (_shouldTrace)
 171            {
 0172                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 173            }
 0174            cancellationToken.ThrowIfCancellationRequested();
 0175            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0176            if (_shouldTrace)
 177            {
 0178                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 179            }
 0180            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0181            cancellationToken.ThrowIfCancellationRequested();
 0182            string _responseContent = null;
 0183            if ((int)_statusCode != 201)
 184            {
 0185                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 186                try
 187                {
 0188                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0189                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0190                    if (_errorBody != null)
 191                    {
 0192                        ex.Body = _errorBody;
 193                    }
 0194                }
 0195                catch (JsonException)
 196                {
 197                    // Ignore the exception
 0198                }
 0199                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0200                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0201                if (_shouldTrace)
 202                {
 0203                    ServiceClientTracing.Error(_invocationId, ex);
 204                }
 0205                _httpRequest.Dispose();
 0206                if (_httpResponse != null)
 207                {
 0208                    _httpResponse.Dispose();
 209                }
 0210                throw ex;
 211            }
 212            // Create Result
 0213            var _result = new AzureOperationResponse<Application>();
 0214            _result.Request = _httpRequest;
 0215            _result.Response = _httpResponse;
 0216            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 217            {
 0218                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 219            }
 220            // Deserialize Response
 0221            if ((int)_statusCode == 201)
 222            {
 0223                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 224                try
 225                {
 0226                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Application>(_responseContent, C
 0227                }
 0228                catch (JsonException ex)
 229                {
 0230                    _httpRequest.Dispose();
 0231                    if (_httpResponse != null)
 232                    {
 0233                        _httpResponse.Dispose();
 234                    }
 0235                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 236                }
 237            }
 0238            if (_shouldTrace)
 239            {
 0240                ServiceClientTracing.Exit(_invocationId, _result);
 241            }
 0242            return _result;
 0243        }
 244
 245        /// <summary>
 246        /// Lists applications by filter parameters.
 247        /// </summary>
 248        /// <param name='odataQuery'>
 249        /// OData parameters to apply to the operation.
 250        /// </param>
 251        /// <param name='customHeaders'>
 252        /// Headers that will be added to request.
 253        /// </param>
 254        /// <param name='cancellationToken'>
 255        /// The cancellation token.
 256        /// </param>
 257        /// <exception cref="GraphErrorException">
 258        /// Thrown when the operation returned an invalid status code
 259        /// </exception>
 260        /// <exception cref="SerializationException">
 261        /// Thrown when unable to deserialize the response
 262        /// </exception>
 263        /// <exception cref="ValidationException">
 264        /// Thrown when a required parameter is null
 265        /// </exception>
 266        /// <exception cref="System.ArgumentNullException">
 267        /// Thrown when a required parameter is null
 268        /// </exception>
 269        /// <return>
 270        /// A response object containing the response body and response headers.
 271        /// </return>
 272        public async Task<AzureOperationResponse<IPage<Application>>> ListWithHttpMessagesAsync(ODataQuery<Application> 
 273        {
 0274            if (Client.ApiVersion == null)
 275            {
 0276                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 277            }
 0278            if (Client.TenantID == null)
 279            {
 0280                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 281            }
 282            // Tracing
 0283            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0284            string _invocationId = null;
 0285            if (_shouldTrace)
 286            {
 0287                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0288                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0289                tracingParameters.Add("odataQuery", odataQuery);
 0290                tracingParameters.Add("cancellationToken", cancellationToken);
 0291                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 292            }
 293            // Construct URL
 0294            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0295            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 0296            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 0297            List<string> _queryParameters = new List<string>();
 0298            if (odataQuery != null)
 299            {
 0300                var _odataFilter = odataQuery.ToString();
 0301                if (!string.IsNullOrEmpty(_odataFilter))
 302                {
 0303                    _queryParameters.Add(_odataFilter);
 304                }
 305            }
 0306            if (Client.ApiVersion != null)
 307            {
 0308                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 309            }
 0310            if (_queryParameters.Count > 0)
 311            {
 0312                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 313            }
 314            // Create HTTP transport objects
 0315            var _httpRequest = new HttpRequestMessage();
 0316            HttpResponseMessage _httpResponse = null;
 0317            _httpRequest.Method = new HttpMethod("GET");
 0318            _httpRequest.RequestUri = new System.Uri(_url);
 319            // Set Headers
 0320            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 321            {
 0322                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 323            }
 0324            if (Client.AcceptLanguage != null)
 325            {
 0326                if (_httpRequest.Headers.Contains("accept-language"))
 327                {
 0328                    _httpRequest.Headers.Remove("accept-language");
 329                }
 0330                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 331            }
 332
 333
 0334            if (customHeaders != null)
 335            {
 0336                foreach(var _header in customHeaders)
 337                {
 0338                    if (_httpRequest.Headers.Contains(_header.Key))
 339                    {
 0340                        _httpRequest.Headers.Remove(_header.Key);
 341                    }
 0342                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 343                }
 344            }
 345
 346            // Serialize Request
 0347            string _requestContent = null;
 348            // Set Credentials
 0349            if (Client.Credentials != null)
 350            {
 0351                cancellationToken.ThrowIfCancellationRequested();
 0352                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 353            }
 354            // Send Request
 0355            if (_shouldTrace)
 356            {
 0357                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 358            }
 0359            cancellationToken.ThrowIfCancellationRequested();
 0360            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0361            if (_shouldTrace)
 362            {
 0363                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 364            }
 0365            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0366            cancellationToken.ThrowIfCancellationRequested();
 0367            string _responseContent = null;
 0368            if ((int)_statusCode != 200)
 369            {
 0370                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 371                try
 372                {
 0373                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0374                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0375                    if (_errorBody != null)
 376                    {
 0377                        ex.Body = _errorBody;
 378                    }
 0379                }
 0380                catch (JsonException)
 381                {
 382                    // Ignore the exception
 0383                }
 0384                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0385                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0386                if (_shouldTrace)
 387                {
 0388                    ServiceClientTracing.Error(_invocationId, ex);
 389                }
 0390                _httpRequest.Dispose();
 0391                if (_httpResponse != null)
 392                {
 0393                    _httpResponse.Dispose();
 394                }
 0395                throw ex;
 396            }
 397            // Create Result
 0398            var _result = new AzureOperationResponse<IPage<Application>>();
 0399            _result.Request = _httpRequest;
 0400            _result.Response = _httpResponse;
 0401            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 402            {
 0403                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 404            }
 405            // Deserialize Response
 0406            if ((int)_statusCode == 200)
 407            {
 0408                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 409                try
 410                {
 0411                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<Application>>(_responseCont
 0412                }
 0413                catch (JsonException ex)
 414                {
 0415                    _httpRequest.Dispose();
 0416                    if (_httpResponse != null)
 417                    {
 0418                        _httpResponse.Dispose();
 419                    }
 0420                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 421                }
 422            }
 0423            if (_shouldTrace)
 424            {
 0425                ServiceClientTracing.Exit(_invocationId, _result);
 426            }
 0427            return _result;
 0428        }
 429
 430        /// <summary>
 431        /// Delete an application.
 432        /// </summary>
 433        /// <param name='applicationObjectId'>
 434        /// Application object ID.
 435        /// </param>
 436        /// <param name='customHeaders'>
 437        /// Headers that will be added to request.
 438        /// </param>
 439        /// <param name='cancellationToken'>
 440        /// The cancellation token.
 441        /// </param>
 442        /// <exception cref="GraphErrorException">
 443        /// Thrown when the operation returned an invalid status code
 444        /// </exception>
 445        /// <exception cref="ValidationException">
 446        /// Thrown when a required parameter is null
 447        /// </exception>
 448        /// <exception cref="System.ArgumentNullException">
 449        /// Thrown when a required parameter is null
 450        /// </exception>
 451        /// <return>
 452        /// A response object containing the response body and response headers.
 453        /// </return>
 454        public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string applicationObjectId, Dictionary<str
 455        {
 0456            if (applicationObjectId == null)
 457            {
 0458                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 459            }
 0460            if (Client.ApiVersion == null)
 461            {
 0462                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 463            }
 0464            if (Client.TenantID == null)
 465            {
 0466                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 467            }
 468            // Tracing
 0469            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0470            string _invocationId = null;
 0471            if (_shouldTrace)
 472            {
 0473                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0474                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0475                tracingParameters.Add("applicationObjectId", applicationObjectId);
 0476                tracingParameters.Add("cancellationToken", cancellationToken);
 0477                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 478            }
 479            // Construct URL
 0480            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0481            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 0482            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 0483            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 0484            List<string> _queryParameters = new List<string>();
 0485            if (Client.ApiVersion != null)
 486            {
 0487                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 488            }
 0489            if (_queryParameters.Count > 0)
 490            {
 0491                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 492            }
 493            // Create HTTP transport objects
 0494            var _httpRequest = new HttpRequestMessage();
 0495            HttpResponseMessage _httpResponse = null;
 0496            _httpRequest.Method = new HttpMethod("DELETE");
 0497            _httpRequest.RequestUri = new System.Uri(_url);
 498            // Set Headers
 0499            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 500            {
 0501                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 502            }
 0503            if (Client.AcceptLanguage != null)
 504            {
 0505                if (_httpRequest.Headers.Contains("accept-language"))
 506                {
 0507                    _httpRequest.Headers.Remove("accept-language");
 508                }
 0509                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 510            }
 511
 512
 0513            if (customHeaders != null)
 514            {
 0515                foreach(var _header in customHeaders)
 516                {
 0517                    if (_httpRequest.Headers.Contains(_header.Key))
 518                    {
 0519                        _httpRequest.Headers.Remove(_header.Key);
 520                    }
 0521                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 522                }
 523            }
 524
 525            // Serialize Request
 0526            string _requestContent = null;
 527            // Set Credentials
 0528            if (Client.Credentials != null)
 529            {
 0530                cancellationToken.ThrowIfCancellationRequested();
 0531                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 532            }
 533            // Send Request
 0534            if (_shouldTrace)
 535            {
 0536                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 537            }
 0538            cancellationToken.ThrowIfCancellationRequested();
 0539            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0540            if (_shouldTrace)
 541            {
 0542                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 543            }
 0544            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0545            cancellationToken.ThrowIfCancellationRequested();
 0546            string _responseContent = null;
 0547            if ((int)_statusCode != 204)
 548            {
 0549                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 550                try
 551                {
 0552                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0553                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0554                    if (_errorBody != null)
 555                    {
 0556                        ex.Body = _errorBody;
 557                    }
 0558                }
 0559                catch (JsonException)
 560                {
 561                    // Ignore the exception
 0562                }
 0563                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0564                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0565                if (_shouldTrace)
 566                {
 0567                    ServiceClientTracing.Error(_invocationId, ex);
 568                }
 0569                _httpRequest.Dispose();
 0570                if (_httpResponse != null)
 571                {
 0572                    _httpResponse.Dispose();
 573                }
 0574                throw ex;
 575            }
 576            // Create Result
 0577            var _result = new AzureOperationResponse();
 0578            _result.Request = _httpRequest;
 0579            _result.Response = _httpResponse;
 0580            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 581            {
 0582                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 583            }
 0584            if (_shouldTrace)
 585            {
 0586                ServiceClientTracing.Exit(_invocationId, _result);
 587            }
 0588            return _result;
 0589        }
 590
 591        /// <summary>
 592        /// Get an application by object ID.
 593        /// </summary>
 594        /// <param name='applicationObjectId'>
 595        /// Application object ID.
 596        /// </param>
 597        /// <param name='customHeaders'>
 598        /// Headers that will be added to request.
 599        /// </param>
 600        /// <param name='cancellationToken'>
 601        /// The cancellation token.
 602        /// </param>
 603        /// <exception cref="GraphErrorException">
 604        /// Thrown when the operation returned an invalid status code
 605        /// </exception>
 606        /// <exception cref="SerializationException">
 607        /// Thrown when unable to deserialize the response
 608        /// </exception>
 609        /// <exception cref="ValidationException">
 610        /// Thrown when a required parameter is null
 611        /// </exception>
 612        /// <exception cref="System.ArgumentNullException">
 613        /// Thrown when a required parameter is null
 614        /// </exception>
 615        /// <return>
 616        /// A response object containing the response body and response headers.
 617        /// </return>
 618        public async Task<AzureOperationResponse<Application>> GetWithHttpMessagesAsync(string applicationObjectId, Dict
 619        {
 0620            if (applicationObjectId == null)
 621            {
 0622                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 623            }
 0624            if (Client.ApiVersion == null)
 625            {
 0626                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 627            }
 0628            if (Client.TenantID == null)
 629            {
 0630                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 631            }
 632            // Tracing
 0633            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0634            string _invocationId = null;
 0635            if (_shouldTrace)
 636            {
 0637                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0638                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0639                tracingParameters.Add("applicationObjectId", applicationObjectId);
 0640                tracingParameters.Add("cancellationToken", cancellationToken);
 0641                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 642            }
 643            // Construct URL
 0644            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0645            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 0646            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 0647            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 0648            List<string> _queryParameters = new List<string>();
 0649            if (Client.ApiVersion != null)
 650            {
 0651                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 652            }
 0653            if (_queryParameters.Count > 0)
 654            {
 0655                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 656            }
 657            // Create HTTP transport objects
 0658            var _httpRequest = new HttpRequestMessage();
 0659            HttpResponseMessage _httpResponse = null;
 0660            _httpRequest.Method = new HttpMethod("GET");
 0661            _httpRequest.RequestUri = new System.Uri(_url);
 662            // Set Headers
 0663            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 664            {
 0665                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 666            }
 0667            if (Client.AcceptLanguage != null)
 668            {
 0669                if (_httpRequest.Headers.Contains("accept-language"))
 670                {
 0671                    _httpRequest.Headers.Remove("accept-language");
 672                }
 0673                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 674            }
 675
 676
 0677            if (customHeaders != null)
 678            {
 0679                foreach(var _header in customHeaders)
 680                {
 0681                    if (_httpRequest.Headers.Contains(_header.Key))
 682                    {
 0683                        _httpRequest.Headers.Remove(_header.Key);
 684                    }
 0685                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 686                }
 687            }
 688
 689            // Serialize Request
 0690            string _requestContent = null;
 691            // Set Credentials
 0692            if (Client.Credentials != null)
 693            {
 0694                cancellationToken.ThrowIfCancellationRequested();
 0695                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 696            }
 697            // Send Request
 0698            if (_shouldTrace)
 699            {
 0700                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 701            }
 0702            cancellationToken.ThrowIfCancellationRequested();
 0703            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0704            if (_shouldTrace)
 705            {
 0706                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 707            }
 0708            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0709            cancellationToken.ThrowIfCancellationRequested();
 0710            string _responseContent = null;
 0711            if ((int)_statusCode != 200)
 712            {
 0713                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 714                try
 715                {
 0716                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0717                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0718                    if (_errorBody != null)
 719                    {
 0720                        ex.Body = _errorBody;
 721                    }
 0722                }
 0723                catch (JsonException)
 724                {
 725                    // Ignore the exception
 0726                }
 0727                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0728                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0729                if (_shouldTrace)
 730                {
 0731                    ServiceClientTracing.Error(_invocationId, ex);
 732                }
 0733                _httpRequest.Dispose();
 0734                if (_httpResponse != null)
 735                {
 0736                    _httpResponse.Dispose();
 737                }
 0738                throw ex;
 739            }
 740            // Create Result
 0741            var _result = new AzureOperationResponse<Application>();
 0742            _result.Request = _httpRequest;
 0743            _result.Response = _httpResponse;
 0744            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 745            {
 0746                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 747            }
 748            // Deserialize Response
 0749            if ((int)_statusCode == 200)
 750            {
 0751                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 752                try
 753                {
 0754                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Application>(_responseContent, C
 0755                }
 0756                catch (JsonException ex)
 757                {
 0758                    _httpRequest.Dispose();
 0759                    if (_httpResponse != null)
 760                    {
 0761                        _httpResponse.Dispose();
 762                    }
 0763                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 764                }
 765            }
 0766            if (_shouldTrace)
 767            {
 0768                ServiceClientTracing.Exit(_invocationId, _result);
 769            }
 0770            return _result;
 0771        }
 772
 773        /// <summary>
 774        /// Update an existing application.
 775        /// </summary>
 776        /// <param name='applicationObjectId'>
 777        /// Application object ID.
 778        /// </param>
 779        /// <param name='parameters'>
 780        /// Parameters to update an existing application.
 781        /// </param>
 782        /// <param name='customHeaders'>
 783        /// Headers that will be added to request.
 784        /// </param>
 785        /// <param name='cancellationToken'>
 786        /// The cancellation token.
 787        /// </param>
 788        /// <exception cref="GraphErrorException">
 789        /// Thrown when the operation returned an invalid status code
 790        /// </exception>
 791        /// <exception cref="ValidationException">
 792        /// Thrown when a required parameter is null
 793        /// </exception>
 794        /// <exception cref="System.ArgumentNullException">
 795        /// Thrown when a required parameter is null
 796        /// </exception>
 797        /// <return>
 798        /// A response object containing the response body and response headers.
 799        /// </return>
 800        public async Task<AzureOperationResponse> PatchWithHttpMessagesAsync(string applicationObjectId, ApplicationUpda
 801        {
 0802            if (applicationObjectId == null)
 803            {
 0804                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 805            }
 0806            if (parameters == null)
 807            {
 0808                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 809            }
 0810            if (Client.ApiVersion == null)
 811            {
 0812                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 813            }
 0814            if (Client.TenantID == null)
 815            {
 0816                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 817            }
 818            // Tracing
 0819            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0820            string _invocationId = null;
 0821            if (_shouldTrace)
 822            {
 0823                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0824                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0825                tracingParameters.Add("applicationObjectId", applicationObjectId);
 0826                tracingParameters.Add("parameters", parameters);
 0827                tracingParameters.Add("cancellationToken", cancellationToken);
 0828                ServiceClientTracing.Enter(_invocationId, this, "Patch", tracingParameters);
 829            }
 830            // Construct URL
 0831            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0832            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 0833            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 0834            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 0835            List<string> _queryParameters = new List<string>();
 0836            if (Client.ApiVersion != null)
 837            {
 0838                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 839            }
 0840            if (_queryParameters.Count > 0)
 841            {
 0842                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 843            }
 844            // Create HTTP transport objects
 0845            var _httpRequest = new HttpRequestMessage();
 0846            HttpResponseMessage _httpResponse = null;
 0847            _httpRequest.Method = new HttpMethod("PATCH");
 0848            _httpRequest.RequestUri = new System.Uri(_url);
 849            // Set Headers
 0850            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 851            {
 0852                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 853            }
 0854            if (Client.AcceptLanguage != null)
 855            {
 0856                if (_httpRequest.Headers.Contains("accept-language"))
 857                {
 0858                    _httpRequest.Headers.Remove("accept-language");
 859                }
 0860                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 861            }
 862
 863
 0864            if (customHeaders != null)
 865            {
 0866                foreach(var _header in customHeaders)
 867                {
 0868                    if (_httpRequest.Headers.Contains(_header.Key))
 869                    {
 0870                        _httpRequest.Headers.Remove(_header.Key);
 871                    }
 0872                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 873                }
 874            }
 875
 876            // Serialize Request
 0877            string _requestContent = null;
 0878            if(parameters != null)
 879            {
 0880                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 0881                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0882                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 883            }
 884            // Set Credentials
 0885            if (Client.Credentials != null)
 886            {
 0887                cancellationToken.ThrowIfCancellationRequested();
 0888                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 889            }
 890            // Send Request
 0891            if (_shouldTrace)
 892            {
 0893                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 894            }
 0895            cancellationToken.ThrowIfCancellationRequested();
 0896            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0897            if (_shouldTrace)
 898            {
 0899                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 900            }
 0901            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0902            cancellationToken.ThrowIfCancellationRequested();
 0903            string _responseContent = null;
 0904            if ((int)_statusCode != 204)
 905            {
 0906                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 907                try
 908                {
 0909                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0910                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 0911                    if (_errorBody != null)
 912                    {
 0913                        ex.Body = _errorBody;
 914                    }
 0915                }
 0916                catch (JsonException)
 917                {
 918                    // Ignore the exception
 0919                }
 0920                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0921                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0922                if (_shouldTrace)
 923                {
 0924                    ServiceClientTracing.Error(_invocationId, ex);
 925                }
 0926                _httpRequest.Dispose();
 0927                if (_httpResponse != null)
 928                {
 0929                    _httpResponse.Dispose();
 930                }
 0931                throw ex;
 932            }
 933            // Create Result
 0934            var _result = new AzureOperationResponse();
 0935            _result.Request = _httpRequest;
 0936            _result.Response = _httpResponse;
 0937            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 938            {
 0939                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 940            }
 0941            if (_shouldTrace)
 942            {
 0943                ServiceClientTracing.Exit(_invocationId, _result);
 944            }
 0945            return _result;
 0946        }
 947
 948        /// <summary>
 949        /// Directory objects that are owners of the application.
 950        /// </summary>
 951        /// <remarks>
 952        /// The owners are a set of non-admin users who are allowed to modify this
 953        /// object.
 954        /// </remarks>
 955        /// <param name='applicationObjectId'>
 956        /// The object ID of the application for which to get owners.
 957        /// </param>
 958        /// <param name='customHeaders'>
 959        /// Headers that will be added to request.
 960        /// </param>
 961        /// <param name='cancellationToken'>
 962        /// The cancellation token.
 963        /// </param>
 964        /// <exception cref="GraphErrorException">
 965        /// Thrown when the operation returned an invalid status code
 966        /// </exception>
 967        /// <exception cref="SerializationException">
 968        /// Thrown when unable to deserialize the response
 969        /// </exception>
 970        /// <exception cref="ValidationException">
 971        /// Thrown when a required parameter is null
 972        /// </exception>
 973        /// <exception cref="System.ArgumentNullException">
 974        /// Thrown when a required parameter is null
 975        /// </exception>
 976        /// <return>
 977        /// A response object containing the response body and response headers.
 978        /// </return>
 979        public async Task<AzureOperationResponse<IPage<DirectoryObject>>> ListOwnersWithHttpMessagesAsync(string applica
 980        {
 0981            if (applicationObjectId == null)
 982            {
 0983                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 984            }
 0985            if (Client.ApiVersion == null)
 986            {
 0987                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 988            }
 0989            if (Client.TenantID == null)
 990            {
 0991                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 992            }
 993            // Tracing
 0994            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0995            string _invocationId = null;
 0996            if (_shouldTrace)
 997            {
 0998                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0999                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01000                tracingParameters.Add("applicationObjectId", applicationObjectId);
 01001                tracingParameters.Add("cancellationToken", cancellationToken);
 01002                ServiceClientTracing.Enter(_invocationId, this, "ListOwners", tracingParameters);
 1003            }
 1004            // Construct URL
 01005            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01006            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 01007            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 01008            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01009            List<string> _queryParameters = new List<string>();
 01010            if (Client.ApiVersion != null)
 1011            {
 01012                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1013            }
 01014            if (_queryParameters.Count > 0)
 1015            {
 01016                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1017            }
 1018            // Create HTTP transport objects
 01019            var _httpRequest = new HttpRequestMessage();
 01020            HttpResponseMessage _httpResponse = null;
 01021            _httpRequest.Method = new HttpMethod("GET");
 01022            _httpRequest.RequestUri = new System.Uri(_url);
 1023            // Set Headers
 01024            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1025            {
 01026                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1027            }
 01028            if (Client.AcceptLanguage != null)
 1029            {
 01030                if (_httpRequest.Headers.Contains("accept-language"))
 1031                {
 01032                    _httpRequest.Headers.Remove("accept-language");
 1033                }
 01034                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1035            }
 1036
 1037
 01038            if (customHeaders != null)
 1039            {
 01040                foreach(var _header in customHeaders)
 1041                {
 01042                    if (_httpRequest.Headers.Contains(_header.Key))
 1043                    {
 01044                        _httpRequest.Headers.Remove(_header.Key);
 1045                    }
 01046                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1047                }
 1048            }
 1049
 1050            // Serialize Request
 01051            string _requestContent = null;
 1052            // Set Credentials
 01053            if (Client.Credentials != null)
 1054            {
 01055                cancellationToken.ThrowIfCancellationRequested();
 01056                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1057            }
 1058            // Send Request
 01059            if (_shouldTrace)
 1060            {
 01061                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1062            }
 01063            cancellationToken.ThrowIfCancellationRequested();
 01064            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01065            if (_shouldTrace)
 1066            {
 01067                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1068            }
 01069            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01070            cancellationToken.ThrowIfCancellationRequested();
 01071            string _responseContent = null;
 01072            if ((int)_statusCode != 200)
 1073            {
 01074                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1075                try
 1076                {
 01077                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01078                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01079                    if (_errorBody != null)
 1080                    {
 01081                        ex.Body = _errorBody;
 1082                    }
 01083                }
 01084                catch (JsonException)
 1085                {
 1086                    // Ignore the exception
 01087                }
 01088                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01089                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01090                if (_shouldTrace)
 1091                {
 01092                    ServiceClientTracing.Error(_invocationId, ex);
 1093                }
 01094                _httpRequest.Dispose();
 01095                if (_httpResponse != null)
 1096                {
 01097                    _httpResponse.Dispose();
 1098                }
 01099                throw ex;
 1100            }
 1101            // Create Result
 01102            var _result = new AzureOperationResponse<IPage<DirectoryObject>>();
 01103            _result.Request = _httpRequest;
 01104            _result.Response = _httpResponse;
 01105            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1106            {
 01107                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1108            }
 1109            // Deserialize Response
 01110            if ((int)_statusCode == 200)
 1111            {
 01112                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1113                try
 1114                {
 01115                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response
 01116                }
 01117                catch (JsonException ex)
 1118                {
 01119                    _httpRequest.Dispose();
 01120                    if (_httpResponse != null)
 1121                    {
 01122                        _httpResponse.Dispose();
 1123                    }
 01124                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1125                }
 1126            }
 01127            if (_shouldTrace)
 1128            {
 01129                ServiceClientTracing.Exit(_invocationId, _result);
 1130            }
 01131            return _result;
 01132        }
 1133
 1134        /// <summary>
 1135        /// Add an owner to an application.
 1136        /// </summary>
 1137        /// <param name='applicationObjectId'>
 1138        /// The object ID of the application to which to add the owner.
 1139        /// </param>
 1140        /// <param name='parameters'>
 1141        /// The URL of the owner object, such as
 1142        /// https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b
 1143        /// </param>
 1144        /// <param name='customHeaders'>
 1145        /// Headers that will be added to request.
 1146        /// </param>
 1147        /// <param name='cancellationToken'>
 1148        /// The cancellation token.
 1149        /// </param>
 1150        /// <exception cref="GraphErrorException">
 1151        /// Thrown when the operation returned an invalid status code
 1152        /// </exception>
 1153        /// <exception cref="ValidationException">
 1154        /// Thrown when a required parameter is null
 1155        /// </exception>
 1156        /// <exception cref="System.ArgumentNullException">
 1157        /// Thrown when a required parameter is null
 1158        /// </exception>
 1159        /// <return>
 1160        /// A response object containing the response body and response headers.
 1161        /// </return>
 1162        public async Task<AzureOperationResponse> AddOwnerWithHttpMessagesAsync(string applicationObjectId, AddOwnerPara
 1163        {
 01164            if (applicationObjectId == null)
 1165            {
 01166                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 1167            }
 01168            if (parameters == null)
 1169            {
 01170                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 1171            }
 01172            if (parameters != null)
 1173            {
 01174                parameters.Validate();
 1175            }
 01176            if (Client.ApiVersion == null)
 1177            {
 01178                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1179            }
 01180            if (Client.TenantID == null)
 1181            {
 01182                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1183            }
 1184            // Tracing
 01185            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01186            string _invocationId = null;
 01187            if (_shouldTrace)
 1188            {
 01189                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01190                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01191                tracingParameters.Add("applicationObjectId", applicationObjectId);
 01192                tracingParameters.Add("parameters", parameters);
 01193                tracingParameters.Add("cancellationToken", cancellationToken);
 01194                ServiceClientTracing.Enter(_invocationId, this, "AddOwner", tracingParameters);
 1195            }
 1196            // Construct URL
 01197            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01198            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 01199            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 01200            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01201            List<string> _queryParameters = new List<string>();
 01202            if (Client.ApiVersion != null)
 1203            {
 01204                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1205            }
 01206            if (_queryParameters.Count > 0)
 1207            {
 01208                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1209            }
 1210            // Create HTTP transport objects
 01211            var _httpRequest = new HttpRequestMessage();
 01212            HttpResponseMessage _httpResponse = null;
 01213            _httpRequest.Method = new HttpMethod("POST");
 01214            _httpRequest.RequestUri = new System.Uri(_url);
 1215            // Set Headers
 01216            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1217            {
 01218                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1219            }
 01220            if (Client.AcceptLanguage != null)
 1221            {
 01222                if (_httpRequest.Headers.Contains("accept-language"))
 1223                {
 01224                    _httpRequest.Headers.Remove("accept-language");
 1225                }
 01226                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1227            }
 1228
 1229
 01230            if (customHeaders != null)
 1231            {
 01232                foreach(var _header in customHeaders)
 1233                {
 01234                    if (_httpRequest.Headers.Contains(_header.Key))
 1235                    {
 01236                        _httpRequest.Headers.Remove(_header.Key);
 1237                    }
 01238                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1239                }
 1240            }
 1241
 1242            // Serialize Request
 01243            string _requestContent = null;
 01244            if(parameters != null)
 1245            {
 01246                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 01247                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01248                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1249            }
 1250            // Set Credentials
 01251            if (Client.Credentials != null)
 1252            {
 01253                cancellationToken.ThrowIfCancellationRequested();
 01254                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1255            }
 1256            // Send Request
 01257            if (_shouldTrace)
 1258            {
 01259                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1260            }
 01261            cancellationToken.ThrowIfCancellationRequested();
 01262            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01263            if (_shouldTrace)
 1264            {
 01265                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1266            }
 01267            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01268            cancellationToken.ThrowIfCancellationRequested();
 01269            string _responseContent = null;
 01270            if ((int)_statusCode != 204)
 1271            {
 01272                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1273                try
 1274                {
 01275                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01276                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01277                    if (_errorBody != null)
 1278                    {
 01279                        ex.Body = _errorBody;
 1280                    }
 01281                }
 01282                catch (JsonException)
 1283                {
 1284                    // Ignore the exception
 01285                }
 01286                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01287                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01288                if (_shouldTrace)
 1289                {
 01290                    ServiceClientTracing.Error(_invocationId, ex);
 1291                }
 01292                _httpRequest.Dispose();
 01293                if (_httpResponse != null)
 1294                {
 01295                    _httpResponse.Dispose();
 1296                }
 01297                throw ex;
 1298            }
 1299            // Create Result
 01300            var _result = new AzureOperationResponse();
 01301            _result.Request = _httpRequest;
 01302            _result.Response = _httpResponse;
 01303            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1304            {
 01305                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1306            }
 01307            if (_shouldTrace)
 1308            {
 01309                ServiceClientTracing.Exit(_invocationId, _result);
 1310            }
 01311            return _result;
 01312        }
 1313
 1314        /// <summary>
 1315        /// Remove a member from owners.
 1316        /// </summary>
 1317        /// <param name='applicationObjectId'>
 1318        /// The object ID of the application from which to remove the owner.
 1319        /// </param>
 1320        /// <param name='ownerObjectId'>
 1321        /// Owner object id
 1322        /// </param>
 1323        /// <param name='customHeaders'>
 1324        /// Headers that will be added to request.
 1325        /// </param>
 1326        /// <param name='cancellationToken'>
 1327        /// The cancellation token.
 1328        /// </param>
 1329        /// <exception cref="GraphErrorException">
 1330        /// Thrown when the operation returned an invalid status code
 1331        /// </exception>
 1332        /// <exception cref="ValidationException">
 1333        /// Thrown when a required parameter is null
 1334        /// </exception>
 1335        /// <exception cref="System.ArgumentNullException">
 1336        /// Thrown when a required parameter is null
 1337        /// </exception>
 1338        /// <return>
 1339        /// A response object containing the response body and response headers.
 1340        /// </return>
 1341        public async Task<AzureOperationResponse> RemoveOwnerWithHttpMessagesAsync(string applicationObjectId, string ow
 1342        {
 01343            if (applicationObjectId == null)
 1344            {
 01345                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 1346            }
 01347            if (ownerObjectId == null)
 1348            {
 01349                throw new ValidationException(ValidationRules.CannotBeNull, "ownerObjectId");
 1350            }
 01351            if (Client.ApiVersion == null)
 1352            {
 01353                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1354            }
 01355            if (Client.TenantID == null)
 1356            {
 01357                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1358            }
 1359            // Tracing
 01360            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01361            string _invocationId = null;
 01362            if (_shouldTrace)
 1363            {
 01364                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01365                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01366                tracingParameters.Add("applicationObjectId", applicationObjectId);
 01367                tracingParameters.Add("ownerObjectId", ownerObjectId);
 01368                tracingParameters.Add("cancellationToken", cancellationToken);
 01369                ServiceClientTracing.Enter(_invocationId, this, "RemoveOwner", tracingParameters);
 1370            }
 1371            // Construct URL
 01372            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01373            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 01374            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 01375            _url = _url.Replace("{ownerObjectId}", System.Uri.EscapeDataString(ownerObjectId));
 01376            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01377            List<string> _queryParameters = new List<string>();
 01378            if (Client.ApiVersion != null)
 1379            {
 01380                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1381            }
 01382            if (_queryParameters.Count > 0)
 1383            {
 01384                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1385            }
 1386            // Create HTTP transport objects
 01387            var _httpRequest = new HttpRequestMessage();
 01388            HttpResponseMessage _httpResponse = null;
 01389            _httpRequest.Method = new HttpMethod("DELETE");
 01390            _httpRequest.RequestUri = new System.Uri(_url);
 1391            // Set Headers
 01392            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1393            {
 01394                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1395            }
 01396            if (Client.AcceptLanguage != null)
 1397            {
 01398                if (_httpRequest.Headers.Contains("accept-language"))
 1399                {
 01400                    _httpRequest.Headers.Remove("accept-language");
 1401                }
 01402                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1403            }
 1404
 1405
 01406            if (customHeaders != null)
 1407            {
 01408                foreach(var _header in customHeaders)
 1409                {
 01410                    if (_httpRequest.Headers.Contains(_header.Key))
 1411                    {
 01412                        _httpRequest.Headers.Remove(_header.Key);
 1413                    }
 01414                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1415                }
 1416            }
 1417
 1418            // Serialize Request
 01419            string _requestContent = null;
 1420            // Set Credentials
 01421            if (Client.Credentials != null)
 1422            {
 01423                cancellationToken.ThrowIfCancellationRequested();
 01424                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1425            }
 1426            // Send Request
 01427            if (_shouldTrace)
 1428            {
 01429                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1430            }
 01431            cancellationToken.ThrowIfCancellationRequested();
 01432            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01433            if (_shouldTrace)
 1434            {
 01435                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1436            }
 01437            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01438            cancellationToken.ThrowIfCancellationRequested();
 01439            string _responseContent = null;
 01440            if ((int)_statusCode != 204)
 1441            {
 01442                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1443                try
 1444                {
 01445                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01446                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01447                    if (_errorBody != null)
 1448                    {
 01449                        ex.Body = _errorBody;
 1450                    }
 01451                }
 01452                catch (JsonException)
 1453                {
 1454                    // Ignore the exception
 01455                }
 01456                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01457                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01458                if (_shouldTrace)
 1459                {
 01460                    ServiceClientTracing.Error(_invocationId, ex);
 1461                }
 01462                _httpRequest.Dispose();
 01463                if (_httpResponse != null)
 1464                {
 01465                    _httpResponse.Dispose();
 1466                }
 01467                throw ex;
 1468            }
 1469            // Create Result
 01470            var _result = new AzureOperationResponse();
 01471            _result.Request = _httpRequest;
 01472            _result.Response = _httpResponse;
 01473            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1474            {
 01475                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1476            }
 01477            if (_shouldTrace)
 1478            {
 01479                ServiceClientTracing.Exit(_invocationId, _result);
 1480            }
 01481            return _result;
 01482        }
 1483
 1484        /// <summary>
 1485        /// Get the keyCredentials associated with an application.
 1486        /// </summary>
 1487        /// <param name='applicationObjectId'>
 1488        /// Application object ID.
 1489        /// </param>
 1490        /// <param name='customHeaders'>
 1491        /// Headers that will be added to request.
 1492        /// </param>
 1493        /// <param name='cancellationToken'>
 1494        /// The cancellation token.
 1495        /// </param>
 1496        /// <exception cref="GraphErrorException">
 1497        /// Thrown when the operation returned an invalid status code
 1498        /// </exception>
 1499        /// <exception cref="SerializationException">
 1500        /// Thrown when unable to deserialize the response
 1501        /// </exception>
 1502        /// <exception cref="ValidationException">
 1503        /// Thrown when a required parameter is null
 1504        /// </exception>
 1505        /// <exception cref="System.ArgumentNullException">
 1506        /// Thrown when a required parameter is null
 1507        /// </exception>
 1508        /// <return>
 1509        /// A response object containing the response body and response headers.
 1510        /// </return>
 1511        public async Task<AzureOperationResponse<IEnumerable<KeyCredential>>> ListKeyCredentialsWithHttpMessagesAsync(st
 1512        {
 01513            if (applicationObjectId == null)
 1514            {
 01515                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 1516            }
 01517            if (Client.ApiVersion == null)
 1518            {
 01519                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1520            }
 01521            if (Client.TenantID == null)
 1522            {
 01523                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1524            }
 1525            // Tracing
 01526            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01527            string _invocationId = null;
 01528            if (_shouldTrace)
 1529            {
 01530                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01531                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01532                tracingParameters.Add("applicationObjectId", applicationObjectId);
 01533                tracingParameters.Add("cancellationToken", cancellationToken);
 01534                ServiceClientTracing.Enter(_invocationId, this, "ListKeyCredentials", tracingParameters);
 1535            }
 1536            // Construct URL
 01537            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01538            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 01539            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 01540            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01541            List<string> _queryParameters = new List<string>();
 01542            if (Client.ApiVersion != null)
 1543            {
 01544                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1545            }
 01546            if (_queryParameters.Count > 0)
 1547            {
 01548                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1549            }
 1550            // Create HTTP transport objects
 01551            var _httpRequest = new HttpRequestMessage();
 01552            HttpResponseMessage _httpResponse = null;
 01553            _httpRequest.Method = new HttpMethod("GET");
 01554            _httpRequest.RequestUri = new System.Uri(_url);
 1555            // Set Headers
 01556            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1557            {
 01558                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1559            }
 01560            if (Client.AcceptLanguage != null)
 1561            {
 01562                if (_httpRequest.Headers.Contains("accept-language"))
 1563                {
 01564                    _httpRequest.Headers.Remove("accept-language");
 1565                }
 01566                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1567            }
 1568
 1569
 01570            if (customHeaders != null)
 1571            {
 01572                foreach(var _header in customHeaders)
 1573                {
 01574                    if (_httpRequest.Headers.Contains(_header.Key))
 1575                    {
 01576                        _httpRequest.Headers.Remove(_header.Key);
 1577                    }
 01578                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1579                }
 1580            }
 1581
 1582            // Serialize Request
 01583            string _requestContent = null;
 1584            // Set Credentials
 01585            if (Client.Credentials != null)
 1586            {
 01587                cancellationToken.ThrowIfCancellationRequested();
 01588                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1589            }
 1590            // Send Request
 01591            if (_shouldTrace)
 1592            {
 01593                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1594            }
 01595            cancellationToken.ThrowIfCancellationRequested();
 01596            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01597            if (_shouldTrace)
 1598            {
 01599                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1600            }
 01601            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01602            cancellationToken.ThrowIfCancellationRequested();
 01603            string _responseContent = null;
 01604            if ((int)_statusCode != 200)
 1605            {
 01606                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1607                try
 1608                {
 01609                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01610                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01611                    if (_errorBody != null)
 1612                    {
 01613                        ex.Body = _errorBody;
 1614                    }
 01615                }
 01616                catch (JsonException)
 1617                {
 1618                    // Ignore the exception
 01619                }
 01620                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01621                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01622                if (_shouldTrace)
 1623                {
 01624                    ServiceClientTracing.Error(_invocationId, ex);
 1625                }
 01626                _httpRequest.Dispose();
 01627                if (_httpResponse != null)
 1628                {
 01629                    _httpResponse.Dispose();
 1630                }
 01631                throw ex;
 1632            }
 1633            // Create Result
 01634            var _result = new AzureOperationResponse<IEnumerable<KeyCredential>>();
 01635            _result.Request = _httpRequest;
 01636            _result.Response = _httpResponse;
 01637            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1638            {
 01639                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1640            }
 1641            // Deserialize Response
 01642            if ((int)_statusCode == 200)
 1643            {
 01644                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1645                try
 1646                {
 01647                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<KeyCredential>>(_responseC
 01648                }
 01649                catch (JsonException ex)
 1650                {
 01651                    _httpRequest.Dispose();
 01652                    if (_httpResponse != null)
 1653                    {
 01654                        _httpResponse.Dispose();
 1655                    }
 01656                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1657                }
 1658            }
 01659            if (_shouldTrace)
 1660            {
 01661                ServiceClientTracing.Exit(_invocationId, _result);
 1662            }
 01663            return _result;
 01664        }
 1665
 1666        /// <summary>
 1667        /// Update the keyCredentials associated with an application.
 1668        /// </summary>
 1669        /// <param name='applicationObjectId'>
 1670        /// Application object ID.
 1671        /// </param>
 1672        /// <param name='parameters'>
 1673        /// Parameters to update the keyCredentials of an existing application.
 1674        /// </param>
 1675        /// <param name='customHeaders'>
 1676        /// Headers that will be added to request.
 1677        /// </param>
 1678        /// <param name='cancellationToken'>
 1679        /// The cancellation token.
 1680        /// </param>
 1681        /// <exception cref="GraphErrorException">
 1682        /// Thrown when the operation returned an invalid status code
 1683        /// </exception>
 1684        /// <exception cref="ValidationException">
 1685        /// Thrown when a required parameter is null
 1686        /// </exception>
 1687        /// <exception cref="System.ArgumentNullException">
 1688        /// Thrown when a required parameter is null
 1689        /// </exception>
 1690        /// <return>
 1691        /// A response object containing the response body and response headers.
 1692        /// </return>
 1693        public async Task<AzureOperationResponse> UpdateKeyCredentialsWithHttpMessagesAsync(string applicationObjectId, 
 1694        {
 01695            if (applicationObjectId == null)
 1696            {
 01697                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 1698            }
 01699            if (parameters == null)
 1700            {
 01701                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 1702            }
 01703            if (Client.ApiVersion == null)
 1704            {
 01705                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1706            }
 01707            if (Client.TenantID == null)
 1708            {
 01709                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1710            }
 1711            // Tracing
 01712            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01713            string _invocationId = null;
 01714            if (_shouldTrace)
 1715            {
 01716                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01717                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01718                tracingParameters.Add("applicationObjectId", applicationObjectId);
 01719                tracingParameters.Add("parameters", parameters);
 01720                tracingParameters.Add("cancellationToken", cancellationToken);
 01721                ServiceClientTracing.Enter(_invocationId, this, "UpdateKeyCredentials", tracingParameters);
 1722            }
 1723            // Construct URL
 01724            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01725            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 01726            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 01727            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01728            List<string> _queryParameters = new List<string>();
 01729            if (Client.ApiVersion != null)
 1730            {
 01731                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1732            }
 01733            if (_queryParameters.Count > 0)
 1734            {
 01735                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1736            }
 1737            // Create HTTP transport objects
 01738            var _httpRequest = new HttpRequestMessage();
 01739            HttpResponseMessage _httpResponse = null;
 01740            _httpRequest.Method = new HttpMethod("PATCH");
 01741            _httpRequest.RequestUri = new System.Uri(_url);
 1742            // Set Headers
 01743            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1744            {
 01745                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1746            }
 01747            if (Client.AcceptLanguage != null)
 1748            {
 01749                if (_httpRequest.Headers.Contains("accept-language"))
 1750                {
 01751                    _httpRequest.Headers.Remove("accept-language");
 1752                }
 01753                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1754            }
 1755
 1756
 01757            if (customHeaders != null)
 1758            {
 01759                foreach(var _header in customHeaders)
 1760                {
 01761                    if (_httpRequest.Headers.Contains(_header.Key))
 1762                    {
 01763                        _httpRequest.Headers.Remove(_header.Key);
 1764                    }
 01765                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1766                }
 1767            }
 1768
 1769            // Serialize Request
 01770            string _requestContent = null;
 01771            if(parameters != null)
 1772            {
 01773                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 01774                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01775                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1776            }
 1777            // Set Credentials
 01778            if (Client.Credentials != null)
 1779            {
 01780                cancellationToken.ThrowIfCancellationRequested();
 01781                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1782            }
 1783            // Send Request
 01784            if (_shouldTrace)
 1785            {
 01786                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1787            }
 01788            cancellationToken.ThrowIfCancellationRequested();
 01789            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01790            if (_shouldTrace)
 1791            {
 01792                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1793            }
 01794            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01795            cancellationToken.ThrowIfCancellationRequested();
 01796            string _responseContent = null;
 01797            if ((int)_statusCode != 204)
 1798            {
 01799                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1800                try
 1801                {
 01802                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01803                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01804                    if (_errorBody != null)
 1805                    {
 01806                        ex.Body = _errorBody;
 1807                    }
 01808                }
 01809                catch (JsonException)
 1810                {
 1811                    // Ignore the exception
 01812                }
 01813                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01814                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01815                if (_shouldTrace)
 1816                {
 01817                    ServiceClientTracing.Error(_invocationId, ex);
 1818                }
 01819                _httpRequest.Dispose();
 01820                if (_httpResponse != null)
 1821                {
 01822                    _httpResponse.Dispose();
 1823                }
 01824                throw ex;
 1825            }
 1826            // Create Result
 01827            var _result = new AzureOperationResponse();
 01828            _result.Request = _httpRequest;
 01829            _result.Response = _httpResponse;
 01830            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1831            {
 01832                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1833            }
 01834            if (_shouldTrace)
 1835            {
 01836                ServiceClientTracing.Exit(_invocationId, _result);
 1837            }
 01838            return _result;
 01839        }
 1840
 1841        /// <summary>
 1842        /// Get the passwordCredentials associated with an application.
 1843        /// </summary>
 1844        /// <param name='applicationObjectId'>
 1845        /// Application object ID.
 1846        /// </param>
 1847        /// <param name='customHeaders'>
 1848        /// Headers that will be added to request.
 1849        /// </param>
 1850        /// <param name='cancellationToken'>
 1851        /// The cancellation token.
 1852        /// </param>
 1853        /// <exception cref="GraphErrorException">
 1854        /// Thrown when the operation returned an invalid status code
 1855        /// </exception>
 1856        /// <exception cref="SerializationException">
 1857        /// Thrown when unable to deserialize the response
 1858        /// </exception>
 1859        /// <exception cref="ValidationException">
 1860        /// Thrown when a required parameter is null
 1861        /// </exception>
 1862        /// <exception cref="System.ArgumentNullException">
 1863        /// Thrown when a required parameter is null
 1864        /// </exception>
 1865        /// <return>
 1866        /// A response object containing the response body and response headers.
 1867        /// </return>
 1868        public async Task<AzureOperationResponse<IEnumerable<PasswordCredential>>> ListPasswordCredentialsWithHttpMessag
 1869        {
 01870            if (applicationObjectId == null)
 1871            {
 01872                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 1873            }
 01874            if (Client.ApiVersion == null)
 1875            {
 01876                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1877            }
 01878            if (Client.TenantID == null)
 1879            {
 01880                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 1881            }
 1882            // Tracing
 01883            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01884            string _invocationId = null;
 01885            if (_shouldTrace)
 1886            {
 01887                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01888                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01889                tracingParameters.Add("applicationObjectId", applicationObjectId);
 01890                tracingParameters.Add("cancellationToken", cancellationToken);
 01891                ServiceClientTracing.Enter(_invocationId, this, "ListPasswordCredentials", tracingParameters);
 1892            }
 1893            // Construct URL
 01894            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01895            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 01896            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 01897            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 01898            List<string> _queryParameters = new List<string>();
 01899            if (Client.ApiVersion != null)
 1900            {
 01901                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1902            }
 01903            if (_queryParameters.Count > 0)
 1904            {
 01905                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1906            }
 1907            // Create HTTP transport objects
 01908            var _httpRequest = new HttpRequestMessage();
 01909            HttpResponseMessage _httpResponse = null;
 01910            _httpRequest.Method = new HttpMethod("GET");
 01911            _httpRequest.RequestUri = new System.Uri(_url);
 1912            // Set Headers
 01913            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1914            {
 01915                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1916            }
 01917            if (Client.AcceptLanguage != null)
 1918            {
 01919                if (_httpRequest.Headers.Contains("accept-language"))
 1920                {
 01921                    _httpRequest.Headers.Remove("accept-language");
 1922                }
 01923                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1924            }
 1925
 1926
 01927            if (customHeaders != null)
 1928            {
 01929                foreach(var _header in customHeaders)
 1930                {
 01931                    if (_httpRequest.Headers.Contains(_header.Key))
 1932                    {
 01933                        _httpRequest.Headers.Remove(_header.Key);
 1934                    }
 01935                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1936                }
 1937            }
 1938
 1939            // Serialize Request
 01940            string _requestContent = null;
 1941            // Set Credentials
 01942            if (Client.Credentials != null)
 1943            {
 01944                cancellationToken.ThrowIfCancellationRequested();
 01945                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1946            }
 1947            // Send Request
 01948            if (_shouldTrace)
 1949            {
 01950                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1951            }
 01952            cancellationToken.ThrowIfCancellationRequested();
 01953            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01954            if (_shouldTrace)
 1955            {
 01956                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1957            }
 01958            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01959            cancellationToken.ThrowIfCancellationRequested();
 01960            string _responseContent = null;
 01961            if ((int)_statusCode != 200)
 1962            {
 01963                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 1964                try
 1965                {
 01966                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01967                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 01968                    if (_errorBody != null)
 1969                    {
 01970                        ex.Body = _errorBody;
 1971                    }
 01972                }
 01973                catch (JsonException)
 1974                {
 1975                    // Ignore the exception
 01976                }
 01977                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01978                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01979                if (_shouldTrace)
 1980                {
 01981                    ServiceClientTracing.Error(_invocationId, ex);
 1982                }
 01983                _httpRequest.Dispose();
 01984                if (_httpResponse != null)
 1985                {
 01986                    _httpResponse.Dispose();
 1987                }
 01988                throw ex;
 1989            }
 1990            // Create Result
 01991            var _result = new AzureOperationResponse<IEnumerable<PasswordCredential>>();
 01992            _result.Request = _httpRequest;
 01993            _result.Response = _httpResponse;
 01994            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1995            {
 01996                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1997            }
 1998            // Deserialize Response
 01999            if ((int)_statusCode == 200)
 2000            {
 02001                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2002                try
 2003                {
 02004                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<PasswordCredential>>(_resp
 02005                }
 02006                catch (JsonException ex)
 2007                {
 02008                    _httpRequest.Dispose();
 02009                    if (_httpResponse != null)
 2010                    {
 02011                        _httpResponse.Dispose();
 2012                    }
 02013                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2014                }
 2015            }
 02016            if (_shouldTrace)
 2017            {
 02018                ServiceClientTracing.Exit(_invocationId, _result);
 2019            }
 02020            return _result;
 02021        }
 2022
 2023        /// <summary>
 2024        /// Update passwordCredentials associated with an application.
 2025        /// </summary>
 2026        /// <param name='applicationObjectId'>
 2027        /// Application object ID.
 2028        /// </param>
 2029        /// <param name='parameters'>
 2030        /// Parameters to update passwordCredentials of an existing application.
 2031        /// </param>
 2032        /// <param name='customHeaders'>
 2033        /// Headers that will be added to request.
 2034        /// </param>
 2035        /// <param name='cancellationToken'>
 2036        /// The cancellation token.
 2037        /// </param>
 2038        /// <exception cref="GraphErrorException">
 2039        /// Thrown when the operation returned an invalid status code
 2040        /// </exception>
 2041        /// <exception cref="ValidationException">
 2042        /// Thrown when a required parameter is null
 2043        /// </exception>
 2044        /// <exception cref="System.ArgumentNullException">
 2045        /// Thrown when a required parameter is null
 2046        /// </exception>
 2047        /// <return>
 2048        /// A response object containing the response body and response headers.
 2049        /// </return>
 2050        public async Task<AzureOperationResponse> UpdatePasswordCredentialsWithHttpMessagesAsync(string applicationObjec
 2051        {
 02052            if (applicationObjectId == null)
 2053            {
 02054                throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId");
 2055            }
 02056            if (parameters == null)
 2057            {
 02058                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 2059            }
 02060            if (Client.ApiVersion == null)
 2061            {
 02062                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2063            }
 02064            if (Client.TenantID == null)
 2065            {
 02066                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 2067            }
 2068            // Tracing
 02069            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02070            string _invocationId = null;
 02071            if (_shouldTrace)
 2072            {
 02073                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02074                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02075                tracingParameters.Add("applicationObjectId", applicationObjectId);
 02076                tracingParameters.Add("parameters", parameters);
 02077                tracingParameters.Add("cancellationToken", cancellationToken);
 02078                ServiceClientTracing.Enter(_invocationId, this, "UpdatePasswordCredentials", tracingParameters);
 2079            }
 2080            // Construct URL
 02081            var _baseUrl = Client.BaseUri.AbsoluteUri;
 02082            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/applic
 02083            _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId));
 02084            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 02085            List<string> _queryParameters = new List<string>();
 02086            if (Client.ApiVersion != null)
 2087            {
 02088                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2089            }
 02090            if (_queryParameters.Count > 0)
 2091            {
 02092                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2093            }
 2094            // Create HTTP transport objects
 02095            var _httpRequest = new HttpRequestMessage();
 02096            HttpResponseMessage _httpResponse = null;
 02097            _httpRequest.Method = new HttpMethod("PATCH");
 02098            _httpRequest.RequestUri = new System.Uri(_url);
 2099            // Set Headers
 02100            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2101            {
 02102                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 2103            }
 02104            if (Client.AcceptLanguage != null)
 2105            {
 02106                if (_httpRequest.Headers.Contains("accept-language"))
 2107                {
 02108                    _httpRequest.Headers.Remove("accept-language");
 2109                }
 02110                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2111            }
 2112
 2113
 02114            if (customHeaders != null)
 2115            {
 02116                foreach(var _header in customHeaders)
 2117                {
 02118                    if (_httpRequest.Headers.Contains(_header.Key))
 2119                    {
 02120                        _httpRequest.Headers.Remove(_header.Key);
 2121                    }
 02122                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2123                }
 2124            }
 2125
 2126            // Serialize Request
 02127            string _requestContent = null;
 02128            if(parameters != null)
 2129            {
 02130                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 02131                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 02132                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 2133            }
 2134            // Set Credentials
 02135            if (Client.Credentials != null)
 2136            {
 02137                cancellationToken.ThrowIfCancellationRequested();
 02138                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2139            }
 2140            // Send Request
 02141            if (_shouldTrace)
 2142            {
 02143                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2144            }
 02145            cancellationToken.ThrowIfCancellationRequested();
 02146            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02147            if (_shouldTrace)
 2148            {
 02149                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2150            }
 02151            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02152            cancellationToken.ThrowIfCancellationRequested();
 02153            string _responseContent = null;
 02154            if ((int)_statusCode != 204)
 2155            {
 02156                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2157                try
 2158                {
 02159                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02160                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 02161                    if (_errorBody != null)
 2162                    {
 02163                        ex.Body = _errorBody;
 2164                    }
 02165                }
 02166                catch (JsonException)
 2167                {
 2168                    // Ignore the exception
 02169                }
 02170                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02171                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02172                if (_shouldTrace)
 2173                {
 02174                    ServiceClientTracing.Error(_invocationId, ex);
 2175                }
 02176                _httpRequest.Dispose();
 02177                if (_httpResponse != null)
 2178                {
 02179                    _httpResponse.Dispose();
 2180                }
 02181                throw ex;
 2182            }
 2183            // Create Result
 02184            var _result = new AzureOperationResponse();
 02185            _result.Request = _httpRequest;
 02186            _result.Response = _httpResponse;
 02187            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 2188            {
 02189                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 2190            }
 02191            if (_shouldTrace)
 2192            {
 02193                ServiceClientTracing.Exit(_invocationId, _result);
 2194            }
 02195            return _result;
 02196        }
 2197
 2198        /// <summary>
 2199        /// Gets an object id for a given application id from the current tenant.
 2200        /// </summary>
 2201        /// <param name='applicationID'>
 2202        /// The application ID.
 2203        /// </param>
 2204        /// <param name='customHeaders'>
 2205        /// Headers that will be added to request.
 2206        /// </param>
 2207        /// <param name='cancellationToken'>
 2208        /// The cancellation token.
 2209        /// </param>
 2210        /// <exception cref="GraphErrorException">
 2211        /// Thrown when the operation returned an invalid status code
 2212        /// </exception>
 2213        /// <exception cref="SerializationException">
 2214        /// Thrown when unable to deserialize the response
 2215        /// </exception>
 2216        /// <exception cref="ValidationException">
 2217        /// Thrown when a required parameter is null
 2218        /// </exception>
 2219        /// <exception cref="System.ArgumentNullException">
 2220        /// Thrown when a required parameter is null
 2221        /// </exception>
 2222        /// <return>
 2223        /// A response object containing the response body and response headers.
 2224        /// </return>
 2225        public async Task<AzureOperationResponse<ServicePrincipalObjectResult>> GetServicePrincipalsIdByAppIdWithHttpMes
 2226        {
 02227            if (Client.ApiVersion == null)
 2228            {
 02229                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2230            }
 02231            if (Client.TenantID == null)
 2232            {
 02233                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 2234            }
 02235            if (applicationID == null)
 2236            {
 02237                throw new ValidationException(ValidationRules.CannotBeNull, "applicationID");
 2238            }
 2239            // Tracing
 02240            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02241            string _invocationId = null;
 02242            if (_shouldTrace)
 2243            {
 02244                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02245                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02246                tracingParameters.Add("applicationID", applicationID);
 02247                tracingParameters.Add("cancellationToken", cancellationToken);
 02248                ServiceClientTracing.Enter(_invocationId, this, "GetServicePrincipalsIdByAppId", tracingParameters);
 2249            }
 2250            // Construct URL
 02251            var _baseUrl = Client.BaseUri.AbsoluteUri;
 02252            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/servic
 02253            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 02254            _url = _url.Replace("{applicationID}", System.Uri.EscapeDataString(applicationID));
 02255            List<string> _queryParameters = new List<string>();
 02256            if (Client.ApiVersion != null)
 2257            {
 02258                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2259            }
 02260            if (_queryParameters.Count > 0)
 2261            {
 02262                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2263            }
 2264            // Create HTTP transport objects
 02265            var _httpRequest = new HttpRequestMessage();
 02266            HttpResponseMessage _httpResponse = null;
 02267            _httpRequest.Method = new HttpMethod("GET");
 02268            _httpRequest.RequestUri = new System.Uri(_url);
 2269            // Set Headers
 02270            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2271            {
 02272                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 2273            }
 02274            if (Client.AcceptLanguage != null)
 2275            {
 02276                if (_httpRequest.Headers.Contains("accept-language"))
 2277                {
 02278                    _httpRequest.Headers.Remove("accept-language");
 2279                }
 02280                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2281            }
 2282
 2283
 02284            if (customHeaders != null)
 2285            {
 02286                foreach(var _header in customHeaders)
 2287                {
 02288                    if (_httpRequest.Headers.Contains(_header.Key))
 2289                    {
 02290                        _httpRequest.Headers.Remove(_header.Key);
 2291                    }
 02292                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2293                }
 2294            }
 2295
 2296            // Serialize Request
 02297            string _requestContent = null;
 2298            // Set Credentials
 02299            if (Client.Credentials != null)
 2300            {
 02301                cancellationToken.ThrowIfCancellationRequested();
 02302                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2303            }
 2304            // Send Request
 02305            if (_shouldTrace)
 2306            {
 02307                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2308            }
 02309            cancellationToken.ThrowIfCancellationRequested();
 02310            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02311            if (_shouldTrace)
 2312            {
 02313                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2314            }
 02315            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02316            cancellationToken.ThrowIfCancellationRequested();
 02317            string _responseContent = null;
 02318            if ((int)_statusCode != 200)
 2319            {
 02320                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2321                try
 2322                {
 02323                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02324                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 02325                    if (_errorBody != null)
 2326                    {
 02327                        ex.Body = _errorBody;
 2328                    }
 02329                }
 02330                catch (JsonException)
 2331                {
 2332                    // Ignore the exception
 02333                }
 02334                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02335                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02336                if (_shouldTrace)
 2337                {
 02338                    ServiceClientTracing.Error(_invocationId, ex);
 2339                }
 02340                _httpRequest.Dispose();
 02341                if (_httpResponse != null)
 2342                {
 02343                    _httpResponse.Dispose();
 2344                }
 02345                throw ex;
 2346            }
 2347            // Create Result
 02348            var _result = new AzureOperationResponse<ServicePrincipalObjectResult>();
 02349            _result.Request = _httpRequest;
 02350            _result.Response = _httpResponse;
 02351            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 2352            {
 02353                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 2354            }
 2355            // Deserialize Response
 02356            if ((int)_statusCode == 200)
 2357            {
 02358                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2359                try
 2360                {
 02361                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ServicePrincipalObjectResult>(_r
 02362                }
 02363                catch (JsonException ex)
 2364                {
 02365                    _httpRequest.Dispose();
 02366                    if (_httpResponse != null)
 2367                    {
 02368                        _httpResponse.Dispose();
 2369                    }
 02370                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2371                }
 2372            }
 02373            if (_shouldTrace)
 2374            {
 02375                ServiceClientTracing.Exit(_invocationId, _result);
 2376            }
 02377            return _result;
 02378        }
 2379
 2380        /// <summary>
 2381        /// Gets a list of applications from the current tenant.
 2382        /// </summary>
 2383        /// <param name='nextLink'>
 2384        /// Next link for the list operation.
 2385        /// </param>
 2386        /// <param name='customHeaders'>
 2387        /// Headers that will be added to request.
 2388        /// </param>
 2389        /// <param name='cancellationToken'>
 2390        /// The cancellation token.
 2391        /// </param>
 2392        /// <exception cref="GraphErrorException">
 2393        /// Thrown when the operation returned an invalid status code
 2394        /// </exception>
 2395        /// <exception cref="SerializationException">
 2396        /// Thrown when unable to deserialize the response
 2397        /// </exception>
 2398        /// <exception cref="ValidationException">
 2399        /// Thrown when a required parameter is null
 2400        /// </exception>
 2401        /// <exception cref="System.ArgumentNullException">
 2402        /// Thrown when a required parameter is null
 2403        /// </exception>
 2404        /// <return>
 2405        /// A response object containing the response body and response headers.
 2406        /// </return>
 2407        public async Task<AzureOperationResponse<IPage<Application>>> ListNextWithHttpMessagesAsync(string nextLink, Dic
 2408        {
 02409            if (nextLink == null)
 2410            {
 02411                throw new ValidationException(ValidationRules.CannotBeNull, "nextLink");
 2412            }
 02413            if (Client.ApiVersion == null)
 2414            {
 02415                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 2416            }
 02417            if (Client.TenantID == null)
 2418            {
 02419                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 2420            }
 2421            // Tracing
 02422            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02423            string _invocationId = null;
 02424            if (_shouldTrace)
 2425            {
 02426                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02427                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02428                tracingParameters.Add("nextLink", nextLink);
 02429                tracingParameters.Add("cancellationToken", cancellationToken);
 02430                ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
 2431            }
 2432            // Construct URL
 02433            var _baseUrl = Client.BaseUri.AbsoluteUri;
 02434            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/{nextL
 02435            _url = _url.Replace("{nextLink}", nextLink);
 02436            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 02437            List<string> _queryParameters = new List<string>();
 02438            if (Client.ApiVersion != null)
 2439            {
 02440                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 2441            }
 02442            if (_queryParameters.Count > 0)
 2443            {
 02444                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2445            }
 2446            // Create HTTP transport objects
 02447            var _httpRequest = new HttpRequestMessage();
 02448            HttpResponseMessage _httpResponse = null;
 02449            _httpRequest.Method = new HttpMethod("GET");
 02450            _httpRequest.RequestUri = new System.Uri(_url);
 2451            // Set Headers
 02452            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2453            {
 02454                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 2455            }
 02456            if (Client.AcceptLanguage != null)
 2457            {
 02458                if (_httpRequest.Headers.Contains("accept-language"))
 2459                {
 02460                    _httpRequest.Headers.Remove("accept-language");
 2461                }
 02462                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2463            }
 2464
 2465
 02466            if (customHeaders != null)
 2467            {
 02468                foreach(var _header in customHeaders)
 2469                {
 02470                    if (_httpRequest.Headers.Contains(_header.Key))
 2471                    {
 02472                        _httpRequest.Headers.Remove(_header.Key);
 2473                    }
 02474                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2475                }
 2476            }
 2477
 2478            // Serialize Request
 02479            string _requestContent = null;
 2480            // Set Credentials
 02481            if (Client.Credentials != null)
 2482            {
 02483                cancellationToken.ThrowIfCancellationRequested();
 02484                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2485            }
 2486            // Send Request
 02487            if (_shouldTrace)
 2488            {
 02489                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2490            }
 02491            cancellationToken.ThrowIfCancellationRequested();
 02492            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02493            if (_shouldTrace)
 2494            {
 02495                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2496            }
 02497            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02498            cancellationToken.ThrowIfCancellationRequested();
 02499            string _responseContent = null;
 02500            if ((int)_statusCode != 200)
 2501            {
 02502                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2503                try
 2504                {
 02505                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02506                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 02507                    if (_errorBody != null)
 2508                    {
 02509                        ex.Body = _errorBody;
 2510                    }
 02511                }
 02512                catch (JsonException)
 2513                {
 2514                    // Ignore the exception
 02515                }
 02516                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02517                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02518                if (_shouldTrace)
 2519                {
 02520                    ServiceClientTracing.Error(_invocationId, ex);
 2521                }
 02522                _httpRequest.Dispose();
 02523                if (_httpResponse != null)
 2524                {
 02525                    _httpResponse.Dispose();
 2526                }
 02527                throw ex;
 2528            }
 2529            // Create Result
 02530            var _result = new AzureOperationResponse<IPage<Application>>();
 02531            _result.Request = _httpRequest;
 02532            _result.Response = _httpResponse;
 02533            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 2534            {
 02535                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 2536            }
 2537            // Deserialize Response
 02538            if ((int)_statusCode == 200)
 2539            {
 02540                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2541                try
 2542                {
 02543                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<Application>>(_responseCont
 02544                }
 02545                catch (JsonException ex)
 2546                {
 02547                    _httpRequest.Dispose();
 02548                    if (_httpResponse != null)
 2549                    {
 02550                        _httpResponse.Dispose();
 2551                    }
 02552                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2553                }
 2554            }
 02555            if (_shouldTrace)
 2556            {
 02557                ServiceClientTracing.Exit(_invocationId, _result);
 2558            }
 02559            return _result;
 02560        }
 2561
 2562        /// <summary>
 2563        /// Directory objects that are owners of the application.
 2564        /// </summary>
 2565        /// <remarks>
 2566        /// The owners are a set of non-admin users who are allowed to modify this
 2567        /// object.
 2568        /// </remarks>
 2569        /// <param name='nextPageLink'>
 2570        /// The NextLink from the previous successful call to List operation.
 2571        /// </param>
 2572        /// <param name='customHeaders'>
 2573        /// Headers that will be added to request.
 2574        /// </param>
 2575        /// <param name='cancellationToken'>
 2576        /// The cancellation token.
 2577        /// </param>
 2578        /// <exception cref="GraphErrorException">
 2579        /// Thrown when the operation returned an invalid status code
 2580        /// </exception>
 2581        /// <exception cref="SerializationException">
 2582        /// Thrown when unable to deserialize the response
 2583        /// </exception>
 2584        /// <exception cref="ValidationException">
 2585        /// Thrown when a required parameter is null
 2586        /// </exception>
 2587        /// <exception cref="System.ArgumentNullException">
 2588        /// Thrown when a required parameter is null
 2589        /// </exception>
 2590        /// <return>
 2591        /// A response object containing the response body and response headers.
 2592        /// </return>
 2593        public async Task<AzureOperationResponse<IPage<DirectoryObject>>> ListOwnersNextWithHttpMessagesAsync(string nex
 2594        {
 02595            if (nextPageLink == null)
 2596            {
 02597                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 2598            }
 2599            // Tracing
 02600            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02601            string _invocationId = null;
 02602            if (_shouldTrace)
 2603            {
 02604                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02605                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02606                tracingParameters.Add("nextPageLink", nextPageLink);
 02607                tracingParameters.Add("cancellationToken", cancellationToken);
 02608                ServiceClientTracing.Enter(_invocationId, this, "ListOwnersNext", tracingParameters);
 2609            }
 2610            // Construct URL
 02611            string _url = "{nextLink}";
 02612            _url = _url.Replace("{nextLink}", nextPageLink);
 02613            List<string> _queryParameters = new List<string>();
 02614            if (_queryParameters.Count > 0)
 2615            {
 02616                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 2617            }
 2618            // Create HTTP transport objects
 02619            var _httpRequest = new HttpRequestMessage();
 02620            HttpResponseMessage _httpResponse = null;
 02621            _httpRequest.Method = new HttpMethod("GET");
 02622            _httpRequest.RequestUri = new System.Uri(_url);
 2623            // Set Headers
 02624            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 2625            {
 02626                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 2627            }
 02628            if (Client.AcceptLanguage != null)
 2629            {
 02630                if (_httpRequest.Headers.Contains("accept-language"))
 2631                {
 02632                    _httpRequest.Headers.Remove("accept-language");
 2633                }
 02634                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 2635            }
 2636
 2637
 02638            if (customHeaders != null)
 2639            {
 02640                foreach(var _header in customHeaders)
 2641                {
 02642                    if (_httpRequest.Headers.Contains(_header.Key))
 2643                    {
 02644                        _httpRequest.Headers.Remove(_header.Key);
 2645                    }
 02646                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2647                }
 2648            }
 2649
 2650            // Serialize Request
 02651            string _requestContent = null;
 2652            // Set Credentials
 02653            if (Client.Credentials != null)
 2654            {
 02655                cancellationToken.ThrowIfCancellationRequested();
 02656                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2657            }
 2658            // Send Request
 02659            if (_shouldTrace)
 2660            {
 02661                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2662            }
 02663            cancellationToken.ThrowIfCancellationRequested();
 02664            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02665            if (_shouldTrace)
 2666            {
 02667                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2668            }
 02669            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02670            cancellationToken.ThrowIfCancellationRequested();
 02671            string _responseContent = null;
 02672            if ((int)_statusCode != 200)
 2673            {
 02674                var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu
 2675                try
 2676                {
 02677                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02678                    GraphError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC
 02679                    if (_errorBody != null)
 2680                    {
 02681                        ex.Body = _errorBody;
 2682                    }
 02683                }
 02684                catch (JsonException)
 2685                {
 2686                    // Ignore the exception
 02687                }
 02688                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02689                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02690                if (_shouldTrace)
 2691                {
 02692                    ServiceClientTracing.Error(_invocationId, ex);
 2693                }
 02694                _httpRequest.Dispose();
 02695                if (_httpResponse != null)
 2696                {
 02697                    _httpResponse.Dispose();
 2698                }
 02699                throw ex;
 2700            }
 2701            // Create Result
 02702            var _result = new AzureOperationResponse<IPage<DirectoryObject>>();
 02703            _result.Request = _httpRequest;
 02704            _result.Response = _httpResponse;
 02705            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 2706            {
 02707                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 2708            }
 2709            // Deserialize Response
 02710            if ((int)_statusCode == 200)
 2711            {
 02712                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2713                try
 2714                {
 02715                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response
 02716                }
 02717                catch (JsonException ex)
 2718                {
 02719                    _httpRequest.Dispose();
 02720                    if (_httpResponse != null)
 2721                    {
 02722                        _httpResponse.Dispose();
 2723                    }
 02724                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2725                }
 2726            }
 02727            if (_shouldTrace)
 2728            {
 02729                ServiceClientTracing.Exit(_invocationId, _result);
 2730            }
 02731            return _result;
 02732        }
 2733
 2734    }
 2735}