< Summary

Class:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.AzureAccounts
Assembly:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\AzureAccounts.cs
Covered lines:4
Uncovered lines:310
Coverable lines:314
Total lines:738
Line coverage:1.2% (4 of 314)
Covered branches:1
Total branches:154
Branch coverage:0.6% (1 of 154)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-0%100%
AssignToAppWithHttpMessagesAsync()-0%0%
GetAssignedWithHttpMessagesAsync()-0%0%
RemoveFromAppWithHttpMessagesAsync()-0%0%
ListUserLUISAccountsWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\AzureAccounts.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.CognitiveServices.Language.LUIS.Authoring
 12{
 13    using Microsoft.Rest;
 14    using Models;
 15    using Newtonsoft.Json;
 16    using System.Collections;
 17    using System.Collections.Generic;
 18    using System.IO;
 19    using System.Linq;
 20    using System.Net;
 21    using System.Net.Http;
 22    using System.Threading;
 23    using System.Threading.Tasks;
 24
 25    /// <summary>
 26    /// AzureAccounts operations.
 27    /// </summary>
 28    public partial class AzureAccounts : IServiceOperations<LUISAuthoringClient>, IAzureAccounts
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the AzureAccounts class.
 32        /// </summary>
 33        /// <param name='client'>
 34        /// Reference to the service client.
 35        /// </param>
 36        /// <exception cref="System.ArgumentNullException">
 37        /// Thrown when a required parameter is null
 38        /// </exception>
 15639        public AzureAccounts(LUISAuthoringClient client)
 40        {
 15641            if (client == null)
 42            {
 043                throw new System.ArgumentNullException("client");
 44            }
 15645            Client = client;
 15646        }
 47
 48        /// <summary>
 49        /// Gets a reference to the LUISAuthoringClient
 50        /// </summary>
 051        public LUISAuthoringClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// apps - Assign a LUIS Azure account to an application
 55        /// </summary>
 56        /// <remarks>
 57        /// Assigns an Azure account to the application.
 58        /// </remarks>
 59        /// <param name='appId'>
 60        /// The application ID.
 61        /// </param>
 62        /// <param name='armToken'>
 63        /// The custom arm token header to use; containing the user's ARM token used to
 64        /// validate azure accounts information.
 65        /// </param>
 66        /// <param name='azureAccountInfoObject'>
 67        /// The Azure account information object.
 68        /// </param>
 69        /// <param name='customHeaders'>
 70        /// Headers that will be added to request.
 71        /// </param>
 72        /// <param name='cancellationToken'>
 73        /// The cancellation token.
 74        /// </param>
 75        /// <exception cref="ErrorResponseException">
 76        /// Thrown when the operation returned an invalid status code
 77        /// </exception>
 78        /// <exception cref="SerializationException">
 79        /// Thrown when unable to deserialize the response
 80        /// </exception>
 81        /// <exception cref="ValidationException">
 82        /// Thrown when a required parameter is null
 83        /// </exception>
 84        /// <exception cref="System.ArgumentNullException">
 85        /// Thrown when a required parameter is null
 86        /// </exception>
 87        /// <return>
 88        /// A response object containing the response body and response headers.
 89        /// </return>
 90        public async Task<HttpOperationResponse<OperationStatus>> AssignToAppWithHttpMessagesAsync(System.Guid appId, st
 91        {
 092            if (Client.Endpoint == null)
 93            {
 094                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 95            }
 096            if (azureAccountInfoObject != null)
 97            {
 098                azureAccountInfoObject.Validate();
 99            }
 100            // Tracing
 0101            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0102            string _invocationId = null;
 0103            if (_shouldTrace)
 104            {
 0105                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0106                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0107                tracingParameters.Add("appId", appId);
 0108                tracingParameters.Add("armToken", armToken);
 0109                tracingParameters.Add("azureAccountInfoObject", azureAccountInfoObject);
 0110                tracingParameters.Add("cancellationToken", cancellationToken);
 0111                ServiceClientTracing.Enter(_invocationId, this, "AssignToApp", tracingParameters);
 112            }
 113            // Construct URL
 0114            var _baseUrl = Client.BaseUri;
 0115            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/azureaccounts";
 0116            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0117            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 118            // Create HTTP transport objects
 0119            var _httpRequest = new HttpRequestMessage();
 0120            HttpResponseMessage _httpResponse = null;
 0121            _httpRequest.Method = new HttpMethod("POST");
 0122            _httpRequest.RequestUri = new System.Uri(_url);
 123            // Set Headers
 0124            if (armToken != null)
 125            {
 0126                if (_httpRequest.Headers.Contains("ArmToken"))
 127                {
 0128                    _httpRequest.Headers.Remove("ArmToken");
 129                }
 0130                _httpRequest.Headers.TryAddWithoutValidation("ArmToken", armToken);
 131            }
 132
 133
 0134            if (customHeaders != null)
 135            {
 0136                foreach(var _header in customHeaders)
 137                {
 0138                    if (_httpRequest.Headers.Contains(_header.Key))
 139                    {
 0140                        _httpRequest.Headers.Remove(_header.Key);
 141                    }
 0142                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 143                }
 144            }
 145
 146            // Serialize Request
 0147            string _requestContent = null;
 0148            if(azureAccountInfoObject != null)
 149            {
 0150                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(azureAccountInfoObject, Client.Seri
 0151                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0152                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 153            }
 154            // Set Credentials
 0155            if (Client.Credentials != null)
 156            {
 0157                cancellationToken.ThrowIfCancellationRequested();
 0158                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 159            }
 160            // Send Request
 0161            if (_shouldTrace)
 162            {
 0163                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 164            }
 0165            cancellationToken.ThrowIfCancellationRequested();
 0166            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0167            if (_shouldTrace)
 168            {
 0169                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 170            }
 0171            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0172            cancellationToken.ThrowIfCancellationRequested();
 0173            string _responseContent = null;
 0174            if ((int)_statusCode != 201)
 175            {
 0176                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 177                try
 178                {
 0179                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0180                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0181                    if (_errorBody != null)
 182                    {
 0183                        ex.Body = _errorBody;
 184                    }
 0185                }
 0186                catch (JsonException)
 187                {
 188                    // Ignore the exception
 0189                }
 0190                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0191                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0192                if (_shouldTrace)
 193                {
 0194                    ServiceClientTracing.Error(_invocationId, ex);
 195                }
 0196                _httpRequest.Dispose();
 0197                if (_httpResponse != null)
 198                {
 0199                    _httpResponse.Dispose();
 200                }
 0201                throw ex;
 202            }
 203            // Create Result
 0204            var _result = new HttpOperationResponse<OperationStatus>();
 0205            _result.Request = _httpRequest;
 0206            _result.Response = _httpResponse;
 207            // Deserialize Response
 0208            if ((int)_statusCode == 201)
 209            {
 0210                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 211                try
 212                {
 0213                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 0214                }
 0215                catch (JsonException ex)
 216                {
 0217                    _httpRequest.Dispose();
 0218                    if (_httpResponse != null)
 219                    {
 0220                        _httpResponse.Dispose();
 221                    }
 0222                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 223                }
 224            }
 0225            if (_shouldTrace)
 226            {
 0227                ServiceClientTracing.Exit(_invocationId, _result);
 228            }
 0229            return _result;
 0230        }
 231
 232        /// <summary>
 233        /// apps - Get LUIS Azure accounts assigned to the application
 234        /// </summary>
 235        /// <remarks>
 236        /// Gets the LUIS Azure accounts assigned to the application for the user using
 237        /// his ARM token.
 238        /// </remarks>
 239        /// <param name='appId'>
 240        /// The application ID.
 241        /// </param>
 242        /// <param name='armToken'>
 243        /// The custom arm token header to use; containing the user's ARM token used to
 244        /// validate azure accounts information.
 245        /// </param>
 246        /// <param name='customHeaders'>
 247        /// Headers that will be added to request.
 248        /// </param>
 249        /// <param name='cancellationToken'>
 250        /// The cancellation token.
 251        /// </param>
 252        /// <exception cref="ErrorResponseException">
 253        /// Thrown when the operation returned an invalid status code
 254        /// </exception>
 255        /// <exception cref="SerializationException">
 256        /// Thrown when unable to deserialize the response
 257        /// </exception>
 258        /// <exception cref="ValidationException">
 259        /// Thrown when a required parameter is null
 260        /// </exception>
 261        /// <exception cref="System.ArgumentNullException">
 262        /// Thrown when a required parameter is null
 263        /// </exception>
 264        /// <return>
 265        /// A response object containing the response body and response headers.
 266        /// </return>
 267        public async Task<HttpOperationResponse<IList<AzureAccountInfoObject>>> GetAssignedWithHttpMessagesAsync(System.
 268        {
 0269            if (Client.Endpoint == null)
 270            {
 0271                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 272            }
 273            // Tracing
 0274            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0275            string _invocationId = null;
 0276            if (_shouldTrace)
 277            {
 0278                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0279                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0280                tracingParameters.Add("appId", appId);
 0281                tracingParameters.Add("armToken", armToken);
 0282                tracingParameters.Add("cancellationToken", cancellationToken);
 0283                ServiceClientTracing.Enter(_invocationId, this, "GetAssigned", tracingParameters);
 284            }
 285            // Construct URL
 0286            var _baseUrl = Client.BaseUri;
 0287            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/azureaccounts";
 0288            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0289            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 290            // Create HTTP transport objects
 0291            var _httpRequest = new HttpRequestMessage();
 0292            HttpResponseMessage _httpResponse = null;
 0293            _httpRequest.Method = new HttpMethod("GET");
 0294            _httpRequest.RequestUri = new System.Uri(_url);
 295            // Set Headers
 0296            if (armToken != null)
 297            {
 0298                if (_httpRequest.Headers.Contains("ArmToken"))
 299                {
 0300                    _httpRequest.Headers.Remove("ArmToken");
 301                }
 0302                _httpRequest.Headers.TryAddWithoutValidation("ArmToken", armToken);
 303            }
 304
 305
 0306            if (customHeaders != null)
 307            {
 0308                foreach(var _header in customHeaders)
 309                {
 0310                    if (_httpRequest.Headers.Contains(_header.Key))
 311                    {
 0312                        _httpRequest.Headers.Remove(_header.Key);
 313                    }
 0314                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 315                }
 316            }
 317
 318            // Serialize Request
 0319            string _requestContent = null;
 320            // Set Credentials
 0321            if (Client.Credentials != null)
 322            {
 0323                cancellationToken.ThrowIfCancellationRequested();
 0324                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 325            }
 326            // Send Request
 0327            if (_shouldTrace)
 328            {
 0329                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 330            }
 0331            cancellationToken.ThrowIfCancellationRequested();
 0332            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0333            if (_shouldTrace)
 334            {
 0335                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 336            }
 0337            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0338            cancellationToken.ThrowIfCancellationRequested();
 0339            string _responseContent = null;
 0340            if ((int)_statusCode != 200)
 341            {
 0342                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 343                try
 344                {
 0345                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0346                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0347                    if (_errorBody != null)
 348                    {
 0349                        ex.Body = _errorBody;
 350                    }
 0351                }
 0352                catch (JsonException)
 353                {
 354                    // Ignore the exception
 0355                }
 0356                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0357                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0358                if (_shouldTrace)
 359                {
 0360                    ServiceClientTracing.Error(_invocationId, ex);
 361                }
 0362                _httpRequest.Dispose();
 0363                if (_httpResponse != null)
 364                {
 0365                    _httpResponse.Dispose();
 366                }
 0367                throw ex;
 368            }
 369            // Create Result
 0370            var _result = new HttpOperationResponse<IList<AzureAccountInfoObject>>();
 0371            _result.Request = _httpRequest;
 0372            _result.Response = _httpResponse;
 373            // Deserialize Response
 0374            if ((int)_statusCode == 200)
 375            {
 0376                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 377                try
 378                {
 0379                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<AzureAccountInfoObject>>(_
 0380                }
 0381                catch (JsonException ex)
 382                {
 0383                    _httpRequest.Dispose();
 0384                    if (_httpResponse != null)
 385                    {
 0386                        _httpResponse.Dispose();
 387                    }
 0388                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 389                }
 390            }
 0391            if (_shouldTrace)
 392            {
 0393                ServiceClientTracing.Exit(_invocationId, _result);
 394            }
 0395            return _result;
 0396        }
 397
 398        /// <summary>
 399        /// apps - Removes an assigned LUIS Azure account from an application
 400        /// </summary>
 401        /// <remarks>
 402        /// Removes assigned Azure account from the application.
 403        /// </remarks>
 404        /// <param name='appId'>
 405        /// The application ID.
 406        /// </param>
 407        /// <param name='armToken'>
 408        /// The custom arm token header to use; containing the user's ARM token used to
 409        /// validate azure accounts information.
 410        /// </param>
 411        /// <param name='azureAccountInfoObject'>
 412        /// The Azure account information object.
 413        /// </param>
 414        /// <param name='customHeaders'>
 415        /// Headers that will be added to request.
 416        /// </param>
 417        /// <param name='cancellationToken'>
 418        /// The cancellation token.
 419        /// </param>
 420        /// <exception cref="ErrorResponseException">
 421        /// Thrown when the operation returned an invalid status code
 422        /// </exception>
 423        /// <exception cref="SerializationException">
 424        /// Thrown when unable to deserialize the response
 425        /// </exception>
 426        /// <exception cref="ValidationException">
 427        /// Thrown when a required parameter is null
 428        /// </exception>
 429        /// <exception cref="System.ArgumentNullException">
 430        /// Thrown when a required parameter is null
 431        /// </exception>
 432        /// <return>
 433        /// A response object containing the response body and response headers.
 434        /// </return>
 435        public async Task<HttpOperationResponse<OperationStatus>> RemoveFromAppWithHttpMessagesAsync(System.Guid appId, 
 436        {
 0437            if (Client.Endpoint == null)
 438            {
 0439                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 440            }
 0441            if (azureAccountInfoObject != null)
 442            {
 0443                azureAccountInfoObject.Validate();
 444            }
 445            // Tracing
 0446            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0447            string _invocationId = null;
 0448            if (_shouldTrace)
 449            {
 0450                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0451                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0452                tracingParameters.Add("appId", appId);
 0453                tracingParameters.Add("armToken", armToken);
 0454                tracingParameters.Add("azureAccountInfoObject", azureAccountInfoObject);
 0455                tracingParameters.Add("cancellationToken", cancellationToken);
 0456                ServiceClientTracing.Enter(_invocationId, this, "RemoveFromApp", tracingParameters);
 457            }
 458            // Construct URL
 0459            var _baseUrl = Client.BaseUri;
 0460            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/azureaccounts";
 0461            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0462            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 463            // Create HTTP transport objects
 0464            var _httpRequest = new HttpRequestMessage();
 0465            HttpResponseMessage _httpResponse = null;
 0466            _httpRequest.Method = new HttpMethod("DELETE");
 0467            _httpRequest.RequestUri = new System.Uri(_url);
 468            // Set Headers
 0469            if (armToken != null)
 470            {
 0471                if (_httpRequest.Headers.Contains("ArmToken"))
 472                {
 0473                    _httpRequest.Headers.Remove("ArmToken");
 474                }
 0475                _httpRequest.Headers.TryAddWithoutValidation("ArmToken", armToken);
 476            }
 477
 478
 0479            if (customHeaders != null)
 480            {
 0481                foreach(var _header in customHeaders)
 482                {
 0483                    if (_httpRequest.Headers.Contains(_header.Key))
 484                    {
 0485                        _httpRequest.Headers.Remove(_header.Key);
 486                    }
 0487                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 488                }
 489            }
 490
 491            // Serialize Request
 0492            string _requestContent = null;
 0493            if(azureAccountInfoObject != null)
 494            {
 0495                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(azureAccountInfoObject, Client.Seri
 0496                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0497                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 498            }
 499            // Set Credentials
 0500            if (Client.Credentials != null)
 501            {
 0502                cancellationToken.ThrowIfCancellationRequested();
 0503                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 504            }
 505            // Send Request
 0506            if (_shouldTrace)
 507            {
 0508                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 509            }
 0510            cancellationToken.ThrowIfCancellationRequested();
 0511            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0512            if (_shouldTrace)
 513            {
 0514                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 515            }
 0516            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0517            cancellationToken.ThrowIfCancellationRequested();
 0518            string _responseContent = null;
 0519            if ((int)_statusCode != 200)
 520            {
 0521                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 522                try
 523                {
 0524                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0525                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0526                    if (_errorBody != null)
 527                    {
 0528                        ex.Body = _errorBody;
 529                    }
 0530                }
 0531                catch (JsonException)
 532                {
 533                    // Ignore the exception
 0534                }
 0535                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0536                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0537                if (_shouldTrace)
 538                {
 0539                    ServiceClientTracing.Error(_invocationId, ex);
 540                }
 0541                _httpRequest.Dispose();
 0542                if (_httpResponse != null)
 543                {
 0544                    _httpResponse.Dispose();
 545                }
 0546                throw ex;
 547            }
 548            // Create Result
 0549            var _result = new HttpOperationResponse<OperationStatus>();
 0550            _result.Request = _httpRequest;
 0551            _result.Response = _httpResponse;
 552            // Deserialize Response
 0553            if ((int)_statusCode == 200)
 554            {
 0555                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 556                try
 557                {
 0558                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 0559                }
 0560                catch (JsonException ex)
 561                {
 0562                    _httpRequest.Dispose();
 0563                    if (_httpResponse != null)
 564                    {
 0565                        _httpResponse.Dispose();
 566                    }
 0567                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 568                }
 569            }
 0570            if (_shouldTrace)
 571            {
 0572                ServiceClientTracing.Exit(_invocationId, _result);
 573            }
 0574            return _result;
 0575        }
 576
 577        /// <summary>
 578        /// user - Get LUIS Azure accounts
 579        /// </summary>
 580        /// <remarks>
 581        /// Gets the LUIS Azure accounts for the user using his ARM token.
 582        /// </remarks>
 583        /// <param name='armToken'>
 584        /// The custom arm token header to use; containing the user's ARM token used to
 585        /// validate azure accounts information.
 586        /// </param>
 587        /// <param name='customHeaders'>
 588        /// Headers that will be added to request.
 589        /// </param>
 590        /// <param name='cancellationToken'>
 591        /// The cancellation token.
 592        /// </param>
 593        /// <exception cref="ErrorResponseException">
 594        /// Thrown when the operation returned an invalid status code
 595        /// </exception>
 596        /// <exception cref="SerializationException">
 597        /// Thrown when unable to deserialize the response
 598        /// </exception>
 599        /// <exception cref="ValidationException">
 600        /// Thrown when a required parameter is null
 601        /// </exception>
 602        /// <exception cref="System.ArgumentNullException">
 603        /// Thrown when a required parameter is null
 604        /// </exception>
 605        /// <return>
 606        /// A response object containing the response body and response headers.
 607        /// </return>
 608        public async Task<HttpOperationResponse<IList<AzureAccountInfoObject>>> ListUserLUISAccountsWithHttpMessagesAsyn
 609        {
 0610            if (Client.Endpoint == null)
 611            {
 0612                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 613            }
 614            // Tracing
 0615            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0616            string _invocationId = null;
 0617            if (_shouldTrace)
 618            {
 0619                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0620                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0621                tracingParameters.Add("armToken", armToken);
 0622                tracingParameters.Add("cancellationToken", cancellationToken);
 0623                ServiceClientTracing.Enter(_invocationId, this, "ListUserLUISAccounts", tracingParameters);
 624            }
 625            // Construct URL
 0626            var _baseUrl = Client.BaseUri;
 0627            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "azureaccounts";
 0628            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 629            // Create HTTP transport objects
 0630            var _httpRequest = new HttpRequestMessage();
 0631            HttpResponseMessage _httpResponse = null;
 0632            _httpRequest.Method = new HttpMethod("GET");
 0633            _httpRequest.RequestUri = new System.Uri(_url);
 634            // Set Headers
 0635            if (armToken != null)
 636            {
 0637                if (_httpRequest.Headers.Contains("ArmToken"))
 638                {
 0639                    _httpRequest.Headers.Remove("ArmToken");
 640                }
 0641                _httpRequest.Headers.TryAddWithoutValidation("ArmToken", armToken);
 642            }
 643
 644
 0645            if (customHeaders != null)
 646            {
 0647                foreach(var _header in customHeaders)
 648                {
 0649                    if (_httpRequest.Headers.Contains(_header.Key))
 650                    {
 0651                        _httpRequest.Headers.Remove(_header.Key);
 652                    }
 0653                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 654                }
 655            }
 656
 657            // Serialize Request
 0658            string _requestContent = null;
 659            // Set Credentials
 0660            if (Client.Credentials != null)
 661            {
 0662                cancellationToken.ThrowIfCancellationRequested();
 0663                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 664            }
 665            // Send Request
 0666            if (_shouldTrace)
 667            {
 0668                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 669            }
 0670            cancellationToken.ThrowIfCancellationRequested();
 0671            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0672            if (_shouldTrace)
 673            {
 0674                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 675            }
 0676            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0677            cancellationToken.ThrowIfCancellationRequested();
 0678            string _responseContent = null;
 0679            if ((int)_statusCode != 200)
 680            {
 0681                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 682                try
 683                {
 0684                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0685                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0686                    if (_errorBody != null)
 687                    {
 0688                        ex.Body = _errorBody;
 689                    }
 0690                }
 0691                catch (JsonException)
 692                {
 693                    // Ignore the exception
 0694                }
 0695                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0696                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0697                if (_shouldTrace)
 698                {
 0699                    ServiceClientTracing.Error(_invocationId, ex);
 700                }
 0701                _httpRequest.Dispose();
 0702                if (_httpResponse != null)
 703                {
 0704                    _httpResponse.Dispose();
 705                }
 0706                throw ex;
 707            }
 708            // Create Result
 0709            var _result = new HttpOperationResponse<IList<AzureAccountInfoObject>>();
 0710            _result.Request = _httpRequest;
 0711            _result.Response = _httpResponse;
 712            // Deserialize Response
 0713            if ((int)_statusCode == 200)
 714            {
 0715                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 716                try
 717                {
 0718                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<AzureAccountInfoObject>>(_
 0719                }
 0720                catch (JsonException ex)
 721                {
 0722                    _httpRequest.Dispose();
 0723                    if (_httpResponse != null)
 724                    {
 0725                        _httpResponse.Dispose();
 726                    }
 0727                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 728                }
 729            }
 0730            if (_shouldTrace)
 731            {
 0732                ServiceClientTracing.Exit(_invocationId, _result);
 733            }
 0734            return _result;
 0735        }
 736
 737    }
 738}