< Summary

Class:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Apps
Assembly:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Apps.cs
Covered lines:807
Uncovered lines:931
Coverable lines:1738
Total lines:3811
Line coverage:46.4% (807 of 1738)
Covered branches:310
Total branches:842
Branch coverage:36.8% (310 of 842)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
AddWithHttpMessagesAsync()-53.95%44.74%
ListWithHttpMessagesAsync()-53.66%47.73%
ImportWithHttpMessagesAsync()-55%47.5%
ListCortanaEndpointsWithHttpMessagesAsync()-0%0%
ListDomainsWithHttpMessagesAsync()-50.75%37.5%
ListUsageScenariosWithHttpMessagesAsync()-50.75%37.5%
ListSupportedCulturesWithHttpMessagesAsync()-50.75%37.5%
DownloadQueryLogsWithHttpMessagesAsync()-56.9%40%
GetWithHttpMessagesAsync()-50.72%37.5%
UpdateWithHttpMessagesAsync()-52.63%41.67%
DeleteWithHttpMessagesAsync()-53.33%44.44%
PublishWithHttpMessagesAsync()-48.24%40.48%
GetSettingsWithHttpMessagesAsync()-50.72%37.5%
UpdateSettingsWithHttpMessagesAsync()-52.63%41.67%
GetPublishSettingsWithHttpMessagesAsync()-50.72%37.5%
UpdatePublishSettingsWithHttpMessagesAsync()-52.63%41.67%
ListEndpointsWithHttpMessagesAsync()-50.72%37.5%
ListAvailableCustomPrebuiltDomainsWithHttpMessagesAsync()-50.75%37.5%
AddCustomPrebuiltDomainWithHttpMessagesAsync()-52.7%41.67%
ListAvailableCustomPrebuiltDomainsForCultureWithHttpMessagesAsync()-50.7%38.24%
PackagePublishedApplicationAsGzipWithHttpMessagesAsync()-0%0%
PackageTrainedApplicationAsGzipWithHttpMessagesAsync()-0%0%
ImportV2AppWithHttpMessagesAsync()-55%47.5%
ImportLuFormatWithHttpMessagesAsync()-55%47.5%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Apps.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    /// Apps operations.
 27    /// </summary>
 28    public partial class Apps : IServiceOperations<LUISAuthoringClient>, IApps
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the Apps 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 Apps(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>
 89951        public LUISAuthoringClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Creates a new LUIS app.
 55        /// </summary>
 56        /// <param name='applicationCreateObject'>
 57        /// An application containing Name, Description (optional), Culture, Usage
 58        /// Scenario (optional), Domain (optional) and initial version ID (optional) of
 59        /// the application. Default value for the version ID is "0.1". Note: the
 60        /// culture cannot be changed after the app is created.
 61        /// </param>
 62        /// <param name='customHeaders'>
 63        /// Headers that will be added to request.
 64        /// </param>
 65        /// <param name='cancellationToken'>
 66        /// The cancellation token.
 67        /// </param>
 68        /// <exception cref="ErrorResponseException">
 69        /// Thrown when the operation returned an invalid status code
 70        /// </exception>
 71        /// <exception cref="SerializationException">
 72        /// Thrown when unable to deserialize the response
 73        /// </exception>
 74        /// <exception cref="ValidationException">
 75        /// Thrown when a required parameter is null
 76        /// </exception>
 77        /// <exception cref="System.ArgumentNullException">
 78        /// Thrown when a required parameter is null
 79        /// </exception>
 80        /// <return>
 81        /// A response object containing the response body and response headers.
 82        /// </return>
 83        public async Task<HttpOperationResponse<System.Guid>> AddWithHttpMessagesAsync(ApplicationCreateObject applicati
 84        {
 2785            if (Client.Endpoint == null)
 86            {
 087                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 88            }
 2789            if (applicationCreateObject == null)
 90            {
 091                throw new ValidationException(ValidationRules.CannotBeNull, "applicationCreateObject");
 92            }
 2793            if (applicationCreateObject != null)
 94            {
 2795                applicationCreateObject.Validate();
 96            }
 97            // Tracing
 2798            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2799            string _invocationId = null;
 27100            if (_shouldTrace)
 101            {
 0102                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0103                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0104                tracingParameters.Add("applicationCreateObject", applicationCreateObject);
 0105                tracingParameters.Add("cancellationToken", cancellationToken);
 0106                ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters);
 107            }
 108            // Construct URL
 27109            var _baseUrl = Client.BaseUri;
 27110            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/";
 27111            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 112            // Create HTTP transport objects
 27113            var _httpRequest = new HttpRequestMessage();
 27114            HttpResponseMessage _httpResponse = null;
 27115            _httpRequest.Method = new HttpMethod("POST");
 27116            _httpRequest.RequestUri = new System.Uri(_url);
 117            // Set Headers
 118
 119
 27120            if (customHeaders != null)
 121            {
 0122                foreach(var _header in customHeaders)
 123                {
 0124                    if (_httpRequest.Headers.Contains(_header.Key))
 125                    {
 0126                        _httpRequest.Headers.Remove(_header.Key);
 127                    }
 0128                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 129                }
 130            }
 131
 132            // Serialize Request
 27133            string _requestContent = null;
 27134            if(applicationCreateObject != null)
 135            {
 27136                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(applicationCreateObject, Client.Ser
 27137                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 27138                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 139            }
 140            // Set Credentials
 27141            if (Client.Credentials != null)
 142            {
 27143                cancellationToken.ThrowIfCancellationRequested();
 27144                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 145            }
 146            // Send Request
 27147            if (_shouldTrace)
 148            {
 0149                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 150            }
 27151            cancellationToken.ThrowIfCancellationRequested();
 27152            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 27153            if (_shouldTrace)
 154            {
 0155                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 156            }
 27157            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 27158            cancellationToken.ThrowIfCancellationRequested();
 27159            string _responseContent = null;
 27160            if ((int)_statusCode != 201)
 161            {
 0162                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 163                try
 164                {
 0165                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0166                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0167                    if (_errorBody != null)
 168                    {
 0169                        ex.Body = _errorBody;
 170                    }
 0171                }
 0172                catch (JsonException)
 173                {
 174                    // Ignore the exception
 0175                }
 0176                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0177                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0178                if (_shouldTrace)
 179                {
 0180                    ServiceClientTracing.Error(_invocationId, ex);
 181                }
 0182                _httpRequest.Dispose();
 0183                if (_httpResponse != null)
 184                {
 0185                    _httpResponse.Dispose();
 186                }
 0187                throw ex;
 188            }
 189            // Create Result
 27190            var _result = new HttpOperationResponse<System.Guid>();
 27191            _result.Request = _httpRequest;
 27192            _result.Response = _httpResponse;
 193            // Deserialize Response
 27194            if ((int)_statusCode == 201)
 195            {
 27196                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 197                try
 198                {
 27199                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 27200                }
 0201                catch (JsonException ex)
 202                {
 0203                    _httpRequest.Dispose();
 0204                    if (_httpResponse != null)
 205                    {
 0206                        _httpResponse.Dispose();
 207                    }
 0208                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 209                }
 210            }
 27211            if (_shouldTrace)
 212            {
 0213                ServiceClientTracing.Exit(_invocationId, _result);
 214            }
 27215            return _result;
 27216        }
 217
 218        /// <summary>
 219        /// Lists all of the user's applications.
 220        /// </summary>
 221        /// <param name='skip'>
 222        /// The number of entries to skip. Default value is 0.
 223        /// </param>
 224        /// <param name='take'>
 225        /// The number of entries to return. Maximum page size is 500. Default is 100.
 226        /// </param>
 227        /// <param name='customHeaders'>
 228        /// Headers that will be added to request.
 229        /// </param>
 230        /// <param name='cancellationToken'>
 231        /// The cancellation token.
 232        /// </param>
 233        /// <exception cref="ErrorResponseException">
 234        /// Thrown when the operation returned an invalid status code
 235        /// </exception>
 236        /// <exception cref="SerializationException">
 237        /// Thrown when unable to deserialize the response
 238        /// </exception>
 239        /// <exception cref="ValidationException">
 240        /// Thrown when a required parameter is null
 241        /// </exception>
 242        /// <exception cref="System.ArgumentNullException">
 243        /// Thrown when a required parameter is null
 244        /// </exception>
 245        /// <return>
 246        /// A response object containing the response body and response headers.
 247        /// </return>
 248        public async Task<HttpOperationResponse<IList<ApplicationInfoResponse>>> ListWithHttpMessagesAsync(int? skip = 0
 249        {
 2250            if (Client.Endpoint == null)
 251            {
 0252                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 253            }
 2254            if (skip < 0)
 255            {
 0256                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 257            }
 2258            if (take > 500)
 259            {
 0260                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 261            }
 2262            if (take < 0)
 263            {
 0264                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 265            }
 266            // Tracing
 2267            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2268            string _invocationId = null;
 2269            if (_shouldTrace)
 270            {
 0271                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0272                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0273                tracingParameters.Add("skip", skip);
 0274                tracingParameters.Add("take", take);
 0275                tracingParameters.Add("cancellationToken", cancellationToken);
 0276                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 277            }
 278            // Construct URL
 2279            var _baseUrl = Client.BaseUri;
 2280            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/";
 2281            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 2282            List<string> _queryParameters = new List<string>();
 2283            if (skip != null)
 284            {
 2285                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 286            }
 2287            if (take != null)
 288            {
 2289                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 290            }
 2291            if (_queryParameters.Count > 0)
 292            {
 2293                _url += "?" + string.Join("&", _queryParameters);
 294            }
 295            // Create HTTP transport objects
 2296            var _httpRequest = new HttpRequestMessage();
 2297            HttpResponseMessage _httpResponse = null;
 2298            _httpRequest.Method = new HttpMethod("GET");
 2299            _httpRequest.RequestUri = new System.Uri(_url);
 300            // Set Headers
 301
 302
 2303            if (customHeaders != null)
 304            {
 0305                foreach(var _header in customHeaders)
 306                {
 0307                    if (_httpRequest.Headers.Contains(_header.Key))
 308                    {
 0309                        _httpRequest.Headers.Remove(_header.Key);
 310                    }
 0311                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 312                }
 313            }
 314
 315            // Serialize Request
 2316            string _requestContent = null;
 317            // Set Credentials
 2318            if (Client.Credentials != null)
 319            {
 2320                cancellationToken.ThrowIfCancellationRequested();
 2321                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 322            }
 323            // Send Request
 2324            if (_shouldTrace)
 325            {
 0326                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 327            }
 2328            cancellationToken.ThrowIfCancellationRequested();
 2329            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2330            if (_shouldTrace)
 331            {
 0332                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 333            }
 2334            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2335            cancellationToken.ThrowIfCancellationRequested();
 2336            string _responseContent = null;
 2337            if ((int)_statusCode != 200)
 338            {
 0339                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 340                try
 341                {
 0342                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0343                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0344                    if (_errorBody != null)
 345                    {
 0346                        ex.Body = _errorBody;
 347                    }
 0348                }
 0349                catch (JsonException)
 350                {
 351                    // Ignore the exception
 0352                }
 0353                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0354                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0355                if (_shouldTrace)
 356                {
 0357                    ServiceClientTracing.Error(_invocationId, ex);
 358                }
 0359                _httpRequest.Dispose();
 0360                if (_httpResponse != null)
 361                {
 0362                    _httpResponse.Dispose();
 363                }
 0364                throw ex;
 365            }
 366            // Create Result
 2367            var _result = new HttpOperationResponse<IList<ApplicationInfoResponse>>();
 2368            _result.Request = _httpRequest;
 2369            _result.Response = _httpResponse;
 370            // Deserialize Response
 2371            if ((int)_statusCode == 200)
 372            {
 2373                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 374                try
 375                {
 2376                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ApplicationInfoResponse>>(
 2377                }
 0378                catch (JsonException ex)
 379                {
 0380                    _httpRequest.Dispose();
 0381                    if (_httpResponse != null)
 382                    {
 0383                        _httpResponse.Dispose();
 384                    }
 0385                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 386                }
 387            }
 2388            if (_shouldTrace)
 389            {
 0390                ServiceClientTracing.Exit(_invocationId, _result);
 391            }
 2392            return _result;
 2393        }
 394
 395        /// <summary>
 396        /// Imports an application to LUIS, the application's structure is included in
 397        /// the request body.
 398        /// </summary>
 399        /// <param name='luisApp'>
 400        /// A LUIS application structure.
 401        /// </param>
 402        /// <param name='appName'>
 403        /// The application name to create. If not specified, the application name will
 404        /// be read from the imported object. If the application name already exists,
 405        /// an error is returned.
 406        /// </param>
 407        /// <param name='customHeaders'>
 408        /// Headers that will be added to request.
 409        /// </param>
 410        /// <param name='cancellationToken'>
 411        /// The cancellation token.
 412        /// </param>
 413        /// <exception cref="ErrorResponseException">
 414        /// Thrown when the operation returned an invalid status code
 415        /// </exception>
 416        /// <exception cref="SerializationException">
 417        /// Thrown when unable to deserialize the response
 418        /// </exception>
 419        /// <exception cref="ValidationException">
 420        /// Thrown when a required parameter is null
 421        /// </exception>
 422        /// <exception cref="System.ArgumentNullException">
 423        /// Thrown when a required parameter is null
 424        /// </exception>
 425        /// <return>
 426        /// A response object containing the response body and response headers.
 427        /// </return>
 428        public async Task<HttpOperationResponse<System.Guid>> ImportWithHttpMessagesAsync(LuisApp luisApp, string appNam
 429        {
 2430            if (Client.Endpoint == null)
 431            {
 0432                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 433            }
 2434            if (luisApp == null)
 435            {
 0436                throw new ValidationException(ValidationRules.CannotBeNull, "luisApp");
 437            }
 438            // Tracing
 2439            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2440            string _invocationId = null;
 2441            if (_shouldTrace)
 442            {
 0443                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0444                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0445                tracingParameters.Add("appName", appName);
 0446                tracingParameters.Add("luisApp", luisApp);
 0447                tracingParameters.Add("cancellationToken", cancellationToken);
 0448                ServiceClientTracing.Enter(_invocationId, this, "Import", tracingParameters);
 449            }
 450            // Construct URL
 2451            var _baseUrl = Client.BaseUri;
 2452            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/import";
 2453            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 2454            List<string> _queryParameters = new List<string>();
 2455            if (appName != null)
 456            {
 2457                _queryParameters.Add(string.Format("appName={0}", System.Uri.EscapeDataString(appName)));
 458            }
 2459            if (_queryParameters.Count > 0)
 460            {
 2461                _url += "?" + string.Join("&", _queryParameters);
 462            }
 463            // Create HTTP transport objects
 2464            var _httpRequest = new HttpRequestMessage();
 2465            HttpResponseMessage _httpResponse = null;
 2466            _httpRequest.Method = new HttpMethod("POST");
 2467            _httpRequest.RequestUri = new System.Uri(_url);
 468            // Set Headers
 469
 470
 2471            if (customHeaders != null)
 472            {
 0473                foreach(var _header in customHeaders)
 474                {
 0475                    if (_httpRequest.Headers.Contains(_header.Key))
 476                    {
 0477                        _httpRequest.Headers.Remove(_header.Key);
 478                    }
 0479                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 480                }
 481            }
 482
 483            // Serialize Request
 2484            string _requestContent = null;
 2485            if(luisApp != null)
 486            {
 2487                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(luisApp, Client.SerializationSettin
 2488                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 2489                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 490            }
 491            // Set Credentials
 2492            if (Client.Credentials != null)
 493            {
 2494                cancellationToken.ThrowIfCancellationRequested();
 2495                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 496            }
 497            // Send Request
 2498            if (_shouldTrace)
 499            {
 0500                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 501            }
 2502            cancellationToken.ThrowIfCancellationRequested();
 2503            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2504            if (_shouldTrace)
 505            {
 0506                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 507            }
 2508            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2509            cancellationToken.ThrowIfCancellationRequested();
 2510            string _responseContent = null;
 2511            if ((int)_statusCode != 201)
 512            {
 0513                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 514                try
 515                {
 0516                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0517                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0518                    if (_errorBody != null)
 519                    {
 0520                        ex.Body = _errorBody;
 521                    }
 0522                }
 0523                catch (JsonException)
 524                {
 525                    // Ignore the exception
 0526                }
 0527                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0528                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0529                if (_shouldTrace)
 530                {
 0531                    ServiceClientTracing.Error(_invocationId, ex);
 532                }
 0533                _httpRequest.Dispose();
 0534                if (_httpResponse != null)
 535                {
 0536                    _httpResponse.Dispose();
 537                }
 0538                throw ex;
 539            }
 540            // Create Result
 2541            var _result = new HttpOperationResponse<System.Guid>();
 2542            _result.Request = _httpRequest;
 2543            _result.Response = _httpResponse;
 544            // Deserialize Response
 2545            if ((int)_statusCode == 201)
 546            {
 2547                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 548                try
 549                {
 2550                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 2551                }
 0552                catch (JsonException ex)
 553                {
 0554                    _httpRequest.Dispose();
 0555                    if (_httpResponse != null)
 556                    {
 0557                        _httpResponse.Dispose();
 558                    }
 0559                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 560                }
 561            }
 2562            if (_shouldTrace)
 563            {
 0564                ServiceClientTracing.Exit(_invocationId, _result);
 565            }
 2566            return _result;
 2567        }
 568
 569        /// <summary>
 570        /// Gets the endpoint URLs for the prebuilt Cortana applications.
 571        /// </summary>
 572        /// <param name='customHeaders'>
 573        /// Headers that will be added to request.
 574        /// </param>
 575        /// <param name='cancellationToken'>
 576        /// The cancellation token.
 577        /// </param>
 578        /// <exception cref="ErrorResponseException">
 579        /// Thrown when the operation returned an invalid status code
 580        /// </exception>
 581        /// <exception cref="SerializationException">
 582        /// Thrown when unable to deserialize the response
 583        /// </exception>
 584        /// <exception cref="ValidationException">
 585        /// Thrown when a required parameter is null
 586        /// </exception>
 587        /// <exception cref="System.ArgumentNullException">
 588        /// Thrown when a required parameter is null
 589        /// </exception>
 590        /// <return>
 591        /// A response object containing the response body and response headers.
 592        /// </return>
 593        public async Task<HttpOperationResponse<PersonalAssistantsResponse>> ListCortanaEndpointsWithHttpMessagesAsync(D
 594        {
 0595            if (Client.Endpoint == null)
 596            {
 0597                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 598            }
 599            // Tracing
 0600            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0601            string _invocationId = null;
 0602            if (_shouldTrace)
 603            {
 0604                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0605                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0606                tracingParameters.Add("cancellationToken", cancellationToken);
 0607                ServiceClientTracing.Enter(_invocationId, this, "ListCortanaEndpoints", tracingParameters);
 608            }
 609            // Construct URL
 0610            var _baseUrl = Client.BaseUri;
 0611            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/assistants";
 0612            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 613            // Create HTTP transport objects
 0614            var _httpRequest = new HttpRequestMessage();
 0615            HttpResponseMessage _httpResponse = null;
 0616            _httpRequest.Method = new HttpMethod("GET");
 0617            _httpRequest.RequestUri = new System.Uri(_url);
 618            // Set Headers
 619
 620
 0621            if (customHeaders != null)
 622            {
 0623                foreach(var _header in customHeaders)
 624                {
 0625                    if (_httpRequest.Headers.Contains(_header.Key))
 626                    {
 0627                        _httpRequest.Headers.Remove(_header.Key);
 628                    }
 0629                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 630                }
 631            }
 632
 633            // Serialize Request
 0634            string _requestContent = null;
 635            // Set Credentials
 0636            if (Client.Credentials != null)
 637            {
 0638                cancellationToken.ThrowIfCancellationRequested();
 0639                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 640            }
 641            // Send Request
 0642            if (_shouldTrace)
 643            {
 0644                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 645            }
 0646            cancellationToken.ThrowIfCancellationRequested();
 0647            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0648            if (_shouldTrace)
 649            {
 0650                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 651            }
 0652            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0653            cancellationToken.ThrowIfCancellationRequested();
 0654            string _responseContent = null;
 0655            if ((int)_statusCode != 200)
 656            {
 0657                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 658                try
 659                {
 0660                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0661                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0662                    if (_errorBody != null)
 663                    {
 0664                        ex.Body = _errorBody;
 665                    }
 0666                }
 0667                catch (JsonException)
 668                {
 669                    // Ignore the exception
 0670                }
 0671                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0672                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0673                if (_shouldTrace)
 674                {
 0675                    ServiceClientTracing.Error(_invocationId, ex);
 676                }
 0677                _httpRequest.Dispose();
 0678                if (_httpResponse != null)
 679                {
 0680                    _httpResponse.Dispose();
 681                }
 0682                throw ex;
 683            }
 684            // Create Result
 0685            var _result = new HttpOperationResponse<PersonalAssistantsResponse>();
 0686            _result.Request = _httpRequest;
 0687            _result.Response = _httpResponse;
 688            // Deserialize Response
 0689            if ((int)_statusCode == 200)
 690            {
 0691                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 692                try
 693                {
 0694                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<PersonalAssistantsResponse>(_res
 0695                }
 0696                catch (JsonException ex)
 697                {
 0698                    _httpRequest.Dispose();
 0699                    if (_httpResponse != null)
 700                    {
 0701                        _httpResponse.Dispose();
 702                    }
 0703                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 704                }
 705            }
 0706            if (_shouldTrace)
 707            {
 0708                ServiceClientTracing.Exit(_invocationId, _result);
 709            }
 0710            return _result;
 0711        }
 712
 713        /// <summary>
 714        /// Gets the available application domains.
 715        /// </summary>
 716        /// <param name='customHeaders'>
 717        /// Headers that will be added to request.
 718        /// </param>
 719        /// <param name='cancellationToken'>
 720        /// The cancellation token.
 721        /// </param>
 722        /// <exception cref="ErrorResponseException">
 723        /// Thrown when the operation returned an invalid status code
 724        /// </exception>
 725        /// <exception cref="SerializationException">
 726        /// Thrown when unable to deserialize the response
 727        /// </exception>
 728        /// <exception cref="ValidationException">
 729        /// Thrown when a required parameter is null
 730        /// </exception>
 731        /// <exception cref="System.ArgumentNullException">
 732        /// Thrown when a required parameter is null
 733        /// </exception>
 734        /// <return>
 735        /// A response object containing the response body and response headers.
 736        /// </return>
 737        public async Task<HttpOperationResponse<IList<string>>> ListDomainsWithHttpMessagesAsync(Dictionary<string, List
 738        {
 1739            if (Client.Endpoint == null)
 740            {
 0741                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 742            }
 743            // Tracing
 1744            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 1745            string _invocationId = null;
 1746            if (_shouldTrace)
 747            {
 0748                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0749                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0750                tracingParameters.Add("cancellationToken", cancellationToken);
 0751                ServiceClientTracing.Enter(_invocationId, this, "ListDomains", tracingParameters);
 752            }
 753            // Construct URL
 1754            var _baseUrl = Client.BaseUri;
 1755            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/domains";
 1756            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 757            // Create HTTP transport objects
 1758            var _httpRequest = new HttpRequestMessage();
 1759            HttpResponseMessage _httpResponse = null;
 1760            _httpRequest.Method = new HttpMethod("GET");
 1761            _httpRequest.RequestUri = new System.Uri(_url);
 762            // Set Headers
 763
 764
 1765            if (customHeaders != null)
 766            {
 0767                foreach(var _header in customHeaders)
 768                {
 0769                    if (_httpRequest.Headers.Contains(_header.Key))
 770                    {
 0771                        _httpRequest.Headers.Remove(_header.Key);
 772                    }
 0773                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 774                }
 775            }
 776
 777            // Serialize Request
 1778            string _requestContent = null;
 779            // Set Credentials
 1780            if (Client.Credentials != null)
 781            {
 1782                cancellationToken.ThrowIfCancellationRequested();
 1783                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 784            }
 785            // Send Request
 1786            if (_shouldTrace)
 787            {
 0788                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 789            }
 1790            cancellationToken.ThrowIfCancellationRequested();
 1791            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1792            if (_shouldTrace)
 793            {
 0794                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 795            }
 1796            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 1797            cancellationToken.ThrowIfCancellationRequested();
 1798            string _responseContent = null;
 1799            if ((int)_statusCode != 200)
 800            {
 0801                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 802                try
 803                {
 0804                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0805                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0806                    if (_errorBody != null)
 807                    {
 0808                        ex.Body = _errorBody;
 809                    }
 0810                }
 0811                catch (JsonException)
 812                {
 813                    // Ignore the exception
 0814                }
 0815                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0816                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0817                if (_shouldTrace)
 818                {
 0819                    ServiceClientTracing.Error(_invocationId, ex);
 820                }
 0821                _httpRequest.Dispose();
 0822                if (_httpResponse != null)
 823                {
 0824                    _httpResponse.Dispose();
 825                }
 0826                throw ex;
 827            }
 828            // Create Result
 1829            var _result = new HttpOperationResponse<IList<string>>();
 1830            _result.Request = _httpRequest;
 1831            _result.Response = _httpResponse;
 832            // Deserialize Response
 1833            if ((int)_statusCode == 200)
 834            {
 1835                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 836                try
 837                {
 1838                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<string>>(_responseContent,
 1839                }
 0840                catch (JsonException ex)
 841                {
 0842                    _httpRequest.Dispose();
 0843                    if (_httpResponse != null)
 844                    {
 0845                        _httpResponse.Dispose();
 846                    }
 0847                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 848                }
 849            }
 1850            if (_shouldTrace)
 851            {
 0852                ServiceClientTracing.Exit(_invocationId, _result);
 853            }
 1854            return _result;
 1855        }
 856
 857        /// <summary>
 858        /// Gets the application available usage scenarios.
 859        /// </summary>
 860        /// <param name='customHeaders'>
 861        /// Headers that will be added to request.
 862        /// </param>
 863        /// <param name='cancellationToken'>
 864        /// The cancellation token.
 865        /// </param>
 866        /// <exception cref="ErrorResponseException">
 867        /// Thrown when the operation returned an invalid status code
 868        /// </exception>
 869        /// <exception cref="SerializationException">
 870        /// Thrown when unable to deserialize the response
 871        /// </exception>
 872        /// <exception cref="ValidationException">
 873        /// Thrown when a required parameter is null
 874        /// </exception>
 875        /// <exception cref="System.ArgumentNullException">
 876        /// Thrown when a required parameter is null
 877        /// </exception>
 878        /// <return>
 879        /// A response object containing the response body and response headers.
 880        /// </return>
 881        public async Task<HttpOperationResponse<IList<string>>> ListUsageScenariosWithHttpMessagesAsync(Dictionary<strin
 882        {
 1883            if (Client.Endpoint == null)
 884            {
 0885                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 886            }
 887            // Tracing
 1888            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 1889            string _invocationId = null;
 1890            if (_shouldTrace)
 891            {
 0892                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0893                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0894                tracingParameters.Add("cancellationToken", cancellationToken);
 0895                ServiceClientTracing.Enter(_invocationId, this, "ListUsageScenarios", tracingParameters);
 896            }
 897            // Construct URL
 1898            var _baseUrl = Client.BaseUri;
 1899            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/usagescenarios";
 1900            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 901            // Create HTTP transport objects
 1902            var _httpRequest = new HttpRequestMessage();
 1903            HttpResponseMessage _httpResponse = null;
 1904            _httpRequest.Method = new HttpMethod("GET");
 1905            _httpRequest.RequestUri = new System.Uri(_url);
 906            // Set Headers
 907
 908
 1909            if (customHeaders != null)
 910            {
 0911                foreach(var _header in customHeaders)
 912                {
 0913                    if (_httpRequest.Headers.Contains(_header.Key))
 914                    {
 0915                        _httpRequest.Headers.Remove(_header.Key);
 916                    }
 0917                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 918                }
 919            }
 920
 921            // Serialize Request
 1922            string _requestContent = null;
 923            // Set Credentials
 1924            if (Client.Credentials != null)
 925            {
 1926                cancellationToken.ThrowIfCancellationRequested();
 1927                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 928            }
 929            // Send Request
 1930            if (_shouldTrace)
 931            {
 0932                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 933            }
 1934            cancellationToken.ThrowIfCancellationRequested();
 1935            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1936            if (_shouldTrace)
 937            {
 0938                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 939            }
 1940            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 1941            cancellationToken.ThrowIfCancellationRequested();
 1942            string _responseContent = null;
 1943            if ((int)_statusCode != 200)
 944            {
 0945                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 946                try
 947                {
 0948                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0949                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0950                    if (_errorBody != null)
 951                    {
 0952                        ex.Body = _errorBody;
 953                    }
 0954                }
 0955                catch (JsonException)
 956                {
 957                    // Ignore the exception
 0958                }
 0959                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0960                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0961                if (_shouldTrace)
 962                {
 0963                    ServiceClientTracing.Error(_invocationId, ex);
 964                }
 0965                _httpRequest.Dispose();
 0966                if (_httpResponse != null)
 967                {
 0968                    _httpResponse.Dispose();
 969                }
 0970                throw ex;
 971            }
 972            // Create Result
 1973            var _result = new HttpOperationResponse<IList<string>>();
 1974            _result.Request = _httpRequest;
 1975            _result.Response = _httpResponse;
 976            // Deserialize Response
 1977            if ((int)_statusCode == 200)
 978            {
 1979                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 980                try
 981                {
 1982                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<string>>(_responseContent,
 1983                }
 0984                catch (JsonException ex)
 985                {
 0986                    _httpRequest.Dispose();
 0987                    if (_httpResponse != null)
 988                    {
 0989                        _httpResponse.Dispose();
 990                    }
 0991                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 992                }
 993            }
 1994            if (_shouldTrace)
 995            {
 0996                ServiceClientTracing.Exit(_invocationId, _result);
 997            }
 1998            return _result;
 1999        }
 1000
 1001        /// <summary>
 1002        /// Gets a list of supported cultures. Cultures are equivalent to the written
 1003        /// language and locale. For example,"en-us" represents the U.S. variation of
 1004        /// English.
 1005        /// </summary>
 1006        /// <param name='customHeaders'>
 1007        /// Headers that will be added to request.
 1008        /// </param>
 1009        /// <param name='cancellationToken'>
 1010        /// The cancellation token.
 1011        /// </param>
 1012        /// <exception cref="ErrorResponseException">
 1013        /// Thrown when the operation returned an invalid status code
 1014        /// </exception>
 1015        /// <exception cref="SerializationException">
 1016        /// Thrown when unable to deserialize the response
 1017        /// </exception>
 1018        /// <exception cref="ValidationException">
 1019        /// Thrown when a required parameter is null
 1020        /// </exception>
 1021        /// <exception cref="System.ArgumentNullException">
 1022        /// Thrown when a required parameter is null
 1023        /// </exception>
 1024        /// <return>
 1025        /// A response object containing the response body and response headers.
 1026        /// </return>
 1027        public async Task<HttpOperationResponse<IList<AvailableCulture>>> ListSupportedCulturesWithHttpMessagesAsync(Dic
 1028        {
 11029            if (Client.Endpoint == null)
 1030            {
 01031                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1032            }
 1033            // Tracing
 11034            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 11035            string _invocationId = null;
 11036            if (_shouldTrace)
 1037            {
 01038                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01039                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01040                tracingParameters.Add("cancellationToken", cancellationToken);
 01041                ServiceClientTracing.Enter(_invocationId, this, "ListSupportedCultures", tracingParameters);
 1042            }
 1043            // Construct URL
 11044            var _baseUrl = Client.BaseUri;
 11045            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/cultures";
 11046            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 1047            // Create HTTP transport objects
 11048            var _httpRequest = new HttpRequestMessage();
 11049            HttpResponseMessage _httpResponse = null;
 11050            _httpRequest.Method = new HttpMethod("GET");
 11051            _httpRequest.RequestUri = new System.Uri(_url);
 1052            // Set Headers
 1053
 1054
 11055            if (customHeaders != null)
 1056            {
 01057                foreach(var _header in customHeaders)
 1058                {
 01059                    if (_httpRequest.Headers.Contains(_header.Key))
 1060                    {
 01061                        _httpRequest.Headers.Remove(_header.Key);
 1062                    }
 01063                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1064                }
 1065            }
 1066
 1067            // Serialize Request
 11068            string _requestContent = null;
 1069            // Set Credentials
 11070            if (Client.Credentials != null)
 1071            {
 11072                cancellationToken.ThrowIfCancellationRequested();
 11073                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1074            }
 1075            // Send Request
 11076            if (_shouldTrace)
 1077            {
 01078                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1079            }
 11080            cancellationToken.ThrowIfCancellationRequested();
 11081            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11082            if (_shouldTrace)
 1083            {
 01084                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1085            }
 11086            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 11087            cancellationToken.ThrowIfCancellationRequested();
 11088            string _responseContent = null;
 11089            if ((int)_statusCode != 200)
 1090            {
 01091                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1092                try
 1093                {
 01094                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01095                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01096                    if (_errorBody != null)
 1097                    {
 01098                        ex.Body = _errorBody;
 1099                    }
 01100                }
 01101                catch (JsonException)
 1102                {
 1103                    // Ignore the exception
 01104                }
 01105                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01106                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01107                if (_shouldTrace)
 1108                {
 01109                    ServiceClientTracing.Error(_invocationId, ex);
 1110                }
 01111                _httpRequest.Dispose();
 01112                if (_httpResponse != null)
 1113                {
 01114                    _httpResponse.Dispose();
 1115                }
 01116                throw ex;
 1117            }
 1118            // Create Result
 11119            var _result = new HttpOperationResponse<IList<AvailableCulture>>();
 11120            _result.Request = _httpRequest;
 11121            _result.Response = _httpResponse;
 1122            // Deserialize Response
 11123            if ((int)_statusCode == 200)
 1124            {
 11125                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1126                try
 1127                {
 11128                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<AvailableCulture>>(_respon
 11129                }
 01130                catch (JsonException ex)
 1131                {
 01132                    _httpRequest.Dispose();
 01133                    if (_httpResponse != null)
 1134                    {
 01135                        _httpResponse.Dispose();
 1136                    }
 01137                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1138                }
 1139            }
 11140            if (_shouldTrace)
 1141            {
 01142                ServiceClientTracing.Exit(_invocationId, _result);
 1143            }
 11144            return _result;
 11145        }
 1146
 1147        /// <summary>
 1148        /// Gets the logs of the past month's endpoint queries for the application.
 1149        /// </summary>
 1150        /// <param name='appId'>
 1151        /// The application ID.
 1152        /// </param>
 1153        /// <param name='customHeaders'>
 1154        /// Headers that will be added to request.
 1155        /// </param>
 1156        /// <param name='cancellationToken'>
 1157        /// The cancellation token.
 1158        /// </param>
 1159        /// <exception cref="HttpOperationException">
 1160        /// Thrown when the operation returned an invalid status code
 1161        /// </exception>
 1162        /// <exception cref="SerializationException">
 1163        /// Thrown when unable to deserialize the response
 1164        /// </exception>
 1165        /// <exception cref="ValidationException">
 1166        /// Thrown when a required parameter is null
 1167        /// </exception>
 1168        /// <exception cref="System.ArgumentNullException">
 1169        /// Thrown when a required parameter is null
 1170        /// </exception>
 1171        /// <return>
 1172        /// A response object containing the response body and response headers.
 1173        /// </return>
 1174        public async Task<HttpOperationResponse<Stream>> DownloadQueryLogsWithHttpMessagesAsync(System.Guid appId, Dicti
 1175        {
 11176            if (Client.Endpoint == null)
 1177            {
 01178                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1179            }
 1180            // Tracing
 11181            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 11182            string _invocationId = null;
 11183            if (_shouldTrace)
 1184            {
 01185                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01186                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01187                tracingParameters.Add("appId", appId);
 01188                tracingParameters.Add("cancellationToken", cancellationToken);
 01189                ServiceClientTracing.Enter(_invocationId, this, "DownloadQueryLogs", tracingParameters);
 1190            }
 1191            // Construct URL
 11192            var _baseUrl = Client.BaseUri;
 11193            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/querylogs";
 11194            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 11195            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 1196            // Create HTTP transport objects
 11197            var _httpRequest = new HttpRequestMessage();
 11198            HttpResponseMessage _httpResponse = null;
 11199            _httpRequest.Method = new HttpMethod("GET");
 11200            _httpRequest.RequestUri = new System.Uri(_url);
 1201            // Set Headers
 1202
 1203
 11204            if (customHeaders != null)
 1205            {
 01206                foreach(var _header in customHeaders)
 1207                {
 01208                    if (_httpRequest.Headers.Contains(_header.Key))
 1209                    {
 01210                        _httpRequest.Headers.Remove(_header.Key);
 1211                    }
 01212                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1213                }
 1214            }
 1215
 1216            // Serialize Request
 11217            string _requestContent = null;
 1218            // Set Credentials
 11219            if (Client.Credentials != null)
 1220            {
 11221                cancellationToken.ThrowIfCancellationRequested();
 11222                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1223            }
 1224            // Send Request
 11225            if (_shouldTrace)
 1226            {
 01227                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1228            }
 11229            cancellationToken.ThrowIfCancellationRequested();
 11230            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons
 11231            if (_shouldTrace)
 1232            {
 01233                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1234            }
 11235            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 11236            cancellationToken.ThrowIfCancellationRequested();
 11237            string _responseContent = null;
 11238            if ((int)_statusCode != 200)
 1239            {
 01240                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _st
 01241                if (_httpResponse.Content != null) {
 01242                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1243                }
 1244                else {
 01245                    _responseContent = string.Empty;
 1246                }
 01247                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01248                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01249                if (_shouldTrace)
 1250                {
 01251                    ServiceClientTracing.Error(_invocationId, ex);
 1252                }
 01253                _httpRequest.Dispose();
 01254                if (_httpResponse != null)
 1255                {
 01256                    _httpResponse.Dispose();
 1257                }
 01258                throw ex;
 1259            }
 1260            // Create Result
 11261            var _result = new HttpOperationResponse<Stream>();
 11262            _result.Request = _httpRequest;
 11263            _result.Response = _httpResponse;
 1264            // Deserialize Response
 11265            if ((int)_statusCode == 200)
 1266            {
 11267                _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
 1268            }
 11269            if (_shouldTrace)
 1270            {
 01271                ServiceClientTracing.Exit(_invocationId, _result);
 1272            }
 11273            return _result;
 11274        }
 1275
 1276        /// <summary>
 1277        /// Gets the application info.
 1278        /// </summary>
 1279        /// <param name='appId'>
 1280        /// The application ID.
 1281        /// </param>
 1282        /// <param name='customHeaders'>
 1283        /// Headers that will be added to request.
 1284        /// </param>
 1285        /// <param name='cancellationToken'>
 1286        /// The cancellation token.
 1287        /// </param>
 1288        /// <exception cref="ErrorResponseException">
 1289        /// Thrown when the operation returned an invalid status code
 1290        /// </exception>
 1291        /// <exception cref="SerializationException">
 1292        /// Thrown when unable to deserialize the response
 1293        /// </exception>
 1294        /// <exception cref="ValidationException">
 1295        /// Thrown when a required parameter is null
 1296        /// </exception>
 1297        /// <exception cref="System.ArgumentNullException">
 1298        /// Thrown when a required parameter is null
 1299        /// </exception>
 1300        /// <return>
 1301        /// A response object containing the response body and response headers.
 1302        /// </return>
 1303        public async Task<HttpOperationResponse<ApplicationInfoResponse>> GetWithHttpMessagesAsync(System.Guid appId, Di
 1304        {
 71305            if (Client.Endpoint == null)
 1306            {
 01307                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1308            }
 1309            // Tracing
 71310            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 71311            string _invocationId = null;
 71312            if (_shouldTrace)
 1313            {
 01314                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01315                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01316                tracingParameters.Add("appId", appId);
 01317                tracingParameters.Add("cancellationToken", cancellationToken);
 01318                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 1319            }
 1320            // Construct URL
 71321            var _baseUrl = Client.BaseUri;
 71322            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}";
 71323            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 71324            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 1325            // Create HTTP transport objects
 71326            var _httpRequest = new HttpRequestMessage();
 71327            HttpResponseMessage _httpResponse = null;
 71328            _httpRequest.Method = new HttpMethod("GET");
 71329            _httpRequest.RequestUri = new System.Uri(_url);
 1330            // Set Headers
 1331
 1332
 71333            if (customHeaders != null)
 1334            {
 01335                foreach(var _header in customHeaders)
 1336                {
 01337                    if (_httpRequest.Headers.Contains(_header.Key))
 1338                    {
 01339                        _httpRequest.Headers.Remove(_header.Key);
 1340                    }
 01341                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1342                }
 1343            }
 1344
 1345            // Serialize Request
 71346            string _requestContent = null;
 1347            // Set Credentials
 71348            if (Client.Credentials != null)
 1349            {
 71350                cancellationToken.ThrowIfCancellationRequested();
 71351                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1352            }
 1353            // Send Request
 71354            if (_shouldTrace)
 1355            {
 01356                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1357            }
 71358            cancellationToken.ThrowIfCancellationRequested();
 71359            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 71360            if (_shouldTrace)
 1361            {
 01362                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1363            }
 71364            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 71365            cancellationToken.ThrowIfCancellationRequested();
 71366            string _responseContent = null;
 71367            if ((int)_statusCode != 200)
 1368            {
 01369                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1370                try
 1371                {
 01372                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01373                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01374                    if (_errorBody != null)
 1375                    {
 01376                        ex.Body = _errorBody;
 1377                    }
 01378                }
 01379                catch (JsonException)
 1380                {
 1381                    // Ignore the exception
 01382                }
 01383                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01384                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01385                if (_shouldTrace)
 1386                {
 01387                    ServiceClientTracing.Error(_invocationId, ex);
 1388                }
 01389                _httpRequest.Dispose();
 01390                if (_httpResponse != null)
 1391                {
 01392                    _httpResponse.Dispose();
 1393                }
 01394                throw ex;
 1395            }
 1396            // Create Result
 71397            var _result = new HttpOperationResponse<ApplicationInfoResponse>();
 71398            _result.Request = _httpRequest;
 71399            _result.Response = _httpResponse;
 1400            // Deserialize Response
 71401            if ((int)_statusCode == 200)
 1402            {
 71403                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1404                try
 1405                {
 71406                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ApplicationInfoResponse>(_respon
 71407                }
 01408                catch (JsonException ex)
 1409                {
 01410                    _httpRequest.Dispose();
 01411                    if (_httpResponse != null)
 1412                    {
 01413                        _httpResponse.Dispose();
 1414                    }
 01415                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1416                }
 1417            }
 71418            if (_shouldTrace)
 1419            {
 01420                ServiceClientTracing.Exit(_invocationId, _result);
 1421            }
 71422            return _result;
 71423        }
 1424
 1425        /// <summary>
 1426        /// Updates the name or description of the application.
 1427        /// </summary>
 1428        /// <param name='appId'>
 1429        /// The application ID.
 1430        /// </param>
 1431        /// <param name='applicationUpdateObject'>
 1432        /// A model containing Name and Description of the application.
 1433        /// </param>
 1434        /// <param name='customHeaders'>
 1435        /// Headers that will be added to request.
 1436        /// </param>
 1437        /// <param name='cancellationToken'>
 1438        /// The cancellation token.
 1439        /// </param>
 1440        /// <exception cref="ErrorResponseException">
 1441        /// Thrown when the operation returned an invalid status code
 1442        /// </exception>
 1443        /// <exception cref="SerializationException">
 1444        /// Thrown when unable to deserialize the response
 1445        /// </exception>
 1446        /// <exception cref="ValidationException">
 1447        /// Thrown when a required parameter is null
 1448        /// </exception>
 1449        /// <exception cref="System.ArgumentNullException">
 1450        /// Thrown when a required parameter is null
 1451        /// </exception>
 1452        /// <return>
 1453        /// A response object containing the response body and response headers.
 1454        /// </return>
 1455        public async Task<HttpOperationResponse<OperationStatus>> UpdateWithHttpMessagesAsync(System.Guid appId, Applica
 1456        {
 11457            if (Client.Endpoint == null)
 1458            {
 01459                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1460            }
 11461            if (applicationUpdateObject == null)
 1462            {
 01463                throw new ValidationException(ValidationRules.CannotBeNull, "applicationUpdateObject");
 1464            }
 1465            // Tracing
 11466            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 11467            string _invocationId = null;
 11468            if (_shouldTrace)
 1469            {
 01470                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01471                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01472                tracingParameters.Add("appId", appId);
 01473                tracingParameters.Add("applicationUpdateObject", applicationUpdateObject);
 01474                tracingParameters.Add("cancellationToken", cancellationToken);
 01475                ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
 1476            }
 1477            // Construct URL
 11478            var _baseUrl = Client.BaseUri;
 11479            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}";
 11480            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 11481            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 1482            // Create HTTP transport objects
 11483            var _httpRequest = new HttpRequestMessage();
 11484            HttpResponseMessage _httpResponse = null;
 11485            _httpRequest.Method = new HttpMethod("PUT");
 11486            _httpRequest.RequestUri = new System.Uri(_url);
 1487            // Set Headers
 1488
 1489
 11490            if (customHeaders != null)
 1491            {
 01492                foreach(var _header in customHeaders)
 1493                {
 01494                    if (_httpRequest.Headers.Contains(_header.Key))
 1495                    {
 01496                        _httpRequest.Headers.Remove(_header.Key);
 1497                    }
 01498                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1499                }
 1500            }
 1501
 1502            // Serialize Request
 11503            string _requestContent = null;
 11504            if(applicationUpdateObject != null)
 1505            {
 11506                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(applicationUpdateObject, Client.Ser
 11507                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 11508                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1509            }
 1510            // Set Credentials
 11511            if (Client.Credentials != null)
 1512            {
 11513                cancellationToken.ThrowIfCancellationRequested();
 11514                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1515            }
 1516            // Send Request
 11517            if (_shouldTrace)
 1518            {
 01519                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1520            }
 11521            cancellationToken.ThrowIfCancellationRequested();
 11522            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11523            if (_shouldTrace)
 1524            {
 01525                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1526            }
 11527            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 11528            cancellationToken.ThrowIfCancellationRequested();
 11529            string _responseContent = null;
 11530            if ((int)_statusCode != 200)
 1531            {
 01532                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1533                try
 1534                {
 01535                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01536                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01537                    if (_errorBody != null)
 1538                    {
 01539                        ex.Body = _errorBody;
 1540                    }
 01541                }
 01542                catch (JsonException)
 1543                {
 1544                    // Ignore the exception
 01545                }
 01546                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01547                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01548                if (_shouldTrace)
 1549                {
 01550                    ServiceClientTracing.Error(_invocationId, ex);
 1551                }
 01552                _httpRequest.Dispose();
 01553                if (_httpResponse != null)
 1554                {
 01555                    _httpResponse.Dispose();
 1556                }
 01557                throw ex;
 1558            }
 1559            // Create Result
 11560            var _result = new HttpOperationResponse<OperationStatus>();
 11561            _result.Request = _httpRequest;
 11562            _result.Response = _httpResponse;
 1563            // Deserialize Response
 11564            if ((int)_statusCode == 200)
 1565            {
 11566                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1567                try
 1568                {
 11569                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 11570                }
 01571                catch (JsonException ex)
 1572                {
 01573                    _httpRequest.Dispose();
 01574                    if (_httpResponse != null)
 1575                    {
 01576                        _httpResponse.Dispose();
 1577                    }
 01578                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1579                }
 1580            }
 11581            if (_shouldTrace)
 1582            {
 01583                ServiceClientTracing.Exit(_invocationId, _result);
 1584            }
 11585            return _result;
 11586        }
 1587
 1588        /// <summary>
 1589        /// Deletes an application.
 1590        /// </summary>
 1591        /// <param name='appId'>
 1592        /// The application ID.
 1593        /// </param>
 1594        /// <param name='force'>
 1595        /// A flag to indicate whether to force an operation.
 1596        /// </param>
 1597        /// <param name='customHeaders'>
 1598        /// Headers that will be added to request.
 1599        /// </param>
 1600        /// <param name='cancellationToken'>
 1601        /// The cancellation token.
 1602        /// </param>
 1603        /// <exception cref="ErrorResponseException">
 1604        /// Thrown when the operation returned an invalid status code
 1605        /// </exception>
 1606        /// <exception cref="SerializationException">
 1607        /// Thrown when unable to deserialize the response
 1608        /// </exception>
 1609        /// <exception cref="ValidationException">
 1610        /// Thrown when a required parameter is null
 1611        /// </exception>
 1612        /// <exception cref="System.ArgumentNullException">
 1613        /// Thrown when a required parameter is null
 1614        /// </exception>
 1615        /// <return>
 1616        /// A response object containing the response body and response headers.
 1617        /// </return>
 1618        public async Task<HttpOperationResponse<OperationStatus>> DeleteWithHttpMessagesAsync(System.Guid appId, bool? f
 1619        {
 321620            if (Client.Endpoint == null)
 1621            {
 01622                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1623            }
 1624            // Tracing
 321625            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 321626            string _invocationId = null;
 321627            if (_shouldTrace)
 1628            {
 01629                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01630                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01631                tracingParameters.Add("appId", appId);
 01632                tracingParameters.Add("force", force);
 01633                tracingParameters.Add("cancellationToken", cancellationToken);
 01634                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 1635            }
 1636            // Construct URL
 321637            var _baseUrl = Client.BaseUri;
 321638            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}";
 321639            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 321640            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 321641            List<string> _queryParameters = new List<string>();
 321642            if (force != null)
 1643            {
 321644                _queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonC
 1645            }
 321646            if (_queryParameters.Count > 0)
 1647            {
 321648                _url += "?" + string.Join("&", _queryParameters);
 1649            }
 1650            // Create HTTP transport objects
 321651            var _httpRequest = new HttpRequestMessage();
 321652            HttpResponseMessage _httpResponse = null;
 321653            _httpRequest.Method = new HttpMethod("DELETE");
 321654            _httpRequest.RequestUri = new System.Uri(_url);
 1655            // Set Headers
 1656
 1657
 321658            if (customHeaders != null)
 1659            {
 01660                foreach(var _header in customHeaders)
 1661                {
 01662                    if (_httpRequest.Headers.Contains(_header.Key))
 1663                    {
 01664                        _httpRequest.Headers.Remove(_header.Key);
 1665                    }
 01666                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1667                }
 1668            }
 1669
 1670            // Serialize Request
 321671            string _requestContent = null;
 1672            // Set Credentials
 321673            if (Client.Credentials != null)
 1674            {
 321675                cancellationToken.ThrowIfCancellationRequested();
 321676                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1677            }
 1678            // Send Request
 321679            if (_shouldTrace)
 1680            {
 01681                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1682            }
 321683            cancellationToken.ThrowIfCancellationRequested();
 321684            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 321685            if (_shouldTrace)
 1686            {
 01687                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1688            }
 321689            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 321690            cancellationToken.ThrowIfCancellationRequested();
 321691            string _responseContent = null;
 321692            if ((int)_statusCode != 200)
 1693            {
 01694                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1695                try
 1696                {
 01697                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01698                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01699                    if (_errorBody != null)
 1700                    {
 01701                        ex.Body = _errorBody;
 1702                    }
 01703                }
 01704                catch (JsonException)
 1705                {
 1706                    // Ignore the exception
 01707                }
 01708                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01709                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01710                if (_shouldTrace)
 1711                {
 01712                    ServiceClientTracing.Error(_invocationId, ex);
 1713                }
 01714                _httpRequest.Dispose();
 01715                if (_httpResponse != null)
 1716                {
 01717                    _httpResponse.Dispose();
 1718                }
 01719                throw ex;
 1720            }
 1721            // Create Result
 321722            var _result = new HttpOperationResponse<OperationStatus>();
 321723            _result.Request = _httpRequest;
 321724            _result.Response = _httpResponse;
 1725            // Deserialize Response
 321726            if ((int)_statusCode == 200)
 1727            {
 321728                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1729                try
 1730                {
 321731                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 321732                }
 01733                catch (JsonException ex)
 1734                {
 01735                    _httpRequest.Dispose();
 01736                    if (_httpResponse != null)
 1737                    {
 01738                        _httpResponse.Dispose();
 1739                    }
 01740                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1741                }
 1742            }
 321743            if (_shouldTrace)
 1744            {
 01745                ServiceClientTracing.Exit(_invocationId, _result);
 1746            }
 321747            return _result;
 321748        }
 1749
 1750        /// <summary>
 1751        /// Publishes a specific version of the application.
 1752        /// </summary>
 1753        /// <param name='appId'>
 1754        /// The application ID.
 1755        /// </param>
 1756        /// <param name='applicationPublishObject'>
 1757        /// The application publish object. The region is the target region that the
 1758        /// application is published to.
 1759        /// </param>
 1760        /// <param name='customHeaders'>
 1761        /// Headers that will be added to request.
 1762        /// </param>
 1763        /// <param name='cancellationToken'>
 1764        /// The cancellation token.
 1765        /// </param>
 1766        /// <exception cref="ErrorResponseException">
 1767        /// Thrown when the operation returned an invalid status code
 1768        /// </exception>
 1769        /// <exception cref="SerializationException">
 1770        /// Thrown when unable to deserialize the response
 1771        /// </exception>
 1772        /// <exception cref="ValidationException">
 1773        /// Thrown when a required parameter is null
 1774        /// </exception>
 1775        /// <exception cref="System.ArgumentNullException">
 1776        /// Thrown when a required parameter is null
 1777        /// </exception>
 1778        /// <return>
 1779        /// A response object containing the response body and response headers.
 1780        /// </return>
 1781        public async Task<HttpOperationResponse<ProductionOrStagingEndpointInfo>> PublishWithHttpMessagesAsync(System.Gu
 1782        {
 11783            if (Client.Endpoint == null)
 1784            {
 01785                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1786            }
 11787            if (applicationPublishObject == null)
 1788            {
 01789                throw new ValidationException(ValidationRules.CannotBeNull, "applicationPublishObject");
 1790            }
 1791            // Tracing
 11792            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 11793            string _invocationId = null;
 11794            if (_shouldTrace)
 1795            {
 01796                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01797                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01798                tracingParameters.Add("appId", appId);
 01799                tracingParameters.Add("applicationPublishObject", applicationPublishObject);
 01800                tracingParameters.Add("cancellationToken", cancellationToken);
 01801                ServiceClientTracing.Enter(_invocationId, this, "Publish", tracingParameters);
 1802            }
 1803            // Construct URL
 11804            var _baseUrl = Client.BaseUri;
 11805            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/publish";
 11806            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 11807            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 1808            // Create HTTP transport objects
 11809            var _httpRequest = new HttpRequestMessage();
 11810            HttpResponseMessage _httpResponse = null;
 11811            _httpRequest.Method = new HttpMethod("POST");
 11812            _httpRequest.RequestUri = new System.Uri(_url);
 1813            // Set Headers
 1814
 1815
 11816            if (customHeaders != null)
 1817            {
 01818                foreach(var _header in customHeaders)
 1819                {
 01820                    if (_httpRequest.Headers.Contains(_header.Key))
 1821                    {
 01822                        _httpRequest.Headers.Remove(_header.Key);
 1823                    }
 01824                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1825                }
 1826            }
 1827
 1828            // Serialize Request
 11829            string _requestContent = null;
 11830            if(applicationPublishObject != null)
 1831            {
 11832                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(applicationPublishObject, Client.Se
 11833                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 11834                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1835            }
 1836            // Set Credentials
 11837            if (Client.Credentials != null)
 1838            {
 11839                cancellationToken.ThrowIfCancellationRequested();
 11840                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1841            }
 1842            // Send Request
 11843            if (_shouldTrace)
 1844            {
 01845                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1846            }
 11847            cancellationToken.ThrowIfCancellationRequested();
 11848            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11849            if (_shouldTrace)
 1850            {
 01851                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1852            }
 11853            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 11854            cancellationToken.ThrowIfCancellationRequested();
 11855            string _responseContent = null;
 11856            if ((int)_statusCode != 201 && (int)_statusCode != 207)
 1857            {
 01858                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1859                try
 1860                {
 01861                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01862                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01863                    if (_errorBody != null)
 1864                    {
 01865                        ex.Body = _errorBody;
 1866                    }
 01867                }
 01868                catch (JsonException)
 1869                {
 1870                    // Ignore the exception
 01871                }
 01872                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01873                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01874                if (_shouldTrace)
 1875                {
 01876                    ServiceClientTracing.Error(_invocationId, ex);
 1877                }
 01878                _httpRequest.Dispose();
 01879                if (_httpResponse != null)
 1880                {
 01881                    _httpResponse.Dispose();
 1882                }
 01883                throw ex;
 1884            }
 1885            // Create Result
 11886            var _result = new HttpOperationResponse<ProductionOrStagingEndpointInfo>();
 11887            _result.Request = _httpRequest;
 11888            _result.Response = _httpResponse;
 1889            // Deserialize Response
 11890            if ((int)_statusCode == 201)
 1891            {
 11892                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1893                try
 1894                {
 11895                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ProductionOrStagingEndpointInfo>
 11896                }
 01897                catch (JsonException ex)
 1898                {
 01899                    _httpRequest.Dispose();
 01900                    if (_httpResponse != null)
 1901                    {
 01902                        _httpResponse.Dispose();
 1903                    }
 01904                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1905                }
 1906            }
 1907            // Deserialize Response
 11908            if ((int)_statusCode == 207)
 1909            {
 01910                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1911                try
 1912                {
 01913                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ProductionOrStagingEndpointInfo>
 01914                }
 01915                catch (JsonException ex)
 1916                {
 01917                    _httpRequest.Dispose();
 01918                    if (_httpResponse != null)
 1919                    {
 01920                        _httpResponse.Dispose();
 1921                    }
 01922                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1923                }
 1924            }
 11925            if (_shouldTrace)
 1926            {
 01927                ServiceClientTracing.Exit(_invocationId, _result);
 1928            }
 11929            return _result;
 11930        }
 1931
 1932        /// <summary>
 1933        /// Get the application settings including 'UseAllTrainingData'.
 1934        /// </summary>
 1935        /// <param name='appId'>
 1936        /// The application ID.
 1937        /// </param>
 1938        /// <param name='customHeaders'>
 1939        /// Headers that will be added to request.
 1940        /// </param>
 1941        /// <param name='cancellationToken'>
 1942        /// The cancellation token.
 1943        /// </param>
 1944        /// <exception cref="ErrorResponseException">
 1945        /// Thrown when the operation returned an invalid status code
 1946        /// </exception>
 1947        /// <exception cref="SerializationException">
 1948        /// Thrown when unable to deserialize the response
 1949        /// </exception>
 1950        /// <exception cref="ValidationException">
 1951        /// Thrown when a required parameter is null
 1952        /// </exception>
 1953        /// <exception cref="System.ArgumentNullException">
 1954        /// Thrown when a required parameter is null
 1955        /// </exception>
 1956        /// <return>
 1957        /// A response object containing the response body and response headers.
 1958        /// </return>
 1959        public async Task<HttpOperationResponse<ApplicationSettings>> GetSettingsWithHttpMessagesAsync(System.Guid appId
 1960        {
 21961            if (Client.Endpoint == null)
 1962            {
 01963                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1964            }
 1965            // Tracing
 21966            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 21967            string _invocationId = null;
 21968            if (_shouldTrace)
 1969            {
 01970                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01971                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01972                tracingParameters.Add("appId", appId);
 01973                tracingParameters.Add("cancellationToken", cancellationToken);
 01974                ServiceClientTracing.Enter(_invocationId, this, "GetSettings", tracingParameters);
 1975            }
 1976            // Construct URL
 21977            var _baseUrl = Client.BaseUri;
 21978            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/settings";
 21979            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 21980            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 1981            // Create HTTP transport objects
 21982            var _httpRequest = new HttpRequestMessage();
 21983            HttpResponseMessage _httpResponse = null;
 21984            _httpRequest.Method = new HttpMethod("GET");
 21985            _httpRequest.RequestUri = new System.Uri(_url);
 1986            // Set Headers
 1987
 1988
 21989            if (customHeaders != null)
 1990            {
 01991                foreach(var _header in customHeaders)
 1992                {
 01993                    if (_httpRequest.Headers.Contains(_header.Key))
 1994                    {
 01995                        _httpRequest.Headers.Remove(_header.Key);
 1996                    }
 01997                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1998                }
 1999            }
 2000
 2001            // Serialize Request
 22002            string _requestContent = null;
 2003            // Set Credentials
 22004            if (Client.Credentials != null)
 2005            {
 22006                cancellationToken.ThrowIfCancellationRequested();
 22007                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2008            }
 2009            // Send Request
 22010            if (_shouldTrace)
 2011            {
 02012                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2013            }
 22014            cancellationToken.ThrowIfCancellationRequested();
 22015            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 22016            if (_shouldTrace)
 2017            {
 02018                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2019            }
 22020            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 22021            cancellationToken.ThrowIfCancellationRequested();
 22022            string _responseContent = null;
 22023            if ((int)_statusCode != 200)
 2024            {
 02025                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2026                try
 2027                {
 02028                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02029                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02030                    if (_errorBody != null)
 2031                    {
 02032                        ex.Body = _errorBody;
 2033                    }
 02034                }
 02035                catch (JsonException)
 2036                {
 2037                    // Ignore the exception
 02038                }
 02039                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02040                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02041                if (_shouldTrace)
 2042                {
 02043                    ServiceClientTracing.Error(_invocationId, ex);
 2044                }
 02045                _httpRequest.Dispose();
 02046                if (_httpResponse != null)
 2047                {
 02048                    _httpResponse.Dispose();
 2049                }
 02050                throw ex;
 2051            }
 2052            // Create Result
 22053            var _result = new HttpOperationResponse<ApplicationSettings>();
 22054            _result.Request = _httpRequest;
 22055            _result.Response = _httpResponse;
 2056            // Deserialize Response
 22057            if ((int)_statusCode == 200)
 2058            {
 22059                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2060                try
 2061                {
 22062                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ApplicationSettings>(_responseCo
 22063                }
 02064                catch (JsonException ex)
 2065                {
 02066                    _httpRequest.Dispose();
 02067                    if (_httpResponse != null)
 2068                    {
 02069                        _httpResponse.Dispose();
 2070                    }
 02071                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2072                }
 2073            }
 22074            if (_shouldTrace)
 2075            {
 02076                ServiceClientTracing.Exit(_invocationId, _result);
 2077            }
 22078            return _result;
 22079        }
 2080
 2081        /// <summary>
 2082        /// Updates the application settings including 'UseAllTrainingData'.
 2083        /// </summary>
 2084        /// <param name='appId'>
 2085        /// The application ID.
 2086        /// </param>
 2087        /// <param name='applicationSettingUpdateObject'>
 2088        /// An object containing the new application settings.
 2089        /// </param>
 2090        /// <param name='customHeaders'>
 2091        /// Headers that will be added to request.
 2092        /// </param>
 2093        /// <param name='cancellationToken'>
 2094        /// The cancellation token.
 2095        /// </param>
 2096        /// <exception cref="ErrorResponseException">
 2097        /// Thrown when the operation returned an invalid status code
 2098        /// </exception>
 2099        /// <exception cref="SerializationException">
 2100        /// Thrown when unable to deserialize the response
 2101        /// </exception>
 2102        /// <exception cref="ValidationException">
 2103        /// Thrown when a required parameter is null
 2104        /// </exception>
 2105        /// <exception cref="System.ArgumentNullException">
 2106        /// Thrown when a required parameter is null
 2107        /// </exception>
 2108        /// <return>
 2109        /// A response object containing the response body and response headers.
 2110        /// </return>
 2111        public async Task<HttpOperationResponse<OperationStatus>> UpdateSettingsWithHttpMessagesAsync(System.Guid appId,
 2112        {
 12113            if (Client.Endpoint == null)
 2114            {
 02115                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2116            }
 12117            if (applicationSettingUpdateObject == null)
 2118            {
 02119                throw new ValidationException(ValidationRules.CannotBeNull, "applicationSettingUpdateObject");
 2120            }
 2121            // Tracing
 12122            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 12123            string _invocationId = null;
 12124            if (_shouldTrace)
 2125            {
 02126                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02127                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02128                tracingParameters.Add("appId", appId);
 02129                tracingParameters.Add("applicationSettingUpdateObject", applicationSettingUpdateObject);
 02130                tracingParameters.Add("cancellationToken", cancellationToken);
 02131                ServiceClientTracing.Enter(_invocationId, this, "UpdateSettings", tracingParameters);
 2132            }
 2133            // Construct URL
 12134            var _baseUrl = Client.BaseUri;
 12135            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/settings";
 12136            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 12137            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 2138            // Create HTTP transport objects
 12139            var _httpRequest = new HttpRequestMessage();
 12140            HttpResponseMessage _httpResponse = null;
 12141            _httpRequest.Method = new HttpMethod("PUT");
 12142            _httpRequest.RequestUri = new System.Uri(_url);
 2143            // Set Headers
 2144
 2145
 12146            if (customHeaders != null)
 2147            {
 02148                foreach(var _header in customHeaders)
 2149                {
 02150                    if (_httpRequest.Headers.Contains(_header.Key))
 2151                    {
 02152                        _httpRequest.Headers.Remove(_header.Key);
 2153                    }
 02154                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2155                }
 2156            }
 2157
 2158            // Serialize Request
 12159            string _requestContent = null;
 12160            if(applicationSettingUpdateObject != null)
 2161            {
 12162                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(applicationSettingUpdateObject, Cli
 12163                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 12164                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 2165            }
 2166            // Set Credentials
 12167            if (Client.Credentials != null)
 2168            {
 12169                cancellationToken.ThrowIfCancellationRequested();
 12170                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2171            }
 2172            // Send Request
 12173            if (_shouldTrace)
 2174            {
 02175                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2176            }
 12177            cancellationToken.ThrowIfCancellationRequested();
 12178            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12179            if (_shouldTrace)
 2180            {
 02181                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2182            }
 12183            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 12184            cancellationToken.ThrowIfCancellationRequested();
 12185            string _responseContent = null;
 12186            if ((int)_statusCode != 200)
 2187            {
 02188                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2189                try
 2190                {
 02191                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02192                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02193                    if (_errorBody != null)
 2194                    {
 02195                        ex.Body = _errorBody;
 2196                    }
 02197                }
 02198                catch (JsonException)
 2199                {
 2200                    // Ignore the exception
 02201                }
 02202                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02203                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02204                if (_shouldTrace)
 2205                {
 02206                    ServiceClientTracing.Error(_invocationId, ex);
 2207                }
 02208                _httpRequest.Dispose();
 02209                if (_httpResponse != null)
 2210                {
 02211                    _httpResponse.Dispose();
 2212                }
 02213                throw ex;
 2214            }
 2215            // Create Result
 12216            var _result = new HttpOperationResponse<OperationStatus>();
 12217            _result.Request = _httpRequest;
 12218            _result.Response = _httpResponse;
 2219            // Deserialize Response
 12220            if ((int)_statusCode == 200)
 2221            {
 12222                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2223                try
 2224                {
 12225                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 12226                }
 02227                catch (JsonException ex)
 2228                {
 02229                    _httpRequest.Dispose();
 02230                    if (_httpResponse != null)
 2231                    {
 02232                        _httpResponse.Dispose();
 2233                    }
 02234                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2235                }
 2236            }
 12237            if (_shouldTrace)
 2238            {
 02239                ServiceClientTracing.Exit(_invocationId, _result);
 2240            }
 12241            return _result;
 12242        }
 2243
 2244        /// <summary>
 2245        /// Get the application publish settings including 'UseAllTrainingData'.
 2246        /// </summary>
 2247        /// <param name='appId'>
 2248        /// The application ID.
 2249        /// </param>
 2250        /// <param name='customHeaders'>
 2251        /// Headers that will be added to request.
 2252        /// </param>
 2253        /// <param name='cancellationToken'>
 2254        /// The cancellation token.
 2255        /// </param>
 2256        /// <exception cref="ErrorResponseException">
 2257        /// Thrown when the operation returned an invalid status code
 2258        /// </exception>
 2259        /// <exception cref="SerializationException">
 2260        /// Thrown when unable to deserialize the response
 2261        /// </exception>
 2262        /// <exception cref="ValidationException">
 2263        /// Thrown when a required parameter is null
 2264        /// </exception>
 2265        /// <exception cref="System.ArgumentNullException">
 2266        /// Thrown when a required parameter is null
 2267        /// </exception>
 2268        /// <return>
 2269        /// A response object containing the response body and response headers.
 2270        /// </return>
 2271        public async Task<HttpOperationResponse<PublishSettings>> GetPublishSettingsWithHttpMessagesAsync(System.Guid ap
 2272        {
 22273            if (Client.Endpoint == null)
 2274            {
 02275                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2276            }
 2277            // Tracing
 22278            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 22279            string _invocationId = null;
 22280            if (_shouldTrace)
 2281            {
 02282                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02283                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02284                tracingParameters.Add("appId", appId);
 02285                tracingParameters.Add("cancellationToken", cancellationToken);
 02286                ServiceClientTracing.Enter(_invocationId, this, "GetPublishSettings", tracingParameters);
 2287            }
 2288            // Construct URL
 22289            var _baseUrl = Client.BaseUri;
 22290            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/publishsettings";
 22291            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 22292            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 2293            // Create HTTP transport objects
 22294            var _httpRequest = new HttpRequestMessage();
 22295            HttpResponseMessage _httpResponse = null;
 22296            _httpRequest.Method = new HttpMethod("GET");
 22297            _httpRequest.RequestUri = new System.Uri(_url);
 2298            // Set Headers
 2299
 2300
 22301            if (customHeaders != null)
 2302            {
 02303                foreach(var _header in customHeaders)
 2304                {
 02305                    if (_httpRequest.Headers.Contains(_header.Key))
 2306                    {
 02307                        _httpRequest.Headers.Remove(_header.Key);
 2308                    }
 02309                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2310                }
 2311            }
 2312
 2313            // Serialize Request
 22314            string _requestContent = null;
 2315            // Set Credentials
 22316            if (Client.Credentials != null)
 2317            {
 22318                cancellationToken.ThrowIfCancellationRequested();
 22319                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2320            }
 2321            // Send Request
 22322            if (_shouldTrace)
 2323            {
 02324                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2325            }
 22326            cancellationToken.ThrowIfCancellationRequested();
 22327            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 22328            if (_shouldTrace)
 2329            {
 02330                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2331            }
 22332            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 22333            cancellationToken.ThrowIfCancellationRequested();
 22334            string _responseContent = null;
 22335            if ((int)_statusCode != 200)
 2336            {
 02337                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2338                try
 2339                {
 02340                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02341                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02342                    if (_errorBody != null)
 2343                    {
 02344                        ex.Body = _errorBody;
 2345                    }
 02346                }
 02347                catch (JsonException)
 2348                {
 2349                    // Ignore the exception
 02350                }
 02351                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02352                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02353                if (_shouldTrace)
 2354                {
 02355                    ServiceClientTracing.Error(_invocationId, ex);
 2356                }
 02357                _httpRequest.Dispose();
 02358                if (_httpResponse != null)
 2359                {
 02360                    _httpResponse.Dispose();
 2361                }
 02362                throw ex;
 2363            }
 2364            // Create Result
 22365            var _result = new HttpOperationResponse<PublishSettings>();
 22366            _result.Request = _httpRequest;
 22367            _result.Response = _httpResponse;
 2368            // Deserialize Response
 22369            if ((int)_statusCode == 200)
 2370            {
 22371                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2372                try
 2373                {
 22374                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<PublishSettings>(_responseConten
 22375                }
 02376                catch (JsonException ex)
 2377                {
 02378                    _httpRequest.Dispose();
 02379                    if (_httpResponse != null)
 2380                    {
 02381                        _httpResponse.Dispose();
 2382                    }
 02383                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2384                }
 2385            }
 22386            if (_shouldTrace)
 2387            {
 02388                ServiceClientTracing.Exit(_invocationId, _result);
 2389            }
 22390            return _result;
 22391        }
 2392
 2393        /// <summary>
 2394        /// Updates the application publish settings including 'UseAllTrainingData'.
 2395        /// </summary>
 2396        /// <param name='appId'>
 2397        /// The application ID.
 2398        /// </param>
 2399        /// <param name='publishSettingUpdateObject'>
 2400        /// An object containing the new publish application settings.
 2401        /// </param>
 2402        /// <param name='customHeaders'>
 2403        /// Headers that will be added to request.
 2404        /// </param>
 2405        /// <param name='cancellationToken'>
 2406        /// The cancellation token.
 2407        /// </param>
 2408        /// <exception cref="ErrorResponseException">
 2409        /// Thrown when the operation returned an invalid status code
 2410        /// </exception>
 2411        /// <exception cref="SerializationException">
 2412        /// Thrown when unable to deserialize the response
 2413        /// </exception>
 2414        /// <exception cref="ValidationException">
 2415        /// Thrown when a required parameter is null
 2416        /// </exception>
 2417        /// <exception cref="System.ArgumentNullException">
 2418        /// Thrown when a required parameter is null
 2419        /// </exception>
 2420        /// <return>
 2421        /// A response object containing the response body and response headers.
 2422        /// </return>
 2423        public async Task<HttpOperationResponse<OperationStatus>> UpdatePublishSettingsWithHttpMessagesAsync(System.Guid
 2424        {
 12425            if (Client.Endpoint == null)
 2426            {
 02427                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2428            }
 12429            if (publishSettingUpdateObject == null)
 2430            {
 02431                throw new ValidationException(ValidationRules.CannotBeNull, "publishSettingUpdateObject");
 2432            }
 2433            // Tracing
 12434            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 12435            string _invocationId = null;
 12436            if (_shouldTrace)
 2437            {
 02438                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02439                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02440                tracingParameters.Add("appId", appId);
 02441                tracingParameters.Add("publishSettingUpdateObject", publishSettingUpdateObject);
 02442                tracingParameters.Add("cancellationToken", cancellationToken);
 02443                ServiceClientTracing.Enter(_invocationId, this, "UpdatePublishSettings", tracingParameters);
 2444            }
 2445            // Construct URL
 12446            var _baseUrl = Client.BaseUri;
 12447            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/publishsettings";
 12448            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 12449            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 2450            // Create HTTP transport objects
 12451            var _httpRequest = new HttpRequestMessage();
 12452            HttpResponseMessage _httpResponse = null;
 12453            _httpRequest.Method = new HttpMethod("PUT");
 12454            _httpRequest.RequestUri = new System.Uri(_url);
 2455            // Set Headers
 2456
 2457
 12458            if (customHeaders != null)
 2459            {
 02460                foreach(var _header in customHeaders)
 2461                {
 02462                    if (_httpRequest.Headers.Contains(_header.Key))
 2463                    {
 02464                        _httpRequest.Headers.Remove(_header.Key);
 2465                    }
 02466                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2467                }
 2468            }
 2469
 2470            // Serialize Request
 12471            string _requestContent = null;
 12472            if(publishSettingUpdateObject != null)
 2473            {
 12474                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(publishSettingUpdateObject, Client.
 12475                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 12476                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 2477            }
 2478            // Set Credentials
 12479            if (Client.Credentials != null)
 2480            {
 12481                cancellationToken.ThrowIfCancellationRequested();
 12482                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2483            }
 2484            // Send Request
 12485            if (_shouldTrace)
 2486            {
 02487                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2488            }
 12489            cancellationToken.ThrowIfCancellationRequested();
 12490            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12491            if (_shouldTrace)
 2492            {
 02493                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2494            }
 12495            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 12496            cancellationToken.ThrowIfCancellationRequested();
 12497            string _responseContent = null;
 12498            if ((int)_statusCode != 200)
 2499            {
 02500                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2501                try
 2502                {
 02503                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02504                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02505                    if (_errorBody != null)
 2506                    {
 02507                        ex.Body = _errorBody;
 2508                    }
 02509                }
 02510                catch (JsonException)
 2511                {
 2512                    // Ignore the exception
 02513                }
 02514                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02515                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02516                if (_shouldTrace)
 2517                {
 02518                    ServiceClientTracing.Error(_invocationId, ex);
 2519                }
 02520                _httpRequest.Dispose();
 02521                if (_httpResponse != null)
 2522                {
 02523                    _httpResponse.Dispose();
 2524                }
 02525                throw ex;
 2526            }
 2527            // Create Result
 12528            var _result = new HttpOperationResponse<OperationStatus>();
 12529            _result.Request = _httpRequest;
 12530            _result.Response = _httpResponse;
 2531            // Deserialize Response
 12532            if ((int)_statusCode == 200)
 2533            {
 12534                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2535                try
 2536                {
 12537                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 12538                }
 02539                catch (JsonException ex)
 2540                {
 02541                    _httpRequest.Dispose();
 02542                    if (_httpResponse != null)
 2543                    {
 02544                        _httpResponse.Dispose();
 2545                    }
 02546                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2547                }
 2548            }
 12549            if (_shouldTrace)
 2550            {
 02551                ServiceClientTracing.Exit(_invocationId, _result);
 2552            }
 12553            return _result;
 12554        }
 2555
 2556        /// <summary>
 2557        /// Returns the available endpoint deployment regions and URLs.
 2558        /// </summary>
 2559        /// <param name='appId'>
 2560        /// The application ID.
 2561        /// </param>
 2562        /// <param name='customHeaders'>
 2563        /// Headers that will be added to request.
 2564        /// </param>
 2565        /// <param name='cancellationToken'>
 2566        /// The cancellation token.
 2567        /// </param>
 2568        /// <exception cref="ErrorResponseException">
 2569        /// Thrown when the operation returned an invalid status code
 2570        /// </exception>
 2571        /// <exception cref="SerializationException">
 2572        /// Thrown when unable to deserialize the response
 2573        /// </exception>
 2574        /// <exception cref="ValidationException">
 2575        /// Thrown when a required parameter is null
 2576        /// </exception>
 2577        /// <exception cref="System.ArgumentNullException">
 2578        /// Thrown when a required parameter is null
 2579        /// </exception>
 2580        /// <return>
 2581        /// A response object containing the response body and response headers.
 2582        /// </return>
 2583        public async Task<HttpOperationResponse<IDictionary<string, string>>> ListEndpointsWithHttpMessagesAsync(System.
 2584        {
 12585            if (Client.Endpoint == null)
 2586            {
 02587                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2588            }
 2589            // Tracing
 12590            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 12591            string _invocationId = null;
 12592            if (_shouldTrace)
 2593            {
 02594                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02595                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02596                tracingParameters.Add("appId", appId);
 02597                tracingParameters.Add("cancellationToken", cancellationToken);
 02598                ServiceClientTracing.Enter(_invocationId, this, "ListEndpoints", tracingParameters);
 2599            }
 2600            // Construct URL
 12601            var _baseUrl = Client.BaseUri;
 12602            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/endpoints";
 12603            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 12604            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 2605            // Create HTTP transport objects
 12606            var _httpRequest = new HttpRequestMessage();
 12607            HttpResponseMessage _httpResponse = null;
 12608            _httpRequest.Method = new HttpMethod("GET");
 12609            _httpRequest.RequestUri = new System.Uri(_url);
 2610            // Set Headers
 2611
 2612
 12613            if (customHeaders != null)
 2614            {
 02615                foreach(var _header in customHeaders)
 2616                {
 02617                    if (_httpRequest.Headers.Contains(_header.Key))
 2618                    {
 02619                        _httpRequest.Headers.Remove(_header.Key);
 2620                    }
 02621                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2622                }
 2623            }
 2624
 2625            // Serialize Request
 12626            string _requestContent = null;
 2627            // Set Credentials
 12628            if (Client.Credentials != null)
 2629            {
 12630                cancellationToken.ThrowIfCancellationRequested();
 12631                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2632            }
 2633            // Send Request
 12634            if (_shouldTrace)
 2635            {
 02636                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2637            }
 12638            cancellationToken.ThrowIfCancellationRequested();
 12639            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12640            if (_shouldTrace)
 2641            {
 02642                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2643            }
 12644            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 12645            cancellationToken.ThrowIfCancellationRequested();
 12646            string _responseContent = null;
 12647            if ((int)_statusCode != 200)
 2648            {
 02649                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2650                try
 2651                {
 02652                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02653                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02654                    if (_errorBody != null)
 2655                    {
 02656                        ex.Body = _errorBody;
 2657                    }
 02658                }
 02659                catch (JsonException)
 2660                {
 2661                    // Ignore the exception
 02662                }
 02663                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02664                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02665                if (_shouldTrace)
 2666                {
 02667                    ServiceClientTracing.Error(_invocationId, ex);
 2668                }
 02669                _httpRequest.Dispose();
 02670                if (_httpResponse != null)
 2671                {
 02672                    _httpResponse.Dispose();
 2673                }
 02674                throw ex;
 2675            }
 2676            // Create Result
 12677            var _result = new HttpOperationResponse<IDictionary<string, string>>();
 12678            _result.Request = _httpRequest;
 12679            _result.Response = _httpResponse;
 2680            // Deserialize Response
 12681            if ((int)_statusCode == 200)
 2682            {
 12683                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2684                try
 2685                {
 12686                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IDictionary<string, string>>(_re
 12687                }
 02688                catch (JsonException ex)
 2689                {
 02690                    _httpRequest.Dispose();
 02691                    if (_httpResponse != null)
 2692                    {
 02693                        _httpResponse.Dispose();
 2694                    }
 02695                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2696                }
 2697            }
 12698            if (_shouldTrace)
 2699            {
 02700                ServiceClientTracing.Exit(_invocationId, _result);
 2701            }
 12702            return _result;
 12703        }
 2704
 2705        /// <summary>
 2706        /// Gets all the available custom prebuilt domains for all cultures.
 2707        /// </summary>
 2708        /// <param name='customHeaders'>
 2709        /// Headers that will be added to request.
 2710        /// </param>
 2711        /// <param name='cancellationToken'>
 2712        /// The cancellation token.
 2713        /// </param>
 2714        /// <exception cref="ErrorResponseException">
 2715        /// Thrown when the operation returned an invalid status code
 2716        /// </exception>
 2717        /// <exception cref="SerializationException">
 2718        /// Thrown when unable to deserialize the response
 2719        /// </exception>
 2720        /// <exception cref="ValidationException">
 2721        /// Thrown when a required parameter is null
 2722        /// </exception>
 2723        /// <exception cref="System.ArgumentNullException">
 2724        /// Thrown when a required parameter is null
 2725        /// </exception>
 2726        /// <return>
 2727        /// A response object containing the response body and response headers.
 2728        /// </return>
 2729        public async Task<HttpOperationResponse<IList<PrebuiltDomain>>> ListAvailableCustomPrebuiltDomainsWithHttpMessag
 2730        {
 12731            if (Client.Endpoint == null)
 2732            {
 02733                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2734            }
 2735            // Tracing
 12736            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 12737            string _invocationId = null;
 12738            if (_shouldTrace)
 2739            {
 02740                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02741                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02742                tracingParameters.Add("cancellationToken", cancellationToken);
 02743                ServiceClientTracing.Enter(_invocationId, this, "ListAvailableCustomPrebuiltDomains", tracingParameters)
 2744            }
 2745            // Construct URL
 12746            var _baseUrl = Client.BaseUri;
 12747            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/customprebuiltdomains";
 12748            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 2749            // Create HTTP transport objects
 12750            var _httpRequest = new HttpRequestMessage();
 12751            HttpResponseMessage _httpResponse = null;
 12752            _httpRequest.Method = new HttpMethod("GET");
 12753            _httpRequest.RequestUri = new System.Uri(_url);
 2754            // Set Headers
 2755
 2756
 12757            if (customHeaders != null)
 2758            {
 02759                foreach(var _header in customHeaders)
 2760                {
 02761                    if (_httpRequest.Headers.Contains(_header.Key))
 2762                    {
 02763                        _httpRequest.Headers.Remove(_header.Key);
 2764                    }
 02765                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2766                }
 2767            }
 2768
 2769            // Serialize Request
 12770            string _requestContent = null;
 2771            // Set Credentials
 12772            if (Client.Credentials != null)
 2773            {
 12774                cancellationToken.ThrowIfCancellationRequested();
 12775                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2776            }
 2777            // Send Request
 12778            if (_shouldTrace)
 2779            {
 02780                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2781            }
 12782            cancellationToken.ThrowIfCancellationRequested();
 12783            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12784            if (_shouldTrace)
 2785            {
 02786                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2787            }
 12788            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 12789            cancellationToken.ThrowIfCancellationRequested();
 12790            string _responseContent = null;
 12791            if ((int)_statusCode != 200)
 2792            {
 02793                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2794                try
 2795                {
 02796                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02797                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02798                    if (_errorBody != null)
 2799                    {
 02800                        ex.Body = _errorBody;
 2801                    }
 02802                }
 02803                catch (JsonException)
 2804                {
 2805                    // Ignore the exception
 02806                }
 02807                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02808                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02809                if (_shouldTrace)
 2810                {
 02811                    ServiceClientTracing.Error(_invocationId, ex);
 2812                }
 02813                _httpRequest.Dispose();
 02814                if (_httpResponse != null)
 2815                {
 02816                    _httpResponse.Dispose();
 2817                }
 02818                throw ex;
 2819            }
 2820            // Create Result
 12821            var _result = new HttpOperationResponse<IList<PrebuiltDomain>>();
 12822            _result.Request = _httpRequest;
 12823            _result.Response = _httpResponse;
 2824            // Deserialize Response
 12825            if ((int)_statusCode == 200)
 2826            {
 12827                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2828                try
 2829                {
 12830                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<PrebuiltDomain>>(_response
 12831                }
 02832                catch (JsonException ex)
 2833                {
 02834                    _httpRequest.Dispose();
 02835                    if (_httpResponse != null)
 2836                    {
 02837                        _httpResponse.Dispose();
 2838                    }
 02839                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2840                }
 2841            }
 12842            if (_shouldTrace)
 2843            {
 02844                ServiceClientTracing.Exit(_invocationId, _result);
 2845            }
 12846            return _result;
 12847        }
 2848
 2849        /// <summary>
 2850        /// Adds a prebuilt domain along with its intent and entity models as a new
 2851        /// application.
 2852        /// </summary>
 2853        /// <param name='prebuiltDomainCreateObject'>
 2854        /// A prebuilt domain create object containing the name and culture of the
 2855        /// domain.
 2856        /// </param>
 2857        /// <param name='customHeaders'>
 2858        /// Headers that will be added to request.
 2859        /// </param>
 2860        /// <param name='cancellationToken'>
 2861        /// The cancellation token.
 2862        /// </param>
 2863        /// <exception cref="ErrorResponseException">
 2864        /// Thrown when the operation returned an invalid status code
 2865        /// </exception>
 2866        /// <exception cref="SerializationException">
 2867        /// Thrown when unable to deserialize the response
 2868        /// </exception>
 2869        /// <exception cref="ValidationException">
 2870        /// Thrown when a required parameter is null
 2871        /// </exception>
 2872        /// <exception cref="System.ArgumentNullException">
 2873        /// Thrown when a required parameter is null
 2874        /// </exception>
 2875        /// <return>
 2876        /// A response object containing the response body and response headers.
 2877        /// </return>
 2878        public async Task<HttpOperationResponse<System.Guid>> AddCustomPrebuiltDomainWithHttpMessagesAsync(PrebuiltDomai
 2879        {
 12880            if (Client.Endpoint == null)
 2881            {
 02882                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2883            }
 12884            if (prebuiltDomainCreateObject == null)
 2885            {
 02886                throw new ValidationException(ValidationRules.CannotBeNull, "prebuiltDomainCreateObject");
 2887            }
 2888            // Tracing
 12889            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 12890            string _invocationId = null;
 12891            if (_shouldTrace)
 2892            {
 02893                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02894                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02895                tracingParameters.Add("prebuiltDomainCreateObject", prebuiltDomainCreateObject);
 02896                tracingParameters.Add("cancellationToken", cancellationToken);
 02897                ServiceClientTracing.Enter(_invocationId, this, "AddCustomPrebuiltDomain", tracingParameters);
 2898            }
 2899            // Construct URL
 12900            var _baseUrl = Client.BaseUri;
 12901            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/customprebuiltdomains";
 12902            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 2903            // Create HTTP transport objects
 12904            var _httpRequest = new HttpRequestMessage();
 12905            HttpResponseMessage _httpResponse = null;
 12906            _httpRequest.Method = new HttpMethod("POST");
 12907            _httpRequest.RequestUri = new System.Uri(_url);
 2908            // Set Headers
 2909
 2910
 12911            if (customHeaders != null)
 2912            {
 02913                foreach(var _header in customHeaders)
 2914                {
 02915                    if (_httpRequest.Headers.Contains(_header.Key))
 2916                    {
 02917                        _httpRequest.Headers.Remove(_header.Key);
 2918                    }
 02919                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2920                }
 2921            }
 2922
 2923            // Serialize Request
 12924            string _requestContent = null;
 12925            if(prebuiltDomainCreateObject != null)
 2926            {
 12927                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(prebuiltDomainCreateObject, Client.
 12928                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 12929                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 2930            }
 2931            // Set Credentials
 12932            if (Client.Credentials != null)
 2933            {
 12934                cancellationToken.ThrowIfCancellationRequested();
 12935                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2936            }
 2937            // Send Request
 12938            if (_shouldTrace)
 2939            {
 02940                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2941            }
 12942            cancellationToken.ThrowIfCancellationRequested();
 12943            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12944            if (_shouldTrace)
 2945            {
 02946                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2947            }
 12948            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 12949            cancellationToken.ThrowIfCancellationRequested();
 12950            string _responseContent = null;
 12951            if ((int)_statusCode != 201)
 2952            {
 02953                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2954                try
 2955                {
 02956                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02957                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02958                    if (_errorBody != null)
 2959                    {
 02960                        ex.Body = _errorBody;
 2961                    }
 02962                }
 02963                catch (JsonException)
 2964                {
 2965                    // Ignore the exception
 02966                }
 02967                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02968                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02969                if (_shouldTrace)
 2970                {
 02971                    ServiceClientTracing.Error(_invocationId, ex);
 2972                }
 02973                _httpRequest.Dispose();
 02974                if (_httpResponse != null)
 2975                {
 02976                    _httpResponse.Dispose();
 2977                }
 02978                throw ex;
 2979            }
 2980            // Create Result
 12981            var _result = new HttpOperationResponse<System.Guid>();
 12982            _result.Request = _httpRequest;
 12983            _result.Response = _httpResponse;
 2984            // Deserialize Response
 12985            if ((int)_statusCode == 201)
 2986            {
 12987                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2988                try
 2989                {
 12990                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 12991                }
 02992                catch (JsonException ex)
 2993                {
 02994                    _httpRequest.Dispose();
 02995                    if (_httpResponse != null)
 2996                    {
 02997                        _httpResponse.Dispose();
 2998                    }
 02999                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3000                }
 3001            }
 13002            if (_shouldTrace)
 3003            {
 03004                ServiceClientTracing.Exit(_invocationId, _result);
 3005            }
 13006            return _result;
 13007        }
 3008
 3009        /// <summary>
 3010        /// Gets all the available prebuilt domains for a specific culture.
 3011        /// </summary>
 3012        /// <param name='culture'>
 3013        /// Culture.
 3014        /// </param>
 3015        /// <param name='customHeaders'>
 3016        /// Headers that will be added to request.
 3017        /// </param>
 3018        /// <param name='cancellationToken'>
 3019        /// The cancellation token.
 3020        /// </param>
 3021        /// <exception cref="ErrorResponseException">
 3022        /// Thrown when the operation returned an invalid status code
 3023        /// </exception>
 3024        /// <exception cref="SerializationException">
 3025        /// Thrown when unable to deserialize the response
 3026        /// </exception>
 3027        /// <exception cref="ValidationException">
 3028        /// Thrown when a required parameter is null
 3029        /// </exception>
 3030        /// <exception cref="System.ArgumentNullException">
 3031        /// Thrown when a required parameter is null
 3032        /// </exception>
 3033        /// <return>
 3034        /// A response object containing the response body and response headers.
 3035        /// </return>
 3036        public async Task<HttpOperationResponse<IList<PrebuiltDomain>>> ListAvailableCustomPrebuiltDomainsForCultureWith
 3037        {
 23038            if (Client.Endpoint == null)
 3039            {
 03040                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3041            }
 23042            if (culture == null)
 3043            {
 03044                throw new ValidationException(ValidationRules.CannotBeNull, "culture");
 3045            }
 3046            // Tracing
 23047            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 23048            string _invocationId = null;
 23049            if (_shouldTrace)
 3050            {
 03051                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03052                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03053                tracingParameters.Add("culture", culture);
 03054                tracingParameters.Add("cancellationToken", cancellationToken);
 03055                ServiceClientTracing.Enter(_invocationId, this, "ListAvailableCustomPrebuiltDomainsForCulture", tracingP
 3056            }
 3057            // Construct URL
 23058            var _baseUrl = Client.BaseUri;
 23059            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/customprebuiltdomains/{culture}";
 23060            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 23061            _url = _url.Replace("{culture}", System.Uri.EscapeDataString(culture));
 3062            // Create HTTP transport objects
 23063            var _httpRequest = new HttpRequestMessage();
 23064            HttpResponseMessage _httpResponse = null;
 23065            _httpRequest.Method = new HttpMethod("GET");
 23066            _httpRequest.RequestUri = new System.Uri(_url);
 3067            // Set Headers
 3068
 3069
 23070            if (customHeaders != null)
 3071            {
 03072                foreach(var _header in customHeaders)
 3073                {
 03074                    if (_httpRequest.Headers.Contains(_header.Key))
 3075                    {
 03076                        _httpRequest.Headers.Remove(_header.Key);
 3077                    }
 03078                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3079                }
 3080            }
 3081
 3082            // Serialize Request
 23083            string _requestContent = null;
 3084            // Set Credentials
 23085            if (Client.Credentials != null)
 3086            {
 23087                cancellationToken.ThrowIfCancellationRequested();
 23088                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3089            }
 3090            // Send Request
 23091            if (_shouldTrace)
 3092            {
 03093                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3094            }
 23095            cancellationToken.ThrowIfCancellationRequested();
 23096            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 23097            if (_shouldTrace)
 3098            {
 03099                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3100            }
 23101            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 23102            cancellationToken.ThrowIfCancellationRequested();
 23103            string _responseContent = null;
 23104            if ((int)_statusCode != 200)
 3105            {
 03106                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3107                try
 3108                {
 03109                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03110                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03111                    if (_errorBody != null)
 3112                    {
 03113                        ex.Body = _errorBody;
 3114                    }
 03115                }
 03116                catch (JsonException)
 3117                {
 3118                    // Ignore the exception
 03119                }
 03120                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03121                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03122                if (_shouldTrace)
 3123                {
 03124                    ServiceClientTracing.Error(_invocationId, ex);
 3125                }
 03126                _httpRequest.Dispose();
 03127                if (_httpResponse != null)
 3128                {
 03129                    _httpResponse.Dispose();
 3130                }
 03131                throw ex;
 3132            }
 3133            // Create Result
 23134            var _result = new HttpOperationResponse<IList<PrebuiltDomain>>();
 23135            _result.Request = _httpRequest;
 23136            _result.Response = _httpResponse;
 3137            // Deserialize Response
 23138            if ((int)_statusCode == 200)
 3139            {
 23140                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3141                try
 3142                {
 23143                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<PrebuiltDomain>>(_response
 23144                }
 03145                catch (JsonException ex)
 3146                {
 03147                    _httpRequest.Dispose();
 03148                    if (_httpResponse != null)
 3149                    {
 03150                        _httpResponse.Dispose();
 3151                    }
 03152                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3153                }
 3154            }
 23155            if (_shouldTrace)
 3156            {
 03157                ServiceClientTracing.Exit(_invocationId, _result);
 3158            }
 23159            return _result;
 23160        }
 3161
 3162        /// <summary>
 3163        /// package - Gets published LUIS application package in binary stream GZip
 3164        /// format
 3165        /// </summary>
 3166        /// <remarks>
 3167        /// Packages a published LUIS application as a GZip file to be used in the LUIS
 3168        /// container.
 3169        /// </remarks>
 3170        /// <param name='appId'>
 3171        /// The application ID.
 3172        /// </param>
 3173        /// <param name='slotName'>
 3174        /// The publishing slot name.
 3175        /// </param>
 3176        /// <param name='customHeaders'>
 3177        /// Headers that will be added to request.
 3178        /// </param>
 3179        /// <param name='cancellationToken'>
 3180        /// The cancellation token.
 3181        /// </param>
 3182        /// <exception cref="ErrorResponseException">
 3183        /// Thrown when the operation returned an invalid status code
 3184        /// </exception>
 3185        /// <exception cref="SerializationException">
 3186        /// Thrown when unable to deserialize the response
 3187        /// </exception>
 3188        /// <exception cref="ValidationException">
 3189        /// Thrown when a required parameter is null
 3190        /// </exception>
 3191        /// <exception cref="System.ArgumentNullException">
 3192        /// Thrown when a required parameter is null
 3193        /// </exception>
 3194        /// <return>
 3195        /// A response object containing the response body and response headers.
 3196        /// </return>
 3197        public async Task<HttpOperationResponse<Stream>> PackagePublishedApplicationAsGzipWithHttpMessagesAsync(System.G
 3198        {
 03199            if (Client.Endpoint == null)
 3200            {
 03201                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3202            }
 03203            if (slotName == null)
 3204            {
 03205                throw new ValidationException(ValidationRules.CannotBeNull, "slotName");
 3206            }
 3207            // Tracing
 03208            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 03209            string _invocationId = null;
 03210            if (_shouldTrace)
 3211            {
 03212                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03213                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03214                tracingParameters.Add("appId", appId);
 03215                tracingParameters.Add("slotName", slotName);
 03216                tracingParameters.Add("cancellationToken", cancellationToken);
 03217                ServiceClientTracing.Enter(_invocationId, this, "PackagePublishedApplicationAsGzip", tracingParameters);
 3218            }
 3219            // Construct URL
 03220            var _baseUrl = Client.BaseUri;
 03221            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "package/{appId}/slot/{slotName}/gzip";
 03222            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 03223            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 03224            _url = _url.Replace("{slotName}", System.Uri.EscapeDataString(slotName));
 3225            // Create HTTP transport objects
 03226            var _httpRequest = new HttpRequestMessage();
 03227            HttpResponseMessage _httpResponse = null;
 03228            _httpRequest.Method = new HttpMethod("GET");
 03229            _httpRequest.RequestUri = new System.Uri(_url);
 3230            // Set Headers
 3231
 3232
 03233            if (customHeaders != null)
 3234            {
 03235                foreach(var _header in customHeaders)
 3236                {
 03237                    if (_httpRequest.Headers.Contains(_header.Key))
 3238                    {
 03239                        _httpRequest.Headers.Remove(_header.Key);
 3240                    }
 03241                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3242                }
 3243            }
 3244
 3245            // Serialize Request
 03246            string _requestContent = null;
 3247            // Set Credentials
 03248            if (Client.Credentials != null)
 3249            {
 03250                cancellationToken.ThrowIfCancellationRequested();
 03251                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3252            }
 3253            // Send Request
 03254            if (_shouldTrace)
 3255            {
 03256                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3257            }
 03258            cancellationToken.ThrowIfCancellationRequested();
 03259            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons
 03260            if (_shouldTrace)
 3261            {
 03262                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3263            }
 03264            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03265            cancellationToken.ThrowIfCancellationRequested();
 03266            string _responseContent = null;
 03267            if ((int)_statusCode != 200)
 3268            {
 03269                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3270                try
 3271                {
 03272                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03273                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03274                    if (_errorBody != null)
 3275                    {
 03276                        ex.Body = _errorBody;
 3277                    }
 03278                }
 03279                catch (JsonException)
 3280                {
 3281                    // Ignore the exception
 03282                }
 03283                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03284                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03285                if (_shouldTrace)
 3286                {
 03287                    ServiceClientTracing.Error(_invocationId, ex);
 3288                }
 03289                _httpRequest.Dispose();
 03290                if (_httpResponse != null)
 3291                {
 03292                    _httpResponse.Dispose();
 3293                }
 03294                throw ex;
 3295            }
 3296            // Create Result
 03297            var _result = new HttpOperationResponse<Stream>();
 03298            _result.Request = _httpRequest;
 03299            _result.Response = _httpResponse;
 3300            // Deserialize Response
 03301            if ((int)_statusCode == 200)
 3302            {
 03303                _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
 3304            }
 03305            if (_shouldTrace)
 3306            {
 03307                ServiceClientTracing.Exit(_invocationId, _result);
 3308            }
 03309            return _result;
 03310        }
 3311
 3312        /// <summary>
 3313        /// package - Gets trained LUIS application package in binary stream GZip
 3314        /// format
 3315        /// </summary>
 3316        /// <remarks>
 3317        /// Packages trained LUIS application as GZip file to be used in the LUIS
 3318        /// container.
 3319        /// </remarks>
 3320        /// <param name='appId'>
 3321        /// The application ID.
 3322        /// </param>
 3323        /// <param name='versionId'>
 3324        /// The version ID.
 3325        /// </param>
 3326        /// <param name='customHeaders'>
 3327        /// Headers that will be added to request.
 3328        /// </param>
 3329        /// <param name='cancellationToken'>
 3330        /// The cancellation token.
 3331        /// </param>
 3332        /// <exception cref="ErrorResponseException">
 3333        /// Thrown when the operation returned an invalid status code
 3334        /// </exception>
 3335        /// <exception cref="SerializationException">
 3336        /// Thrown when unable to deserialize the response
 3337        /// </exception>
 3338        /// <exception cref="ValidationException">
 3339        /// Thrown when a required parameter is null
 3340        /// </exception>
 3341        /// <exception cref="System.ArgumentNullException">
 3342        /// Thrown when a required parameter is null
 3343        /// </exception>
 3344        /// <return>
 3345        /// A response object containing the response body and response headers.
 3346        /// </return>
 3347        public async Task<HttpOperationResponse<Stream>> PackageTrainedApplicationAsGzipWithHttpMessagesAsync(System.Gui
 3348        {
 03349            if (Client.Endpoint == null)
 3350            {
 03351                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3352            }
 03353            if (versionId == null)
 3354            {
 03355                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 3356            }
 3357            // Tracing
 03358            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 03359            string _invocationId = null;
 03360            if (_shouldTrace)
 3361            {
 03362                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03363                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03364                tracingParameters.Add("appId", appId);
 03365                tracingParameters.Add("versionId", versionId);
 03366                tracingParameters.Add("cancellationToken", cancellationToken);
 03367                ServiceClientTracing.Enter(_invocationId, this, "PackageTrainedApplicationAsGzip", tracingParameters);
 3368            }
 3369            // Construct URL
 03370            var _baseUrl = Client.BaseUri;
 03371            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "package/{appId}/versions/{versionId}/gzip";
 03372            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 03373            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 03374            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 3375            // Create HTTP transport objects
 03376            var _httpRequest = new HttpRequestMessage();
 03377            HttpResponseMessage _httpResponse = null;
 03378            _httpRequest.Method = new HttpMethod("GET");
 03379            _httpRequest.RequestUri = new System.Uri(_url);
 3380            // Set Headers
 3381
 3382
 03383            if (customHeaders != null)
 3384            {
 03385                foreach(var _header in customHeaders)
 3386                {
 03387                    if (_httpRequest.Headers.Contains(_header.Key))
 3388                    {
 03389                        _httpRequest.Headers.Remove(_header.Key);
 3390                    }
 03391                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3392                }
 3393            }
 3394
 3395            // Serialize Request
 03396            string _requestContent = null;
 3397            // Set Credentials
 03398            if (Client.Credentials != null)
 3399            {
 03400                cancellationToken.ThrowIfCancellationRequested();
 03401                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3402            }
 3403            // Send Request
 03404            if (_shouldTrace)
 3405            {
 03406                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3407            }
 03408            cancellationToken.ThrowIfCancellationRequested();
 03409            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.Respons
 03410            if (_shouldTrace)
 3411            {
 03412                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3413            }
 03414            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03415            cancellationToken.ThrowIfCancellationRequested();
 03416            string _responseContent = null;
 03417            if ((int)_statusCode != 200)
 3418            {
 03419                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3420                try
 3421                {
 03422                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03423                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03424                    if (_errorBody != null)
 3425                    {
 03426                        ex.Body = _errorBody;
 3427                    }
 03428                }
 03429                catch (JsonException)
 3430                {
 3431                    // Ignore the exception
 03432                }
 03433                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03434                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03435                if (_shouldTrace)
 3436                {
 03437                    ServiceClientTracing.Error(_invocationId, ex);
 3438                }
 03439                _httpRequest.Dispose();
 03440                if (_httpResponse != null)
 3441                {
 03442                    _httpResponse.Dispose();
 3443                }
 03444                throw ex;
 3445            }
 3446            // Create Result
 03447            var _result = new HttpOperationResponse<Stream>();
 03448            _result.Request = _httpRequest;
 03449            _result.Response = _httpResponse;
 3450            // Deserialize Response
 03451            if ((int)_statusCode == 200)
 3452            {
 03453                _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
 3454            }
 03455            if (_shouldTrace)
 3456            {
 03457                ServiceClientTracing.Exit(_invocationId, _result);
 3458            }
 03459            return _result;
 03460        }
 3461
 3462        /// <summary>
 3463        /// Imports an application to LUIS, the application's structure is included in
 3464        /// the request body.
 3465        /// </summary>
 3466        /// <param name='luisAppV2'>
 3467        /// A LUIS application structure.
 3468        /// </param>
 3469        /// <param name='appName'>
 3470        /// The application name to create. If not specified, the application name will
 3471        /// be read from the imported object. If the application name already exists,
 3472        /// an error is returned.
 3473        /// </param>
 3474        /// <param name='customHeaders'>
 3475        /// Headers that will be added to request.
 3476        /// </param>
 3477        /// <param name='cancellationToken'>
 3478        /// The cancellation token.
 3479        /// </param>
 3480        /// <exception cref="ErrorResponseException">
 3481        /// Thrown when the operation returned an invalid status code
 3482        /// </exception>
 3483        /// <exception cref="SerializationException">
 3484        /// Thrown when unable to deserialize the response
 3485        /// </exception>
 3486        /// <exception cref="ValidationException">
 3487        /// Thrown when a required parameter is null
 3488        /// </exception>
 3489        /// <exception cref="System.ArgumentNullException">
 3490        /// Thrown when a required parameter is null
 3491        /// </exception>
 3492        /// <return>
 3493        /// A response object containing the response body and response headers.
 3494        /// </return>
 3495        public async Task<HttpOperationResponse<System.Guid>> ImportV2AppWithHttpMessagesAsync(LuisAppV2 luisAppV2, stri
 3496        {
 13497            if (Client.Endpoint == null)
 3498            {
 03499                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3500            }
 13501            if (luisAppV2 == null)
 3502            {
 03503                throw new ValidationException(ValidationRules.CannotBeNull, "luisAppV2");
 3504            }
 3505            // Tracing
 13506            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 13507            string _invocationId = null;
 13508            if (_shouldTrace)
 3509            {
 03510                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03511                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03512                tracingParameters.Add("appName", appName);
 03513                tracingParameters.Add("luisAppV2", luisAppV2);
 03514                tracingParameters.Add("cancellationToken", cancellationToken);
 03515                ServiceClientTracing.Enter(_invocationId, this, "ImportV2App", tracingParameters);
 3516            }
 3517            // Construct URL
 13518            var _baseUrl = Client.BaseUri;
 13519            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/import";
 13520            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 13521            List<string> _queryParameters = new List<string>();
 13522            if (appName != null)
 3523            {
 13524                _queryParameters.Add(string.Format("appName={0}", System.Uri.EscapeDataString(appName)));
 3525            }
 13526            if (_queryParameters.Count > 0)
 3527            {
 13528                _url += "?" + string.Join("&", _queryParameters);
 3529            }
 3530            // Create HTTP transport objects
 13531            var _httpRequest = new HttpRequestMessage();
 13532            HttpResponseMessage _httpResponse = null;
 13533            _httpRequest.Method = new HttpMethod("POST");
 13534            _httpRequest.RequestUri = new System.Uri(_url);
 3535            // Set Headers
 3536
 3537
 13538            if (customHeaders != null)
 3539            {
 03540                foreach(var _header in customHeaders)
 3541                {
 03542                    if (_httpRequest.Headers.Contains(_header.Key))
 3543                    {
 03544                        _httpRequest.Headers.Remove(_header.Key);
 3545                    }
 03546                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3547                }
 3548            }
 3549
 3550            // Serialize Request
 13551            string _requestContent = null;
 13552            if(luisAppV2 != null)
 3553            {
 13554                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(luisAppV2, Client.SerializationSett
 13555                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 13556                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 3557            }
 3558            // Set Credentials
 13559            if (Client.Credentials != null)
 3560            {
 13561                cancellationToken.ThrowIfCancellationRequested();
 13562                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3563            }
 3564            // Send Request
 13565            if (_shouldTrace)
 3566            {
 03567                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3568            }
 13569            cancellationToken.ThrowIfCancellationRequested();
 13570            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13571            if (_shouldTrace)
 3572            {
 03573                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3574            }
 13575            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 13576            cancellationToken.ThrowIfCancellationRequested();
 13577            string _responseContent = null;
 13578            if ((int)_statusCode != 201)
 3579            {
 03580                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3581                try
 3582                {
 03583                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03584                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03585                    if (_errorBody != null)
 3586                    {
 03587                        ex.Body = _errorBody;
 3588                    }
 03589                }
 03590                catch (JsonException)
 3591                {
 3592                    // Ignore the exception
 03593                }
 03594                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03595                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03596                if (_shouldTrace)
 3597                {
 03598                    ServiceClientTracing.Error(_invocationId, ex);
 3599                }
 03600                _httpRequest.Dispose();
 03601                if (_httpResponse != null)
 3602                {
 03603                    _httpResponse.Dispose();
 3604                }
 03605                throw ex;
 3606            }
 3607            // Create Result
 13608            var _result = new HttpOperationResponse<System.Guid>();
 13609            _result.Request = _httpRequest;
 13610            _result.Response = _httpResponse;
 3611            // Deserialize Response
 13612            if ((int)_statusCode == 201)
 3613            {
 13614                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3615                try
 3616                {
 13617                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 13618                }
 03619                catch (JsonException ex)
 3620                {
 03621                    _httpRequest.Dispose();
 03622                    if (_httpResponse != null)
 3623                    {
 03624                        _httpResponse.Dispose();
 3625                    }
 03626                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3627                }
 3628            }
 13629            if (_shouldTrace)
 3630            {
 03631                ServiceClientTracing.Exit(_invocationId, _result);
 3632            }
 13633            return _result;
 13634        }
 3635
 3636        /// <summary>
 3637        /// Imports an application to LUIS, the application's structure is included in
 3638        /// the request body.
 3639        /// </summary>
 3640        /// <param name='luisAppLu'>
 3641        /// A LUIS application structure.
 3642        /// </param>
 3643        /// <param name='appName'>
 3644        /// The application name to create. If not specified, the application name will
 3645        /// be read from the imported object. If the application name already exists,
 3646        /// an error is returned.
 3647        /// </param>
 3648        /// <param name='customHeaders'>
 3649        /// Headers that will be added to request.
 3650        /// </param>
 3651        /// <param name='cancellationToken'>
 3652        /// The cancellation token.
 3653        /// </param>
 3654        /// <exception cref="ErrorResponseException">
 3655        /// Thrown when the operation returned an invalid status code
 3656        /// </exception>
 3657        /// <exception cref="SerializationException">
 3658        /// Thrown when unable to deserialize the response
 3659        /// </exception>
 3660        /// <exception cref="ValidationException">
 3661        /// Thrown when a required parameter is null
 3662        /// </exception>
 3663        /// <exception cref="System.ArgumentNullException">
 3664        /// Thrown when a required parameter is null
 3665        /// </exception>
 3666        /// <return>
 3667        /// A response object containing the response body and response headers.
 3668        /// </return>
 3669        public async Task<HttpOperationResponse<System.Guid>> ImportLuFormatWithHttpMessagesAsync(string luisAppLu, stri
 3670        {
 13671            if (Client.Endpoint == null)
 3672            {
 03673                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3674            }
 13675            if (luisAppLu == null)
 3676            {
 03677                throw new ValidationException(ValidationRules.CannotBeNull, "luisAppLu");
 3678            }
 3679            // Tracing
 13680            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 13681            string _invocationId = null;
 13682            if (_shouldTrace)
 3683            {
 03684                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03685                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03686                tracingParameters.Add("appName", appName);
 03687                tracingParameters.Add("luisAppLu", luisAppLu);
 03688                tracingParameters.Add("cancellationToken", cancellationToken);
 03689                ServiceClientTracing.Enter(_invocationId, this, "ImportLuFormat", tracingParameters);
 3690            }
 3691            // Construct URL
 13692            var _baseUrl = Client.BaseUri;
 13693            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/import";
 13694            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 13695            List<string> _queryParameters = new List<string>();
 13696            if (appName != null)
 3697            {
 13698                _queryParameters.Add(string.Format("appName={0}", System.Uri.EscapeDataString(appName)));
 3699            }
 13700            if (_queryParameters.Count > 0)
 3701            {
 13702                _url += "?" + string.Join("&", _queryParameters);
 3703            }
 3704            // Create HTTP transport objects
 13705            var _httpRequest = new HttpRequestMessage();
 13706            HttpResponseMessage _httpResponse = null;
 13707            _httpRequest.Method = new HttpMethod("POST");
 13708            _httpRequest.RequestUri = new System.Uri(_url);
 3709            // Set Headers
 3710
 3711
 13712            if (customHeaders != null)
 3713            {
 03714                foreach(var _header in customHeaders)
 3715                {
 03716                    if (_httpRequest.Headers.Contains(_header.Key))
 3717                    {
 03718                        _httpRequest.Headers.Remove(_header.Key);
 3719                    }
 03720                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3721                }
 3722            }
 3723
 3724            // Serialize Request
 13725            string _requestContent = null;
 13726            if(luisAppLu != null)
 3727            {
 13728                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(luisAppLu, Client.SerializationSett
 13729                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 13730                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("text/plain
 3731            }
 3732            // Set Credentials
 13733            if (Client.Credentials != null)
 3734            {
 13735                cancellationToken.ThrowIfCancellationRequested();
 13736                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3737            }
 3738            // Send Request
 13739            if (_shouldTrace)
 3740            {
 03741                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3742            }
 13743            cancellationToken.ThrowIfCancellationRequested();
 13744            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13745            if (_shouldTrace)
 3746            {
 03747                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3748            }
 13749            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 13750            cancellationToken.ThrowIfCancellationRequested();
 13751            string _responseContent = null;
 13752            if ((int)_statusCode != 201)
 3753            {
 03754                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3755                try
 3756                {
 03757                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03758                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03759                    if (_errorBody != null)
 3760                    {
 03761                        ex.Body = _errorBody;
 3762                    }
 03763                }
 03764                catch (JsonException)
 3765                {
 3766                    // Ignore the exception
 03767                }
 03768                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03769                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03770                if (_shouldTrace)
 3771                {
 03772                    ServiceClientTracing.Error(_invocationId, ex);
 3773                }
 03774                _httpRequest.Dispose();
 03775                if (_httpResponse != null)
 3776                {
 03777                    _httpResponse.Dispose();
 3778                }
 03779                throw ex;
 3780            }
 3781            // Create Result
 13782            var _result = new HttpOperationResponse<System.Guid>();
 13783            _result.Request = _httpRequest;
 13784            _result.Response = _httpResponse;
 3785            // Deserialize Response
 13786            if ((int)_statusCode == 201)
 3787            {
 13788                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3789                try
 3790                {
 13791                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 13792                }
 03793                catch (JsonException ex)
 3794                {
 03795                    _httpRequest.Dispose();
 03796                    if (_httpResponse != null)
 3797                    {
 03798                        _httpResponse.Dispose();
 3799                    }
 03800                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3801                }
 3802            }
 13803            if (_shouldTrace)
 3804            {
 03805                ServiceClientTracing.Exit(_invocationId, _result);
 3806            }
 13807            return _result;
 13808        }
 3809
 3810    }
 3811}