< Summary

Class:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Features
Assembly:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Features.cs
Covered lines:256
Uncovered lines:400
Coverable lines:656
Total lines:1468
Line coverage:39% (256 of 656)
Covered branches:97
Total branches:312
Branch coverage:31% (97 of 312)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
AddPhraseListWithHttpMessagesAsync()-52.5%42.11%
ListPhraseListsWithHttpMessagesAsync()-53.41%47.83%
ListWithHttpMessagesAsync()-0%0%
GetPhraseListWithHttpMessagesAsync()-50.67%38.24%
UpdatePhraseListWithHttpMessagesAsync()-0%0%
DeletePhraseListWithHttpMessagesAsync()-50.67%38.24%
AddIntentFeatureWithHttpMessagesAsync()-52.44%42.11%
AddEntityFeatureWithHttpMessagesAsync()-52.44%42.11%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Features.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    /// Features operations.
 27    /// </summary>
 28    public partial class Features : IServiceOperations<LUISAuthoringClient>, IFeatures
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the Features 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 Features(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>
 49151        public LUISAuthoringClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Creates a new phraselist feature in a version of the application.
 55        /// </summary>
 56        /// <param name='appId'>
 57        /// The application ID.
 58        /// </param>
 59        /// <param name='versionId'>
 60        /// The version ID.
 61        /// </param>
 62        /// <param name='phraselistCreateObject'>
 63        /// A Phraselist object containing Name, comma-separated Phrases and the
 64        /// isExchangeable boolean. Default value for isExchangeable is true.
 65        /// </param>
 66        /// <param name='customHeaders'>
 67        /// Headers that will be added to request.
 68        /// </param>
 69        /// <param name='cancellationToken'>
 70        /// The cancellation token.
 71        /// </param>
 72        /// <exception cref="ErrorResponseException">
 73        /// Thrown when the operation returned an invalid status code
 74        /// </exception>
 75        /// <exception cref="SerializationException">
 76        /// Thrown when unable to deserialize the response
 77        /// </exception>
 78        /// <exception cref="ValidationException">
 79        /// Thrown when a required parameter is null
 80        /// </exception>
 81        /// <exception cref="System.ArgumentNullException">
 82        /// Thrown when a required parameter is null
 83        /// </exception>
 84        /// <return>
 85        /// A response object containing the response body and response headers.
 86        /// </return>
 87        public async Task<HttpOperationResponse<int?>> AddPhraseListWithHttpMessagesAsync(System.Guid appId, string vers
 88        {
 1189            if (Client.Endpoint == null)
 90            {
 091                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 92            }
 1193            if (versionId == null)
 94            {
 095                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 96            }
 1197            if (phraselistCreateObject == null)
 98            {
 099                throw new ValidationException(ValidationRules.CannotBeNull, "phraselistCreateObject");
 100            }
 101            // Tracing
 11102            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 11103            string _invocationId = null;
 11104            if (_shouldTrace)
 105            {
 0106                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0107                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0108                tracingParameters.Add("appId", appId);
 0109                tracingParameters.Add("versionId", versionId);
 0110                tracingParameters.Add("phraselistCreateObject", phraselistCreateObject);
 0111                tracingParameters.Add("cancellationToken", cancellationToken);
 0112                ServiceClientTracing.Enter(_invocationId, this, "AddPhraseList", tracingParameters);
 113            }
 114            // Construct URL
 11115            var _baseUrl = Client.BaseUri;
 11116            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/phraselists";
 11117            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 11118            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 11119            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 120            // Create HTTP transport objects
 11121            var _httpRequest = new HttpRequestMessage();
 11122            HttpResponseMessage _httpResponse = null;
 11123            _httpRequest.Method = new HttpMethod("POST");
 11124            _httpRequest.RequestUri = new System.Uri(_url);
 125            // Set Headers
 126
 127
 11128            if (customHeaders != null)
 129            {
 0130                foreach(var _header in customHeaders)
 131                {
 0132                    if (_httpRequest.Headers.Contains(_header.Key))
 133                    {
 0134                        _httpRequest.Headers.Remove(_header.Key);
 135                    }
 0136                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 137                }
 138            }
 139
 140            // Serialize Request
 11141            string _requestContent = null;
 11142            if(phraselistCreateObject != null)
 143            {
 11144                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(phraselistCreateObject, Client.Seri
 11145                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 11146                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 147            }
 148            // Set Credentials
 11149            if (Client.Credentials != null)
 150            {
 11151                cancellationToken.ThrowIfCancellationRequested();
 11152                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 153            }
 154            // Send Request
 11155            if (_shouldTrace)
 156            {
 0157                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 158            }
 11159            cancellationToken.ThrowIfCancellationRequested();
 11160            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11161            if (_shouldTrace)
 162            {
 0163                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 164            }
 11165            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 11166            cancellationToken.ThrowIfCancellationRequested();
 11167            string _responseContent = null;
 11168            if ((int)_statusCode != 201)
 169            {
 0170                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 171                try
 172                {
 0173                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0174                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0175                    if (_errorBody != null)
 176                    {
 0177                        ex.Body = _errorBody;
 178                    }
 0179                }
 0180                catch (JsonException)
 181                {
 182                    // Ignore the exception
 0183                }
 0184                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0185                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0186                if (_shouldTrace)
 187                {
 0188                    ServiceClientTracing.Error(_invocationId, ex);
 189                }
 0190                _httpRequest.Dispose();
 0191                if (_httpResponse != null)
 192                {
 0193                    _httpResponse.Dispose();
 194                }
 0195                throw ex;
 196            }
 197            // Create Result
 11198            var _result = new HttpOperationResponse<int?>();
 11199            _result.Request = _httpRequest;
 11200            _result.Response = _httpResponse;
 201            // Deserialize Response
 11202            if ((int)_statusCode == 201)
 203            {
 11204                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 205                try
 206                {
 11207                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<int?>(_responseContent, Client.D
 11208                }
 0209                catch (JsonException ex)
 210                {
 0211                    _httpRequest.Dispose();
 0212                    if (_httpResponse != null)
 213                    {
 0214                        _httpResponse.Dispose();
 215                    }
 0216                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 217                }
 218            }
 11219            if (_shouldTrace)
 220            {
 0221                ServiceClientTracing.Exit(_invocationId, _result);
 222            }
 11223            return _result;
 11224        }
 225
 226        /// <summary>
 227        /// Gets all the phraselist features in a version of the application.
 228        /// </summary>
 229        /// <param name='appId'>
 230        /// The application ID.
 231        /// </param>
 232        /// <param name='versionId'>
 233        /// The version ID.
 234        /// </param>
 235        /// <param name='skip'>
 236        /// The number of entries to skip. Default value is 0.
 237        /// </param>
 238        /// <param name='take'>
 239        /// The number of entries to return. Maximum page size is 500. Default is 100.
 240        /// </param>
 241        /// <param name='customHeaders'>
 242        /// Headers that will be added to request.
 243        /// </param>
 244        /// <param name='cancellationToken'>
 245        /// The cancellation token.
 246        /// </param>
 247        /// <exception cref="ErrorResponseException">
 248        /// Thrown when the operation returned an invalid status code
 249        /// </exception>
 250        /// <exception cref="SerializationException">
 251        /// Thrown when unable to deserialize the response
 252        /// </exception>
 253        /// <exception cref="ValidationException">
 254        /// Thrown when a required parameter is null
 255        /// </exception>
 256        /// <exception cref="System.ArgumentNullException">
 257        /// Thrown when a required parameter is null
 258        /// </exception>
 259        /// <return>
 260        /// A response object containing the response body and response headers.
 261        /// </return>
 262        public async Task<HttpOperationResponse<IList<PhraseListFeatureInfo>>> ListPhraseListsWithHttpMessagesAsync(Syst
 263        {
 2264            if (Client.Endpoint == null)
 265            {
 0266                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 267            }
 2268            if (versionId == null)
 269            {
 0270                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 271            }
 2272            if (skip < 0)
 273            {
 0274                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 275            }
 2276            if (take > 500)
 277            {
 0278                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 279            }
 2280            if (take < 0)
 281            {
 0282                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 283            }
 284            // Tracing
 2285            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2286            string _invocationId = null;
 2287            if (_shouldTrace)
 288            {
 0289                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0290                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0291                tracingParameters.Add("appId", appId);
 0292                tracingParameters.Add("versionId", versionId);
 0293                tracingParameters.Add("skip", skip);
 0294                tracingParameters.Add("take", take);
 0295                tracingParameters.Add("cancellationToken", cancellationToken);
 0296                ServiceClientTracing.Enter(_invocationId, this, "ListPhraseLists", tracingParameters);
 297            }
 298            // Construct URL
 2299            var _baseUrl = Client.BaseUri;
 2300            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/phraselists";
 2301            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 2302            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 2303            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 2304            List<string> _queryParameters = new List<string>();
 2305            if (skip != null)
 306            {
 2307                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 308            }
 2309            if (take != null)
 310            {
 2311                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 312            }
 2313            if (_queryParameters.Count > 0)
 314            {
 2315                _url += "?" + string.Join("&", _queryParameters);
 316            }
 317            // Create HTTP transport objects
 2318            var _httpRequest = new HttpRequestMessage();
 2319            HttpResponseMessage _httpResponse = null;
 2320            _httpRequest.Method = new HttpMethod("GET");
 2321            _httpRequest.RequestUri = new System.Uri(_url);
 322            // Set Headers
 323
 324
 2325            if (customHeaders != null)
 326            {
 0327                foreach(var _header in customHeaders)
 328                {
 0329                    if (_httpRequest.Headers.Contains(_header.Key))
 330                    {
 0331                        _httpRequest.Headers.Remove(_header.Key);
 332                    }
 0333                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 334                }
 335            }
 336
 337            // Serialize Request
 2338            string _requestContent = null;
 339            // Set Credentials
 2340            if (Client.Credentials != null)
 341            {
 2342                cancellationToken.ThrowIfCancellationRequested();
 2343                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 344            }
 345            // Send Request
 2346            if (_shouldTrace)
 347            {
 0348                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 349            }
 2350            cancellationToken.ThrowIfCancellationRequested();
 2351            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2352            if (_shouldTrace)
 353            {
 0354                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 355            }
 2356            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2357            cancellationToken.ThrowIfCancellationRequested();
 2358            string _responseContent = null;
 2359            if ((int)_statusCode != 200)
 360            {
 0361                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 362                try
 363                {
 0364                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0365                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0366                    if (_errorBody != null)
 367                    {
 0368                        ex.Body = _errorBody;
 369                    }
 0370                }
 0371                catch (JsonException)
 372                {
 373                    // Ignore the exception
 0374                }
 0375                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0376                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0377                if (_shouldTrace)
 378                {
 0379                    ServiceClientTracing.Error(_invocationId, ex);
 380                }
 0381                _httpRequest.Dispose();
 0382                if (_httpResponse != null)
 383                {
 0384                    _httpResponse.Dispose();
 385                }
 0386                throw ex;
 387            }
 388            // Create Result
 2389            var _result = new HttpOperationResponse<IList<PhraseListFeatureInfo>>();
 2390            _result.Request = _httpRequest;
 2391            _result.Response = _httpResponse;
 392            // Deserialize Response
 2393            if ((int)_statusCode == 200)
 394            {
 2395                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 396                try
 397                {
 2398                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<PhraseListFeatureInfo>>(_r
 2399                }
 0400                catch (JsonException ex)
 401                {
 0402                    _httpRequest.Dispose();
 0403                    if (_httpResponse != null)
 404                    {
 0405                        _httpResponse.Dispose();
 406                    }
 0407                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 408                }
 409            }
 2410            if (_shouldTrace)
 411            {
 0412                ServiceClientTracing.Exit(_invocationId, _result);
 413            }
 2414            return _result;
 2415        }
 416
 417        /// <summary>
 418        /// Gets all the extraction phraselist and pattern features in a version of the
 419        /// application.
 420        /// </summary>
 421        /// <param name='appId'>
 422        /// The application ID.
 423        /// </param>
 424        /// <param name='versionId'>
 425        /// The version ID.
 426        /// </param>
 427        /// <param name='skip'>
 428        /// The number of entries to skip. Default value is 0.
 429        /// </param>
 430        /// <param name='take'>
 431        /// The number of entries to return. Maximum page size is 500. Default is 100.
 432        /// </param>
 433        /// <param name='customHeaders'>
 434        /// Headers that will be added to request.
 435        /// </param>
 436        /// <param name='cancellationToken'>
 437        /// The cancellation token.
 438        /// </param>
 439        /// <exception cref="ErrorResponseException">
 440        /// Thrown when the operation returned an invalid status code
 441        /// </exception>
 442        /// <exception cref="SerializationException">
 443        /// Thrown when unable to deserialize the response
 444        /// </exception>
 445        /// <exception cref="ValidationException">
 446        /// Thrown when a required parameter is null
 447        /// </exception>
 448        /// <exception cref="System.ArgumentNullException">
 449        /// Thrown when a required parameter is null
 450        /// </exception>
 451        /// <return>
 452        /// A response object containing the response body and response headers.
 453        /// </return>
 454        public async Task<HttpOperationResponse<FeaturesResponseObject>> ListWithHttpMessagesAsync(System.Guid appId, st
 455        {
 0456            if (Client.Endpoint == null)
 457            {
 0458                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 459            }
 0460            if (versionId == null)
 461            {
 0462                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 463            }
 0464            if (skip < 0)
 465            {
 0466                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 467            }
 0468            if (take > 500)
 469            {
 0470                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 471            }
 0472            if (take < 0)
 473            {
 0474                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 475            }
 476            // Tracing
 0477            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0478            string _invocationId = null;
 0479            if (_shouldTrace)
 480            {
 0481                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0482                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0483                tracingParameters.Add("appId", appId);
 0484                tracingParameters.Add("versionId", versionId);
 0485                tracingParameters.Add("skip", skip);
 0486                tracingParameters.Add("take", take);
 0487                tracingParameters.Add("cancellationToken", cancellationToken);
 0488                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 489            }
 490            // Construct URL
 0491            var _baseUrl = Client.BaseUri;
 0492            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/features";
 0493            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0494            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 0495            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 0496            List<string> _queryParameters = new List<string>();
 0497            if (skip != null)
 498            {
 0499                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 500            }
 0501            if (take != null)
 502            {
 0503                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 504            }
 0505            if (_queryParameters.Count > 0)
 506            {
 0507                _url += "?" + string.Join("&", _queryParameters);
 508            }
 509            // Create HTTP transport objects
 0510            var _httpRequest = new HttpRequestMessage();
 0511            HttpResponseMessage _httpResponse = null;
 0512            _httpRequest.Method = new HttpMethod("GET");
 0513            _httpRequest.RequestUri = new System.Uri(_url);
 514            // Set Headers
 515
 516
 0517            if (customHeaders != null)
 518            {
 0519                foreach(var _header in customHeaders)
 520                {
 0521                    if (_httpRequest.Headers.Contains(_header.Key))
 522                    {
 0523                        _httpRequest.Headers.Remove(_header.Key);
 524                    }
 0525                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 526                }
 527            }
 528
 529            // Serialize Request
 0530            string _requestContent = null;
 531            // Set Credentials
 0532            if (Client.Credentials != null)
 533            {
 0534                cancellationToken.ThrowIfCancellationRequested();
 0535                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 536            }
 537            // Send Request
 0538            if (_shouldTrace)
 539            {
 0540                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 541            }
 0542            cancellationToken.ThrowIfCancellationRequested();
 0543            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0544            if (_shouldTrace)
 545            {
 0546                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 547            }
 0548            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0549            cancellationToken.ThrowIfCancellationRequested();
 0550            string _responseContent = null;
 0551            if ((int)_statusCode != 200)
 552            {
 0553                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 554                try
 555                {
 0556                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0557                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0558                    if (_errorBody != null)
 559                    {
 0560                        ex.Body = _errorBody;
 561                    }
 0562                }
 0563                catch (JsonException)
 564                {
 565                    // Ignore the exception
 0566                }
 0567                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0568                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0569                if (_shouldTrace)
 570                {
 0571                    ServiceClientTracing.Error(_invocationId, ex);
 572                }
 0573                _httpRequest.Dispose();
 0574                if (_httpResponse != null)
 575                {
 0576                    _httpResponse.Dispose();
 577                }
 0578                throw ex;
 579            }
 580            // Create Result
 0581            var _result = new HttpOperationResponse<FeaturesResponseObject>();
 0582            _result.Request = _httpRequest;
 0583            _result.Response = _httpResponse;
 584            // Deserialize Response
 0585            if ((int)_statusCode == 200)
 586            {
 0587                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 588                try
 589                {
 0590                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<FeaturesResponseObject>(_respons
 0591                }
 0592                catch (JsonException ex)
 593                {
 0594                    _httpRequest.Dispose();
 0595                    if (_httpResponse != null)
 596                    {
 0597                        _httpResponse.Dispose();
 598                    }
 0599                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 600                }
 601            }
 0602            if (_shouldTrace)
 603            {
 0604                ServiceClientTracing.Exit(_invocationId, _result);
 605            }
 0606            return _result;
 0607        }
 608
 609        /// <summary>
 610        /// Gets phraselist feature info in a version of the application.
 611        /// </summary>
 612        /// <param name='appId'>
 613        /// The application ID.
 614        /// </param>
 615        /// <param name='versionId'>
 616        /// The version ID.
 617        /// </param>
 618        /// <param name='phraselistId'>
 619        /// The ID of the feature to be retrieved.
 620        /// </param>
 621        /// <param name='customHeaders'>
 622        /// Headers that will be added to request.
 623        /// </param>
 624        /// <param name='cancellationToken'>
 625        /// The cancellation token.
 626        /// </param>
 627        /// <exception cref="ErrorResponseException">
 628        /// Thrown when the operation returned an invalid status code
 629        /// </exception>
 630        /// <exception cref="SerializationException">
 631        /// Thrown when unable to deserialize the response
 632        /// </exception>
 633        /// <exception cref="ValidationException">
 634        /// Thrown when a required parameter is null
 635        /// </exception>
 636        /// <exception cref="System.ArgumentNullException">
 637        /// Thrown when a required parameter is null
 638        /// </exception>
 639        /// <return>
 640        /// A response object containing the response body and response headers.
 641        /// </return>
 642        public async Task<HttpOperationResponse<PhraseListFeatureInfo>> GetPhraseListWithHttpMessagesAsync(System.Guid a
 643        {
 3644            if (Client.Endpoint == null)
 645            {
 0646                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 647            }
 3648            if (versionId == null)
 649            {
 0650                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 651            }
 652            // Tracing
 3653            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 3654            string _invocationId = null;
 3655            if (_shouldTrace)
 656            {
 0657                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0658                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0659                tracingParameters.Add("appId", appId);
 0660                tracingParameters.Add("versionId", versionId);
 0661                tracingParameters.Add("phraselistId", phraselistId);
 0662                tracingParameters.Add("cancellationToken", cancellationToken);
 0663                ServiceClientTracing.Enter(_invocationId, this, "GetPhraseList", tracingParameters);
 664            }
 665            // Construct URL
 3666            var _baseUrl = Client.BaseUri;
 3667            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/phraselists/{
 3668            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 3669            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 3670            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 3671            _url = _url.Replace("{phraselistId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Seriali
 672            // Create HTTP transport objects
 3673            var _httpRequest = new HttpRequestMessage();
 3674            HttpResponseMessage _httpResponse = null;
 3675            _httpRequest.Method = new HttpMethod("GET");
 3676            _httpRequest.RequestUri = new System.Uri(_url);
 677            // Set Headers
 678
 679
 3680            if (customHeaders != null)
 681            {
 0682                foreach(var _header in customHeaders)
 683                {
 0684                    if (_httpRequest.Headers.Contains(_header.Key))
 685                    {
 0686                        _httpRequest.Headers.Remove(_header.Key);
 687                    }
 0688                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 689                }
 690            }
 691
 692            // Serialize Request
 3693            string _requestContent = null;
 694            // Set Credentials
 3695            if (Client.Credentials != null)
 696            {
 3697                cancellationToken.ThrowIfCancellationRequested();
 3698                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 699            }
 700            // Send Request
 3701            if (_shouldTrace)
 702            {
 0703                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 704            }
 3705            cancellationToken.ThrowIfCancellationRequested();
 3706            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3707            if (_shouldTrace)
 708            {
 0709                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 710            }
 3711            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 3712            cancellationToken.ThrowIfCancellationRequested();
 3713            string _responseContent = null;
 3714            if ((int)_statusCode != 200)
 715            {
 0716                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 717                try
 718                {
 0719                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0720                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0721                    if (_errorBody != null)
 722                    {
 0723                        ex.Body = _errorBody;
 724                    }
 0725                }
 0726                catch (JsonException)
 727                {
 728                    // Ignore the exception
 0729                }
 0730                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0731                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0732                if (_shouldTrace)
 733                {
 0734                    ServiceClientTracing.Error(_invocationId, ex);
 735                }
 0736                _httpRequest.Dispose();
 0737                if (_httpResponse != null)
 738                {
 0739                    _httpResponse.Dispose();
 740                }
 0741                throw ex;
 742            }
 743            // Create Result
 3744            var _result = new HttpOperationResponse<PhraseListFeatureInfo>();
 3745            _result.Request = _httpRequest;
 3746            _result.Response = _httpResponse;
 747            // Deserialize Response
 3748            if ((int)_statusCode == 200)
 749            {
 3750                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 751                try
 752                {
 3753                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<PhraseListFeatureInfo>(_response
 3754                }
 0755                catch (JsonException ex)
 756                {
 0757                    _httpRequest.Dispose();
 0758                    if (_httpResponse != null)
 759                    {
 0760                        _httpResponse.Dispose();
 761                    }
 0762                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 763                }
 764            }
 3765            if (_shouldTrace)
 766            {
 0767                ServiceClientTracing.Exit(_invocationId, _result);
 768            }
 3769            return _result;
 3770        }
 771
 772        /// <summary>
 773        /// Updates the phrases, the state and the name of the phraselist feature in a
 774        /// version of the application.
 775        /// </summary>
 776        /// <param name='appId'>
 777        /// The application ID.
 778        /// </param>
 779        /// <param name='versionId'>
 780        /// The version ID.
 781        /// </param>
 782        /// <param name='phraselistId'>
 783        /// The ID of the feature to be updated.
 784        /// </param>
 785        /// <param name='phraselistUpdateObject'>
 786        /// The new values for: - Just a boolean called IsActive, in which case the
 787        /// status of the feature will be changed. - Name, Pattern, Mode, and a boolean
 788        /// called IsActive to update the feature.
 789        /// </param>
 790        /// <param name='customHeaders'>
 791        /// Headers that will be added to request.
 792        /// </param>
 793        /// <param name='cancellationToken'>
 794        /// The cancellation token.
 795        /// </param>
 796        /// <exception cref="ErrorResponseException">
 797        /// Thrown when the operation returned an invalid status code
 798        /// </exception>
 799        /// <exception cref="SerializationException">
 800        /// Thrown when unable to deserialize the response
 801        /// </exception>
 802        /// <exception cref="ValidationException">
 803        /// Thrown when a required parameter is null
 804        /// </exception>
 805        /// <exception cref="System.ArgumentNullException">
 806        /// Thrown when a required parameter is null
 807        /// </exception>
 808        /// <return>
 809        /// A response object containing the response body and response headers.
 810        /// </return>
 811        public async Task<HttpOperationResponse<OperationStatus>> UpdatePhraseListWithHttpMessagesAsync(System.Guid appI
 812        {
 0813            if (Client.Endpoint == null)
 814            {
 0815                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 816            }
 0817            if (versionId == null)
 818            {
 0819                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 820            }
 821            // Tracing
 0822            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0823            string _invocationId = null;
 0824            if (_shouldTrace)
 825            {
 0826                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0827                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0828                tracingParameters.Add("appId", appId);
 0829                tracingParameters.Add("versionId", versionId);
 0830                tracingParameters.Add("phraselistId", phraselistId);
 0831                tracingParameters.Add("phraselistUpdateObject", phraselistUpdateObject);
 0832                tracingParameters.Add("cancellationToken", cancellationToken);
 0833                ServiceClientTracing.Enter(_invocationId, this, "UpdatePhraseList", tracingParameters);
 834            }
 835            // Construct URL
 0836            var _baseUrl = Client.BaseUri;
 0837            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/phraselists/{
 0838            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0839            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 0840            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 0841            _url = _url.Replace("{phraselistId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Seriali
 842            // Create HTTP transport objects
 0843            var _httpRequest = new HttpRequestMessage();
 0844            HttpResponseMessage _httpResponse = null;
 0845            _httpRequest.Method = new HttpMethod("PUT");
 0846            _httpRequest.RequestUri = new System.Uri(_url);
 847            // Set Headers
 848
 849
 0850            if (customHeaders != null)
 851            {
 0852                foreach(var _header in customHeaders)
 853                {
 0854                    if (_httpRequest.Headers.Contains(_header.Key))
 855                    {
 0856                        _httpRequest.Headers.Remove(_header.Key);
 857                    }
 0858                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 859                }
 860            }
 861
 862            // Serialize Request
 0863            string _requestContent = null;
 0864            if(phraselistUpdateObject != null)
 865            {
 0866                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(phraselistUpdateObject, Client.Seri
 0867                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0868                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 869            }
 870            // Set Credentials
 0871            if (Client.Credentials != null)
 872            {
 0873                cancellationToken.ThrowIfCancellationRequested();
 0874                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 875            }
 876            // Send Request
 0877            if (_shouldTrace)
 878            {
 0879                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 880            }
 0881            cancellationToken.ThrowIfCancellationRequested();
 0882            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0883            if (_shouldTrace)
 884            {
 0885                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 886            }
 0887            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0888            cancellationToken.ThrowIfCancellationRequested();
 0889            string _responseContent = null;
 0890            if ((int)_statusCode != 200)
 891            {
 0892                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 893                try
 894                {
 0895                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0896                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0897                    if (_errorBody != null)
 898                    {
 0899                        ex.Body = _errorBody;
 900                    }
 0901                }
 0902                catch (JsonException)
 903                {
 904                    // Ignore the exception
 0905                }
 0906                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0907                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0908                if (_shouldTrace)
 909                {
 0910                    ServiceClientTracing.Error(_invocationId, ex);
 911                }
 0912                _httpRequest.Dispose();
 0913                if (_httpResponse != null)
 914                {
 0915                    _httpResponse.Dispose();
 916                }
 0917                throw ex;
 918            }
 919            // Create Result
 0920            var _result = new HttpOperationResponse<OperationStatus>();
 0921            _result.Request = _httpRequest;
 0922            _result.Response = _httpResponse;
 923            // Deserialize Response
 0924            if ((int)_statusCode == 200)
 925            {
 0926                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 927                try
 928                {
 0929                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 0930                }
 0931                catch (JsonException ex)
 932                {
 0933                    _httpRequest.Dispose();
 0934                    if (_httpResponse != null)
 935                    {
 0936                        _httpResponse.Dispose();
 937                    }
 0938                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 939                }
 940            }
 0941            if (_shouldTrace)
 942            {
 0943                ServiceClientTracing.Exit(_invocationId, _result);
 944            }
 0945            return _result;
 0946        }
 947
 948        /// <summary>
 949        /// Deletes a phraselist feature from a version of the application.
 950        /// </summary>
 951        /// <param name='appId'>
 952        /// The application ID.
 953        /// </param>
 954        /// <param name='versionId'>
 955        /// The version ID.
 956        /// </param>
 957        /// <param name='phraselistId'>
 958        /// The ID of the feature to be deleted.
 959        /// </param>
 960        /// <param name='customHeaders'>
 961        /// Headers that will be added to request.
 962        /// </param>
 963        /// <param name='cancellationToken'>
 964        /// The cancellation token.
 965        /// </param>
 966        /// <exception cref="ErrorResponseException">
 967        /// Thrown when the operation returned an invalid status code
 968        /// </exception>
 969        /// <exception cref="SerializationException">
 970        /// Thrown when unable to deserialize the response
 971        /// </exception>
 972        /// <exception cref="ValidationException">
 973        /// Thrown when a required parameter is null
 974        /// </exception>
 975        /// <exception cref="System.ArgumentNullException">
 976        /// Thrown when a required parameter is null
 977        /// </exception>
 978        /// <return>
 979        /// A response object containing the response body and response headers.
 980        /// </return>
 981        public async Task<HttpOperationResponse<OperationStatus>> DeletePhraseListWithHttpMessagesAsync(System.Guid appI
 982        {
 11983            if (Client.Endpoint == null)
 984            {
 0985                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 986            }
 11987            if (versionId == null)
 988            {
 0989                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 990            }
 991            // Tracing
 11992            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 11993            string _invocationId = null;
 11994            if (_shouldTrace)
 995            {
 0996                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0997                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0998                tracingParameters.Add("appId", appId);
 0999                tracingParameters.Add("versionId", versionId);
 01000                tracingParameters.Add("phraselistId", phraselistId);
 01001                tracingParameters.Add("cancellationToken", cancellationToken);
 01002                ServiceClientTracing.Enter(_invocationId, this, "DeletePhraseList", tracingParameters);
 1003            }
 1004            // Construct URL
 111005            var _baseUrl = Client.BaseUri;
 111006            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/phraselists/{
 111007            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 111008            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 111009            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 111010            _url = _url.Replace("{phraselistId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Seriali
 1011            // Create HTTP transport objects
 111012            var _httpRequest = new HttpRequestMessage();
 111013            HttpResponseMessage _httpResponse = null;
 111014            _httpRequest.Method = new HttpMethod("DELETE");
 111015            _httpRequest.RequestUri = new System.Uri(_url);
 1016            // Set Headers
 1017
 1018
 111019            if (customHeaders != null)
 1020            {
 01021                foreach(var _header in customHeaders)
 1022                {
 01023                    if (_httpRequest.Headers.Contains(_header.Key))
 1024                    {
 01025                        _httpRequest.Headers.Remove(_header.Key);
 1026                    }
 01027                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1028                }
 1029            }
 1030
 1031            // Serialize Request
 111032            string _requestContent = null;
 1033            // Set Credentials
 111034            if (Client.Credentials != null)
 1035            {
 111036                cancellationToken.ThrowIfCancellationRequested();
 111037                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1038            }
 1039            // Send Request
 111040            if (_shouldTrace)
 1041            {
 01042                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1043            }
 111044            cancellationToken.ThrowIfCancellationRequested();
 111045            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 111046            if (_shouldTrace)
 1047            {
 01048                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1049            }
 111050            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 111051            cancellationToken.ThrowIfCancellationRequested();
 111052            string _responseContent = null;
 111053            if ((int)_statusCode != 200)
 1054            {
 01055                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1056                try
 1057                {
 01058                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01059                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01060                    if (_errorBody != null)
 1061                    {
 01062                        ex.Body = _errorBody;
 1063                    }
 01064                }
 01065                catch (JsonException)
 1066                {
 1067                    // Ignore the exception
 01068                }
 01069                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01070                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01071                if (_shouldTrace)
 1072                {
 01073                    ServiceClientTracing.Error(_invocationId, ex);
 1074                }
 01075                _httpRequest.Dispose();
 01076                if (_httpResponse != null)
 1077                {
 01078                    _httpResponse.Dispose();
 1079                }
 01080                throw ex;
 1081            }
 1082            // Create Result
 111083            var _result = new HttpOperationResponse<OperationStatus>();
 111084            _result.Request = _httpRequest;
 111085            _result.Response = _httpResponse;
 1086            // Deserialize Response
 111087            if ((int)_statusCode == 200)
 1088            {
 111089                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1090                try
 1091                {
 111092                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 111093                }
 01094                catch (JsonException ex)
 1095                {
 01096                    _httpRequest.Dispose();
 01097                    if (_httpResponse != null)
 1098                    {
 01099                        _httpResponse.Dispose();
 1100                    }
 01101                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1102                }
 1103            }
 111104            if (_shouldTrace)
 1105            {
 01106                ServiceClientTracing.Exit(_invocationId, _result);
 1107            }
 111108            return _result;
 111109        }
 1110
 1111        /// <summary>
 1112        /// Adds a new feature relation to be used by the intent in a version of the
 1113        /// application.
 1114        /// </summary>
 1115        /// <param name='appId'>
 1116        /// The application ID.
 1117        /// </param>
 1118        /// <param name='versionId'>
 1119        /// The version ID.
 1120        /// </param>
 1121        /// <param name='intentId'>
 1122        /// The intent classifier ID.
 1123        /// </param>
 1124        /// <param name='featureRelationCreateObject'>
 1125        /// A Feature relation information object.
 1126        /// </param>
 1127        /// <param name='customHeaders'>
 1128        /// Headers that will be added to request.
 1129        /// </param>
 1130        /// <param name='cancellationToken'>
 1131        /// The cancellation token.
 1132        /// </param>
 1133        /// <exception cref="ErrorResponseException">
 1134        /// Thrown when the operation returned an invalid status code
 1135        /// </exception>
 1136        /// <exception cref="SerializationException">
 1137        /// Thrown when unable to deserialize the response
 1138        /// </exception>
 1139        /// <exception cref="ValidationException">
 1140        /// Thrown when a required parameter is null
 1141        /// </exception>
 1142        /// <exception cref="System.ArgumentNullException">
 1143        /// Thrown when a required parameter is null
 1144        /// </exception>
 1145        /// <return>
 1146        /// A response object containing the response body and response headers.
 1147        /// </return>
 1148        public async Task<HttpOperationResponse<OperationStatus>> AddIntentFeatureWithHttpMessagesAsync(System.Guid appI
 1149        {
 41150            if (Client.Endpoint == null)
 1151            {
 01152                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1153            }
 41154            if (versionId == null)
 1155            {
 01156                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 1157            }
 41158            if (featureRelationCreateObject == null)
 1159            {
 01160                throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationCreateObject");
 1161            }
 1162            // Tracing
 41163            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 41164            string _invocationId = null;
 41165            if (_shouldTrace)
 1166            {
 01167                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01168                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01169                tracingParameters.Add("appId", appId);
 01170                tracingParameters.Add("versionId", versionId);
 01171                tracingParameters.Add("intentId", intentId);
 01172                tracingParameters.Add("featureRelationCreateObject", featureRelationCreateObject);
 01173                tracingParameters.Add("cancellationToken", cancellationToken);
 01174                ServiceClientTracing.Enter(_invocationId, this, "AddIntentFeature", tracingParameters);
 1175            }
 1176            // Construct URL
 41177            var _baseUrl = Client.BaseUri;
 41178            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte
 41179            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 41180            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 41181            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 41182            _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 1183            // Create HTTP transport objects
 41184            var _httpRequest = new HttpRequestMessage();
 41185            HttpResponseMessage _httpResponse = null;
 41186            _httpRequest.Method = new HttpMethod("POST");
 41187            _httpRequest.RequestUri = new System.Uri(_url);
 1188            // Set Headers
 1189
 1190
 41191            if (customHeaders != null)
 1192            {
 01193                foreach(var _header in customHeaders)
 1194                {
 01195                    if (_httpRequest.Headers.Contains(_header.Key))
 1196                    {
 01197                        _httpRequest.Headers.Remove(_header.Key);
 1198                    }
 01199                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1200                }
 1201            }
 1202
 1203            // Serialize Request
 41204            string _requestContent = null;
 41205            if(featureRelationCreateObject != null)
 1206            {
 41207                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationCreateObject, Client
 41208                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 41209                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1210            }
 1211            // Set Credentials
 41212            if (Client.Credentials != null)
 1213            {
 41214                cancellationToken.ThrowIfCancellationRequested();
 41215                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1216            }
 1217            // Send Request
 41218            if (_shouldTrace)
 1219            {
 01220                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1221            }
 41222            cancellationToken.ThrowIfCancellationRequested();
 41223            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 41224            if (_shouldTrace)
 1225            {
 01226                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1227            }
 41228            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 41229            cancellationToken.ThrowIfCancellationRequested();
 41230            string _responseContent = null;
 41231            if ((int)_statusCode != 200)
 1232            {
 01233                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1234                try
 1235                {
 01236                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01237                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01238                    if (_errorBody != null)
 1239                    {
 01240                        ex.Body = _errorBody;
 1241                    }
 01242                }
 01243                catch (JsonException)
 1244                {
 1245                    // Ignore the exception
 01246                }
 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
 41261            var _result = new HttpOperationResponse<OperationStatus>();
 41262            _result.Request = _httpRequest;
 41263            _result.Response = _httpResponse;
 1264            // Deserialize Response
 41265            if ((int)_statusCode == 200)
 1266            {
 41267                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1268                try
 1269                {
 41270                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 41271                }
 01272                catch (JsonException ex)
 1273                {
 01274                    _httpRequest.Dispose();
 01275                    if (_httpResponse != null)
 1276                    {
 01277                        _httpResponse.Dispose();
 1278                    }
 01279                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1280                }
 1281            }
 41282            if (_shouldTrace)
 1283            {
 01284                ServiceClientTracing.Exit(_invocationId, _result);
 1285            }
 41286            return _result;
 41287        }
 1288
 1289        /// <summary>
 1290        /// Adds a new feature relation to be used by the entity in a version of the
 1291        /// application.
 1292        /// </summary>
 1293        /// <param name='appId'>
 1294        /// The application ID.
 1295        /// </param>
 1296        /// <param name='versionId'>
 1297        /// The version ID.
 1298        /// </param>
 1299        /// <param name='entityId'>
 1300        /// The entity extractor ID.
 1301        /// </param>
 1302        /// <param name='featureRelationCreateObject'>
 1303        /// A Feature relation information object.
 1304        /// </param>
 1305        /// <param name='customHeaders'>
 1306        /// Headers that will be added to request.
 1307        /// </param>
 1308        /// <param name='cancellationToken'>
 1309        /// The cancellation token.
 1310        /// </param>
 1311        /// <exception cref="ErrorResponseException">
 1312        /// Thrown when the operation returned an invalid status code
 1313        /// </exception>
 1314        /// <exception cref="SerializationException">
 1315        /// Thrown when unable to deserialize the response
 1316        /// </exception>
 1317        /// <exception cref="ValidationException">
 1318        /// Thrown when a required parameter is null
 1319        /// </exception>
 1320        /// <exception cref="System.ArgumentNullException">
 1321        /// Thrown when a required parameter is null
 1322        /// </exception>
 1323        /// <return>
 1324        /// A response object containing the response body and response headers.
 1325        /// </return>
 1326        public async Task<HttpOperationResponse<OperationStatus>> AddEntityFeatureWithHttpMessagesAsync(System.Guid appI
 1327        {
 51328            if (Client.Endpoint == null)
 1329            {
 01330                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1331            }
 51332            if (versionId == null)
 1333            {
 01334                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 1335            }
 51336            if (featureRelationCreateObject == null)
 1337            {
 01338                throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationCreateObject");
 1339            }
 1340            // Tracing
 51341            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 51342            string _invocationId = null;
 51343            if (_shouldTrace)
 1344            {
 01345                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01346                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01347                tracingParameters.Add("appId", appId);
 01348                tracingParameters.Add("versionId", versionId);
 01349                tracingParameters.Add("entityId", entityId);
 01350                tracingParameters.Add("featureRelationCreateObject", featureRelationCreateObject);
 01351                tracingParameters.Add("cancellationToken", cancellationToken);
 01352                ServiceClientTracing.Enter(_invocationId, this, "AddEntityFeature", tracingParameters);
 1353            }
 1354            // Construct URL
 51355            var _baseUrl = Client.BaseUri;
 51356            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 51357            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 51358            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 51359            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 51360            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 1361            // Create HTTP transport objects
 51362            var _httpRequest = new HttpRequestMessage();
 51363            HttpResponseMessage _httpResponse = null;
 51364            _httpRequest.Method = new HttpMethod("POST");
 51365            _httpRequest.RequestUri = new System.Uri(_url);
 1366            // Set Headers
 1367
 1368
 51369            if (customHeaders != null)
 1370            {
 01371                foreach(var _header in customHeaders)
 1372                {
 01373                    if (_httpRequest.Headers.Contains(_header.Key))
 1374                    {
 01375                        _httpRequest.Headers.Remove(_header.Key);
 1376                    }
 01377                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1378                }
 1379            }
 1380
 1381            // Serialize Request
 51382            string _requestContent = null;
 51383            if(featureRelationCreateObject != null)
 1384            {
 51385                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationCreateObject, Client
 51386                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 51387                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1388            }
 1389            // Set Credentials
 51390            if (Client.Credentials != null)
 1391            {
 51392                cancellationToken.ThrowIfCancellationRequested();
 51393                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1394            }
 1395            // Send Request
 51396            if (_shouldTrace)
 1397            {
 01398                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1399            }
 51400            cancellationToken.ThrowIfCancellationRequested();
 51401            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 51402            if (_shouldTrace)
 1403            {
 01404                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1405            }
 51406            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 51407            cancellationToken.ThrowIfCancellationRequested();
 51408            string _responseContent = null;
 51409            if ((int)_statusCode != 200)
 1410            {
 01411                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1412                try
 1413                {
 01414                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01415                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01416                    if (_errorBody != null)
 1417                    {
 01418                        ex.Body = _errorBody;
 1419                    }
 01420                }
 01421                catch (JsonException)
 1422                {
 1423                    // Ignore the exception
 01424                }
 01425                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01426                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01427                if (_shouldTrace)
 1428                {
 01429                    ServiceClientTracing.Error(_invocationId, ex);
 1430                }
 01431                _httpRequest.Dispose();
 01432                if (_httpResponse != null)
 1433                {
 01434                    _httpResponse.Dispose();
 1435                }
 01436                throw ex;
 1437            }
 1438            // Create Result
 51439            var _result = new HttpOperationResponse<OperationStatus>();
 51440            _result.Request = _httpRequest;
 51441            _result.Response = _httpResponse;
 1442            // Deserialize Response
 51443            if ((int)_statusCode == 200)
 1444            {
 51445                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1446                try
 1447                {
 51448                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 51449                }
 01450                catch (JsonException ex)
 1451                {
 01452                    _httpRequest.Dispose();
 01453                    if (_httpResponse != null)
 1454                    {
 01455                        _httpResponse.Dispose();
 1456                    }
 01457                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1458                }
 1459            }
 51460            if (_shouldTrace)
 1461            {
 01462                ServiceClientTracing.Exit(_invocationId, _result);
 1463            }
 51464            return _result;
 51465        }
 1466
 1467    }
 1468}