< Summary

Class:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Model
Assembly:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Model.cs
Covered lines:3370
Uncovered lines:5402
Coverable lines:8772
Total lines:19123
Line coverage:38.4% (3370 of 8772)
Covered branches:1236
Total branches:4066
Branch coverage:30.3% (1236 of 4066)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
AddIntentWithHttpMessagesAsync()-52.5%42.11%
ListIntentsWithHttpMessagesAsync()-53.41%47.83%
AddEntityWithHttpMessagesAsync()-52.5%42.11%
ListEntitiesWithHttpMessagesAsync()-53.41%47.83%
ListHierarchicalEntitiesWithHttpMessagesAsync()-0%0%
ListCompositeEntitiesWithHttpMessagesAsync()-0%0%
ListClosedListsWithHttpMessagesAsync()-53.41%47.83%
AddClosedListWithHttpMessagesAsync()-52.5%42.11%
AddPrebuiltWithHttpMessagesAsync()-52.5%42.11%
ListPrebuiltsWithHttpMessagesAsync()-53.41%47.83%
ListPrebuiltEntitiesWithHttpMessagesAsync()-50.68%38.24%
ListModelsWithHttpMessagesAsync()-0%0%
ExamplesMethodWithHttpMessagesAsync()-0%0%
GetIntentWithHttpMessagesAsync()-50.67%38.24%
UpdateIntentWithHttpMessagesAsync()-52.44%42.11%
DeleteIntentWithHttpMessagesAsync()-53.09%44.74%
GetEntityWithHttpMessagesAsync()-50.67%38.24%
DeleteEntityWithHttpMessagesAsync()-50.67%38.24%
UpdateEntityChildWithHttpMessagesAsync()-52.44%42.11%
GetIntentFeaturesWithHttpMessagesAsync()-50.67%38.24%
ReplaceIntentFeaturesWithHttpMessagesAsync()-0%0%
DeleteIntentFeatureWithHttpMessagesAsync()-52.44%42.11%
GetEntityFeaturesWithHttpMessagesAsync()-50.67%38.24%
ReplaceEntityFeaturesWithHttpMessagesAsync()-0%0%
DeleteEntityFeatureWithHttpMessagesAsync()-52.44%42.11%
GetHierarchicalEntityWithHttpMessagesAsync()-0%0%
UpdateHierarchicalEntityWithHttpMessagesAsync()-0%0%
DeleteHierarchicalEntityWithHttpMessagesAsync()-0%0%
GetCompositeEntityWithHttpMessagesAsync()-0%0%
UpdateCompositeEntityWithHttpMessagesAsync()-0%0%
DeleteCompositeEntityWithHttpMessagesAsync()-0%0%
GetClosedListWithHttpMessagesAsync()-50.67%38.24%
UpdateClosedListWithHttpMessagesAsync()-52.44%42.11%
PatchClosedListWithHttpMessagesAsync()-52.44%42.11%
DeleteClosedListWithHttpMessagesAsync()-50.67%38.24%
GetPrebuiltWithHttpMessagesAsync()-50.67%38.24%
DeletePrebuiltWithHttpMessagesAsync()-50.67%38.24%
DeleteSubListWithHttpMessagesAsync()-50.65%38.24%
UpdateSubListWithHttpMessagesAsync()-52.38%42.11%
ListIntentSuggestionsWithHttpMessagesAsync()-0%0%
ListEntitySuggestionsWithHttpMessagesAsync()-53.41%47.73%
AddSubListWithHttpMessagesAsync()-52.44%42.11%
AddCustomPrebuiltDomainWithHttpMessagesAsync()-52.5%42.11%
AddCustomPrebuiltIntentWithHttpMessagesAsync()-52.5%42.11%
ListCustomPrebuiltIntentsWithHttpMessagesAsync()-50.68%38.24%
AddCustomPrebuiltEntityWithHttpMessagesAsync()-52.5%42.11%
ListCustomPrebuiltEntitiesWithHttpMessagesAsync()-50.68%38.24%
ListCustomPrebuiltModelsWithHttpMessagesAsync()-50.68%38.24%
DeleteCustomPrebuiltDomainWithHttpMessagesAsync()-50.65%38.89%
AddEntityChildWithHttpMessagesAsync()-52.44%42.11%
GetHierarchicalEntityChildWithHttpMessagesAsync()-0%0%
UpdateHierarchicalEntityChildWithHttpMessagesAsync()-0%0%
DeleteHierarchicalEntityChildWithHttpMessagesAsync()-0%0%
AddCompositeEntityChildWithHttpMessagesAsync()-0%0%
DeleteCompositeEntityChildWithHttpMessagesAsync()-0%0%
ListRegexEntityInfosWithHttpMessagesAsync()-53.41%47.83%
CreateRegexEntityModelWithHttpMessagesAsync()-52.5%42.11%
ListPatternAnyEntityInfosWithHttpMessagesAsync()-53.41%47.83%
CreatePatternAnyEntityModelWithHttpMessagesAsync()-52.5%42.11%
ListEntityRolesWithHttpMessagesAsync()-50.67%38.24%
CreateEntityRoleWithHttpMessagesAsync()-52.44%42.11%
ListPrebuiltEntityRolesWithHttpMessagesAsync()-50.67%38.24%
CreatePrebuiltEntityRoleWithHttpMessagesAsync()-52.44%42.11%
ListClosedListEntityRolesWithHttpMessagesAsync()-50.67%38.24%
CreateClosedListEntityRoleWithHttpMessagesAsync()-52.44%42.11%
ListRegexEntityRolesWithHttpMessagesAsync()-50.67%38.24%
CreateRegexEntityRoleWithHttpMessagesAsync()-52.44%42.11%
ListCompositeEntityRolesWithHttpMessagesAsync()-0%0%
CreateCompositeEntityRoleWithHttpMessagesAsync()-0%0%
ListPatternAnyEntityRolesWithHttpMessagesAsync()-50.67%38.24%
CreatePatternAnyEntityRoleWithHttpMessagesAsync()-52.44%42.11%
ListHierarchicalEntityRolesWithHttpMessagesAsync()-0%0%
CreateHierarchicalEntityRoleWithHttpMessagesAsync()-0%0%
ListCustomPrebuiltEntityRolesWithHttpMessagesAsync()-50.67%38.24%
CreateCustomPrebuiltEntityRoleWithHttpMessagesAsync()-52.44%42.11%
GetExplicitListWithHttpMessagesAsync()-50.67%38.24%
AddExplicitListItemWithHttpMessagesAsync()-52.44%42.11%
GetRegexEntityEntityInfoWithHttpMessagesAsync()-50.67%38.24%
UpdateRegexEntityModelWithHttpMessagesAsync()-52.44%42.11%
DeleteRegexEntityModelWithHttpMessagesAsync()-50.67%38.24%
GetPatternAnyEntityInfoWithHttpMessagesAsync()-50.67%38.24%
UpdatePatternAnyEntityModelWithHttpMessagesAsync()-52.44%42.11%
DeletePatternAnyEntityModelWithHttpMessagesAsync()-50.67%38.24%
GetEntityRoleWithHttpMessagesAsync()-50.65%38.24%
UpdateEntityRoleWithHttpMessagesAsync()-52.38%42.11%
DeleteEntityRoleWithHttpMessagesAsync()-50.65%38.24%
GetPrebuiltEntityRoleWithHttpMessagesAsync()-50.65%38.24%
UpdatePrebuiltEntityRoleWithHttpMessagesAsync()-52.38%42.11%
DeletePrebuiltEntityRoleWithHttpMessagesAsync()-50.65%38.24%
GetClosedListEntityRoleWithHttpMessagesAsync()-50.65%38.24%
UpdateClosedListEntityRoleWithHttpMessagesAsync()-52.38%42.11%
DeleteClosedListEntityRoleWithHttpMessagesAsync()-50.65%38.24%
GetRegexEntityRoleWithHttpMessagesAsync()-50.65%38.24%
UpdateRegexEntityRoleWithHttpMessagesAsync()-52.38%42.11%
DeleteRegexEntityRoleWithHttpMessagesAsync()-50.65%38.24%
GetCompositeEntityRoleWithHttpMessagesAsync()-0%0%
UpdateCompositeEntityRoleWithHttpMessagesAsync()-0%0%
DeleteCompositeEntityRoleWithHttpMessagesAsync()-0%0%
GetPatternAnyEntityRoleWithHttpMessagesAsync()-50.65%38.24%
UpdatePatternAnyEntityRoleWithHttpMessagesAsync()-52.38%42.11%
DeletePatternAnyEntityRoleWithHttpMessagesAsync()-50.65%38.24%
GetHierarchicalEntityRoleWithHttpMessagesAsync()-0%0%
UpdateHierarchicalEntityRoleWithHttpMessagesAsync()-0%0%
DeleteHierarchicalEntityRoleWithHttpMessagesAsync()-0%0%
GetCustomEntityRoleWithHttpMessagesAsync()-50.65%38.24%
UpdateCustomPrebuiltEntityRoleWithHttpMessagesAsync()-52.38%42.11%
DeleteCustomEntityRoleWithHttpMessagesAsync()-50.65%38.24%
GetExplicitListItemWithHttpMessagesAsync()-50.65%38.24%
UpdateExplicitListItemWithHttpMessagesAsync()-52.38%42.11%
DeleteExplicitListItemWithHttpMessagesAsync()-50.65%38.24%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Model.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    /// Model operations.
 27    /// </summary>
 28    public partial class Model : IServiceOperations<LUISAuthoringClient>, IModel
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the Model 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 Model(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>
 370251        public LUISAuthoringClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Adds an intent to 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='intentCreateObject'>
 63        /// A model object containing the name of the new intent.
 64        /// </param>
 65        /// <param name='customHeaders'>
 66        /// Headers that will be added to request.
 67        /// </param>
 68        /// <param name='cancellationToken'>
 69        /// The cancellation token.
 70        /// </param>
 71        /// <exception cref="ErrorResponseException">
 72        /// Thrown when the operation returned an invalid status code
 73        /// </exception>
 74        /// <exception cref="SerializationException">
 75        /// Thrown when unable to deserialize the response
 76        /// </exception>
 77        /// <exception cref="ValidationException">
 78        /// Thrown when a required parameter is null
 79        /// </exception>
 80        /// <exception cref="System.ArgumentNullException">
 81        /// Thrown when a required parameter is null
 82        /// </exception>
 83        /// <return>
 84        /// A response object containing the response body and response headers.
 85        /// </return>
 86        public async Task<HttpOperationResponse<System.Guid>> AddIntentWithHttpMessagesAsync(System.Guid appId, string v
 87        {
 1288            if (Client.Endpoint == null)
 89            {
 090                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 91            }
 1292            if (versionId == null)
 93            {
 094                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 95            }
 1296            if (intentCreateObject == null)
 97            {
 098                throw new ValidationException(ValidationRules.CannotBeNull, "intentCreateObject");
 99            }
 100            // Tracing
 12101            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 12102            string _invocationId = null;
 12103            if (_shouldTrace)
 104            {
 0105                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0106                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0107                tracingParameters.Add("appId", appId);
 0108                tracingParameters.Add("versionId", versionId);
 0109                tracingParameters.Add("intentCreateObject", intentCreateObject);
 0110                tracingParameters.Add("cancellationToken", cancellationToken);
 0111                ServiceClientTracing.Enter(_invocationId, this, "AddIntent", tracingParameters);
 112            }
 113            // Construct URL
 12114            var _baseUrl = Client.BaseUri;
 12115            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents";
 12116            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 12117            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 12118            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 119            // Create HTTP transport objects
 12120            var _httpRequest = new HttpRequestMessage();
 12121            HttpResponseMessage _httpResponse = null;
 12122            _httpRequest.Method = new HttpMethod("POST");
 12123            _httpRequest.RequestUri = new System.Uri(_url);
 124            // Set Headers
 125
 126
 12127            if (customHeaders != null)
 128            {
 0129                foreach(var _header in customHeaders)
 130                {
 0131                    if (_httpRequest.Headers.Contains(_header.Key))
 132                    {
 0133                        _httpRequest.Headers.Remove(_header.Key);
 134                    }
 0135                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 136                }
 137            }
 138
 139            // Serialize Request
 12140            string _requestContent = null;
 12141            if(intentCreateObject != null)
 142            {
 12143                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(intentCreateObject, Client.Serializ
 12144                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 12145                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 146            }
 147            // Set Credentials
 12148            if (Client.Credentials != null)
 149            {
 12150                cancellationToken.ThrowIfCancellationRequested();
 12151                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 152            }
 153            // Send Request
 12154            if (_shouldTrace)
 155            {
 0156                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 157            }
 12158            cancellationToken.ThrowIfCancellationRequested();
 12159            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12160            if (_shouldTrace)
 161            {
 0162                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 163            }
 12164            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 12165            cancellationToken.ThrowIfCancellationRequested();
 12166            string _responseContent = null;
 12167            if ((int)_statusCode != 201)
 168            {
 0169                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 170                try
 171                {
 0172                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0173                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0174                    if (_errorBody != null)
 175                    {
 0176                        ex.Body = _errorBody;
 177                    }
 0178                }
 0179                catch (JsonException)
 180                {
 181                    // Ignore the exception
 0182                }
 0183                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0184                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0185                if (_shouldTrace)
 186                {
 0187                    ServiceClientTracing.Error(_invocationId, ex);
 188                }
 0189                _httpRequest.Dispose();
 0190                if (_httpResponse != null)
 191                {
 0192                    _httpResponse.Dispose();
 193                }
 0194                throw ex;
 195            }
 196            // Create Result
 12197            var _result = new HttpOperationResponse<System.Guid>();
 12198            _result.Request = _httpRequest;
 12199            _result.Response = _httpResponse;
 200            // Deserialize Response
 12201            if ((int)_statusCode == 201)
 202            {
 12203                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 204                try
 205                {
 12206                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 12207                }
 0208                catch (JsonException ex)
 209                {
 0210                    _httpRequest.Dispose();
 0211                    if (_httpResponse != null)
 212                    {
 0213                        _httpResponse.Dispose();
 214                    }
 0215                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 216                }
 217            }
 12218            if (_shouldTrace)
 219            {
 0220                ServiceClientTracing.Exit(_invocationId, _result);
 221            }
 12222            return _result;
 12223        }
 224
 225        /// <summary>
 226        /// Gets information about the intent models in a version of the application.
 227        /// </summary>
 228        /// <param name='appId'>
 229        /// The application ID.
 230        /// </param>
 231        /// <param name='versionId'>
 232        /// The version ID.
 233        /// </param>
 234        /// <param name='skip'>
 235        /// The number of entries to skip. Default value is 0.
 236        /// </param>
 237        /// <param name='take'>
 238        /// The number of entries to return. Maximum page size is 500. Default is 100.
 239        /// </param>
 240        /// <param name='customHeaders'>
 241        /// Headers that will be added to request.
 242        /// </param>
 243        /// <param name='cancellationToken'>
 244        /// The cancellation token.
 245        /// </param>
 246        /// <exception cref="ErrorResponseException">
 247        /// Thrown when the operation returned an invalid status code
 248        /// </exception>
 249        /// <exception cref="SerializationException">
 250        /// Thrown when unable to deserialize the response
 251        /// </exception>
 252        /// <exception cref="ValidationException">
 253        /// Thrown when a required parameter is null
 254        /// </exception>
 255        /// <exception cref="System.ArgumentNullException">
 256        /// Thrown when a required parameter is null
 257        /// </exception>
 258        /// <return>
 259        /// A response object containing the response body and response headers.
 260        /// </return>
 261        public async Task<HttpOperationResponse<IList<IntentClassifier>>> ListIntentsWithHttpMessagesAsync(System.Guid a
 262        {
 4263            if (Client.Endpoint == null)
 264            {
 0265                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 266            }
 4267            if (versionId == null)
 268            {
 0269                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 270            }
 4271            if (skip < 0)
 272            {
 0273                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 274            }
 4275            if (take > 500)
 276            {
 0277                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 278            }
 4279            if (take < 0)
 280            {
 0281                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 282            }
 283            // Tracing
 4284            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 4285            string _invocationId = null;
 4286            if (_shouldTrace)
 287            {
 0288                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0289                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0290                tracingParameters.Add("appId", appId);
 0291                tracingParameters.Add("versionId", versionId);
 0292                tracingParameters.Add("skip", skip);
 0293                tracingParameters.Add("take", take);
 0294                tracingParameters.Add("cancellationToken", cancellationToken);
 0295                ServiceClientTracing.Enter(_invocationId, this, "ListIntents", tracingParameters);
 296            }
 297            // Construct URL
 4298            var _baseUrl = Client.BaseUri;
 4299            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents";
 4300            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 4301            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 4302            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 4303            List<string> _queryParameters = new List<string>();
 4304            if (skip != null)
 305            {
 4306                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 307            }
 4308            if (take != null)
 309            {
 4310                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 311            }
 4312            if (_queryParameters.Count > 0)
 313            {
 4314                _url += "?" + string.Join("&", _queryParameters);
 315            }
 316            // Create HTTP transport objects
 4317            var _httpRequest = new HttpRequestMessage();
 4318            HttpResponseMessage _httpResponse = null;
 4319            _httpRequest.Method = new HttpMethod("GET");
 4320            _httpRequest.RequestUri = new System.Uri(_url);
 321            // Set Headers
 322
 323
 4324            if (customHeaders != null)
 325            {
 0326                foreach(var _header in customHeaders)
 327                {
 0328                    if (_httpRequest.Headers.Contains(_header.Key))
 329                    {
 0330                        _httpRequest.Headers.Remove(_header.Key);
 331                    }
 0332                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 333                }
 334            }
 335
 336            // Serialize Request
 4337            string _requestContent = null;
 338            // Set Credentials
 4339            if (Client.Credentials != null)
 340            {
 4341                cancellationToken.ThrowIfCancellationRequested();
 4342                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 343            }
 344            // Send Request
 4345            if (_shouldTrace)
 346            {
 0347                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 348            }
 4349            cancellationToken.ThrowIfCancellationRequested();
 4350            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4351            if (_shouldTrace)
 352            {
 0353                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 354            }
 4355            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 4356            cancellationToken.ThrowIfCancellationRequested();
 4357            string _responseContent = null;
 4358            if ((int)_statusCode != 200)
 359            {
 0360                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 361                try
 362                {
 0363                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0364                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0365                    if (_errorBody != null)
 366                    {
 0367                        ex.Body = _errorBody;
 368                    }
 0369                }
 0370                catch (JsonException)
 371                {
 372                    // Ignore the exception
 0373                }
 0374                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0375                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0376                if (_shouldTrace)
 377                {
 0378                    ServiceClientTracing.Error(_invocationId, ex);
 379                }
 0380                _httpRequest.Dispose();
 0381                if (_httpResponse != null)
 382                {
 0383                    _httpResponse.Dispose();
 384                }
 0385                throw ex;
 386            }
 387            // Create Result
 4388            var _result = new HttpOperationResponse<IList<IntentClassifier>>();
 4389            _result.Request = _httpRequest;
 4390            _result.Response = _httpResponse;
 391            // Deserialize Response
 4392            if ((int)_statusCode == 200)
 393            {
 4394                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 395                try
 396                {
 4397                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<IntentClassifier>>(_respon
 4398                }
 0399                catch (JsonException ex)
 400                {
 0401                    _httpRequest.Dispose();
 0402                    if (_httpResponse != null)
 403                    {
 0404                        _httpResponse.Dispose();
 405                    }
 0406                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 407                }
 408            }
 4409            if (_shouldTrace)
 410            {
 0411                ServiceClientTracing.Exit(_invocationId, _result);
 412            }
 4413            return _result;
 4414        }
 415
 416        /// <summary>
 417        /// Adds an entity extractor to a version of the application.
 418        /// </summary>
 419        /// <param name='appId'>
 420        /// The application ID.
 421        /// </param>
 422        /// <param name='versionId'>
 423        /// The version ID.
 424        /// </param>
 425        /// <param name='entityModelCreateObject'>
 426        /// A model object containing the name of the new entity extractor and its
 427        /// children.
 428        /// </param>
 429        /// <param name='customHeaders'>
 430        /// Headers that will be added to request.
 431        /// </param>
 432        /// <param name='cancellationToken'>
 433        /// The cancellation token.
 434        /// </param>
 435        /// <exception cref="ErrorResponseException">
 436        /// Thrown when the operation returned an invalid status code
 437        /// </exception>
 438        /// <exception cref="SerializationException">
 439        /// Thrown when unable to deserialize the response
 440        /// </exception>
 441        /// <exception cref="ValidationException">
 442        /// Thrown when a required parameter is null
 443        /// </exception>
 444        /// <exception cref="System.ArgumentNullException">
 445        /// Thrown when a required parameter is null
 446        /// </exception>
 447        /// <return>
 448        /// A response object containing the response body and response headers.
 449        /// </return>
 450        public async Task<HttpOperationResponse<System.Guid>> AddEntityWithHttpMessagesAsync(System.Guid appId, string v
 451        {
 33452            if (Client.Endpoint == null)
 453            {
 0454                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 455            }
 33456            if (versionId == null)
 457            {
 0458                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 459            }
 33460            if (entityModelCreateObject == null)
 461            {
 0462                throw new ValidationException(ValidationRules.CannotBeNull, "entityModelCreateObject");
 463            }
 464            // Tracing
 33465            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 33466            string _invocationId = null;
 33467            if (_shouldTrace)
 468            {
 0469                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0470                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0471                tracingParameters.Add("appId", appId);
 0472                tracingParameters.Add("versionId", versionId);
 0473                tracingParameters.Add("entityModelCreateObject", entityModelCreateObject);
 0474                tracingParameters.Add("cancellationToken", cancellationToken);
 0475                ServiceClientTracing.Enter(_invocationId, this, "AddEntity", tracingParameters);
 476            }
 477            // Construct URL
 33478            var _baseUrl = Client.BaseUri;
 33479            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities";
 33480            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 33481            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 33482            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 483            // Create HTTP transport objects
 33484            var _httpRequest = new HttpRequestMessage();
 33485            HttpResponseMessage _httpResponse = null;
 33486            _httpRequest.Method = new HttpMethod("POST");
 33487            _httpRequest.RequestUri = new System.Uri(_url);
 488            // Set Headers
 489
 490
 33491            if (customHeaders != null)
 492            {
 0493                foreach(var _header in customHeaders)
 494                {
 0495                    if (_httpRequest.Headers.Contains(_header.Key))
 496                    {
 0497                        _httpRequest.Headers.Remove(_header.Key);
 498                    }
 0499                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 500                }
 501            }
 502
 503            // Serialize Request
 33504            string _requestContent = null;
 33505            if(entityModelCreateObject != null)
 506            {
 33507                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityModelCreateObject, Client.Ser
 33508                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 33509                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 510            }
 511            // Set Credentials
 33512            if (Client.Credentials != null)
 513            {
 33514                cancellationToken.ThrowIfCancellationRequested();
 33515                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 516            }
 517            // Send Request
 33518            if (_shouldTrace)
 519            {
 0520                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 521            }
 33522            cancellationToken.ThrowIfCancellationRequested();
 33523            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 33524            if (_shouldTrace)
 525            {
 0526                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 527            }
 33528            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 33529            cancellationToken.ThrowIfCancellationRequested();
 33530            string _responseContent = null;
 33531            if ((int)_statusCode != 201)
 532            {
 0533                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 534                try
 535                {
 0536                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0537                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0538                    if (_errorBody != null)
 539                    {
 0540                        ex.Body = _errorBody;
 541                    }
 0542                }
 0543                catch (JsonException)
 544                {
 545                    // Ignore the exception
 0546                }
 0547                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0548                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0549                if (_shouldTrace)
 550                {
 0551                    ServiceClientTracing.Error(_invocationId, ex);
 552                }
 0553                _httpRequest.Dispose();
 0554                if (_httpResponse != null)
 555                {
 0556                    _httpResponse.Dispose();
 557                }
 0558                throw ex;
 559            }
 560            // Create Result
 33561            var _result = new HttpOperationResponse<System.Guid>();
 33562            _result.Request = _httpRequest;
 33563            _result.Response = _httpResponse;
 564            // Deserialize Response
 33565            if ((int)_statusCode == 201)
 566            {
 33567                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 568                try
 569                {
 33570                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 33571                }
 0572                catch (JsonException ex)
 573                {
 0574                    _httpRequest.Dispose();
 0575                    if (_httpResponse != null)
 576                    {
 0577                        _httpResponse.Dispose();
 578                    }
 0579                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 580                }
 581            }
 33582            if (_shouldTrace)
 583            {
 0584                ServiceClientTracing.Exit(_invocationId, _result);
 585            }
 33586            return _result;
 33587        }
 588
 589        /// <summary>
 590        /// Gets information about all the simple entity models in a version of the
 591        /// application.
 592        /// </summary>
 593        /// <param name='appId'>
 594        /// The application ID.
 595        /// </param>
 596        /// <param name='versionId'>
 597        /// The version ID.
 598        /// </param>
 599        /// <param name='skip'>
 600        /// The number of entries to skip. Default value is 0.
 601        /// </param>
 602        /// <param name='take'>
 603        /// The number of entries to return. Maximum page size is 500. Default is 100.
 604        /// </param>
 605        /// <param name='customHeaders'>
 606        /// Headers that will be added to request.
 607        /// </param>
 608        /// <param name='cancellationToken'>
 609        /// The cancellation token.
 610        /// </param>
 611        /// <exception cref="ErrorResponseException">
 612        /// Thrown when the operation returned an invalid status code
 613        /// </exception>
 614        /// <exception cref="SerializationException">
 615        /// Thrown when unable to deserialize the response
 616        /// </exception>
 617        /// <exception cref="ValidationException">
 618        /// Thrown when a required parameter is null
 619        /// </exception>
 620        /// <exception cref="System.ArgumentNullException">
 621        /// Thrown when a required parameter is null
 622        /// </exception>
 623        /// <return>
 624        /// A response object containing the response body and response headers.
 625        /// </return>
 626        public async Task<HttpOperationResponse<IList<NDepthEntityExtractor>>> ListEntitiesWithHttpMessagesAsync(System.
 627        {
 3628            if (Client.Endpoint == null)
 629            {
 0630                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 631            }
 3632            if (versionId == null)
 633            {
 0634                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 635            }
 3636            if (skip < 0)
 637            {
 0638                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 639            }
 3640            if (take > 500)
 641            {
 0642                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 643            }
 3644            if (take < 0)
 645            {
 0646                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 647            }
 648            // Tracing
 3649            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 3650            string _invocationId = null;
 3651            if (_shouldTrace)
 652            {
 0653                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0654                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0655                tracingParameters.Add("appId", appId);
 0656                tracingParameters.Add("versionId", versionId);
 0657                tracingParameters.Add("skip", skip);
 0658                tracingParameters.Add("take", take);
 0659                tracingParameters.Add("cancellationToken", cancellationToken);
 0660                ServiceClientTracing.Enter(_invocationId, this, "ListEntities", tracingParameters);
 661            }
 662            // Construct URL
 3663            var _baseUrl = Client.BaseUri;
 3664            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities";
 3665            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 3666            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 3667            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 3668            List<string> _queryParameters = new List<string>();
 3669            if (skip != null)
 670            {
 3671                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 672            }
 3673            if (take != null)
 674            {
 3675                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 676            }
 3677            if (_queryParameters.Count > 0)
 678            {
 3679                _url += "?" + string.Join("&", _queryParameters);
 680            }
 681            // Create HTTP transport objects
 3682            var _httpRequest = new HttpRequestMessage();
 3683            HttpResponseMessage _httpResponse = null;
 3684            _httpRequest.Method = new HttpMethod("GET");
 3685            _httpRequest.RequestUri = new System.Uri(_url);
 686            // Set Headers
 687
 688
 3689            if (customHeaders != null)
 690            {
 0691                foreach(var _header in customHeaders)
 692                {
 0693                    if (_httpRequest.Headers.Contains(_header.Key))
 694                    {
 0695                        _httpRequest.Headers.Remove(_header.Key);
 696                    }
 0697                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 698                }
 699            }
 700
 701            // Serialize Request
 3702            string _requestContent = null;
 703            // Set Credentials
 3704            if (Client.Credentials != null)
 705            {
 3706                cancellationToken.ThrowIfCancellationRequested();
 3707                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 708            }
 709            // Send Request
 3710            if (_shouldTrace)
 711            {
 0712                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 713            }
 3714            cancellationToken.ThrowIfCancellationRequested();
 3715            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3716            if (_shouldTrace)
 717            {
 0718                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 719            }
 3720            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 3721            cancellationToken.ThrowIfCancellationRequested();
 3722            string _responseContent = null;
 3723            if ((int)_statusCode != 200)
 724            {
 0725                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 726                try
 727                {
 0728                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0729                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0730                    if (_errorBody != null)
 731                    {
 0732                        ex.Body = _errorBody;
 733                    }
 0734                }
 0735                catch (JsonException)
 736                {
 737                    // Ignore the exception
 0738                }
 0739                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0740                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0741                if (_shouldTrace)
 742                {
 0743                    ServiceClientTracing.Error(_invocationId, ex);
 744                }
 0745                _httpRequest.Dispose();
 0746                if (_httpResponse != null)
 747                {
 0748                    _httpResponse.Dispose();
 749                }
 0750                throw ex;
 751            }
 752            // Create Result
 3753            var _result = new HttpOperationResponse<IList<NDepthEntityExtractor>>();
 3754            _result.Request = _httpRequest;
 3755            _result.Response = _httpResponse;
 756            // Deserialize Response
 3757            if ((int)_statusCode == 200)
 758            {
 3759                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 760                try
 761                {
 3762                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<NDepthEntityExtractor>>(_r
 3763                }
 0764                catch (JsonException ex)
 765                {
 0766                    _httpRequest.Dispose();
 0767                    if (_httpResponse != null)
 768                    {
 0769                        _httpResponse.Dispose();
 770                    }
 0771                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 772                }
 773            }
 3774            if (_shouldTrace)
 775            {
 0776                ServiceClientTracing.Exit(_invocationId, _result);
 777            }
 3778            return _result;
 3779        }
 780
 781        /// <summary>
 782        /// Gets information about all the hierarchical entity models in a version of
 783        /// the application.
 784        /// </summary>
 785        /// <param name='appId'>
 786        /// The application ID.
 787        /// </param>
 788        /// <param name='versionId'>
 789        /// The version ID.
 790        /// </param>
 791        /// <param name='skip'>
 792        /// The number of entries to skip. Default value is 0.
 793        /// </param>
 794        /// <param name='take'>
 795        /// The number of entries to return. Maximum page size is 500. Default is 100.
 796        /// </param>
 797        /// <param name='customHeaders'>
 798        /// Headers that will be added to request.
 799        /// </param>
 800        /// <param name='cancellationToken'>
 801        /// The cancellation token.
 802        /// </param>
 803        /// <exception cref="ErrorResponseException">
 804        /// Thrown when the operation returned an invalid status code
 805        /// </exception>
 806        /// <exception cref="SerializationException">
 807        /// Thrown when unable to deserialize the response
 808        /// </exception>
 809        /// <exception cref="ValidationException">
 810        /// Thrown when a required parameter is null
 811        /// </exception>
 812        /// <exception cref="System.ArgumentNullException">
 813        /// Thrown when a required parameter is null
 814        /// </exception>
 815        /// <return>
 816        /// A response object containing the response body and response headers.
 817        /// </return>
 818        public async Task<HttpOperationResponse<IList<HierarchicalEntityExtractor>>> ListHierarchicalEntitiesWithHttpMes
 819        {
 0820            if (Client.Endpoint == null)
 821            {
 0822                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 823            }
 0824            if (versionId == null)
 825            {
 0826                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 827            }
 0828            if (skip < 0)
 829            {
 0830                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 831            }
 0832            if (take > 500)
 833            {
 0834                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 835            }
 0836            if (take < 0)
 837            {
 0838                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 839            }
 840            // Tracing
 0841            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0842            string _invocationId = null;
 0843            if (_shouldTrace)
 844            {
 0845                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0846                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0847                tracingParameters.Add("appId", appId);
 0848                tracingParameters.Add("versionId", versionId);
 0849                tracingParameters.Add("skip", skip);
 0850                tracingParameters.Add("take", take);
 0851                tracingParameters.Add("cancellationToken", cancellationToken);
 0852                ServiceClientTracing.Enter(_invocationId, this, "ListHierarchicalEntities", tracingParameters);
 853            }
 854            // Construct URL
 0855            var _baseUrl = Client.BaseUri;
 0856            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 0857            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0858            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 0859            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 0860            List<string> _queryParameters = new List<string>();
 0861            if (skip != null)
 862            {
 0863                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 864            }
 0865            if (take != null)
 866            {
 0867                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 868            }
 0869            if (_queryParameters.Count > 0)
 870            {
 0871                _url += "?" + string.Join("&", _queryParameters);
 872            }
 873            // Create HTTP transport objects
 0874            var _httpRequest = new HttpRequestMessage();
 0875            HttpResponseMessage _httpResponse = null;
 0876            _httpRequest.Method = new HttpMethod("GET");
 0877            _httpRequest.RequestUri = new System.Uri(_url);
 878            // Set Headers
 879
 880
 0881            if (customHeaders != null)
 882            {
 0883                foreach(var _header in customHeaders)
 884                {
 0885                    if (_httpRequest.Headers.Contains(_header.Key))
 886                    {
 0887                        _httpRequest.Headers.Remove(_header.Key);
 888                    }
 0889                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 890                }
 891            }
 892
 893            // Serialize Request
 0894            string _requestContent = null;
 895            // Set Credentials
 0896            if (Client.Credentials != null)
 897            {
 0898                cancellationToken.ThrowIfCancellationRequested();
 0899                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 900            }
 901            // Send Request
 0902            if (_shouldTrace)
 903            {
 0904                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 905            }
 0906            cancellationToken.ThrowIfCancellationRequested();
 0907            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0908            if (_shouldTrace)
 909            {
 0910                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 911            }
 0912            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0913            cancellationToken.ThrowIfCancellationRequested();
 0914            string _responseContent = null;
 0915            if ((int)_statusCode != 200)
 916            {
 0917                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 918                try
 919                {
 0920                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0921                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0922                    if (_errorBody != null)
 923                    {
 0924                        ex.Body = _errorBody;
 925                    }
 0926                }
 0927                catch (JsonException)
 928                {
 929                    // Ignore the exception
 0930                }
 0931                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0932                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0933                if (_shouldTrace)
 934                {
 0935                    ServiceClientTracing.Error(_invocationId, ex);
 936                }
 0937                _httpRequest.Dispose();
 0938                if (_httpResponse != null)
 939                {
 0940                    _httpResponse.Dispose();
 941                }
 0942                throw ex;
 943            }
 944            // Create Result
 0945            var _result = new HttpOperationResponse<IList<HierarchicalEntityExtractor>>();
 0946            _result.Request = _httpRequest;
 0947            _result.Response = _httpResponse;
 948            // Deserialize Response
 0949            if ((int)_statusCode == 200)
 950            {
 0951                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 952                try
 953                {
 0954                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<HierarchicalEntityExtracto
 0955                }
 0956                catch (JsonException ex)
 957                {
 0958                    _httpRequest.Dispose();
 0959                    if (_httpResponse != null)
 960                    {
 0961                        _httpResponse.Dispose();
 962                    }
 0963                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 964                }
 965            }
 0966            if (_shouldTrace)
 967            {
 0968                ServiceClientTracing.Exit(_invocationId, _result);
 969            }
 0970            return _result;
 0971        }
 972
 973        /// <summary>
 974        /// Gets information about all the composite entity models in a version of the
 975        /// application.
 976        /// </summary>
 977        /// <param name='appId'>
 978        /// The application ID.
 979        /// </param>
 980        /// <param name='versionId'>
 981        /// The version ID.
 982        /// </param>
 983        /// <param name='skip'>
 984        /// The number of entries to skip. Default value is 0.
 985        /// </param>
 986        /// <param name='take'>
 987        /// The number of entries to return. Maximum page size is 500. Default is 100.
 988        /// </param>
 989        /// <param name='customHeaders'>
 990        /// Headers that will be added to request.
 991        /// </param>
 992        /// <param name='cancellationToken'>
 993        /// The cancellation token.
 994        /// </param>
 995        /// <exception cref="ErrorResponseException">
 996        /// Thrown when the operation returned an invalid status code
 997        /// </exception>
 998        /// <exception cref="SerializationException">
 999        /// Thrown when unable to deserialize the response
 1000        /// </exception>
 1001        /// <exception cref="ValidationException">
 1002        /// Thrown when a required parameter is null
 1003        /// </exception>
 1004        /// <exception cref="System.ArgumentNullException">
 1005        /// Thrown when a required parameter is null
 1006        /// </exception>
 1007        /// <return>
 1008        /// A response object containing the response body and response headers.
 1009        /// </return>
 1010        public async Task<HttpOperationResponse<IList<CompositeEntityExtractor>>> ListCompositeEntitiesWithHttpMessagesA
 1011        {
 01012            if (Client.Endpoint == null)
 1013            {
 01014                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1015            }
 01016            if (versionId == null)
 1017            {
 01018                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 1019            }
 01020            if (skip < 0)
 1021            {
 01022                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 1023            }
 01024            if (take > 500)
 1025            {
 01026                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 1027            }
 01028            if (take < 0)
 1029            {
 01030                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 1031            }
 1032            // Tracing
 01033            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01034            string _invocationId = null;
 01035            if (_shouldTrace)
 1036            {
 01037                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01038                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01039                tracingParameters.Add("appId", appId);
 01040                tracingParameters.Add("versionId", versionId);
 01041                tracingParameters.Add("skip", skip);
 01042                tracingParameters.Add("take", take);
 01043                tracingParameters.Add("cancellationToken", cancellationToken);
 01044                ServiceClientTracing.Enter(_invocationId, this, "ListCompositeEntities", tracingParameters);
 1045            }
 1046            // Construct URL
 01047            var _baseUrl = Client.BaseUri;
 01048            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 01049            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 01050            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 01051            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 01052            List<string> _queryParameters = new List<string>();
 01053            if (skip != null)
 1054            {
 01055                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 1056            }
 01057            if (take != null)
 1058            {
 01059                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 1060            }
 01061            if (_queryParameters.Count > 0)
 1062            {
 01063                _url += "?" + string.Join("&", _queryParameters);
 1064            }
 1065            // Create HTTP transport objects
 01066            var _httpRequest = new HttpRequestMessage();
 01067            HttpResponseMessage _httpResponse = null;
 01068            _httpRequest.Method = new HttpMethod("GET");
 01069            _httpRequest.RequestUri = new System.Uri(_url);
 1070            // Set Headers
 1071
 1072
 01073            if (customHeaders != null)
 1074            {
 01075                foreach(var _header in customHeaders)
 1076                {
 01077                    if (_httpRequest.Headers.Contains(_header.Key))
 1078                    {
 01079                        _httpRequest.Headers.Remove(_header.Key);
 1080                    }
 01081                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1082                }
 1083            }
 1084
 1085            // Serialize Request
 01086            string _requestContent = null;
 1087            // Set Credentials
 01088            if (Client.Credentials != null)
 1089            {
 01090                cancellationToken.ThrowIfCancellationRequested();
 01091                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1092            }
 1093            // Send Request
 01094            if (_shouldTrace)
 1095            {
 01096                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1097            }
 01098            cancellationToken.ThrowIfCancellationRequested();
 01099            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01100            if (_shouldTrace)
 1101            {
 01102                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1103            }
 01104            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01105            cancellationToken.ThrowIfCancellationRequested();
 01106            string _responseContent = null;
 01107            if ((int)_statusCode != 200)
 1108            {
 01109                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1110                try
 1111                {
 01112                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01113                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01114                    if (_errorBody != null)
 1115                    {
 01116                        ex.Body = _errorBody;
 1117                    }
 01118                }
 01119                catch (JsonException)
 1120                {
 1121                    // Ignore the exception
 01122                }
 01123                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01124                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01125                if (_shouldTrace)
 1126                {
 01127                    ServiceClientTracing.Error(_invocationId, ex);
 1128                }
 01129                _httpRequest.Dispose();
 01130                if (_httpResponse != null)
 1131                {
 01132                    _httpResponse.Dispose();
 1133                }
 01134                throw ex;
 1135            }
 1136            // Create Result
 01137            var _result = new HttpOperationResponse<IList<CompositeEntityExtractor>>();
 01138            _result.Request = _httpRequest;
 01139            _result.Response = _httpResponse;
 1140            // Deserialize Response
 01141            if ((int)_statusCode == 200)
 1142            {
 01143                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1144                try
 1145                {
 01146                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<CompositeEntityExtractor>>
 01147                }
 01148                catch (JsonException ex)
 1149                {
 01150                    _httpRequest.Dispose();
 01151                    if (_httpResponse != null)
 1152                    {
 01153                        _httpResponse.Dispose();
 1154                    }
 01155                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1156                }
 1157            }
 01158            if (_shouldTrace)
 1159            {
 01160                ServiceClientTracing.Exit(_invocationId, _result);
 1161            }
 01162            return _result;
 01163        }
 1164
 1165        /// <summary>
 1166        /// Gets information about all the list entity models in a version of the
 1167        /// application.
 1168        /// </summary>
 1169        /// <param name='appId'>
 1170        /// The application ID.
 1171        /// </param>
 1172        /// <param name='versionId'>
 1173        /// The version ID.
 1174        /// </param>
 1175        /// <param name='skip'>
 1176        /// The number of entries to skip. Default value is 0.
 1177        /// </param>
 1178        /// <param name='take'>
 1179        /// The number of entries to return. Maximum page size is 500. Default is 100.
 1180        /// </param>
 1181        /// <param name='customHeaders'>
 1182        /// Headers that will be added to request.
 1183        /// </param>
 1184        /// <param name='cancellationToken'>
 1185        /// The cancellation token.
 1186        /// </param>
 1187        /// <exception cref="ErrorResponseException">
 1188        /// Thrown when the operation returned an invalid status code
 1189        /// </exception>
 1190        /// <exception cref="SerializationException">
 1191        /// Thrown when unable to deserialize the response
 1192        /// </exception>
 1193        /// <exception cref="ValidationException">
 1194        /// Thrown when a required parameter is null
 1195        /// </exception>
 1196        /// <exception cref="System.ArgumentNullException">
 1197        /// Thrown when a required parameter is null
 1198        /// </exception>
 1199        /// <return>
 1200        /// A response object containing the response body and response headers.
 1201        /// </return>
 1202        public async Task<HttpOperationResponse<IList<ClosedListEntityExtractor>>> ListClosedListsWithHttpMessagesAsync(
 1203        {
 21204            if (Client.Endpoint == null)
 1205            {
 01206                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1207            }
 21208            if (versionId == null)
 1209            {
 01210                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 1211            }
 21212            if (skip < 0)
 1213            {
 01214                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 1215            }
 21216            if (take > 500)
 1217            {
 01218                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 1219            }
 21220            if (take < 0)
 1221            {
 01222                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 1223            }
 1224            // Tracing
 21225            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 21226            string _invocationId = null;
 21227            if (_shouldTrace)
 1228            {
 01229                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01230                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01231                tracingParameters.Add("appId", appId);
 01232                tracingParameters.Add("versionId", versionId);
 01233                tracingParameters.Add("skip", skip);
 01234                tracingParameters.Add("take", take);
 01235                tracingParameters.Add("cancellationToken", cancellationToken);
 01236                ServiceClientTracing.Enter(_invocationId, this, "ListClosedLists", tracingParameters);
 1237            }
 1238            // Construct URL
 21239            var _baseUrl = Client.BaseUri;
 21240            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists";
 21241            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 21242            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 21243            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 21244            List<string> _queryParameters = new List<string>();
 21245            if (skip != null)
 1246            {
 21247                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 1248            }
 21249            if (take != null)
 1250            {
 21251                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 1252            }
 21253            if (_queryParameters.Count > 0)
 1254            {
 21255                _url += "?" + string.Join("&", _queryParameters);
 1256            }
 1257            // Create HTTP transport objects
 21258            var _httpRequest = new HttpRequestMessage();
 21259            HttpResponseMessage _httpResponse = null;
 21260            _httpRequest.Method = new HttpMethod("GET");
 21261            _httpRequest.RequestUri = new System.Uri(_url);
 1262            // Set Headers
 1263
 1264
 21265            if (customHeaders != null)
 1266            {
 01267                foreach(var _header in customHeaders)
 1268                {
 01269                    if (_httpRequest.Headers.Contains(_header.Key))
 1270                    {
 01271                        _httpRequest.Headers.Remove(_header.Key);
 1272                    }
 01273                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1274                }
 1275            }
 1276
 1277            // Serialize Request
 21278            string _requestContent = null;
 1279            // Set Credentials
 21280            if (Client.Credentials != null)
 1281            {
 21282                cancellationToken.ThrowIfCancellationRequested();
 21283                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1284            }
 1285            // Send Request
 21286            if (_shouldTrace)
 1287            {
 01288                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1289            }
 21290            cancellationToken.ThrowIfCancellationRequested();
 21291            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 21292            if (_shouldTrace)
 1293            {
 01294                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1295            }
 21296            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 21297            cancellationToken.ThrowIfCancellationRequested();
 21298            string _responseContent = null;
 21299            if ((int)_statusCode != 200)
 1300            {
 01301                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1302                try
 1303                {
 01304                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01305                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01306                    if (_errorBody != null)
 1307                    {
 01308                        ex.Body = _errorBody;
 1309                    }
 01310                }
 01311                catch (JsonException)
 1312                {
 1313                    // Ignore the exception
 01314                }
 01315                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01316                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01317                if (_shouldTrace)
 1318                {
 01319                    ServiceClientTracing.Error(_invocationId, ex);
 1320                }
 01321                _httpRequest.Dispose();
 01322                if (_httpResponse != null)
 1323                {
 01324                    _httpResponse.Dispose();
 1325                }
 01326                throw ex;
 1327            }
 1328            // Create Result
 21329            var _result = new HttpOperationResponse<IList<ClosedListEntityExtractor>>();
 21330            _result.Request = _httpRequest;
 21331            _result.Response = _httpResponse;
 1332            // Deserialize Response
 21333            if ((int)_statusCode == 200)
 1334            {
 21335                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1336                try
 1337                {
 21338                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ClosedListEntityExtractor>
 21339                }
 01340                catch (JsonException ex)
 1341                {
 01342                    _httpRequest.Dispose();
 01343                    if (_httpResponse != null)
 1344                    {
 01345                        _httpResponse.Dispose();
 1346                    }
 01347                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1348                }
 1349            }
 21350            if (_shouldTrace)
 1351            {
 01352                ServiceClientTracing.Exit(_invocationId, _result);
 1353            }
 21354            return _result;
 21355        }
 1356
 1357        /// <summary>
 1358        /// Adds a list entity model to a version of the application.
 1359        /// </summary>
 1360        /// <param name='appId'>
 1361        /// The application ID.
 1362        /// </param>
 1363        /// <param name='versionId'>
 1364        /// The version ID.
 1365        /// </param>
 1366        /// <param name='closedListModelCreateObject'>
 1367        /// A model containing the name and words for the new list entity extractor.
 1368        /// </param>
 1369        /// <param name='customHeaders'>
 1370        /// Headers that will be added to request.
 1371        /// </param>
 1372        /// <param name='cancellationToken'>
 1373        /// The cancellation token.
 1374        /// </param>
 1375        /// <exception cref="ErrorResponseException">
 1376        /// Thrown when the operation returned an invalid status code
 1377        /// </exception>
 1378        /// <exception cref="SerializationException">
 1379        /// Thrown when unable to deserialize the response
 1380        /// </exception>
 1381        /// <exception cref="ValidationException">
 1382        /// Thrown when a required parameter is null
 1383        /// </exception>
 1384        /// <exception cref="System.ArgumentNullException">
 1385        /// Thrown when a required parameter is null
 1386        /// </exception>
 1387        /// <return>
 1388        /// A response object containing the response body and response headers.
 1389        /// </return>
 1390        public async Task<HttpOperationResponse<System.Guid>> AddClosedListWithHttpMessagesAsync(System.Guid appId, stri
 1391        {
 141392            if (Client.Endpoint == null)
 1393            {
 01394                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1395            }
 141396            if (versionId == null)
 1397            {
 01398                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 1399            }
 141400            if (closedListModelCreateObject == null)
 1401            {
 01402                throw new ValidationException(ValidationRules.CannotBeNull, "closedListModelCreateObject");
 1403            }
 1404            // Tracing
 141405            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 141406            string _invocationId = null;
 141407            if (_shouldTrace)
 1408            {
 01409                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01410                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01411                tracingParameters.Add("appId", appId);
 01412                tracingParameters.Add("versionId", versionId);
 01413                tracingParameters.Add("closedListModelCreateObject", closedListModelCreateObject);
 01414                tracingParameters.Add("cancellationToken", cancellationToken);
 01415                ServiceClientTracing.Enter(_invocationId, this, "AddClosedList", tracingParameters);
 1416            }
 1417            // Construct URL
 141418            var _baseUrl = Client.BaseUri;
 141419            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists";
 141420            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 141421            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 141422            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 1423            // Create HTTP transport objects
 141424            var _httpRequest = new HttpRequestMessage();
 141425            HttpResponseMessage _httpResponse = null;
 141426            _httpRequest.Method = new HttpMethod("POST");
 141427            _httpRequest.RequestUri = new System.Uri(_url);
 1428            // Set Headers
 1429
 1430
 141431            if (customHeaders != null)
 1432            {
 01433                foreach(var _header in customHeaders)
 1434                {
 01435                    if (_httpRequest.Headers.Contains(_header.Key))
 1436                    {
 01437                        _httpRequest.Headers.Remove(_header.Key);
 1438                    }
 01439                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1440                }
 1441            }
 1442
 1443            // Serialize Request
 141444            string _requestContent = null;
 141445            if(closedListModelCreateObject != null)
 1446            {
 141447                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(closedListModelCreateObject, Client
 141448                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 141449                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1450            }
 1451            // Set Credentials
 141452            if (Client.Credentials != null)
 1453            {
 141454                cancellationToken.ThrowIfCancellationRequested();
 141455                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1456            }
 1457            // Send Request
 141458            if (_shouldTrace)
 1459            {
 01460                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1461            }
 141462            cancellationToken.ThrowIfCancellationRequested();
 141463            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 141464            if (_shouldTrace)
 1465            {
 01466                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1467            }
 141468            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 141469            cancellationToken.ThrowIfCancellationRequested();
 141470            string _responseContent = null;
 141471            if ((int)_statusCode != 201)
 1472            {
 01473                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1474                try
 1475                {
 01476                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01477                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01478                    if (_errorBody != null)
 1479                    {
 01480                        ex.Body = _errorBody;
 1481                    }
 01482                }
 01483                catch (JsonException)
 1484                {
 1485                    // Ignore the exception
 01486                }
 01487                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01488                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01489                if (_shouldTrace)
 1490                {
 01491                    ServiceClientTracing.Error(_invocationId, ex);
 1492                }
 01493                _httpRequest.Dispose();
 01494                if (_httpResponse != null)
 1495                {
 01496                    _httpResponse.Dispose();
 1497                }
 01498                throw ex;
 1499            }
 1500            // Create Result
 141501            var _result = new HttpOperationResponse<System.Guid>();
 141502            _result.Request = _httpRequest;
 141503            _result.Response = _httpResponse;
 1504            // Deserialize Response
 141505            if ((int)_statusCode == 201)
 1506            {
 141507                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1508                try
 1509                {
 141510                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 141511                }
 01512                catch (JsonException ex)
 1513                {
 01514                    _httpRequest.Dispose();
 01515                    if (_httpResponse != null)
 1516                    {
 01517                        _httpResponse.Dispose();
 1518                    }
 01519                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1520                }
 1521            }
 141522            if (_shouldTrace)
 1523            {
 01524                ServiceClientTracing.Exit(_invocationId, _result);
 1525            }
 141526            return _result;
 141527        }
 1528
 1529        /// <summary>
 1530        /// Adds a list of prebuilt entities to a version of the application.
 1531        /// </summary>
 1532        /// <param name='appId'>
 1533        /// The application ID.
 1534        /// </param>
 1535        /// <param name='versionId'>
 1536        /// The version ID.
 1537        /// </param>
 1538        /// <param name='prebuiltExtractorNames'>
 1539        /// An array of prebuilt entity extractor names.
 1540        /// </param>
 1541        /// <param name='customHeaders'>
 1542        /// Headers that will be added to request.
 1543        /// </param>
 1544        /// <param name='cancellationToken'>
 1545        /// The cancellation token.
 1546        /// </param>
 1547        /// <exception cref="ErrorResponseException">
 1548        /// Thrown when the operation returned an invalid status code
 1549        /// </exception>
 1550        /// <exception cref="SerializationException">
 1551        /// Thrown when unable to deserialize the response
 1552        /// </exception>
 1553        /// <exception cref="ValidationException">
 1554        /// Thrown when a required parameter is null
 1555        /// </exception>
 1556        /// <exception cref="System.ArgumentNullException">
 1557        /// Thrown when a required parameter is null
 1558        /// </exception>
 1559        /// <return>
 1560        /// A response object containing the response body and response headers.
 1561        /// </return>
 1562        public async Task<HttpOperationResponse<IList<PrebuiltEntityExtractor>>> AddPrebuiltWithHttpMessagesAsync(System
 1563        {
 191564            if (Client.Endpoint == null)
 1565            {
 01566                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1567            }
 191568            if (versionId == null)
 1569            {
 01570                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 1571            }
 191572            if (prebuiltExtractorNames == null)
 1573            {
 01574                throw new ValidationException(ValidationRules.CannotBeNull, "prebuiltExtractorNames");
 1575            }
 1576            // Tracing
 191577            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 191578            string _invocationId = null;
 191579            if (_shouldTrace)
 1580            {
 01581                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01582                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01583                tracingParameters.Add("appId", appId);
 01584                tracingParameters.Add("versionId", versionId);
 01585                tracingParameters.Add("prebuiltExtractorNames", prebuiltExtractorNames);
 01586                tracingParameters.Add("cancellationToken", cancellationToken);
 01587                ServiceClientTracing.Enter(_invocationId, this, "AddPrebuilt", tracingParameters);
 1588            }
 1589            // Construct URL
 191590            var _baseUrl = Client.BaseUri;
 191591            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts";
 191592            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 191593            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 191594            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 1595            // Create HTTP transport objects
 191596            var _httpRequest = new HttpRequestMessage();
 191597            HttpResponseMessage _httpResponse = null;
 191598            _httpRequest.Method = new HttpMethod("POST");
 191599            _httpRequest.RequestUri = new System.Uri(_url);
 1600            // Set Headers
 1601
 1602
 191603            if (customHeaders != null)
 1604            {
 01605                foreach(var _header in customHeaders)
 1606                {
 01607                    if (_httpRequest.Headers.Contains(_header.Key))
 1608                    {
 01609                        _httpRequest.Headers.Remove(_header.Key);
 1610                    }
 01611                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1612                }
 1613            }
 1614
 1615            // Serialize Request
 191616            string _requestContent = null;
 191617            if(prebuiltExtractorNames != null)
 1618            {
 191619                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(prebuiltExtractorNames, Client.Seri
 191620                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 191621                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1622            }
 1623            // Set Credentials
 191624            if (Client.Credentials != null)
 1625            {
 191626                cancellationToken.ThrowIfCancellationRequested();
 191627                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1628            }
 1629            // Send Request
 191630            if (_shouldTrace)
 1631            {
 01632                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1633            }
 191634            cancellationToken.ThrowIfCancellationRequested();
 191635            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 191636            if (_shouldTrace)
 1637            {
 01638                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1639            }
 191640            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 191641            cancellationToken.ThrowIfCancellationRequested();
 191642            string _responseContent = null;
 191643            if ((int)_statusCode != 201)
 1644            {
 01645                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1646                try
 1647                {
 01648                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01649                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01650                    if (_errorBody != null)
 1651                    {
 01652                        ex.Body = _errorBody;
 1653                    }
 01654                }
 01655                catch (JsonException)
 1656                {
 1657                    // Ignore the exception
 01658                }
 01659                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01660                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01661                if (_shouldTrace)
 1662                {
 01663                    ServiceClientTracing.Error(_invocationId, ex);
 1664                }
 01665                _httpRequest.Dispose();
 01666                if (_httpResponse != null)
 1667                {
 01668                    _httpResponse.Dispose();
 1669                }
 01670                throw ex;
 1671            }
 1672            // Create Result
 191673            var _result = new HttpOperationResponse<IList<PrebuiltEntityExtractor>>();
 191674            _result.Request = _httpRequest;
 191675            _result.Response = _httpResponse;
 1676            // Deserialize Response
 191677            if ((int)_statusCode == 201)
 1678            {
 191679                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1680                try
 1681                {
 191682                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<PrebuiltEntityExtractor>>(
 191683                }
 01684                catch (JsonException ex)
 1685                {
 01686                    _httpRequest.Dispose();
 01687                    if (_httpResponse != null)
 1688                    {
 01689                        _httpResponse.Dispose();
 1690                    }
 01691                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1692                }
 1693            }
 191694            if (_shouldTrace)
 1695            {
 01696                ServiceClientTracing.Exit(_invocationId, _result);
 1697            }
 191698            return _result;
 191699        }
 1700
 1701        /// <summary>
 1702        /// Gets information about all the prebuilt entities in a version of the
 1703        /// application.
 1704        /// </summary>
 1705        /// <param name='appId'>
 1706        /// The application ID.
 1707        /// </param>
 1708        /// <param name='versionId'>
 1709        /// The version ID.
 1710        /// </param>
 1711        /// <param name='skip'>
 1712        /// The number of entries to skip. Default value is 0.
 1713        /// </param>
 1714        /// <param name='take'>
 1715        /// The number of entries to return. Maximum page size is 500. Default is 100.
 1716        /// </param>
 1717        /// <param name='customHeaders'>
 1718        /// Headers that will be added to request.
 1719        /// </param>
 1720        /// <param name='cancellationToken'>
 1721        /// The cancellation token.
 1722        /// </param>
 1723        /// <exception cref="ErrorResponseException">
 1724        /// Thrown when the operation returned an invalid status code
 1725        /// </exception>
 1726        /// <exception cref="SerializationException">
 1727        /// Thrown when unable to deserialize the response
 1728        /// </exception>
 1729        /// <exception cref="ValidationException">
 1730        /// Thrown when a required parameter is null
 1731        /// </exception>
 1732        /// <exception cref="System.ArgumentNullException">
 1733        /// Thrown when a required parameter is null
 1734        /// </exception>
 1735        /// <return>
 1736        /// A response object containing the response body and response headers.
 1737        /// </return>
 1738        public async Task<HttpOperationResponse<IList<PrebuiltEntityExtractor>>> ListPrebuiltsWithHttpMessagesAsync(Syst
 1739        {
 21740            if (Client.Endpoint == null)
 1741            {
 01742                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1743            }
 21744            if (versionId == null)
 1745            {
 01746                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 1747            }
 21748            if (skip < 0)
 1749            {
 01750                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 1751            }
 21752            if (take > 500)
 1753            {
 01754                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 1755            }
 21756            if (take < 0)
 1757            {
 01758                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 1759            }
 1760            // Tracing
 21761            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 21762            string _invocationId = null;
 21763            if (_shouldTrace)
 1764            {
 01765                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01766                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01767                tracingParameters.Add("appId", appId);
 01768                tracingParameters.Add("versionId", versionId);
 01769                tracingParameters.Add("skip", skip);
 01770                tracingParameters.Add("take", take);
 01771                tracingParameters.Add("cancellationToken", cancellationToken);
 01772                ServiceClientTracing.Enter(_invocationId, this, "ListPrebuilts", tracingParameters);
 1773            }
 1774            // Construct URL
 21775            var _baseUrl = Client.BaseUri;
 21776            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts";
 21777            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 21778            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 21779            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 21780            List<string> _queryParameters = new List<string>();
 21781            if (skip != null)
 1782            {
 21783                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 1784            }
 21785            if (take != null)
 1786            {
 21787                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 1788            }
 21789            if (_queryParameters.Count > 0)
 1790            {
 21791                _url += "?" + string.Join("&", _queryParameters);
 1792            }
 1793            // Create HTTP transport objects
 21794            var _httpRequest = new HttpRequestMessage();
 21795            HttpResponseMessage _httpResponse = null;
 21796            _httpRequest.Method = new HttpMethod("GET");
 21797            _httpRequest.RequestUri = new System.Uri(_url);
 1798            // Set Headers
 1799
 1800
 21801            if (customHeaders != null)
 1802            {
 01803                foreach(var _header in customHeaders)
 1804                {
 01805                    if (_httpRequest.Headers.Contains(_header.Key))
 1806                    {
 01807                        _httpRequest.Headers.Remove(_header.Key);
 1808                    }
 01809                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1810                }
 1811            }
 1812
 1813            // Serialize Request
 21814            string _requestContent = null;
 1815            // Set Credentials
 21816            if (Client.Credentials != null)
 1817            {
 21818                cancellationToken.ThrowIfCancellationRequested();
 21819                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1820            }
 1821            // Send Request
 21822            if (_shouldTrace)
 1823            {
 01824                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1825            }
 21826            cancellationToken.ThrowIfCancellationRequested();
 21827            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 21828            if (_shouldTrace)
 1829            {
 01830                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1831            }
 21832            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 21833            cancellationToken.ThrowIfCancellationRequested();
 21834            string _responseContent = null;
 21835            if ((int)_statusCode != 200)
 1836            {
 01837                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1838                try
 1839                {
 01840                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01841                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 01842                    if (_errorBody != null)
 1843                    {
 01844                        ex.Body = _errorBody;
 1845                    }
 01846                }
 01847                catch (JsonException)
 1848                {
 1849                    // Ignore the exception
 01850                }
 01851                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01852                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01853                if (_shouldTrace)
 1854                {
 01855                    ServiceClientTracing.Error(_invocationId, ex);
 1856                }
 01857                _httpRequest.Dispose();
 01858                if (_httpResponse != null)
 1859                {
 01860                    _httpResponse.Dispose();
 1861                }
 01862                throw ex;
 1863            }
 1864            // Create Result
 21865            var _result = new HttpOperationResponse<IList<PrebuiltEntityExtractor>>();
 21866            _result.Request = _httpRequest;
 21867            _result.Response = _httpResponse;
 1868            // Deserialize Response
 21869            if ((int)_statusCode == 200)
 1870            {
 21871                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1872                try
 1873                {
 21874                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<PrebuiltEntityExtractor>>(
 21875                }
 01876                catch (JsonException ex)
 1877                {
 01878                    _httpRequest.Dispose();
 01879                    if (_httpResponse != null)
 1880                    {
 01881                        _httpResponse.Dispose();
 1882                    }
 01883                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1884                }
 1885            }
 21886            if (_shouldTrace)
 1887            {
 01888                ServiceClientTracing.Exit(_invocationId, _result);
 1889            }
 21890            return _result;
 21891        }
 1892
 1893        /// <summary>
 1894        /// Gets all the available prebuilt entities in a version of the application.
 1895        /// </summary>
 1896        /// <param name='appId'>
 1897        /// The application ID.
 1898        /// </param>
 1899        /// <param name='versionId'>
 1900        /// The version ID.
 1901        /// </param>
 1902        /// <param name='customHeaders'>
 1903        /// Headers that will be added to request.
 1904        /// </param>
 1905        /// <param name='cancellationToken'>
 1906        /// The cancellation token.
 1907        /// </param>
 1908        /// <exception cref="ErrorResponseException">
 1909        /// Thrown when the operation returned an invalid status code
 1910        /// </exception>
 1911        /// <exception cref="SerializationException">
 1912        /// Thrown when unable to deserialize the response
 1913        /// </exception>
 1914        /// <exception cref="ValidationException">
 1915        /// Thrown when a required parameter is null
 1916        /// </exception>
 1917        /// <exception cref="System.ArgumentNullException">
 1918        /// Thrown when a required parameter is null
 1919        /// </exception>
 1920        /// <return>
 1921        /// A response object containing the response body and response headers.
 1922        /// </return>
 1923        public async Task<HttpOperationResponse<IList<AvailablePrebuiltEntityModel>>> ListPrebuiltEntitiesWithHttpMessag
 1924        {
 11925            if (Client.Endpoint == null)
 1926            {
 01927                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 1928            }
 11929            if (versionId == null)
 1930            {
 01931                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 1932            }
 1933            // Tracing
 11934            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 11935            string _invocationId = null;
 11936            if (_shouldTrace)
 1937            {
 01938                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01939                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01940                tracingParameters.Add("appId", appId);
 01941                tracingParameters.Add("versionId", versionId);
 01942                tracingParameters.Add("cancellationToken", cancellationToken);
 01943                ServiceClientTracing.Enter(_invocationId, this, "ListPrebuiltEntities", tracingParameters);
 1944            }
 1945            // Construct URL
 11946            var _baseUrl = Client.BaseUri;
 11947            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/listprebuilts
 11948            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 11949            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 11950            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 1951            // Create HTTP transport objects
 11952            var _httpRequest = new HttpRequestMessage();
 11953            HttpResponseMessage _httpResponse = null;
 11954            _httpRequest.Method = new HttpMethod("GET");
 11955            _httpRequest.RequestUri = new System.Uri(_url);
 1956            // Set Headers
 1957
 1958
 11959            if (customHeaders != null)
 1960            {
 01961                foreach(var _header in customHeaders)
 1962                {
 01963                    if (_httpRequest.Headers.Contains(_header.Key))
 1964                    {
 01965                        _httpRequest.Headers.Remove(_header.Key);
 1966                    }
 01967                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1968                }
 1969            }
 1970
 1971            // Serialize Request
 11972            string _requestContent = null;
 1973            // Set Credentials
 11974            if (Client.Credentials != null)
 1975            {
 11976                cancellationToken.ThrowIfCancellationRequested();
 11977                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1978            }
 1979            // Send Request
 11980            if (_shouldTrace)
 1981            {
 01982                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1983            }
 11984            cancellationToken.ThrowIfCancellationRequested();
 11985            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11986            if (_shouldTrace)
 1987            {
 01988                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1989            }
 11990            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 11991            cancellationToken.ThrowIfCancellationRequested();
 11992            string _responseContent = null;
 11993            if ((int)_statusCode != 200)
 1994            {
 01995                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 1996                try
 1997                {
 01998                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01999                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02000                    if (_errorBody != null)
 2001                    {
 02002                        ex.Body = _errorBody;
 2003                    }
 02004                }
 02005                catch (JsonException)
 2006                {
 2007                    // Ignore the exception
 02008                }
 02009                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02010                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02011                if (_shouldTrace)
 2012                {
 02013                    ServiceClientTracing.Error(_invocationId, ex);
 2014                }
 02015                _httpRequest.Dispose();
 02016                if (_httpResponse != null)
 2017                {
 02018                    _httpResponse.Dispose();
 2019                }
 02020                throw ex;
 2021            }
 2022            // Create Result
 12023            var _result = new HttpOperationResponse<IList<AvailablePrebuiltEntityModel>>();
 12024            _result.Request = _httpRequest;
 12025            _result.Response = _httpResponse;
 2026            // Deserialize Response
 12027            if ((int)_statusCode == 200)
 2028            {
 12029                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2030                try
 2031                {
 12032                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<AvailablePrebuiltEntityMod
 12033                }
 02034                catch (JsonException ex)
 2035                {
 02036                    _httpRequest.Dispose();
 02037                    if (_httpResponse != null)
 2038                    {
 02039                        _httpResponse.Dispose();
 2040                    }
 02041                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2042                }
 2043            }
 12044            if (_shouldTrace)
 2045            {
 02046                ServiceClientTracing.Exit(_invocationId, _result);
 2047            }
 12048            return _result;
 12049        }
 2050
 2051        /// <summary>
 2052        /// Gets information about all the intent and entity models in a version of the
 2053        /// application.
 2054        /// </summary>
 2055        /// <param name='appId'>
 2056        /// The application ID.
 2057        /// </param>
 2058        /// <param name='versionId'>
 2059        /// The version ID.
 2060        /// </param>
 2061        /// <param name='skip'>
 2062        /// The number of entries to skip. Default value is 0.
 2063        /// </param>
 2064        /// <param name='take'>
 2065        /// The number of entries to return. Maximum page size is 500. Default is 100.
 2066        /// </param>
 2067        /// <param name='customHeaders'>
 2068        /// Headers that will be added to request.
 2069        /// </param>
 2070        /// <param name='cancellationToken'>
 2071        /// The cancellation token.
 2072        /// </param>
 2073        /// <exception cref="ErrorResponseException">
 2074        /// Thrown when the operation returned an invalid status code
 2075        /// </exception>
 2076        /// <exception cref="SerializationException">
 2077        /// Thrown when unable to deserialize the response
 2078        /// </exception>
 2079        /// <exception cref="ValidationException">
 2080        /// Thrown when a required parameter is null
 2081        /// </exception>
 2082        /// <exception cref="System.ArgumentNullException">
 2083        /// Thrown when a required parameter is null
 2084        /// </exception>
 2085        /// <return>
 2086        /// A response object containing the response body and response headers.
 2087        /// </return>
 2088        public async Task<HttpOperationResponse<IList<ModelInfoResponse>>> ListModelsWithHttpMessagesAsync(System.Guid a
 2089        {
 02090            if (Client.Endpoint == null)
 2091            {
 02092                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2093            }
 02094            if (versionId == null)
 2095            {
 02096                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 2097            }
 02098            if (skip < 0)
 2099            {
 02100                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 2101            }
 02102            if (take > 500)
 2103            {
 02104                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 2105            }
 02106            if (take < 0)
 2107            {
 02108                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 2109            }
 2110            // Tracing
 02111            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02112            string _invocationId = null;
 02113            if (_shouldTrace)
 2114            {
 02115                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02116                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02117                tracingParameters.Add("appId", appId);
 02118                tracingParameters.Add("versionId", versionId);
 02119                tracingParameters.Add("skip", skip);
 02120                tracingParameters.Add("take", take);
 02121                tracingParameters.Add("cancellationToken", cancellationToken);
 02122                ServiceClientTracing.Enter(_invocationId, this, "ListModels", tracingParameters);
 2123            }
 2124            // Construct URL
 02125            var _baseUrl = Client.BaseUri;
 02126            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/models";
 02127            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 02128            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 02129            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 02130            List<string> _queryParameters = new List<string>();
 02131            if (skip != null)
 2132            {
 02133                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 2134            }
 02135            if (take != null)
 2136            {
 02137                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 2138            }
 02139            if (_queryParameters.Count > 0)
 2140            {
 02141                _url += "?" + string.Join("&", _queryParameters);
 2142            }
 2143            // Create HTTP transport objects
 02144            var _httpRequest = new HttpRequestMessage();
 02145            HttpResponseMessage _httpResponse = null;
 02146            _httpRequest.Method = new HttpMethod("GET");
 02147            _httpRequest.RequestUri = new System.Uri(_url);
 2148            // Set Headers
 2149
 2150
 02151            if (customHeaders != null)
 2152            {
 02153                foreach(var _header in customHeaders)
 2154                {
 02155                    if (_httpRequest.Headers.Contains(_header.Key))
 2156                    {
 02157                        _httpRequest.Headers.Remove(_header.Key);
 2158                    }
 02159                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2160                }
 2161            }
 2162
 2163            // Serialize Request
 02164            string _requestContent = null;
 2165            // Set Credentials
 02166            if (Client.Credentials != null)
 2167            {
 02168                cancellationToken.ThrowIfCancellationRequested();
 02169                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2170            }
 2171            // Send Request
 02172            if (_shouldTrace)
 2173            {
 02174                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2175            }
 02176            cancellationToken.ThrowIfCancellationRequested();
 02177            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02178            if (_shouldTrace)
 2179            {
 02180                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2181            }
 02182            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02183            cancellationToken.ThrowIfCancellationRequested();
 02184            string _responseContent = null;
 02185            if ((int)_statusCode != 200)
 2186            {
 02187                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2188                try
 2189                {
 02190                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02191                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02192                    if (_errorBody != null)
 2193                    {
 02194                        ex.Body = _errorBody;
 2195                    }
 02196                }
 02197                catch (JsonException)
 2198                {
 2199                    // Ignore the exception
 02200                }
 02201                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02202                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02203                if (_shouldTrace)
 2204                {
 02205                    ServiceClientTracing.Error(_invocationId, ex);
 2206                }
 02207                _httpRequest.Dispose();
 02208                if (_httpResponse != null)
 2209                {
 02210                    _httpResponse.Dispose();
 2211                }
 02212                throw ex;
 2213            }
 2214            // Create Result
 02215            var _result = new HttpOperationResponse<IList<ModelInfoResponse>>();
 02216            _result.Request = _httpRequest;
 02217            _result.Response = _httpResponse;
 2218            // Deserialize Response
 02219            if ((int)_statusCode == 200)
 2220            {
 02221                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2222                try
 2223                {
 02224                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ModelInfoResponse>>(_respo
 02225                }
 02226                catch (JsonException ex)
 2227                {
 02228                    _httpRequest.Dispose();
 02229                    if (_httpResponse != null)
 2230                    {
 02231                        _httpResponse.Dispose();
 2232                    }
 02233                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2234                }
 2235            }
 02236            if (_shouldTrace)
 2237            {
 02238                ServiceClientTracing.Exit(_invocationId, _result);
 2239            }
 02240            return _result;
 02241        }
 2242
 2243        /// <summary>
 2244        /// Gets the example utterances for the given intent or entity model in a
 2245        /// version of the application.
 2246        /// </summary>
 2247        /// <param name='appId'>
 2248        /// The application ID.
 2249        /// </param>
 2250        /// <param name='versionId'>
 2251        /// The version ID.
 2252        /// </param>
 2253        /// <param name='modelId'>
 2254        /// The ID (GUID) of the model.
 2255        /// </param>
 2256        /// <param name='skip'>
 2257        /// The number of entries to skip. Default value is 0.
 2258        /// </param>
 2259        /// <param name='take'>
 2260        /// The number of entries to return. Maximum page size is 500. Default is 100.
 2261        /// </param>
 2262        /// <param name='customHeaders'>
 2263        /// Headers that will be added to request.
 2264        /// </param>
 2265        /// <param name='cancellationToken'>
 2266        /// The cancellation token.
 2267        /// </param>
 2268        /// <exception cref="ErrorResponseException">
 2269        /// Thrown when the operation returned an invalid status code
 2270        /// </exception>
 2271        /// <exception cref="SerializationException">
 2272        /// Thrown when unable to deserialize the response
 2273        /// </exception>
 2274        /// <exception cref="ValidationException">
 2275        /// Thrown when a required parameter is null
 2276        /// </exception>
 2277        /// <exception cref="System.ArgumentNullException">
 2278        /// Thrown when a required parameter is null
 2279        /// </exception>
 2280        /// <return>
 2281        /// A response object containing the response body and response headers.
 2282        /// </return>
 2283        public async Task<HttpOperationResponse<IList<LabelTextObject>>> ExamplesMethodWithHttpMessagesAsync(System.Guid
 2284        {
 02285            if (Client.Endpoint == null)
 2286            {
 02287                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2288            }
 02289            if (versionId == null)
 2290            {
 02291                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 2292            }
 02293            if (modelId == null)
 2294            {
 02295                throw new ValidationException(ValidationRules.CannotBeNull, "modelId");
 2296            }
 02297            if (skip < 0)
 2298            {
 02299                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 2300            }
 02301            if (take > 500)
 2302            {
 02303                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 2304            }
 02305            if (take < 0)
 2306            {
 02307                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 2308            }
 2309            // Tracing
 02310            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 02311            string _invocationId = null;
 02312            if (_shouldTrace)
 2313            {
 02314                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02315                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02316                tracingParameters.Add("appId", appId);
 02317                tracingParameters.Add("versionId", versionId);
 02318                tracingParameters.Add("modelId", modelId);
 02319                tracingParameters.Add("skip", skip);
 02320                tracingParameters.Add("take", take);
 02321                tracingParameters.Add("cancellationToken", cancellationToken);
 02322                ServiceClientTracing.Enter(_invocationId, this, "ExamplesMethod", tracingParameters);
 2323            }
 2324            // Construct URL
 02325            var _baseUrl = Client.BaseUri;
 02326            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/models/{model
 02327            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 02328            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 02329            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 02330            _url = _url.Replace("{modelId}", System.Uri.EscapeDataString(modelId));
 02331            List<string> _queryParameters = new List<string>();
 02332            if (skip != null)
 2333            {
 02334                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 2335            }
 02336            if (take != null)
 2337            {
 02338                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 2339            }
 02340            if (_queryParameters.Count > 0)
 2341            {
 02342                _url += "?" + string.Join("&", _queryParameters);
 2343            }
 2344            // Create HTTP transport objects
 02345            var _httpRequest = new HttpRequestMessage();
 02346            HttpResponseMessage _httpResponse = null;
 02347            _httpRequest.Method = new HttpMethod("GET");
 02348            _httpRequest.RequestUri = new System.Uri(_url);
 2349            // Set Headers
 2350
 2351
 02352            if (customHeaders != null)
 2353            {
 02354                foreach(var _header in customHeaders)
 2355                {
 02356                    if (_httpRequest.Headers.Contains(_header.Key))
 2357                    {
 02358                        _httpRequest.Headers.Remove(_header.Key);
 2359                    }
 02360                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2361                }
 2362            }
 2363
 2364            // Serialize Request
 02365            string _requestContent = null;
 2366            // Set Credentials
 02367            if (Client.Credentials != null)
 2368            {
 02369                cancellationToken.ThrowIfCancellationRequested();
 02370                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2371            }
 2372            // Send Request
 02373            if (_shouldTrace)
 2374            {
 02375                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2376            }
 02377            cancellationToken.ThrowIfCancellationRequested();
 02378            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 02379            if (_shouldTrace)
 2380            {
 02381                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2382            }
 02383            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 02384            cancellationToken.ThrowIfCancellationRequested();
 02385            string _responseContent = null;
 02386            if ((int)_statusCode != 200)
 2387            {
 02388                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2389                try
 2390                {
 02391                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02392                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02393                    if (_errorBody != null)
 2394                    {
 02395                        ex.Body = _errorBody;
 2396                    }
 02397                }
 02398                catch (JsonException)
 2399                {
 2400                    // Ignore the exception
 02401                }
 02402                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02403                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02404                if (_shouldTrace)
 2405                {
 02406                    ServiceClientTracing.Error(_invocationId, ex);
 2407                }
 02408                _httpRequest.Dispose();
 02409                if (_httpResponse != null)
 2410                {
 02411                    _httpResponse.Dispose();
 2412                }
 02413                throw ex;
 2414            }
 2415            // Create Result
 02416            var _result = new HttpOperationResponse<IList<LabelTextObject>>();
 02417            _result.Request = _httpRequest;
 02418            _result.Response = _httpResponse;
 2419            // Deserialize Response
 02420            if ((int)_statusCode == 200)
 2421            {
 02422                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2423                try
 2424                {
 02425                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<LabelTextObject>>(_respons
 02426                }
 02427                catch (JsonException ex)
 2428                {
 02429                    _httpRequest.Dispose();
 02430                    if (_httpResponse != null)
 2431                    {
 02432                        _httpResponse.Dispose();
 2433                    }
 02434                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2435                }
 2436            }
 02437            if (_shouldTrace)
 2438            {
 02439                ServiceClientTracing.Exit(_invocationId, _result);
 2440            }
 02441            return _result;
 02442        }
 2443
 2444        /// <summary>
 2445        /// Gets information about the intent model in a version of the application.
 2446        /// </summary>
 2447        /// <param name='appId'>
 2448        /// The application ID.
 2449        /// </param>
 2450        /// <param name='versionId'>
 2451        /// The version ID.
 2452        /// </param>
 2453        /// <param name='intentId'>
 2454        /// The intent classifier ID.
 2455        /// </param>
 2456        /// <param name='customHeaders'>
 2457        /// Headers that will be added to request.
 2458        /// </param>
 2459        /// <param name='cancellationToken'>
 2460        /// The cancellation token.
 2461        /// </param>
 2462        /// <exception cref="ErrorResponseException">
 2463        /// Thrown when the operation returned an invalid status code
 2464        /// </exception>
 2465        /// <exception cref="SerializationException">
 2466        /// Thrown when unable to deserialize the response
 2467        /// </exception>
 2468        /// <exception cref="ValidationException">
 2469        /// Thrown when a required parameter is null
 2470        /// </exception>
 2471        /// <exception cref="System.ArgumentNullException">
 2472        /// Thrown when a required parameter is null
 2473        /// </exception>
 2474        /// <return>
 2475        /// A response object containing the response body and response headers.
 2476        /// </return>
 2477        public async Task<HttpOperationResponse<IntentClassifier>> GetIntentWithHttpMessagesAsync(System.Guid appId, str
 2478        {
 32479            if (Client.Endpoint == null)
 2480            {
 02481                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2482            }
 32483            if (versionId == null)
 2484            {
 02485                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 2486            }
 2487            // Tracing
 32488            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 32489            string _invocationId = null;
 32490            if (_shouldTrace)
 2491            {
 02492                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02493                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02494                tracingParameters.Add("appId", appId);
 02495                tracingParameters.Add("versionId", versionId);
 02496                tracingParameters.Add("intentId", intentId);
 02497                tracingParameters.Add("cancellationToken", cancellationToken);
 02498                ServiceClientTracing.Enter(_invocationId, this, "GetIntent", tracingParameters);
 2499            }
 2500            // Construct URL
 32501            var _baseUrl = Client.BaseUri;
 32502            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte
 32503            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 32504            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 32505            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 32506            _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 2507            // Create HTTP transport objects
 32508            var _httpRequest = new HttpRequestMessage();
 32509            HttpResponseMessage _httpResponse = null;
 32510            _httpRequest.Method = new HttpMethod("GET");
 32511            _httpRequest.RequestUri = new System.Uri(_url);
 2512            // Set Headers
 2513
 2514
 32515            if (customHeaders != null)
 2516            {
 02517                foreach(var _header in customHeaders)
 2518                {
 02519                    if (_httpRequest.Headers.Contains(_header.Key))
 2520                    {
 02521                        _httpRequest.Headers.Remove(_header.Key);
 2522                    }
 02523                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2524                }
 2525            }
 2526
 2527            // Serialize Request
 32528            string _requestContent = null;
 2529            // Set Credentials
 32530            if (Client.Credentials != null)
 2531            {
 32532                cancellationToken.ThrowIfCancellationRequested();
 32533                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2534            }
 2535            // Send Request
 32536            if (_shouldTrace)
 2537            {
 02538                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2539            }
 32540            cancellationToken.ThrowIfCancellationRequested();
 32541            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 32542            if (_shouldTrace)
 2543            {
 02544                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2545            }
 32546            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 32547            cancellationToken.ThrowIfCancellationRequested();
 32548            string _responseContent = null;
 32549            if ((int)_statusCode != 200)
 2550            {
 02551                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2552                try
 2553                {
 02554                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02555                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02556                    if (_errorBody != null)
 2557                    {
 02558                        ex.Body = _errorBody;
 2559                    }
 02560                }
 02561                catch (JsonException)
 2562                {
 2563                    // Ignore the exception
 02564                }
 02565                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02566                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02567                if (_shouldTrace)
 2568                {
 02569                    ServiceClientTracing.Error(_invocationId, ex);
 2570                }
 02571                _httpRequest.Dispose();
 02572                if (_httpResponse != null)
 2573                {
 02574                    _httpResponse.Dispose();
 2575                }
 02576                throw ex;
 2577            }
 2578            // Create Result
 32579            var _result = new HttpOperationResponse<IntentClassifier>();
 32580            _result.Request = _httpRequest;
 32581            _result.Response = _httpResponse;
 2582            // Deserialize Response
 32583            if ((int)_statusCode == 200)
 2584            {
 32585                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2586                try
 2587                {
 32588                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IntentClassifier>(_responseConte
 32589                }
 02590                catch (JsonException ex)
 2591                {
 02592                    _httpRequest.Dispose();
 02593                    if (_httpResponse != null)
 2594                    {
 02595                        _httpResponse.Dispose();
 2596                    }
 02597                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2598                }
 2599            }
 32600            if (_shouldTrace)
 2601            {
 02602                ServiceClientTracing.Exit(_invocationId, _result);
 2603            }
 32604            return _result;
 32605        }
 2606
 2607        /// <summary>
 2608        /// Updates the name of an intent in a version of the application.
 2609        /// </summary>
 2610        /// <param name='appId'>
 2611        /// The application ID.
 2612        /// </param>
 2613        /// <param name='versionId'>
 2614        /// The version ID.
 2615        /// </param>
 2616        /// <param name='intentId'>
 2617        /// The intent classifier ID.
 2618        /// </param>
 2619        /// <param name='modelUpdateObject'>
 2620        /// A model object containing the new intent name.
 2621        /// </param>
 2622        /// <param name='customHeaders'>
 2623        /// Headers that will be added to request.
 2624        /// </param>
 2625        /// <param name='cancellationToken'>
 2626        /// The cancellation token.
 2627        /// </param>
 2628        /// <exception cref="ErrorResponseException">
 2629        /// Thrown when the operation returned an invalid status code
 2630        /// </exception>
 2631        /// <exception cref="SerializationException">
 2632        /// Thrown when unable to deserialize the response
 2633        /// </exception>
 2634        /// <exception cref="ValidationException">
 2635        /// Thrown when a required parameter is null
 2636        /// </exception>
 2637        /// <exception cref="System.ArgumentNullException">
 2638        /// Thrown when a required parameter is null
 2639        /// </exception>
 2640        /// <return>
 2641        /// A response object containing the response body and response headers.
 2642        /// </return>
 2643        public async Task<HttpOperationResponse<OperationStatus>> UpdateIntentWithHttpMessagesAsync(System.Guid appId, s
 2644        {
 12645            if (Client.Endpoint == null)
 2646            {
 02647                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2648            }
 12649            if (versionId == null)
 2650            {
 02651                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 2652            }
 12653            if (modelUpdateObject == null)
 2654            {
 02655                throw new ValidationException(ValidationRules.CannotBeNull, "modelUpdateObject");
 2656            }
 2657            // Tracing
 12658            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 12659            string _invocationId = null;
 12660            if (_shouldTrace)
 2661            {
 02662                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02663                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02664                tracingParameters.Add("appId", appId);
 02665                tracingParameters.Add("versionId", versionId);
 02666                tracingParameters.Add("intentId", intentId);
 02667                tracingParameters.Add("modelUpdateObject", modelUpdateObject);
 02668                tracingParameters.Add("cancellationToken", cancellationToken);
 02669                ServiceClientTracing.Enter(_invocationId, this, "UpdateIntent", tracingParameters);
 2670            }
 2671            // Construct URL
 12672            var _baseUrl = Client.BaseUri;
 12673            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte
 12674            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 12675            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 12676            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 12677            _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 2678            // Create HTTP transport objects
 12679            var _httpRequest = new HttpRequestMessage();
 12680            HttpResponseMessage _httpResponse = null;
 12681            _httpRequest.Method = new HttpMethod("PUT");
 12682            _httpRequest.RequestUri = new System.Uri(_url);
 2683            // Set Headers
 2684
 2685
 12686            if (customHeaders != null)
 2687            {
 02688                foreach(var _header in customHeaders)
 2689                {
 02690                    if (_httpRequest.Headers.Contains(_header.Key))
 2691                    {
 02692                        _httpRequest.Headers.Remove(_header.Key);
 2693                    }
 02694                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2695                }
 2696            }
 2697
 2698            // Serialize Request
 12699            string _requestContent = null;
 12700            if(modelUpdateObject != null)
 2701            {
 12702                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(modelUpdateObject, Client.Serializa
 12703                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 12704                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 2705            }
 2706            // Set Credentials
 12707            if (Client.Credentials != null)
 2708            {
 12709                cancellationToken.ThrowIfCancellationRequested();
 12710                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2711            }
 2712            // Send Request
 12713            if (_shouldTrace)
 2714            {
 02715                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2716            }
 12717            cancellationToken.ThrowIfCancellationRequested();
 12718            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12719            if (_shouldTrace)
 2720            {
 02721                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2722            }
 12723            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 12724            cancellationToken.ThrowIfCancellationRequested();
 12725            string _responseContent = null;
 12726            if ((int)_statusCode != 200)
 2727            {
 02728                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2729                try
 2730                {
 02731                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02732                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02733                    if (_errorBody != null)
 2734                    {
 02735                        ex.Body = _errorBody;
 2736                    }
 02737                }
 02738                catch (JsonException)
 2739                {
 2740                    // Ignore the exception
 02741                }
 02742                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02743                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02744                if (_shouldTrace)
 2745                {
 02746                    ServiceClientTracing.Error(_invocationId, ex);
 2747                }
 02748                _httpRequest.Dispose();
 02749                if (_httpResponse != null)
 2750                {
 02751                    _httpResponse.Dispose();
 2752                }
 02753                throw ex;
 2754            }
 2755            // Create Result
 12756            var _result = new HttpOperationResponse<OperationStatus>();
 12757            _result.Request = _httpRequest;
 12758            _result.Response = _httpResponse;
 2759            // Deserialize Response
 12760            if ((int)_statusCode == 200)
 2761            {
 12762                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2763                try
 2764                {
 12765                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 12766                }
 02767                catch (JsonException ex)
 2768                {
 02769                    _httpRequest.Dispose();
 02770                    if (_httpResponse != null)
 2771                    {
 02772                        _httpResponse.Dispose();
 2773                    }
 02774                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2775                }
 2776            }
 12777            if (_shouldTrace)
 2778            {
 02779                ServiceClientTracing.Exit(_invocationId, _result);
 2780            }
 12781            return _result;
 12782        }
 2783
 2784        /// <summary>
 2785        /// Deletes an intent from a version of the application.
 2786        /// </summary>
 2787        /// <param name='appId'>
 2788        /// The application ID.
 2789        /// </param>
 2790        /// <param name='versionId'>
 2791        /// The version ID.
 2792        /// </param>
 2793        /// <param name='intentId'>
 2794        /// The intent classifier ID.
 2795        /// </param>
 2796        /// <param name='deleteUtterances'>
 2797        /// If true, deletes the intent's example utterances. If false, moves the
 2798        /// example utterances to the None intent. The default value is false.
 2799        /// </param>
 2800        /// <param name='customHeaders'>
 2801        /// Headers that will be added to request.
 2802        /// </param>
 2803        /// <param name='cancellationToken'>
 2804        /// The cancellation token.
 2805        /// </param>
 2806        /// <exception cref="ErrorResponseException">
 2807        /// Thrown when the operation returned an invalid status code
 2808        /// </exception>
 2809        /// <exception cref="SerializationException">
 2810        /// Thrown when unable to deserialize the response
 2811        /// </exception>
 2812        /// <exception cref="ValidationException">
 2813        /// Thrown when a required parameter is null
 2814        /// </exception>
 2815        /// <exception cref="System.ArgumentNullException">
 2816        /// Thrown when a required parameter is null
 2817        /// </exception>
 2818        /// <return>
 2819        /// A response object containing the response body and response headers.
 2820        /// </return>
 2821        public async Task<HttpOperationResponse<OperationStatus>> DeleteIntentWithHttpMessagesAsync(System.Guid appId, s
 2822        {
 92823            if (Client.Endpoint == null)
 2824            {
 02825                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2826            }
 92827            if (versionId == null)
 2828            {
 02829                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 2830            }
 2831            // Tracing
 92832            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 92833            string _invocationId = null;
 92834            if (_shouldTrace)
 2835            {
 02836                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02837                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02838                tracingParameters.Add("appId", appId);
 02839                tracingParameters.Add("versionId", versionId);
 02840                tracingParameters.Add("intentId", intentId);
 02841                tracingParameters.Add("deleteUtterances", deleteUtterances);
 02842                tracingParameters.Add("cancellationToken", cancellationToken);
 02843                ServiceClientTracing.Enter(_invocationId, this, "DeleteIntent", tracingParameters);
 2844            }
 2845            // Construct URL
 92846            var _baseUrl = Client.BaseUri;
 92847            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte
 92848            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 92849            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 92850            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 92851            _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 92852            List<string> _queryParameters = new List<string>();
 92853            if (deleteUtterances != null)
 2854            {
 92855                _queryParameters.Add(string.Format("deleteUtterances={0}", System.Uri.EscapeDataString(Rest.Serializatio
 2856            }
 92857            if (_queryParameters.Count > 0)
 2858            {
 92859                _url += "?" + string.Join("&", _queryParameters);
 2860            }
 2861            // Create HTTP transport objects
 92862            var _httpRequest = new HttpRequestMessage();
 92863            HttpResponseMessage _httpResponse = null;
 92864            _httpRequest.Method = new HttpMethod("DELETE");
 92865            _httpRequest.RequestUri = new System.Uri(_url);
 2866            // Set Headers
 2867
 2868
 92869            if (customHeaders != null)
 2870            {
 02871                foreach(var _header in customHeaders)
 2872                {
 02873                    if (_httpRequest.Headers.Contains(_header.Key))
 2874                    {
 02875                        _httpRequest.Headers.Remove(_header.Key);
 2876                    }
 02877                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2878                }
 2879            }
 2880
 2881            // Serialize Request
 92882            string _requestContent = null;
 2883            // Set Credentials
 92884            if (Client.Credentials != null)
 2885            {
 92886                cancellationToken.ThrowIfCancellationRequested();
 92887                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2888            }
 2889            // Send Request
 92890            if (_shouldTrace)
 2891            {
 02892                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2893            }
 92894            cancellationToken.ThrowIfCancellationRequested();
 92895            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 92896            if (_shouldTrace)
 2897            {
 02898                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2899            }
 92900            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 92901            cancellationToken.ThrowIfCancellationRequested();
 92902            string _responseContent = null;
 92903            if ((int)_statusCode != 200)
 2904            {
 02905                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 2906                try
 2907                {
 02908                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02909                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 02910                    if (_errorBody != null)
 2911                    {
 02912                        ex.Body = _errorBody;
 2913                    }
 02914                }
 02915                catch (JsonException)
 2916                {
 2917                    // Ignore the exception
 02918                }
 02919                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02920                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02921                if (_shouldTrace)
 2922                {
 02923                    ServiceClientTracing.Error(_invocationId, ex);
 2924                }
 02925                _httpRequest.Dispose();
 02926                if (_httpResponse != null)
 2927                {
 02928                    _httpResponse.Dispose();
 2929                }
 02930                throw ex;
 2931            }
 2932            // Create Result
 92933            var _result = new HttpOperationResponse<OperationStatus>();
 92934            _result.Request = _httpRequest;
 92935            _result.Response = _httpResponse;
 2936            // Deserialize Response
 92937            if ((int)_statusCode == 200)
 2938            {
 92939                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2940                try
 2941                {
 92942                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 92943                }
 02944                catch (JsonException ex)
 2945                {
 02946                    _httpRequest.Dispose();
 02947                    if (_httpResponse != null)
 2948                    {
 02949                        _httpResponse.Dispose();
 2950                    }
 02951                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2952                }
 2953            }
 92954            if (_shouldTrace)
 2955            {
 02956                ServiceClientTracing.Exit(_invocationId, _result);
 2957            }
 92958            return _result;
 92959        }
 2960
 2961        /// <summary>
 2962        /// Gets information about an entity model in a version of the application.
 2963        /// </summary>
 2964        /// <param name='appId'>
 2965        /// The application ID.
 2966        /// </param>
 2967        /// <param name='versionId'>
 2968        /// The version ID.
 2969        /// </param>
 2970        /// <param name='entityId'>
 2971        /// The entity extractor ID.
 2972        /// </param>
 2973        /// <param name='customHeaders'>
 2974        /// Headers that will be added to request.
 2975        /// </param>
 2976        /// <param name='cancellationToken'>
 2977        /// The cancellation token.
 2978        /// </param>
 2979        /// <exception cref="ErrorResponseException">
 2980        /// Thrown when the operation returned an invalid status code
 2981        /// </exception>
 2982        /// <exception cref="SerializationException">
 2983        /// Thrown when unable to deserialize the response
 2984        /// </exception>
 2985        /// <exception cref="ValidationException">
 2986        /// Thrown when a required parameter is null
 2987        /// </exception>
 2988        /// <exception cref="System.ArgumentNullException">
 2989        /// Thrown when a required parameter is null
 2990        /// </exception>
 2991        /// <return>
 2992        /// A response object containing the response body and response headers.
 2993        /// </return>
 2994        public async Task<HttpOperationResponse<NDepthEntityExtractor>> GetEntityWithHttpMessagesAsync(System.Guid appId
 2995        {
 102996            if (Client.Endpoint == null)
 2997            {
 02998                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 2999            }
 103000            if (versionId == null)
 3001            {
 03002                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 3003            }
 3004            // Tracing
 103005            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 103006            string _invocationId = null;
 103007            if (_shouldTrace)
 3008            {
 03009                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03010                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03011                tracingParameters.Add("appId", appId);
 03012                tracingParameters.Add("versionId", versionId);
 03013                tracingParameters.Add("entityId", entityId);
 03014                tracingParameters.Add("cancellationToken", cancellationToken);
 03015                ServiceClientTracing.Enter(_invocationId, this, "GetEntity", tracingParameters);
 3016            }
 3017            // Construct URL
 103018            var _baseUrl = Client.BaseUri;
 103019            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 103020            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 103021            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 103022            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 103023            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 3024            // Create HTTP transport objects
 103025            var _httpRequest = new HttpRequestMessage();
 103026            HttpResponseMessage _httpResponse = null;
 103027            _httpRequest.Method = new HttpMethod("GET");
 103028            _httpRequest.RequestUri = new System.Uri(_url);
 3029            // Set Headers
 3030
 3031
 103032            if (customHeaders != null)
 3033            {
 03034                foreach(var _header in customHeaders)
 3035                {
 03036                    if (_httpRequest.Headers.Contains(_header.Key))
 3037                    {
 03038                        _httpRequest.Headers.Remove(_header.Key);
 3039                    }
 03040                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3041                }
 3042            }
 3043
 3044            // Serialize Request
 103045            string _requestContent = null;
 3046            // Set Credentials
 103047            if (Client.Credentials != null)
 3048            {
 103049                cancellationToken.ThrowIfCancellationRequested();
 103050                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3051            }
 3052            // Send Request
 103053            if (_shouldTrace)
 3054            {
 03055                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3056            }
 103057            cancellationToken.ThrowIfCancellationRequested();
 103058            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 103059            if (_shouldTrace)
 3060            {
 03061                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3062            }
 103063            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 103064            cancellationToken.ThrowIfCancellationRequested();
 103065            string _responseContent = null;
 103066            if ((int)_statusCode != 200)
 3067            {
 03068                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3069                try
 3070                {
 03071                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03072                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03073                    if (_errorBody != null)
 3074                    {
 03075                        ex.Body = _errorBody;
 3076                    }
 03077                }
 03078                catch (JsonException)
 3079                {
 3080                    // Ignore the exception
 03081                }
 03082                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03083                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03084                if (_shouldTrace)
 3085                {
 03086                    ServiceClientTracing.Error(_invocationId, ex);
 3087                }
 03088                _httpRequest.Dispose();
 03089                if (_httpResponse != null)
 3090                {
 03091                    _httpResponse.Dispose();
 3092                }
 03093                throw ex;
 3094            }
 3095            // Create Result
 103096            var _result = new HttpOperationResponse<NDepthEntityExtractor>();
 103097            _result.Request = _httpRequest;
 103098            _result.Response = _httpResponse;
 3099            // Deserialize Response
 103100            if ((int)_statusCode == 200)
 3101            {
 103102                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3103                try
 3104                {
 103105                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<NDepthEntityExtractor>(_response
 103106                }
 03107                catch (JsonException ex)
 3108                {
 03109                    _httpRequest.Dispose();
 03110                    if (_httpResponse != null)
 3111                    {
 03112                        _httpResponse.Dispose();
 3113                    }
 03114                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3115                }
 3116            }
 103117            if (_shouldTrace)
 3118            {
 03119                ServiceClientTracing.Exit(_invocationId, _result);
 3120            }
 103121            return _result;
 103122        }
 3123
 3124        /// <summary>
 3125        /// Deletes an entity or a child from a version of the application.
 3126        /// </summary>
 3127        /// <param name='appId'>
 3128        /// The application ID.
 3129        /// </param>
 3130        /// <param name='versionId'>
 3131        /// The version ID.
 3132        /// </param>
 3133        /// <param name='entityId'>
 3134        /// The entity extractor or the child entity extractor ID.
 3135        /// </param>
 3136        /// <param name='customHeaders'>
 3137        /// Headers that will be added to request.
 3138        /// </param>
 3139        /// <param name='cancellationToken'>
 3140        /// The cancellation token.
 3141        /// </param>
 3142        /// <exception cref="ErrorResponseException">
 3143        /// Thrown when the operation returned an invalid status code
 3144        /// </exception>
 3145        /// <exception cref="SerializationException">
 3146        /// Thrown when unable to deserialize the response
 3147        /// </exception>
 3148        /// <exception cref="ValidationException">
 3149        /// Thrown when a required parameter is null
 3150        /// </exception>
 3151        /// <exception cref="System.ArgumentNullException">
 3152        /// Thrown when a required parameter is null
 3153        /// </exception>
 3154        /// <return>
 3155        /// A response object containing the response body and response headers.
 3156        /// </return>
 3157        public async Task<HttpOperationResponse<OperationStatus>> DeleteEntityWithHttpMessagesAsync(System.Guid appId, s
 3158        {
 353159            if (Client.Endpoint == null)
 3160            {
 03161                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3162            }
 353163            if (versionId == null)
 3164            {
 03165                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 3166            }
 3167            // Tracing
 353168            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 353169            string _invocationId = null;
 353170            if (_shouldTrace)
 3171            {
 03172                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03173                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03174                tracingParameters.Add("appId", appId);
 03175                tracingParameters.Add("versionId", versionId);
 03176                tracingParameters.Add("entityId", entityId);
 03177                tracingParameters.Add("cancellationToken", cancellationToken);
 03178                ServiceClientTracing.Enter(_invocationId, this, "DeleteEntity", tracingParameters);
 3179            }
 3180            // Construct URL
 353181            var _baseUrl = Client.BaseUri;
 353182            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 353183            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 353184            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 353185            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 353186            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 3187            // Create HTTP transport objects
 353188            var _httpRequest = new HttpRequestMessage();
 353189            HttpResponseMessage _httpResponse = null;
 353190            _httpRequest.Method = new HttpMethod("DELETE");
 353191            _httpRequest.RequestUri = new System.Uri(_url);
 3192            // Set Headers
 3193
 3194
 353195            if (customHeaders != null)
 3196            {
 03197                foreach(var _header in customHeaders)
 3198                {
 03199                    if (_httpRequest.Headers.Contains(_header.Key))
 3200                    {
 03201                        _httpRequest.Headers.Remove(_header.Key);
 3202                    }
 03203                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3204                }
 3205            }
 3206
 3207            // Serialize Request
 353208            string _requestContent = null;
 3209            // Set Credentials
 353210            if (Client.Credentials != null)
 3211            {
 353212                cancellationToken.ThrowIfCancellationRequested();
 353213                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3214            }
 3215            // Send Request
 353216            if (_shouldTrace)
 3217            {
 03218                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3219            }
 353220            cancellationToken.ThrowIfCancellationRequested();
 353221            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 353222            if (_shouldTrace)
 3223            {
 03224                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3225            }
 353226            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 353227            cancellationToken.ThrowIfCancellationRequested();
 353228            string _responseContent = null;
 353229            if ((int)_statusCode != 200)
 3230            {
 03231                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3232                try
 3233                {
 03234                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03235                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03236                    if (_errorBody != null)
 3237                    {
 03238                        ex.Body = _errorBody;
 3239                    }
 03240                }
 03241                catch (JsonException)
 3242                {
 3243                    // Ignore the exception
 03244                }
 03245                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03246                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03247                if (_shouldTrace)
 3248                {
 03249                    ServiceClientTracing.Error(_invocationId, ex);
 3250                }
 03251                _httpRequest.Dispose();
 03252                if (_httpResponse != null)
 3253                {
 03254                    _httpResponse.Dispose();
 3255                }
 03256                throw ex;
 3257            }
 3258            // Create Result
 353259            var _result = new HttpOperationResponse<OperationStatus>();
 353260            _result.Request = _httpRequest;
 353261            _result.Response = _httpResponse;
 3262            // Deserialize Response
 353263            if ((int)_statusCode == 200)
 3264            {
 353265                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3266                try
 3267                {
 353268                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 353269                }
 03270                catch (JsonException ex)
 3271                {
 03272                    _httpRequest.Dispose();
 03273                    if (_httpResponse != null)
 3274                    {
 03275                        _httpResponse.Dispose();
 3276                    }
 03277                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3278                }
 3279            }
 353280            if (_shouldTrace)
 3281            {
 03282                ServiceClientTracing.Exit(_invocationId, _result);
 3283            }
 353284            return _result;
 353285        }
 3286
 3287        /// <summary>
 3288        /// Updates the name of an entity extractor or the name and instanceOf model of
 3289        /// a child entity extractor.
 3290        /// </summary>
 3291        /// <param name='appId'>
 3292        /// The application ID.
 3293        /// </param>
 3294        /// <param name='versionId'>
 3295        /// The version ID.
 3296        /// </param>
 3297        /// <param name='entityId'>
 3298        /// The entity extractor or the child entity extractor ID.
 3299        /// </param>
 3300        /// <param name='entityModelUpdateObject'>
 3301        /// A model object containing the name new entity extractor or the name and
 3302        /// instance of model of a child entity extractor
 3303        /// </param>
 3304        /// <param name='customHeaders'>
 3305        /// Headers that will be added to request.
 3306        /// </param>
 3307        /// <param name='cancellationToken'>
 3308        /// The cancellation token.
 3309        /// </param>
 3310        /// <exception cref="ErrorResponseException">
 3311        /// Thrown when the operation returned an invalid status code
 3312        /// </exception>
 3313        /// <exception cref="SerializationException">
 3314        /// Thrown when unable to deserialize the response
 3315        /// </exception>
 3316        /// <exception cref="ValidationException">
 3317        /// Thrown when a required parameter is null
 3318        /// </exception>
 3319        /// <exception cref="System.ArgumentNullException">
 3320        /// Thrown when a required parameter is null
 3321        /// </exception>
 3322        /// <return>
 3323        /// A response object containing the response body and response headers.
 3324        /// </return>
 3325        public async Task<HttpOperationResponse<OperationStatus>> UpdateEntityChildWithHttpMessagesAsync(System.Guid app
 3326        {
 33327            if (Client.Endpoint == null)
 3328            {
 03329                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3330            }
 33331            if (versionId == null)
 3332            {
 03333                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 3334            }
 33335            if (entityModelUpdateObject == null)
 3336            {
 03337                throw new ValidationException(ValidationRules.CannotBeNull, "entityModelUpdateObject");
 3338            }
 3339            // Tracing
 33340            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 33341            string _invocationId = null;
 33342            if (_shouldTrace)
 3343            {
 03344                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03345                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03346                tracingParameters.Add("appId", appId);
 03347                tracingParameters.Add("versionId", versionId);
 03348                tracingParameters.Add("entityId", entityId);
 03349                tracingParameters.Add("entityModelUpdateObject", entityModelUpdateObject);
 03350                tracingParameters.Add("cancellationToken", cancellationToken);
 03351                ServiceClientTracing.Enter(_invocationId, this, "UpdateEntityChild", tracingParameters);
 3352            }
 3353            // Construct URL
 33354            var _baseUrl = Client.BaseUri;
 33355            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 33356            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 33357            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 33358            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 33359            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 3360            // Create HTTP transport objects
 33361            var _httpRequest = new HttpRequestMessage();
 33362            HttpResponseMessage _httpResponse = null;
 33363            _httpRequest.Method = new HttpMethod("PATCH");
 33364            _httpRequest.RequestUri = new System.Uri(_url);
 3365            // Set Headers
 3366
 3367
 33368            if (customHeaders != null)
 3369            {
 03370                foreach(var _header in customHeaders)
 3371                {
 03372                    if (_httpRequest.Headers.Contains(_header.Key))
 3373                    {
 03374                        _httpRequest.Headers.Remove(_header.Key);
 3375                    }
 03376                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3377                }
 3378            }
 3379
 3380            // Serialize Request
 33381            string _requestContent = null;
 33382            if(entityModelUpdateObject != null)
 3383            {
 33384                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityModelUpdateObject, Client.Ser
 33385                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 33386                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 3387            }
 3388            // Set Credentials
 33389            if (Client.Credentials != null)
 3390            {
 33391                cancellationToken.ThrowIfCancellationRequested();
 33392                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3393            }
 3394            // Send Request
 33395            if (_shouldTrace)
 3396            {
 03397                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3398            }
 33399            cancellationToken.ThrowIfCancellationRequested();
 33400            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 33401            if (_shouldTrace)
 3402            {
 03403                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3404            }
 33405            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 33406            cancellationToken.ThrowIfCancellationRequested();
 33407            string _responseContent = null;
 33408            if ((int)_statusCode != 200)
 3409            {
 03410                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3411                try
 3412                {
 03413                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03414                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03415                    if (_errorBody != null)
 3416                    {
 03417                        ex.Body = _errorBody;
 3418                    }
 03419                }
 03420                catch (JsonException)
 3421                {
 3422                    // Ignore the exception
 03423                }
 03424                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03425                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03426                if (_shouldTrace)
 3427                {
 03428                    ServiceClientTracing.Error(_invocationId, ex);
 3429                }
 03430                _httpRequest.Dispose();
 03431                if (_httpResponse != null)
 3432                {
 03433                    _httpResponse.Dispose();
 3434                }
 03435                throw ex;
 3436            }
 3437            // Create Result
 33438            var _result = new HttpOperationResponse<OperationStatus>();
 33439            _result.Request = _httpRequest;
 33440            _result.Response = _httpResponse;
 3441            // Deserialize Response
 33442            if ((int)_statusCode == 200)
 3443            {
 33444                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3445                try
 3446                {
 33447                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 33448                }
 03449                catch (JsonException ex)
 3450                {
 03451                    _httpRequest.Dispose();
 03452                    if (_httpResponse != null)
 3453                    {
 03454                        _httpResponse.Dispose();
 3455                    }
 03456                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3457                }
 3458            }
 33459            if (_shouldTrace)
 3460            {
 03461                ServiceClientTracing.Exit(_invocationId, _result);
 3462            }
 33463            return _result;
 33464        }
 3465
 3466        /// <summary>
 3467        /// Gets the information of the features used by the intent in a version of the
 3468        /// application.
 3469        /// </summary>
 3470        /// <param name='appId'>
 3471        /// The application ID.
 3472        /// </param>
 3473        /// <param name='versionId'>
 3474        /// The version ID.
 3475        /// </param>
 3476        /// <param name='intentId'>
 3477        /// The intent classifier ID.
 3478        /// </param>
 3479        /// <param name='customHeaders'>
 3480        /// Headers that will be added to request.
 3481        /// </param>
 3482        /// <param name='cancellationToken'>
 3483        /// The cancellation token.
 3484        /// </param>
 3485        /// <exception cref="ErrorResponseException">
 3486        /// Thrown when the operation returned an invalid status code
 3487        /// </exception>
 3488        /// <exception cref="SerializationException">
 3489        /// Thrown when unable to deserialize the response
 3490        /// </exception>
 3491        /// <exception cref="ValidationException">
 3492        /// Thrown when a required parameter is null
 3493        /// </exception>
 3494        /// <exception cref="System.ArgumentNullException">
 3495        /// Thrown when a required parameter is null
 3496        /// </exception>
 3497        /// <return>
 3498        /// A response object containing the response body and response headers.
 3499        /// </return>
 3500        public async Task<HttpOperationResponse<IList<ModelFeatureInformation>>> GetIntentFeaturesWithHttpMessagesAsync(
 3501        {
 13502            if (Client.Endpoint == null)
 3503            {
 03504                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3505            }
 13506            if (versionId == null)
 3507            {
 03508                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 3509            }
 3510            // Tracing
 13511            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 13512            string _invocationId = null;
 13513            if (_shouldTrace)
 3514            {
 03515                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03516                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03517                tracingParameters.Add("appId", appId);
 03518                tracingParameters.Add("versionId", versionId);
 03519                tracingParameters.Add("intentId", intentId);
 03520                tracingParameters.Add("cancellationToken", cancellationToken);
 03521                ServiceClientTracing.Enter(_invocationId, this, "GetIntentFeatures", tracingParameters);
 3522            }
 3523            // Construct URL
 13524            var _baseUrl = Client.BaseUri;
 13525            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte
 13526            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 13527            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 13528            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 13529            _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 3530            // Create HTTP transport objects
 13531            var _httpRequest = new HttpRequestMessage();
 13532            HttpResponseMessage _httpResponse = null;
 13533            _httpRequest.Method = new HttpMethod("GET");
 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;
 3552            // Set Credentials
 13553            if (Client.Credentials != null)
 3554            {
 13555                cancellationToken.ThrowIfCancellationRequested();
 13556                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3557            }
 3558            // Send Request
 13559            if (_shouldTrace)
 3560            {
 03561                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3562            }
 13563            cancellationToken.ThrowIfCancellationRequested();
 13564            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13565            if (_shouldTrace)
 3566            {
 03567                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3568            }
 13569            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 13570            cancellationToken.ThrowIfCancellationRequested();
 13571            string _responseContent = null;
 13572            if ((int)_statusCode != 200)
 3573            {
 03574                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3575                try
 3576                {
 03577                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03578                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03579                    if (_errorBody != null)
 3580                    {
 03581                        ex.Body = _errorBody;
 3582                    }
 03583                }
 03584                catch (JsonException)
 3585                {
 3586                    // Ignore the exception
 03587                }
 03588                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03589                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03590                if (_shouldTrace)
 3591                {
 03592                    ServiceClientTracing.Error(_invocationId, ex);
 3593                }
 03594                _httpRequest.Dispose();
 03595                if (_httpResponse != null)
 3596                {
 03597                    _httpResponse.Dispose();
 3598                }
 03599                throw ex;
 3600            }
 3601            // Create Result
 13602            var _result = new HttpOperationResponse<IList<ModelFeatureInformation>>();
 13603            _result.Request = _httpRequest;
 13604            _result.Response = _httpResponse;
 3605            // Deserialize Response
 13606            if ((int)_statusCode == 200)
 3607            {
 13608                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3609                try
 3610                {
 13611                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ModelFeatureInformation>>(
 13612                }
 03613                catch (JsonException ex)
 3614                {
 03615                    _httpRequest.Dispose();
 03616                    if (_httpResponse != null)
 3617                    {
 03618                        _httpResponse.Dispose();
 3619                    }
 03620                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3621                }
 3622            }
 13623            if (_shouldTrace)
 3624            {
 03625                ServiceClientTracing.Exit(_invocationId, _result);
 3626            }
 13627            return _result;
 13628        }
 3629
 3630        /// <summary>
 3631        /// Updates the information of the features used by the intent in a version of
 3632        /// the application.
 3633        /// </summary>
 3634        /// <param name='appId'>
 3635        /// The application ID.
 3636        /// </param>
 3637        /// <param name='versionId'>
 3638        /// The version ID.
 3639        /// </param>
 3640        /// <param name='intentId'>
 3641        /// The intent classifier ID.
 3642        /// </param>
 3643        /// <param name='featureRelationsUpdateObject'>
 3644        /// A list of feature information objects containing the new feature relations.
 3645        /// </param>
 3646        /// <param name='customHeaders'>
 3647        /// Headers that will be added to request.
 3648        /// </param>
 3649        /// <param name='cancellationToken'>
 3650        /// The cancellation token.
 3651        /// </param>
 3652        /// <exception cref="ErrorResponseException">
 3653        /// Thrown when the operation returned an invalid status code
 3654        /// </exception>
 3655        /// <exception cref="SerializationException">
 3656        /// Thrown when unable to deserialize the response
 3657        /// </exception>
 3658        /// <exception cref="ValidationException">
 3659        /// Thrown when a required parameter is null
 3660        /// </exception>
 3661        /// <exception cref="System.ArgumentNullException">
 3662        /// Thrown when a required parameter is null
 3663        /// </exception>
 3664        /// <return>
 3665        /// A response object containing the response body and response headers.
 3666        /// </return>
 3667        public async Task<HttpOperationResponse<OperationStatus>> ReplaceIntentFeaturesWithHttpMessagesAsync(System.Guid
 3668        {
 03669            if (Client.Endpoint == null)
 3670            {
 03671                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3672            }
 03673            if (versionId == null)
 3674            {
 03675                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 3676            }
 03677            if (featureRelationsUpdateObject == null)
 3678            {
 03679                throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationsUpdateObject");
 3680            }
 3681            // Tracing
 03682            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 03683            string _invocationId = null;
 03684            if (_shouldTrace)
 3685            {
 03686                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03687                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03688                tracingParameters.Add("appId", appId);
 03689                tracingParameters.Add("versionId", versionId);
 03690                tracingParameters.Add("intentId", intentId);
 03691                tracingParameters.Add("featureRelationsUpdateObject", featureRelationsUpdateObject);
 03692                tracingParameters.Add("cancellationToken", cancellationToken);
 03693                ServiceClientTracing.Enter(_invocationId, this, "ReplaceIntentFeatures", tracingParameters);
 3694            }
 3695            // Construct URL
 03696            var _baseUrl = Client.BaseUri;
 03697            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte
 03698            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 03699            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 03700            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 03701            _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 3702            // Create HTTP transport objects
 03703            var _httpRequest = new HttpRequestMessage();
 03704            HttpResponseMessage _httpResponse = null;
 03705            _httpRequest.Method = new HttpMethod("PUT");
 03706            _httpRequest.RequestUri = new System.Uri(_url);
 3707            // Set Headers
 3708
 3709
 03710            if (customHeaders != null)
 3711            {
 03712                foreach(var _header in customHeaders)
 3713                {
 03714                    if (_httpRequest.Headers.Contains(_header.Key))
 3715                    {
 03716                        _httpRequest.Headers.Remove(_header.Key);
 3717                    }
 03718                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3719                }
 3720            }
 3721
 3722            // Serialize Request
 03723            string _requestContent = null;
 03724            if(featureRelationsUpdateObject != null)
 3725            {
 03726                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationsUpdateObject, Clien
 03727                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 03728                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 3729            }
 3730            // Set Credentials
 03731            if (Client.Credentials != null)
 3732            {
 03733                cancellationToken.ThrowIfCancellationRequested();
 03734                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3735            }
 3736            // Send Request
 03737            if (_shouldTrace)
 3738            {
 03739                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3740            }
 03741            cancellationToken.ThrowIfCancellationRequested();
 03742            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 03743            if (_shouldTrace)
 3744            {
 03745                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3746            }
 03747            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 03748            cancellationToken.ThrowIfCancellationRequested();
 03749            string _responseContent = null;
 03750            if ((int)_statusCode != 200)
 3751            {
 03752                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3753                try
 3754                {
 03755                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03756                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03757                    if (_errorBody != null)
 3758                    {
 03759                        ex.Body = _errorBody;
 3760                    }
 03761                }
 03762                catch (JsonException)
 3763                {
 3764                    // Ignore the exception
 03765                }
 03766                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03767                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03768                if (_shouldTrace)
 3769                {
 03770                    ServiceClientTracing.Error(_invocationId, ex);
 3771                }
 03772                _httpRequest.Dispose();
 03773                if (_httpResponse != null)
 3774                {
 03775                    _httpResponse.Dispose();
 3776                }
 03777                throw ex;
 3778            }
 3779            // Create Result
 03780            var _result = new HttpOperationResponse<OperationStatus>();
 03781            _result.Request = _httpRequest;
 03782            _result.Response = _httpResponse;
 3783            // Deserialize Response
 03784            if ((int)_statusCode == 200)
 3785            {
 03786                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3787                try
 3788                {
 03789                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 03790                }
 03791                catch (JsonException ex)
 3792                {
 03793                    _httpRequest.Dispose();
 03794                    if (_httpResponse != null)
 3795                    {
 03796                        _httpResponse.Dispose();
 3797                    }
 03798                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3799                }
 3800            }
 03801            if (_shouldTrace)
 3802            {
 03803                ServiceClientTracing.Exit(_invocationId, _result);
 3804            }
 03805            return _result;
 03806        }
 3807
 3808        /// <summary>
 3809        /// Deletes a relation from the feature relations used by the intent in a
 3810        /// version of the application.
 3811        /// </summary>
 3812        /// <param name='appId'>
 3813        /// The application ID.
 3814        /// </param>
 3815        /// <param name='versionId'>
 3816        /// The version ID.
 3817        /// </param>
 3818        /// <param name='intentId'>
 3819        /// The intent classifier ID.
 3820        /// </param>
 3821        /// <param name='featureRelationDeleteObject'>
 3822        /// A feature information object containing the feature relation to delete.
 3823        /// </param>
 3824        /// <param name='customHeaders'>
 3825        /// Headers that will be added to request.
 3826        /// </param>
 3827        /// <param name='cancellationToken'>
 3828        /// The cancellation token.
 3829        /// </param>
 3830        /// <exception cref="ErrorResponseException">
 3831        /// Thrown when the operation returned an invalid status code
 3832        /// </exception>
 3833        /// <exception cref="SerializationException">
 3834        /// Thrown when unable to deserialize the response
 3835        /// </exception>
 3836        /// <exception cref="ValidationException">
 3837        /// Thrown when a required parameter is null
 3838        /// </exception>
 3839        /// <exception cref="System.ArgumentNullException">
 3840        /// Thrown when a required parameter is null
 3841        /// </exception>
 3842        /// <return>
 3843        /// A response object containing the response body and response headers.
 3844        /// </return>
 3845        public async Task<HttpOperationResponse<OperationStatus>> DeleteIntentFeatureWithHttpMessagesAsync(System.Guid a
 3846        {
 13847            if (Client.Endpoint == null)
 3848            {
 03849                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 3850            }
 13851            if (versionId == null)
 3852            {
 03853                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 3854            }
 13855            if (featureRelationDeleteObject == null)
 3856            {
 03857                throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationDeleteObject");
 3858            }
 3859            // Tracing
 13860            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 13861            string _invocationId = null;
 13862            if (_shouldTrace)
 3863            {
 03864                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03865                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03866                tracingParameters.Add("appId", appId);
 03867                tracingParameters.Add("versionId", versionId);
 03868                tracingParameters.Add("intentId", intentId);
 03869                tracingParameters.Add("featureRelationDeleteObject", featureRelationDeleteObject);
 03870                tracingParameters.Add("cancellationToken", cancellationToken);
 03871                ServiceClientTracing.Enter(_invocationId, this, "DeleteIntentFeature", tracingParameters);
 3872            }
 3873            // Construct URL
 13874            var _baseUrl = Client.BaseUri;
 13875            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte
 13876            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 13877            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 13878            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 13879            _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 3880            // Create HTTP transport objects
 13881            var _httpRequest = new HttpRequestMessage();
 13882            HttpResponseMessage _httpResponse = null;
 13883            _httpRequest.Method = new HttpMethod("DELETE");
 13884            _httpRequest.RequestUri = new System.Uri(_url);
 3885            // Set Headers
 3886
 3887
 13888            if (customHeaders != null)
 3889            {
 03890                foreach(var _header in customHeaders)
 3891                {
 03892                    if (_httpRequest.Headers.Contains(_header.Key))
 3893                    {
 03894                        _httpRequest.Headers.Remove(_header.Key);
 3895                    }
 03896                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3897                }
 3898            }
 3899
 3900            // Serialize Request
 13901            string _requestContent = null;
 13902            if(featureRelationDeleteObject != null)
 3903            {
 13904                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationDeleteObject, Client
 13905                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 13906                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 3907            }
 3908            // Set Credentials
 13909            if (Client.Credentials != null)
 3910            {
 13911                cancellationToken.ThrowIfCancellationRequested();
 13912                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3913            }
 3914            // Send Request
 13915            if (_shouldTrace)
 3916            {
 03917                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3918            }
 13919            cancellationToken.ThrowIfCancellationRequested();
 13920            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13921            if (_shouldTrace)
 3922            {
 03923                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3924            }
 13925            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 13926            cancellationToken.ThrowIfCancellationRequested();
 13927            string _responseContent = null;
 13928            if ((int)_statusCode != 200)
 3929            {
 03930                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 3931                try
 3932                {
 03933                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03934                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 03935                    if (_errorBody != null)
 3936                    {
 03937                        ex.Body = _errorBody;
 3938                    }
 03939                }
 03940                catch (JsonException)
 3941                {
 3942                    // Ignore the exception
 03943                }
 03944                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03945                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03946                if (_shouldTrace)
 3947                {
 03948                    ServiceClientTracing.Error(_invocationId, ex);
 3949                }
 03950                _httpRequest.Dispose();
 03951                if (_httpResponse != null)
 3952                {
 03953                    _httpResponse.Dispose();
 3954                }
 03955                throw ex;
 3956            }
 3957            // Create Result
 13958            var _result = new HttpOperationResponse<OperationStatus>();
 13959            _result.Request = _httpRequest;
 13960            _result.Response = _httpResponse;
 3961            // Deserialize Response
 13962            if ((int)_statusCode == 200)
 3963            {
 13964                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3965                try
 3966                {
 13967                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 13968                }
 03969                catch (JsonException ex)
 3970                {
 03971                    _httpRequest.Dispose();
 03972                    if (_httpResponse != null)
 3973                    {
 03974                        _httpResponse.Dispose();
 3975                    }
 03976                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3977                }
 3978            }
 13979            if (_shouldTrace)
 3980            {
 03981                ServiceClientTracing.Exit(_invocationId, _result);
 3982            }
 13983            return _result;
 13984        }
 3985
 3986        /// <summary>
 3987        /// Gets the information of the features used by the entity in a version of the
 3988        /// application.
 3989        /// </summary>
 3990        /// <param name='appId'>
 3991        /// The application ID.
 3992        /// </param>
 3993        /// <param name='versionId'>
 3994        /// The version ID.
 3995        /// </param>
 3996        /// <param name='entityId'>
 3997        /// The entity extractor ID.
 3998        /// </param>
 3999        /// <param name='customHeaders'>
 4000        /// Headers that will be added to request.
 4001        /// </param>
 4002        /// <param name='cancellationToken'>
 4003        /// The cancellation token.
 4004        /// </param>
 4005        /// <exception cref="ErrorResponseException">
 4006        /// Thrown when the operation returned an invalid status code
 4007        /// </exception>
 4008        /// <exception cref="SerializationException">
 4009        /// Thrown when unable to deserialize the response
 4010        /// </exception>
 4011        /// <exception cref="ValidationException">
 4012        /// Thrown when a required parameter is null
 4013        /// </exception>
 4014        /// <exception cref="System.ArgumentNullException">
 4015        /// Thrown when a required parameter is null
 4016        /// </exception>
 4017        /// <return>
 4018        /// A response object containing the response body and response headers.
 4019        /// </return>
 4020        public async Task<HttpOperationResponse<IList<ModelFeatureInformation>>> GetEntityFeaturesWithHttpMessagesAsync(
 4021        {
 24022            if (Client.Endpoint == null)
 4023            {
 04024                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 4025            }
 24026            if (versionId == null)
 4027            {
 04028                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 4029            }
 4030            // Tracing
 24031            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 24032            string _invocationId = null;
 24033            if (_shouldTrace)
 4034            {
 04035                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04036                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04037                tracingParameters.Add("appId", appId);
 04038                tracingParameters.Add("versionId", versionId);
 04039                tracingParameters.Add("entityId", entityId);
 04040                tracingParameters.Add("cancellationToken", cancellationToken);
 04041                ServiceClientTracing.Enter(_invocationId, this, "GetEntityFeatures", tracingParameters);
 4042            }
 4043            // Construct URL
 24044            var _baseUrl = Client.BaseUri;
 24045            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 24046            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 24047            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 24048            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 24049            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 4050            // Create HTTP transport objects
 24051            var _httpRequest = new HttpRequestMessage();
 24052            HttpResponseMessage _httpResponse = null;
 24053            _httpRequest.Method = new HttpMethod("GET");
 24054            _httpRequest.RequestUri = new System.Uri(_url);
 4055            // Set Headers
 4056
 4057
 24058            if (customHeaders != null)
 4059            {
 04060                foreach(var _header in customHeaders)
 4061                {
 04062                    if (_httpRequest.Headers.Contains(_header.Key))
 4063                    {
 04064                        _httpRequest.Headers.Remove(_header.Key);
 4065                    }
 04066                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4067                }
 4068            }
 4069
 4070            // Serialize Request
 24071            string _requestContent = null;
 4072            // Set Credentials
 24073            if (Client.Credentials != null)
 4074            {
 24075                cancellationToken.ThrowIfCancellationRequested();
 24076                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4077            }
 4078            // Send Request
 24079            if (_shouldTrace)
 4080            {
 04081                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4082            }
 24083            cancellationToken.ThrowIfCancellationRequested();
 24084            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 24085            if (_shouldTrace)
 4086            {
 04087                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4088            }
 24089            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 24090            cancellationToken.ThrowIfCancellationRequested();
 24091            string _responseContent = null;
 24092            if ((int)_statusCode != 200)
 4093            {
 04094                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 4095                try
 4096                {
 04097                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04098                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 04099                    if (_errorBody != null)
 4100                    {
 04101                        ex.Body = _errorBody;
 4102                    }
 04103                }
 04104                catch (JsonException)
 4105                {
 4106                    // Ignore the exception
 04107                }
 04108                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04109                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04110                if (_shouldTrace)
 4111                {
 04112                    ServiceClientTracing.Error(_invocationId, ex);
 4113                }
 04114                _httpRequest.Dispose();
 04115                if (_httpResponse != null)
 4116                {
 04117                    _httpResponse.Dispose();
 4118                }
 04119                throw ex;
 4120            }
 4121            // Create Result
 24122            var _result = new HttpOperationResponse<IList<ModelFeatureInformation>>();
 24123            _result.Request = _httpRequest;
 24124            _result.Response = _httpResponse;
 4125            // Deserialize Response
 24126            if ((int)_statusCode == 200)
 4127            {
 24128                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4129                try
 4130                {
 24131                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ModelFeatureInformation>>(
 24132                }
 04133                catch (JsonException ex)
 4134                {
 04135                    _httpRequest.Dispose();
 04136                    if (_httpResponse != null)
 4137                    {
 04138                        _httpResponse.Dispose();
 4139                    }
 04140                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4141                }
 4142            }
 24143            if (_shouldTrace)
 4144            {
 04145                ServiceClientTracing.Exit(_invocationId, _result);
 4146            }
 24147            return _result;
 24148        }
 4149
 4150        /// <summary>
 4151        /// Updates the information of the features used by the entity in a version of
 4152        /// the application.
 4153        /// </summary>
 4154        /// <param name='appId'>
 4155        /// The application ID.
 4156        /// </param>
 4157        /// <param name='versionId'>
 4158        /// The version ID.
 4159        /// </param>
 4160        /// <param name='entityId'>
 4161        /// The entity extractor ID.
 4162        /// </param>
 4163        /// <param name='featureRelationsUpdateObject'>
 4164        /// A list of feature information objects containing the new feature relations.
 4165        /// </param>
 4166        /// <param name='customHeaders'>
 4167        /// Headers that will be added to request.
 4168        /// </param>
 4169        /// <param name='cancellationToken'>
 4170        /// The cancellation token.
 4171        /// </param>
 4172        /// <exception cref="ErrorResponseException">
 4173        /// Thrown when the operation returned an invalid status code
 4174        /// </exception>
 4175        /// <exception cref="SerializationException">
 4176        /// Thrown when unable to deserialize the response
 4177        /// </exception>
 4178        /// <exception cref="ValidationException">
 4179        /// Thrown when a required parameter is null
 4180        /// </exception>
 4181        /// <exception cref="System.ArgumentNullException">
 4182        /// Thrown when a required parameter is null
 4183        /// </exception>
 4184        /// <return>
 4185        /// A response object containing the response body and response headers.
 4186        /// </return>
 4187        public async Task<HttpOperationResponse<OperationStatus>> ReplaceEntityFeaturesWithHttpMessagesAsync(System.Guid
 4188        {
 04189            if (Client.Endpoint == null)
 4190            {
 04191                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 4192            }
 04193            if (versionId == null)
 4194            {
 04195                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 4196            }
 04197            if (featureRelationsUpdateObject == null)
 4198            {
 04199                throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationsUpdateObject");
 4200            }
 4201            // Tracing
 04202            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 04203            string _invocationId = null;
 04204            if (_shouldTrace)
 4205            {
 04206                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04207                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04208                tracingParameters.Add("appId", appId);
 04209                tracingParameters.Add("versionId", versionId);
 04210                tracingParameters.Add("entityId", entityId);
 04211                tracingParameters.Add("featureRelationsUpdateObject", featureRelationsUpdateObject);
 04212                tracingParameters.Add("cancellationToken", cancellationToken);
 04213                ServiceClientTracing.Enter(_invocationId, this, "ReplaceEntityFeatures", tracingParameters);
 4214            }
 4215            // Construct URL
 04216            var _baseUrl = Client.BaseUri;
 04217            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 04218            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 04219            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 04220            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 04221            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 4222            // Create HTTP transport objects
 04223            var _httpRequest = new HttpRequestMessage();
 04224            HttpResponseMessage _httpResponse = null;
 04225            _httpRequest.Method = new HttpMethod("PUT");
 04226            _httpRequest.RequestUri = new System.Uri(_url);
 4227            // Set Headers
 4228
 4229
 04230            if (customHeaders != null)
 4231            {
 04232                foreach(var _header in customHeaders)
 4233                {
 04234                    if (_httpRequest.Headers.Contains(_header.Key))
 4235                    {
 04236                        _httpRequest.Headers.Remove(_header.Key);
 4237                    }
 04238                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4239                }
 4240            }
 4241
 4242            // Serialize Request
 04243            string _requestContent = null;
 04244            if(featureRelationsUpdateObject != null)
 4245            {
 04246                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationsUpdateObject, Clien
 04247                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 04248                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 4249            }
 4250            // Set Credentials
 04251            if (Client.Credentials != null)
 4252            {
 04253                cancellationToken.ThrowIfCancellationRequested();
 04254                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4255            }
 4256            // Send Request
 04257            if (_shouldTrace)
 4258            {
 04259                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4260            }
 04261            cancellationToken.ThrowIfCancellationRequested();
 04262            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 04263            if (_shouldTrace)
 4264            {
 04265                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4266            }
 04267            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 04268            cancellationToken.ThrowIfCancellationRequested();
 04269            string _responseContent = null;
 04270            if ((int)_statusCode != 200)
 4271            {
 04272                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 4273                try
 4274                {
 04275                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04276                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 04277                    if (_errorBody != null)
 4278                    {
 04279                        ex.Body = _errorBody;
 4280                    }
 04281                }
 04282                catch (JsonException)
 4283                {
 4284                    // Ignore the exception
 04285                }
 04286                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04287                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04288                if (_shouldTrace)
 4289                {
 04290                    ServiceClientTracing.Error(_invocationId, ex);
 4291                }
 04292                _httpRequest.Dispose();
 04293                if (_httpResponse != null)
 4294                {
 04295                    _httpResponse.Dispose();
 4296                }
 04297                throw ex;
 4298            }
 4299            // Create Result
 04300            var _result = new HttpOperationResponse<OperationStatus>();
 04301            _result.Request = _httpRequest;
 04302            _result.Response = _httpResponse;
 4303            // Deserialize Response
 04304            if ((int)_statusCode == 200)
 4305            {
 04306                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4307                try
 4308                {
 04309                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 04310                }
 04311                catch (JsonException ex)
 4312                {
 04313                    _httpRequest.Dispose();
 04314                    if (_httpResponse != null)
 4315                    {
 04316                        _httpResponse.Dispose();
 4317                    }
 04318                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4319                }
 4320            }
 04321            if (_shouldTrace)
 4322            {
 04323                ServiceClientTracing.Exit(_invocationId, _result);
 4324            }
 04325            return _result;
 04326        }
 4327
 4328        /// <summary>
 4329        /// Deletes a relation from the feature relations used by the entity in a
 4330        /// version of the application.
 4331        /// </summary>
 4332        /// <param name='appId'>
 4333        /// The application ID.
 4334        /// </param>
 4335        /// <param name='versionId'>
 4336        /// The version ID.
 4337        /// </param>
 4338        /// <param name='entityId'>
 4339        /// The entity extractor ID.
 4340        /// </param>
 4341        /// <param name='featureRelationDeleteObject'>
 4342        /// A feature information object containing the feature relation to delete.
 4343        /// </param>
 4344        /// <param name='customHeaders'>
 4345        /// Headers that will be added to request.
 4346        /// </param>
 4347        /// <param name='cancellationToken'>
 4348        /// The cancellation token.
 4349        /// </param>
 4350        /// <exception cref="ErrorResponseException">
 4351        /// Thrown when the operation returned an invalid status code
 4352        /// </exception>
 4353        /// <exception cref="SerializationException">
 4354        /// Thrown when unable to deserialize the response
 4355        /// </exception>
 4356        /// <exception cref="ValidationException">
 4357        /// Thrown when a required parameter is null
 4358        /// </exception>
 4359        /// <exception cref="System.ArgumentNullException">
 4360        /// Thrown when a required parameter is null
 4361        /// </exception>
 4362        /// <return>
 4363        /// A response object containing the response body and response headers.
 4364        /// </return>
 4365        public async Task<HttpOperationResponse<OperationStatus>> DeleteEntityFeatureWithHttpMessagesAsync(System.Guid a
 4366        {
 14367            if (Client.Endpoint == null)
 4368            {
 04369                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 4370            }
 14371            if (versionId == null)
 4372            {
 04373                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 4374            }
 14375            if (featureRelationDeleteObject == null)
 4376            {
 04377                throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationDeleteObject");
 4378            }
 4379            // Tracing
 14380            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 14381            string _invocationId = null;
 14382            if (_shouldTrace)
 4383            {
 04384                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04385                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04386                tracingParameters.Add("appId", appId);
 04387                tracingParameters.Add("versionId", versionId);
 04388                tracingParameters.Add("entityId", entityId);
 04389                tracingParameters.Add("featureRelationDeleteObject", featureRelationDeleteObject);
 04390                tracingParameters.Add("cancellationToken", cancellationToken);
 04391                ServiceClientTracing.Enter(_invocationId, this, "DeleteEntityFeature", tracingParameters);
 4392            }
 4393            // Construct URL
 14394            var _baseUrl = Client.BaseUri;
 14395            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 14396            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 14397            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 14398            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 14399            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 4400            // Create HTTP transport objects
 14401            var _httpRequest = new HttpRequestMessage();
 14402            HttpResponseMessage _httpResponse = null;
 14403            _httpRequest.Method = new HttpMethod("DELETE");
 14404            _httpRequest.RequestUri = new System.Uri(_url);
 4405            // Set Headers
 4406
 4407
 14408            if (customHeaders != null)
 4409            {
 04410                foreach(var _header in customHeaders)
 4411                {
 04412                    if (_httpRequest.Headers.Contains(_header.Key))
 4413                    {
 04414                        _httpRequest.Headers.Remove(_header.Key);
 4415                    }
 04416                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4417                }
 4418            }
 4419
 4420            // Serialize Request
 14421            string _requestContent = null;
 14422            if(featureRelationDeleteObject != null)
 4423            {
 14424                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationDeleteObject, Client
 14425                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 14426                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 4427            }
 4428            // Set Credentials
 14429            if (Client.Credentials != null)
 4430            {
 14431                cancellationToken.ThrowIfCancellationRequested();
 14432                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4433            }
 4434            // Send Request
 14435            if (_shouldTrace)
 4436            {
 04437                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4438            }
 14439            cancellationToken.ThrowIfCancellationRequested();
 14440            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 14441            if (_shouldTrace)
 4442            {
 04443                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4444            }
 14445            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 14446            cancellationToken.ThrowIfCancellationRequested();
 14447            string _responseContent = null;
 14448            if ((int)_statusCode != 200)
 4449            {
 04450                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 4451                try
 4452                {
 04453                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04454                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 04455                    if (_errorBody != null)
 4456                    {
 04457                        ex.Body = _errorBody;
 4458                    }
 04459                }
 04460                catch (JsonException)
 4461                {
 4462                    // Ignore the exception
 04463                }
 04464                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04465                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04466                if (_shouldTrace)
 4467                {
 04468                    ServiceClientTracing.Error(_invocationId, ex);
 4469                }
 04470                _httpRequest.Dispose();
 04471                if (_httpResponse != null)
 4472                {
 04473                    _httpResponse.Dispose();
 4474                }
 04475                throw ex;
 4476            }
 4477            // Create Result
 14478            var _result = new HttpOperationResponse<OperationStatus>();
 14479            _result.Request = _httpRequest;
 14480            _result.Response = _httpResponse;
 4481            // Deserialize Response
 14482            if ((int)_statusCode == 200)
 4483            {
 14484                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4485                try
 4486                {
 14487                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 14488                }
 04489                catch (JsonException ex)
 4490                {
 04491                    _httpRequest.Dispose();
 04492                    if (_httpResponse != null)
 4493                    {
 04494                        _httpResponse.Dispose();
 4495                    }
 04496                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4497                }
 4498            }
 14499            if (_shouldTrace)
 4500            {
 04501                ServiceClientTracing.Exit(_invocationId, _result);
 4502            }
 14503            return _result;
 14504        }
 4505
 4506        /// <summary>
 4507        /// Gets information about a hierarchical entity in a version of the
 4508        /// application.
 4509        /// </summary>
 4510        /// <param name='appId'>
 4511        /// The application ID.
 4512        /// </param>
 4513        /// <param name='versionId'>
 4514        /// The version ID.
 4515        /// </param>
 4516        /// <param name='hEntityId'>
 4517        /// The hierarchical entity extractor ID.
 4518        /// </param>
 4519        /// <param name='customHeaders'>
 4520        /// Headers that will be added to request.
 4521        /// </param>
 4522        /// <param name='cancellationToken'>
 4523        /// The cancellation token.
 4524        /// </param>
 4525        /// <exception cref="ErrorResponseException">
 4526        /// Thrown when the operation returned an invalid status code
 4527        /// </exception>
 4528        /// <exception cref="SerializationException">
 4529        /// Thrown when unable to deserialize the response
 4530        /// </exception>
 4531        /// <exception cref="ValidationException">
 4532        /// Thrown when a required parameter is null
 4533        /// </exception>
 4534        /// <exception cref="System.ArgumentNullException">
 4535        /// Thrown when a required parameter is null
 4536        /// </exception>
 4537        /// <return>
 4538        /// A response object containing the response body and response headers.
 4539        /// </return>
 4540        public async Task<HttpOperationResponse<HierarchicalEntityExtractor>> GetHierarchicalEntityWithHttpMessagesAsync
 4541        {
 04542            if (Client.Endpoint == null)
 4543            {
 04544                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 4545            }
 04546            if (versionId == null)
 4547            {
 04548                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 4549            }
 4550            // Tracing
 04551            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 04552            string _invocationId = null;
 04553            if (_shouldTrace)
 4554            {
 04555                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04556                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04557                tracingParameters.Add("appId", appId);
 04558                tracingParameters.Add("versionId", versionId);
 04559                tracingParameters.Add("hEntityId", hEntityId);
 04560                tracingParameters.Add("cancellationToken", cancellationToken);
 04561                ServiceClientTracing.Enter(_invocationId, this, "GetHierarchicalEntity", tracingParameters);
 4562            }
 4563            // Construct URL
 04564            var _baseUrl = Client.BaseUri;
 04565            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 04566            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 04567            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 04568            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 04569            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 4570            // Create HTTP transport objects
 04571            var _httpRequest = new HttpRequestMessage();
 04572            HttpResponseMessage _httpResponse = null;
 04573            _httpRequest.Method = new HttpMethod("GET");
 04574            _httpRequest.RequestUri = new System.Uri(_url);
 4575            // Set Headers
 4576
 4577
 04578            if (customHeaders != null)
 4579            {
 04580                foreach(var _header in customHeaders)
 4581                {
 04582                    if (_httpRequest.Headers.Contains(_header.Key))
 4583                    {
 04584                        _httpRequest.Headers.Remove(_header.Key);
 4585                    }
 04586                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4587                }
 4588            }
 4589
 4590            // Serialize Request
 04591            string _requestContent = null;
 4592            // Set Credentials
 04593            if (Client.Credentials != null)
 4594            {
 04595                cancellationToken.ThrowIfCancellationRequested();
 04596                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4597            }
 4598            // Send Request
 04599            if (_shouldTrace)
 4600            {
 04601                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4602            }
 04603            cancellationToken.ThrowIfCancellationRequested();
 04604            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 04605            if (_shouldTrace)
 4606            {
 04607                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4608            }
 04609            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 04610            cancellationToken.ThrowIfCancellationRequested();
 04611            string _responseContent = null;
 04612            if ((int)_statusCode != 200)
 4613            {
 04614                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 4615                try
 4616                {
 04617                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04618                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 04619                    if (_errorBody != null)
 4620                    {
 04621                        ex.Body = _errorBody;
 4622                    }
 04623                }
 04624                catch (JsonException)
 4625                {
 4626                    // Ignore the exception
 04627                }
 04628                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04629                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04630                if (_shouldTrace)
 4631                {
 04632                    ServiceClientTracing.Error(_invocationId, ex);
 4633                }
 04634                _httpRequest.Dispose();
 04635                if (_httpResponse != null)
 4636                {
 04637                    _httpResponse.Dispose();
 4638                }
 04639                throw ex;
 4640            }
 4641            // Create Result
 04642            var _result = new HttpOperationResponse<HierarchicalEntityExtractor>();
 04643            _result.Request = _httpRequest;
 04644            _result.Response = _httpResponse;
 4645            // Deserialize Response
 04646            if ((int)_statusCode == 200)
 4647            {
 04648                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4649                try
 4650                {
 04651                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<HierarchicalEntityExtractor>(_re
 04652                }
 04653                catch (JsonException ex)
 4654                {
 04655                    _httpRequest.Dispose();
 04656                    if (_httpResponse != null)
 4657                    {
 04658                        _httpResponse.Dispose();
 4659                    }
 04660                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4661                }
 4662            }
 04663            if (_shouldTrace)
 4664            {
 04665                ServiceClientTracing.Exit(_invocationId, _result);
 4666            }
 04667            return _result;
 04668        }
 4669
 4670        /// <summary>
 4671        /// Updates the name of a hierarchical entity model in a version of the
 4672        /// application.
 4673        /// </summary>
 4674        /// <param name='appId'>
 4675        /// The application ID.
 4676        /// </param>
 4677        /// <param name='versionId'>
 4678        /// The version ID.
 4679        /// </param>
 4680        /// <param name='hEntityId'>
 4681        /// The hierarchical entity extractor ID.
 4682        /// </param>
 4683        /// <param name='modelUpdateObject'>
 4684        /// Model containing names of the hierarchical entity.
 4685        /// </param>
 4686        /// <param name='customHeaders'>
 4687        /// Headers that will be added to request.
 4688        /// </param>
 4689        /// <param name='cancellationToken'>
 4690        /// The cancellation token.
 4691        /// </param>
 4692        /// <exception cref="ErrorResponseException">
 4693        /// Thrown when the operation returned an invalid status code
 4694        /// </exception>
 4695        /// <exception cref="SerializationException">
 4696        /// Thrown when unable to deserialize the response
 4697        /// </exception>
 4698        /// <exception cref="ValidationException">
 4699        /// Thrown when a required parameter is null
 4700        /// </exception>
 4701        /// <exception cref="System.ArgumentNullException">
 4702        /// Thrown when a required parameter is null
 4703        /// </exception>
 4704        /// <return>
 4705        /// A response object containing the response body and response headers.
 4706        /// </return>
 4707        public async Task<HttpOperationResponse<OperationStatus>> UpdateHierarchicalEntityWithHttpMessagesAsync(System.G
 4708        {
 04709            if (Client.Endpoint == null)
 4710            {
 04711                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 4712            }
 04713            if (versionId == null)
 4714            {
 04715                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 4716            }
 04717            if (modelUpdateObject == null)
 4718            {
 04719                throw new ValidationException(ValidationRules.CannotBeNull, "modelUpdateObject");
 4720            }
 4721            // Tracing
 04722            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 04723            string _invocationId = null;
 04724            if (_shouldTrace)
 4725            {
 04726                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04727                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04728                tracingParameters.Add("appId", appId);
 04729                tracingParameters.Add("versionId", versionId);
 04730                tracingParameters.Add("hEntityId", hEntityId);
 04731                tracingParameters.Add("modelUpdateObject", modelUpdateObject);
 04732                tracingParameters.Add("cancellationToken", cancellationToken);
 04733                ServiceClientTracing.Enter(_invocationId, this, "UpdateHierarchicalEntity", tracingParameters);
 4734            }
 4735            // Construct URL
 04736            var _baseUrl = Client.BaseUri;
 04737            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 04738            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 04739            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 04740            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 04741            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 4742            // Create HTTP transport objects
 04743            var _httpRequest = new HttpRequestMessage();
 04744            HttpResponseMessage _httpResponse = null;
 04745            _httpRequest.Method = new HttpMethod("PATCH");
 04746            _httpRequest.RequestUri = new System.Uri(_url);
 4747            // Set Headers
 4748
 4749
 04750            if (customHeaders != null)
 4751            {
 04752                foreach(var _header in customHeaders)
 4753                {
 04754                    if (_httpRequest.Headers.Contains(_header.Key))
 4755                    {
 04756                        _httpRequest.Headers.Remove(_header.Key);
 4757                    }
 04758                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4759                }
 4760            }
 4761
 4762            // Serialize Request
 04763            string _requestContent = null;
 04764            if(modelUpdateObject != null)
 4765            {
 04766                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(modelUpdateObject, Client.Serializa
 04767                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 04768                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 4769            }
 4770            // Set Credentials
 04771            if (Client.Credentials != null)
 4772            {
 04773                cancellationToken.ThrowIfCancellationRequested();
 04774                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4775            }
 4776            // Send Request
 04777            if (_shouldTrace)
 4778            {
 04779                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4780            }
 04781            cancellationToken.ThrowIfCancellationRequested();
 04782            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 04783            if (_shouldTrace)
 4784            {
 04785                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4786            }
 04787            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 04788            cancellationToken.ThrowIfCancellationRequested();
 04789            string _responseContent = null;
 04790            if ((int)_statusCode != 200)
 4791            {
 04792                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 4793                try
 4794                {
 04795                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04796                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 04797                    if (_errorBody != null)
 4798                    {
 04799                        ex.Body = _errorBody;
 4800                    }
 04801                }
 04802                catch (JsonException)
 4803                {
 4804                    // Ignore the exception
 04805                }
 04806                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04807                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04808                if (_shouldTrace)
 4809                {
 04810                    ServiceClientTracing.Error(_invocationId, ex);
 4811                }
 04812                _httpRequest.Dispose();
 04813                if (_httpResponse != null)
 4814                {
 04815                    _httpResponse.Dispose();
 4816                }
 04817                throw ex;
 4818            }
 4819            // Create Result
 04820            var _result = new HttpOperationResponse<OperationStatus>();
 04821            _result.Request = _httpRequest;
 04822            _result.Response = _httpResponse;
 4823            // Deserialize Response
 04824            if ((int)_statusCode == 200)
 4825            {
 04826                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4827                try
 4828                {
 04829                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 04830                }
 04831                catch (JsonException ex)
 4832                {
 04833                    _httpRequest.Dispose();
 04834                    if (_httpResponse != null)
 4835                    {
 04836                        _httpResponse.Dispose();
 4837                    }
 04838                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4839                }
 4840            }
 04841            if (_shouldTrace)
 4842            {
 04843                ServiceClientTracing.Exit(_invocationId, _result);
 4844            }
 04845            return _result;
 04846        }
 4847
 4848        /// <summary>
 4849        /// Deletes a hierarchical entity from a version of the application.
 4850        /// </summary>
 4851        /// <param name='appId'>
 4852        /// The application ID.
 4853        /// </param>
 4854        /// <param name='versionId'>
 4855        /// The version ID.
 4856        /// </param>
 4857        /// <param name='hEntityId'>
 4858        /// The hierarchical entity extractor ID.
 4859        /// </param>
 4860        /// <param name='customHeaders'>
 4861        /// Headers that will be added to request.
 4862        /// </param>
 4863        /// <param name='cancellationToken'>
 4864        /// The cancellation token.
 4865        /// </param>
 4866        /// <exception cref="ErrorResponseException">
 4867        /// Thrown when the operation returned an invalid status code
 4868        /// </exception>
 4869        /// <exception cref="SerializationException">
 4870        /// Thrown when unable to deserialize the response
 4871        /// </exception>
 4872        /// <exception cref="ValidationException">
 4873        /// Thrown when a required parameter is null
 4874        /// </exception>
 4875        /// <exception cref="System.ArgumentNullException">
 4876        /// Thrown when a required parameter is null
 4877        /// </exception>
 4878        /// <return>
 4879        /// A response object containing the response body and response headers.
 4880        /// </return>
 4881        public async Task<HttpOperationResponse<OperationStatus>> DeleteHierarchicalEntityWithHttpMessagesAsync(System.G
 4882        {
 04883            if (Client.Endpoint == null)
 4884            {
 04885                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 4886            }
 04887            if (versionId == null)
 4888            {
 04889                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 4890            }
 4891            // Tracing
 04892            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 04893            string _invocationId = null;
 04894            if (_shouldTrace)
 4895            {
 04896                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04897                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04898                tracingParameters.Add("appId", appId);
 04899                tracingParameters.Add("versionId", versionId);
 04900                tracingParameters.Add("hEntityId", hEntityId);
 04901                tracingParameters.Add("cancellationToken", cancellationToken);
 04902                ServiceClientTracing.Enter(_invocationId, this, "DeleteHierarchicalEntity", tracingParameters);
 4903            }
 4904            // Construct URL
 04905            var _baseUrl = Client.BaseUri;
 04906            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 04907            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 04908            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 04909            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 04910            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 4911            // Create HTTP transport objects
 04912            var _httpRequest = new HttpRequestMessage();
 04913            HttpResponseMessage _httpResponse = null;
 04914            _httpRequest.Method = new HttpMethod("DELETE");
 04915            _httpRequest.RequestUri = new System.Uri(_url);
 4916            // Set Headers
 4917
 4918
 04919            if (customHeaders != null)
 4920            {
 04921                foreach(var _header in customHeaders)
 4922                {
 04923                    if (_httpRequest.Headers.Contains(_header.Key))
 4924                    {
 04925                        _httpRequest.Headers.Remove(_header.Key);
 4926                    }
 04927                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4928                }
 4929            }
 4930
 4931            // Serialize Request
 04932            string _requestContent = null;
 4933            // Set Credentials
 04934            if (Client.Credentials != null)
 4935            {
 04936                cancellationToken.ThrowIfCancellationRequested();
 04937                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4938            }
 4939            // Send Request
 04940            if (_shouldTrace)
 4941            {
 04942                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4943            }
 04944            cancellationToken.ThrowIfCancellationRequested();
 04945            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 04946            if (_shouldTrace)
 4947            {
 04948                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4949            }
 04950            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 04951            cancellationToken.ThrowIfCancellationRequested();
 04952            string _responseContent = null;
 04953            if ((int)_statusCode != 200)
 4954            {
 04955                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 4956                try
 4957                {
 04958                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04959                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 04960                    if (_errorBody != null)
 4961                    {
 04962                        ex.Body = _errorBody;
 4963                    }
 04964                }
 04965                catch (JsonException)
 4966                {
 4967                    // Ignore the exception
 04968                }
 04969                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04970                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04971                if (_shouldTrace)
 4972                {
 04973                    ServiceClientTracing.Error(_invocationId, ex);
 4974                }
 04975                _httpRequest.Dispose();
 04976                if (_httpResponse != null)
 4977                {
 04978                    _httpResponse.Dispose();
 4979                }
 04980                throw ex;
 4981            }
 4982            // Create Result
 04983            var _result = new HttpOperationResponse<OperationStatus>();
 04984            _result.Request = _httpRequest;
 04985            _result.Response = _httpResponse;
 4986            // Deserialize Response
 04987            if ((int)_statusCode == 200)
 4988            {
 04989                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4990                try
 4991                {
 04992                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 04993                }
 04994                catch (JsonException ex)
 4995                {
 04996                    _httpRequest.Dispose();
 04997                    if (_httpResponse != null)
 4998                    {
 04999                        _httpResponse.Dispose();
 5000                    }
 05001                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5002                }
 5003            }
 05004            if (_shouldTrace)
 5005            {
 05006                ServiceClientTracing.Exit(_invocationId, _result);
 5007            }
 05008            return _result;
 05009        }
 5010
 5011        /// <summary>
 5012        /// Gets information about a composite entity in a version of the application.
 5013        /// </summary>
 5014        /// <param name='appId'>
 5015        /// The application ID.
 5016        /// </param>
 5017        /// <param name='versionId'>
 5018        /// The version ID.
 5019        /// </param>
 5020        /// <param name='cEntityId'>
 5021        /// The composite entity extractor ID.
 5022        /// </param>
 5023        /// <param name='customHeaders'>
 5024        /// Headers that will be added to request.
 5025        /// </param>
 5026        /// <param name='cancellationToken'>
 5027        /// The cancellation token.
 5028        /// </param>
 5029        /// <exception cref="ErrorResponseException">
 5030        /// Thrown when the operation returned an invalid status code
 5031        /// </exception>
 5032        /// <exception cref="SerializationException">
 5033        /// Thrown when unable to deserialize the response
 5034        /// </exception>
 5035        /// <exception cref="ValidationException">
 5036        /// Thrown when a required parameter is null
 5037        /// </exception>
 5038        /// <exception cref="System.ArgumentNullException">
 5039        /// Thrown when a required parameter is null
 5040        /// </exception>
 5041        /// <return>
 5042        /// A response object containing the response body and response headers.
 5043        /// </return>
 5044        public async Task<HttpOperationResponse<CompositeEntityExtractor>> GetCompositeEntityWithHttpMessagesAsync(Syste
 5045        {
 05046            if (Client.Endpoint == null)
 5047            {
 05048                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 5049            }
 05050            if (versionId == null)
 5051            {
 05052                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 5053            }
 5054            // Tracing
 05055            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 05056            string _invocationId = null;
 05057            if (_shouldTrace)
 5058            {
 05059                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05060                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05061                tracingParameters.Add("appId", appId);
 05062                tracingParameters.Add("versionId", versionId);
 05063                tracingParameters.Add("cEntityId", cEntityId);
 05064                tracingParameters.Add("cancellationToken", cancellationToken);
 05065                ServiceClientTracing.Enter(_invocationId, this, "GetCompositeEntity", tracingParameters);
 5066            }
 5067            // Construct URL
 05068            var _baseUrl = Client.BaseUri;
 05069            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 05070            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 05071            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 05072            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 05073            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 5074            // Create HTTP transport objects
 05075            var _httpRequest = new HttpRequestMessage();
 05076            HttpResponseMessage _httpResponse = null;
 05077            _httpRequest.Method = new HttpMethod("GET");
 05078            _httpRequest.RequestUri = new System.Uri(_url);
 5079            // Set Headers
 5080
 5081
 05082            if (customHeaders != null)
 5083            {
 05084                foreach(var _header in customHeaders)
 5085                {
 05086                    if (_httpRequest.Headers.Contains(_header.Key))
 5087                    {
 05088                        _httpRequest.Headers.Remove(_header.Key);
 5089                    }
 05090                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5091                }
 5092            }
 5093
 5094            // Serialize Request
 05095            string _requestContent = null;
 5096            // Set Credentials
 05097            if (Client.Credentials != null)
 5098            {
 05099                cancellationToken.ThrowIfCancellationRequested();
 05100                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5101            }
 5102            // Send Request
 05103            if (_shouldTrace)
 5104            {
 05105                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5106            }
 05107            cancellationToken.ThrowIfCancellationRequested();
 05108            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 05109            if (_shouldTrace)
 5110            {
 05111                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5112            }
 05113            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 05114            cancellationToken.ThrowIfCancellationRequested();
 05115            string _responseContent = null;
 05116            if ((int)_statusCode != 200)
 5117            {
 05118                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 5119                try
 5120                {
 05121                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05122                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 05123                    if (_errorBody != null)
 5124                    {
 05125                        ex.Body = _errorBody;
 5126                    }
 05127                }
 05128                catch (JsonException)
 5129                {
 5130                    // Ignore the exception
 05131                }
 05132                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05133                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05134                if (_shouldTrace)
 5135                {
 05136                    ServiceClientTracing.Error(_invocationId, ex);
 5137                }
 05138                _httpRequest.Dispose();
 05139                if (_httpResponse != null)
 5140                {
 05141                    _httpResponse.Dispose();
 5142                }
 05143                throw ex;
 5144            }
 5145            // Create Result
 05146            var _result = new HttpOperationResponse<CompositeEntityExtractor>();
 05147            _result.Request = _httpRequest;
 05148            _result.Response = _httpResponse;
 5149            // Deserialize Response
 05150            if ((int)_statusCode == 200)
 5151            {
 05152                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5153                try
 5154                {
 05155                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<CompositeEntityExtractor>(_respo
 05156                }
 05157                catch (JsonException ex)
 5158                {
 05159                    _httpRequest.Dispose();
 05160                    if (_httpResponse != null)
 5161                    {
 05162                        _httpResponse.Dispose();
 5163                    }
 05164                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5165                }
 5166            }
 05167            if (_shouldTrace)
 5168            {
 05169                ServiceClientTracing.Exit(_invocationId, _result);
 5170            }
 05171            return _result;
 05172        }
 5173
 5174        /// <summary>
 5175        /// Updates a composite entity in a version of the application.
 5176        /// </summary>
 5177        /// <param name='appId'>
 5178        /// The application ID.
 5179        /// </param>
 5180        /// <param name='versionId'>
 5181        /// The version ID.
 5182        /// </param>
 5183        /// <param name='cEntityId'>
 5184        /// The composite entity extractor ID.
 5185        /// </param>
 5186        /// <param name='compositeModelUpdateObject'>
 5187        /// A model object containing the new entity extractor name and children.
 5188        /// </param>
 5189        /// <param name='customHeaders'>
 5190        /// Headers that will be added to request.
 5191        /// </param>
 5192        /// <param name='cancellationToken'>
 5193        /// The cancellation token.
 5194        /// </param>
 5195        /// <exception cref="ErrorResponseException">
 5196        /// Thrown when the operation returned an invalid status code
 5197        /// </exception>
 5198        /// <exception cref="SerializationException">
 5199        /// Thrown when unable to deserialize the response
 5200        /// </exception>
 5201        /// <exception cref="ValidationException">
 5202        /// Thrown when a required parameter is null
 5203        /// </exception>
 5204        /// <exception cref="System.ArgumentNullException">
 5205        /// Thrown when a required parameter is null
 5206        /// </exception>
 5207        /// <return>
 5208        /// A response object containing the response body and response headers.
 5209        /// </return>
 5210        public async Task<HttpOperationResponse<OperationStatus>> UpdateCompositeEntityWithHttpMessagesAsync(System.Guid
 5211        {
 05212            if (Client.Endpoint == null)
 5213            {
 05214                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 5215            }
 05216            if (versionId == null)
 5217            {
 05218                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 5219            }
 05220            if (compositeModelUpdateObject == null)
 5221            {
 05222                throw new ValidationException(ValidationRules.CannotBeNull, "compositeModelUpdateObject");
 5223            }
 5224            // Tracing
 05225            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 05226            string _invocationId = null;
 05227            if (_shouldTrace)
 5228            {
 05229                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05230                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05231                tracingParameters.Add("appId", appId);
 05232                tracingParameters.Add("versionId", versionId);
 05233                tracingParameters.Add("cEntityId", cEntityId);
 05234                tracingParameters.Add("compositeModelUpdateObject", compositeModelUpdateObject);
 05235                tracingParameters.Add("cancellationToken", cancellationToken);
 05236                ServiceClientTracing.Enter(_invocationId, this, "UpdateCompositeEntity", tracingParameters);
 5237            }
 5238            // Construct URL
 05239            var _baseUrl = Client.BaseUri;
 05240            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 05241            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 05242            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 05243            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 05244            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 5245            // Create HTTP transport objects
 05246            var _httpRequest = new HttpRequestMessage();
 05247            HttpResponseMessage _httpResponse = null;
 05248            _httpRequest.Method = new HttpMethod("PUT");
 05249            _httpRequest.RequestUri = new System.Uri(_url);
 5250            // Set Headers
 5251
 5252
 05253            if (customHeaders != null)
 5254            {
 05255                foreach(var _header in customHeaders)
 5256                {
 05257                    if (_httpRequest.Headers.Contains(_header.Key))
 5258                    {
 05259                        _httpRequest.Headers.Remove(_header.Key);
 5260                    }
 05261                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5262                }
 5263            }
 5264
 5265            // Serialize Request
 05266            string _requestContent = null;
 05267            if(compositeModelUpdateObject != null)
 5268            {
 05269                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(compositeModelUpdateObject, Client.
 05270                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 05271                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 5272            }
 5273            // Set Credentials
 05274            if (Client.Credentials != null)
 5275            {
 05276                cancellationToken.ThrowIfCancellationRequested();
 05277                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5278            }
 5279            // Send Request
 05280            if (_shouldTrace)
 5281            {
 05282                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5283            }
 05284            cancellationToken.ThrowIfCancellationRequested();
 05285            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 05286            if (_shouldTrace)
 5287            {
 05288                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5289            }
 05290            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 05291            cancellationToken.ThrowIfCancellationRequested();
 05292            string _responseContent = null;
 05293            if ((int)_statusCode != 200)
 5294            {
 05295                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 5296                try
 5297                {
 05298                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05299                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 05300                    if (_errorBody != null)
 5301                    {
 05302                        ex.Body = _errorBody;
 5303                    }
 05304                }
 05305                catch (JsonException)
 5306                {
 5307                    // Ignore the exception
 05308                }
 05309                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05310                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05311                if (_shouldTrace)
 5312                {
 05313                    ServiceClientTracing.Error(_invocationId, ex);
 5314                }
 05315                _httpRequest.Dispose();
 05316                if (_httpResponse != null)
 5317                {
 05318                    _httpResponse.Dispose();
 5319                }
 05320                throw ex;
 5321            }
 5322            // Create Result
 05323            var _result = new HttpOperationResponse<OperationStatus>();
 05324            _result.Request = _httpRequest;
 05325            _result.Response = _httpResponse;
 5326            // Deserialize Response
 05327            if ((int)_statusCode == 200)
 5328            {
 05329                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5330                try
 5331                {
 05332                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 05333                }
 05334                catch (JsonException ex)
 5335                {
 05336                    _httpRequest.Dispose();
 05337                    if (_httpResponse != null)
 5338                    {
 05339                        _httpResponse.Dispose();
 5340                    }
 05341                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5342                }
 5343            }
 05344            if (_shouldTrace)
 5345            {
 05346                ServiceClientTracing.Exit(_invocationId, _result);
 5347            }
 05348            return _result;
 05349        }
 5350
 5351        /// <summary>
 5352        /// Deletes a composite entity from a version of the application.
 5353        /// </summary>
 5354        /// <param name='appId'>
 5355        /// The application ID.
 5356        /// </param>
 5357        /// <param name='versionId'>
 5358        /// The version ID.
 5359        /// </param>
 5360        /// <param name='cEntityId'>
 5361        /// The composite entity extractor ID.
 5362        /// </param>
 5363        /// <param name='customHeaders'>
 5364        /// Headers that will be added to request.
 5365        /// </param>
 5366        /// <param name='cancellationToken'>
 5367        /// The cancellation token.
 5368        /// </param>
 5369        /// <exception cref="ErrorResponseException">
 5370        /// Thrown when the operation returned an invalid status code
 5371        /// </exception>
 5372        /// <exception cref="SerializationException">
 5373        /// Thrown when unable to deserialize the response
 5374        /// </exception>
 5375        /// <exception cref="ValidationException">
 5376        /// Thrown when a required parameter is null
 5377        /// </exception>
 5378        /// <exception cref="System.ArgumentNullException">
 5379        /// Thrown when a required parameter is null
 5380        /// </exception>
 5381        /// <return>
 5382        /// A response object containing the response body and response headers.
 5383        /// </return>
 5384        public async Task<HttpOperationResponse<OperationStatus>> DeleteCompositeEntityWithHttpMessagesAsync(System.Guid
 5385        {
 05386            if (Client.Endpoint == null)
 5387            {
 05388                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 5389            }
 05390            if (versionId == null)
 5391            {
 05392                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 5393            }
 5394            // Tracing
 05395            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 05396            string _invocationId = null;
 05397            if (_shouldTrace)
 5398            {
 05399                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05400                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05401                tracingParameters.Add("appId", appId);
 05402                tracingParameters.Add("versionId", versionId);
 05403                tracingParameters.Add("cEntityId", cEntityId);
 05404                tracingParameters.Add("cancellationToken", cancellationToken);
 05405                ServiceClientTracing.Enter(_invocationId, this, "DeleteCompositeEntity", tracingParameters);
 5406            }
 5407            // Construct URL
 05408            var _baseUrl = Client.BaseUri;
 05409            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 05410            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 05411            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 05412            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 05413            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 5414            // Create HTTP transport objects
 05415            var _httpRequest = new HttpRequestMessage();
 05416            HttpResponseMessage _httpResponse = null;
 05417            _httpRequest.Method = new HttpMethod("DELETE");
 05418            _httpRequest.RequestUri = new System.Uri(_url);
 5419            // Set Headers
 5420
 5421
 05422            if (customHeaders != null)
 5423            {
 05424                foreach(var _header in customHeaders)
 5425                {
 05426                    if (_httpRequest.Headers.Contains(_header.Key))
 5427                    {
 05428                        _httpRequest.Headers.Remove(_header.Key);
 5429                    }
 05430                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5431                }
 5432            }
 5433
 5434            // Serialize Request
 05435            string _requestContent = null;
 5436            // Set Credentials
 05437            if (Client.Credentials != null)
 5438            {
 05439                cancellationToken.ThrowIfCancellationRequested();
 05440                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5441            }
 5442            // Send Request
 05443            if (_shouldTrace)
 5444            {
 05445                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5446            }
 05447            cancellationToken.ThrowIfCancellationRequested();
 05448            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 05449            if (_shouldTrace)
 5450            {
 05451                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5452            }
 05453            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 05454            cancellationToken.ThrowIfCancellationRequested();
 05455            string _responseContent = null;
 05456            if ((int)_statusCode != 200)
 5457            {
 05458                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 5459                try
 5460                {
 05461                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05462                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 05463                    if (_errorBody != null)
 5464                    {
 05465                        ex.Body = _errorBody;
 5466                    }
 05467                }
 05468                catch (JsonException)
 5469                {
 5470                    // Ignore the exception
 05471                }
 05472                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05473                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05474                if (_shouldTrace)
 5475                {
 05476                    ServiceClientTracing.Error(_invocationId, ex);
 5477                }
 05478                _httpRequest.Dispose();
 05479                if (_httpResponse != null)
 5480                {
 05481                    _httpResponse.Dispose();
 5482                }
 05483                throw ex;
 5484            }
 5485            // Create Result
 05486            var _result = new HttpOperationResponse<OperationStatus>();
 05487            _result.Request = _httpRequest;
 05488            _result.Response = _httpResponse;
 5489            // Deserialize Response
 05490            if ((int)_statusCode == 200)
 5491            {
 05492                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5493                try
 5494                {
 05495                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 05496                }
 05497                catch (JsonException ex)
 5498                {
 05499                    _httpRequest.Dispose();
 05500                    if (_httpResponse != null)
 5501                    {
 05502                        _httpResponse.Dispose();
 5503                    }
 05504                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5505                }
 5506            }
 05507            if (_shouldTrace)
 5508            {
 05509                ServiceClientTracing.Exit(_invocationId, _result);
 5510            }
 05511            return _result;
 05512        }
 5513
 5514        /// <summary>
 5515        /// Gets information about a list entity in a version of the application.
 5516        /// </summary>
 5517        /// <param name='appId'>
 5518        /// The application ID.
 5519        /// </param>
 5520        /// <param name='versionId'>
 5521        /// The version ID.
 5522        /// </param>
 5523        /// <param name='clEntityId'>
 5524        /// The list model ID.
 5525        /// </param>
 5526        /// <param name='customHeaders'>
 5527        /// Headers that will be added to request.
 5528        /// </param>
 5529        /// <param name='cancellationToken'>
 5530        /// The cancellation token.
 5531        /// </param>
 5532        /// <exception cref="ErrorResponseException">
 5533        /// Thrown when the operation returned an invalid status code
 5534        /// </exception>
 5535        /// <exception cref="SerializationException">
 5536        /// Thrown when unable to deserialize the response
 5537        /// </exception>
 5538        /// <exception cref="ValidationException">
 5539        /// Thrown when a required parameter is null
 5540        /// </exception>
 5541        /// <exception cref="System.ArgumentNullException">
 5542        /// Thrown when a required parameter is null
 5543        /// </exception>
 5544        /// <return>
 5545        /// A response object containing the response body and response headers.
 5546        /// </return>
 5547        public async Task<HttpOperationResponse<ClosedListEntityExtractor>> GetClosedListWithHttpMessagesAsync(System.Gu
 5548        {
 85549            if (Client.Endpoint == null)
 5550            {
 05551                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 5552            }
 85553            if (versionId == null)
 5554            {
 05555                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 5556            }
 5557            // Tracing
 85558            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 85559            string _invocationId = null;
 85560            if (_shouldTrace)
 5561            {
 05562                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05563                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05564                tracingParameters.Add("appId", appId);
 05565                tracingParameters.Add("versionId", versionId);
 05566                tracingParameters.Add("clEntityId", clEntityId);
 05567                tracingParameters.Add("cancellationToken", cancellationToken);
 05568                ServiceClientTracing.Enter(_invocationId, this, "GetClosedList", tracingParameters);
 5569            }
 5570            // Construct URL
 85571            var _baseUrl = Client.BaseUri;
 85572            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 85573            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 85574            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 85575            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 85576            _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize
 5577            // Create HTTP transport objects
 85578            var _httpRequest = new HttpRequestMessage();
 85579            HttpResponseMessage _httpResponse = null;
 85580            _httpRequest.Method = new HttpMethod("GET");
 85581            _httpRequest.RequestUri = new System.Uri(_url);
 5582            // Set Headers
 5583
 5584
 85585            if (customHeaders != null)
 5586            {
 05587                foreach(var _header in customHeaders)
 5588                {
 05589                    if (_httpRequest.Headers.Contains(_header.Key))
 5590                    {
 05591                        _httpRequest.Headers.Remove(_header.Key);
 5592                    }
 05593                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5594                }
 5595            }
 5596
 5597            // Serialize Request
 85598            string _requestContent = null;
 5599            // Set Credentials
 85600            if (Client.Credentials != null)
 5601            {
 85602                cancellationToken.ThrowIfCancellationRequested();
 85603                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5604            }
 5605            // Send Request
 85606            if (_shouldTrace)
 5607            {
 05608                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5609            }
 85610            cancellationToken.ThrowIfCancellationRequested();
 85611            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 85612            if (_shouldTrace)
 5613            {
 05614                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5615            }
 85616            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 85617            cancellationToken.ThrowIfCancellationRequested();
 85618            string _responseContent = null;
 85619            if ((int)_statusCode != 200)
 5620            {
 05621                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 5622                try
 5623                {
 05624                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05625                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 05626                    if (_errorBody != null)
 5627                    {
 05628                        ex.Body = _errorBody;
 5629                    }
 05630                }
 05631                catch (JsonException)
 5632                {
 5633                    // Ignore the exception
 05634                }
 05635                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05636                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05637                if (_shouldTrace)
 5638                {
 05639                    ServiceClientTracing.Error(_invocationId, ex);
 5640                }
 05641                _httpRequest.Dispose();
 05642                if (_httpResponse != null)
 5643                {
 05644                    _httpResponse.Dispose();
 5645                }
 05646                throw ex;
 5647            }
 5648            // Create Result
 85649            var _result = new HttpOperationResponse<ClosedListEntityExtractor>();
 85650            _result.Request = _httpRequest;
 85651            _result.Response = _httpResponse;
 5652            // Deserialize Response
 85653            if ((int)_statusCode == 200)
 5654            {
 85655                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5656                try
 5657                {
 85658                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ClosedListEntityExtractor>(_resp
 85659                }
 05660                catch (JsonException ex)
 5661                {
 05662                    _httpRequest.Dispose();
 05663                    if (_httpResponse != null)
 5664                    {
 05665                        _httpResponse.Dispose();
 5666                    }
 05667                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5668                }
 5669            }
 85670            if (_shouldTrace)
 5671            {
 05672                ServiceClientTracing.Exit(_invocationId, _result);
 5673            }
 85674            return _result;
 85675        }
 5676
 5677        /// <summary>
 5678        /// Updates the list entity in a version of the application.
 5679        /// </summary>
 5680        /// <param name='appId'>
 5681        /// The application ID.
 5682        /// </param>
 5683        /// <param name='versionId'>
 5684        /// The version ID.
 5685        /// </param>
 5686        /// <param name='clEntityId'>
 5687        /// The list model ID.
 5688        /// </param>
 5689        /// <param name='closedListModelUpdateObject'>
 5690        /// The new list entity name and words list.
 5691        /// </param>
 5692        /// <param name='customHeaders'>
 5693        /// Headers that will be added to request.
 5694        /// </param>
 5695        /// <param name='cancellationToken'>
 5696        /// The cancellation token.
 5697        /// </param>
 5698        /// <exception cref="ErrorResponseException">
 5699        /// Thrown when the operation returned an invalid status code
 5700        /// </exception>
 5701        /// <exception cref="SerializationException">
 5702        /// Thrown when unable to deserialize the response
 5703        /// </exception>
 5704        /// <exception cref="ValidationException">
 5705        /// Thrown when a required parameter is null
 5706        /// </exception>
 5707        /// <exception cref="System.ArgumentNullException">
 5708        /// Thrown when a required parameter is null
 5709        /// </exception>
 5710        /// <return>
 5711        /// A response object containing the response body and response headers.
 5712        /// </return>
 5713        public async Task<HttpOperationResponse<OperationStatus>> UpdateClosedListWithHttpMessagesAsync(System.Guid appI
 5714        {
 15715            if (Client.Endpoint == null)
 5716            {
 05717                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 5718            }
 15719            if (versionId == null)
 5720            {
 05721                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 5722            }
 15723            if (closedListModelUpdateObject == null)
 5724            {
 05725                throw new ValidationException(ValidationRules.CannotBeNull, "closedListModelUpdateObject");
 5726            }
 5727            // Tracing
 15728            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 15729            string _invocationId = null;
 15730            if (_shouldTrace)
 5731            {
 05732                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05733                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05734                tracingParameters.Add("appId", appId);
 05735                tracingParameters.Add("versionId", versionId);
 05736                tracingParameters.Add("clEntityId", clEntityId);
 05737                tracingParameters.Add("closedListModelUpdateObject", closedListModelUpdateObject);
 05738                tracingParameters.Add("cancellationToken", cancellationToken);
 05739                ServiceClientTracing.Enter(_invocationId, this, "UpdateClosedList", tracingParameters);
 5740            }
 5741            // Construct URL
 15742            var _baseUrl = Client.BaseUri;
 15743            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 15744            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 15745            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 15746            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 15747            _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize
 5748            // Create HTTP transport objects
 15749            var _httpRequest = new HttpRequestMessage();
 15750            HttpResponseMessage _httpResponse = null;
 15751            _httpRequest.Method = new HttpMethod("PUT");
 15752            _httpRequest.RequestUri = new System.Uri(_url);
 5753            // Set Headers
 5754
 5755
 15756            if (customHeaders != null)
 5757            {
 05758                foreach(var _header in customHeaders)
 5759                {
 05760                    if (_httpRequest.Headers.Contains(_header.Key))
 5761                    {
 05762                        _httpRequest.Headers.Remove(_header.Key);
 5763                    }
 05764                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5765                }
 5766            }
 5767
 5768            // Serialize Request
 15769            string _requestContent = null;
 15770            if(closedListModelUpdateObject != null)
 5771            {
 15772                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(closedListModelUpdateObject, Client
 15773                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 15774                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 5775            }
 5776            // Set Credentials
 15777            if (Client.Credentials != null)
 5778            {
 15779                cancellationToken.ThrowIfCancellationRequested();
 15780                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5781            }
 5782            // Send Request
 15783            if (_shouldTrace)
 5784            {
 05785                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5786            }
 15787            cancellationToken.ThrowIfCancellationRequested();
 15788            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 15789            if (_shouldTrace)
 5790            {
 05791                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5792            }
 15793            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 15794            cancellationToken.ThrowIfCancellationRequested();
 15795            string _responseContent = null;
 15796            if ((int)_statusCode != 200)
 5797            {
 05798                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 5799                try
 5800                {
 05801                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05802                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 05803                    if (_errorBody != null)
 5804                    {
 05805                        ex.Body = _errorBody;
 5806                    }
 05807                }
 05808                catch (JsonException)
 5809                {
 5810                    // Ignore the exception
 05811                }
 05812                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05813                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05814                if (_shouldTrace)
 5815                {
 05816                    ServiceClientTracing.Error(_invocationId, ex);
 5817                }
 05818                _httpRequest.Dispose();
 05819                if (_httpResponse != null)
 5820                {
 05821                    _httpResponse.Dispose();
 5822                }
 05823                throw ex;
 5824            }
 5825            // Create Result
 15826            var _result = new HttpOperationResponse<OperationStatus>();
 15827            _result.Request = _httpRequest;
 15828            _result.Response = _httpResponse;
 5829            // Deserialize Response
 15830            if ((int)_statusCode == 200)
 5831            {
 15832                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5833                try
 5834                {
 15835                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 15836                }
 05837                catch (JsonException ex)
 5838                {
 05839                    _httpRequest.Dispose();
 05840                    if (_httpResponse != null)
 5841                    {
 05842                        _httpResponse.Dispose();
 5843                    }
 05844                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5845                }
 5846            }
 15847            if (_shouldTrace)
 5848            {
 05849                ServiceClientTracing.Exit(_invocationId, _result);
 5850            }
 15851            return _result;
 15852        }
 5853
 5854        /// <summary>
 5855        /// Adds a batch of sublists to an existing list entity in a version of the
 5856        /// application.
 5857        /// </summary>
 5858        /// <param name='appId'>
 5859        /// The application ID.
 5860        /// </param>
 5861        /// <param name='versionId'>
 5862        /// The version ID.
 5863        /// </param>
 5864        /// <param name='clEntityId'>
 5865        /// The list entity model ID.
 5866        /// </param>
 5867        /// <param name='closedListModelPatchObject'>
 5868        /// A words list batch.
 5869        /// </param>
 5870        /// <param name='customHeaders'>
 5871        /// Headers that will be added to request.
 5872        /// </param>
 5873        /// <param name='cancellationToken'>
 5874        /// The cancellation token.
 5875        /// </param>
 5876        /// <exception cref="ErrorResponseException">
 5877        /// Thrown when the operation returned an invalid status code
 5878        /// </exception>
 5879        /// <exception cref="SerializationException">
 5880        /// Thrown when unable to deserialize the response
 5881        /// </exception>
 5882        /// <exception cref="ValidationException">
 5883        /// Thrown when a required parameter is null
 5884        /// </exception>
 5885        /// <exception cref="System.ArgumentNullException">
 5886        /// Thrown when a required parameter is null
 5887        /// </exception>
 5888        /// <return>
 5889        /// A response object containing the response body and response headers.
 5890        /// </return>
 5891        public async Task<HttpOperationResponse<OperationStatus>> PatchClosedListWithHttpMessagesAsync(System.Guid appId
 5892        {
 15893            if (Client.Endpoint == null)
 5894            {
 05895                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 5896            }
 15897            if (versionId == null)
 5898            {
 05899                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 5900            }
 15901            if (closedListModelPatchObject == null)
 5902            {
 05903                throw new ValidationException(ValidationRules.CannotBeNull, "closedListModelPatchObject");
 5904            }
 5905            // Tracing
 15906            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 15907            string _invocationId = null;
 15908            if (_shouldTrace)
 5909            {
 05910                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05911                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05912                tracingParameters.Add("appId", appId);
 05913                tracingParameters.Add("versionId", versionId);
 05914                tracingParameters.Add("clEntityId", clEntityId);
 05915                tracingParameters.Add("closedListModelPatchObject", closedListModelPatchObject);
 05916                tracingParameters.Add("cancellationToken", cancellationToken);
 05917                ServiceClientTracing.Enter(_invocationId, this, "PatchClosedList", tracingParameters);
 5918            }
 5919            // Construct URL
 15920            var _baseUrl = Client.BaseUri;
 15921            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 15922            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 15923            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 15924            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 15925            _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize
 5926            // Create HTTP transport objects
 15927            var _httpRequest = new HttpRequestMessage();
 15928            HttpResponseMessage _httpResponse = null;
 15929            _httpRequest.Method = new HttpMethod("PATCH");
 15930            _httpRequest.RequestUri = new System.Uri(_url);
 5931            // Set Headers
 5932
 5933
 15934            if (customHeaders != null)
 5935            {
 05936                foreach(var _header in customHeaders)
 5937                {
 05938                    if (_httpRequest.Headers.Contains(_header.Key))
 5939                    {
 05940                        _httpRequest.Headers.Remove(_header.Key);
 5941                    }
 05942                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5943                }
 5944            }
 5945
 5946            // Serialize Request
 15947            string _requestContent = null;
 15948            if(closedListModelPatchObject != null)
 5949            {
 15950                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(closedListModelPatchObject, Client.
 15951                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 15952                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 5953            }
 5954            // Set Credentials
 15955            if (Client.Credentials != null)
 5956            {
 15957                cancellationToken.ThrowIfCancellationRequested();
 15958                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5959            }
 5960            // Send Request
 15961            if (_shouldTrace)
 5962            {
 05963                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5964            }
 15965            cancellationToken.ThrowIfCancellationRequested();
 15966            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 15967            if (_shouldTrace)
 5968            {
 05969                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5970            }
 15971            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 15972            cancellationToken.ThrowIfCancellationRequested();
 15973            string _responseContent = null;
 15974            if ((int)_statusCode != 200)
 5975            {
 05976                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 5977                try
 5978                {
 05979                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05980                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 05981                    if (_errorBody != null)
 5982                    {
 05983                        ex.Body = _errorBody;
 5984                    }
 05985                }
 05986                catch (JsonException)
 5987                {
 5988                    // Ignore the exception
 05989                }
 05990                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05991                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05992                if (_shouldTrace)
 5993                {
 05994                    ServiceClientTracing.Error(_invocationId, ex);
 5995                }
 05996                _httpRequest.Dispose();
 05997                if (_httpResponse != null)
 5998                {
 05999                    _httpResponse.Dispose();
 6000                }
 06001                throw ex;
 6002            }
 6003            // Create Result
 16004            var _result = new HttpOperationResponse<OperationStatus>();
 16005            _result.Request = _httpRequest;
 16006            _result.Response = _httpResponse;
 6007            // Deserialize Response
 16008            if ((int)_statusCode == 200)
 6009            {
 16010                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6011                try
 6012                {
 16013                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 16014                }
 06015                catch (JsonException ex)
 6016                {
 06017                    _httpRequest.Dispose();
 06018                    if (_httpResponse != null)
 6019                    {
 06020                        _httpResponse.Dispose();
 6021                    }
 06022                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6023                }
 6024            }
 16025            if (_shouldTrace)
 6026            {
 06027                ServiceClientTracing.Exit(_invocationId, _result);
 6028            }
 16029            return _result;
 16030        }
 6031
 6032        /// <summary>
 6033        /// Deletes a list entity model from a version of the application.
 6034        /// </summary>
 6035        /// <param name='appId'>
 6036        /// The application ID.
 6037        /// </param>
 6038        /// <param name='versionId'>
 6039        /// The version ID.
 6040        /// </param>
 6041        /// <param name='clEntityId'>
 6042        /// The list entity model ID.
 6043        /// </param>
 6044        /// <param name='customHeaders'>
 6045        /// Headers that will be added to request.
 6046        /// </param>
 6047        /// <param name='cancellationToken'>
 6048        /// The cancellation token.
 6049        /// </param>
 6050        /// <exception cref="ErrorResponseException">
 6051        /// Thrown when the operation returned an invalid status code
 6052        /// </exception>
 6053        /// <exception cref="SerializationException">
 6054        /// Thrown when unable to deserialize the response
 6055        /// </exception>
 6056        /// <exception cref="ValidationException">
 6057        /// Thrown when a required parameter is null
 6058        /// </exception>
 6059        /// <exception cref="System.ArgumentNullException">
 6060        /// Thrown when a required parameter is null
 6061        /// </exception>
 6062        /// <return>
 6063        /// A response object containing the response body and response headers.
 6064        /// </return>
 6065        public async Task<HttpOperationResponse<OperationStatus>> DeleteClosedListWithHttpMessagesAsync(System.Guid appI
 6066        {
 146067            if (Client.Endpoint == null)
 6068            {
 06069                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 6070            }
 146071            if (versionId == null)
 6072            {
 06073                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 6074            }
 6075            // Tracing
 146076            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 146077            string _invocationId = null;
 146078            if (_shouldTrace)
 6079            {
 06080                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06081                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06082                tracingParameters.Add("appId", appId);
 06083                tracingParameters.Add("versionId", versionId);
 06084                tracingParameters.Add("clEntityId", clEntityId);
 06085                tracingParameters.Add("cancellationToken", cancellationToken);
 06086                ServiceClientTracing.Enter(_invocationId, this, "DeleteClosedList", tracingParameters);
 6087            }
 6088            // Construct URL
 146089            var _baseUrl = Client.BaseUri;
 146090            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 146091            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 146092            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 146093            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 146094            _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize
 6095            // Create HTTP transport objects
 146096            var _httpRequest = new HttpRequestMessage();
 146097            HttpResponseMessage _httpResponse = null;
 146098            _httpRequest.Method = new HttpMethod("DELETE");
 146099            _httpRequest.RequestUri = new System.Uri(_url);
 6100            // Set Headers
 6101
 6102
 146103            if (customHeaders != null)
 6104            {
 06105                foreach(var _header in customHeaders)
 6106                {
 06107                    if (_httpRequest.Headers.Contains(_header.Key))
 6108                    {
 06109                        _httpRequest.Headers.Remove(_header.Key);
 6110                    }
 06111                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6112                }
 6113            }
 6114
 6115            // Serialize Request
 146116            string _requestContent = null;
 6117            // Set Credentials
 146118            if (Client.Credentials != null)
 6119            {
 146120                cancellationToken.ThrowIfCancellationRequested();
 146121                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6122            }
 6123            // Send Request
 146124            if (_shouldTrace)
 6125            {
 06126                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6127            }
 146128            cancellationToken.ThrowIfCancellationRequested();
 146129            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 146130            if (_shouldTrace)
 6131            {
 06132                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6133            }
 146134            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 146135            cancellationToken.ThrowIfCancellationRequested();
 146136            string _responseContent = null;
 146137            if ((int)_statusCode != 200)
 6138            {
 06139                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 6140                try
 6141                {
 06142                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06143                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 06144                    if (_errorBody != null)
 6145                    {
 06146                        ex.Body = _errorBody;
 6147                    }
 06148                }
 06149                catch (JsonException)
 6150                {
 6151                    // Ignore the exception
 06152                }
 06153                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06154                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06155                if (_shouldTrace)
 6156                {
 06157                    ServiceClientTracing.Error(_invocationId, ex);
 6158                }
 06159                _httpRequest.Dispose();
 06160                if (_httpResponse != null)
 6161                {
 06162                    _httpResponse.Dispose();
 6163                }
 06164                throw ex;
 6165            }
 6166            // Create Result
 146167            var _result = new HttpOperationResponse<OperationStatus>();
 146168            _result.Request = _httpRequest;
 146169            _result.Response = _httpResponse;
 6170            // Deserialize Response
 146171            if ((int)_statusCode == 200)
 6172            {
 146173                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6174                try
 6175                {
 146176                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 146177                }
 06178                catch (JsonException ex)
 6179                {
 06180                    _httpRequest.Dispose();
 06181                    if (_httpResponse != null)
 6182                    {
 06183                        _httpResponse.Dispose();
 6184                    }
 06185                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6186                }
 6187            }
 146188            if (_shouldTrace)
 6189            {
 06190                ServiceClientTracing.Exit(_invocationId, _result);
 6191            }
 146192            return _result;
 146193        }
 6194
 6195        /// <summary>
 6196        /// Gets information about a prebuilt entity model in a version of the
 6197        /// application.
 6198        /// </summary>
 6199        /// <param name='appId'>
 6200        /// The application ID.
 6201        /// </param>
 6202        /// <param name='versionId'>
 6203        /// The version ID.
 6204        /// </param>
 6205        /// <param name='prebuiltId'>
 6206        /// The prebuilt entity extractor ID.
 6207        /// </param>
 6208        /// <param name='customHeaders'>
 6209        /// Headers that will be added to request.
 6210        /// </param>
 6211        /// <param name='cancellationToken'>
 6212        /// The cancellation token.
 6213        /// </param>
 6214        /// <exception cref="ErrorResponseException">
 6215        /// Thrown when the operation returned an invalid status code
 6216        /// </exception>
 6217        /// <exception cref="SerializationException">
 6218        /// Thrown when unable to deserialize the response
 6219        /// </exception>
 6220        /// <exception cref="ValidationException">
 6221        /// Thrown when a required parameter is null
 6222        /// </exception>
 6223        /// <exception cref="System.ArgumentNullException">
 6224        /// Thrown when a required parameter is null
 6225        /// </exception>
 6226        /// <return>
 6227        /// A response object containing the response body and response headers.
 6228        /// </return>
 6229        public async Task<HttpOperationResponse<PrebuiltEntityExtractor>> GetPrebuiltWithHttpMessagesAsync(System.Guid a
 6230        {
 16231            if (Client.Endpoint == null)
 6232            {
 06233                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 6234            }
 16235            if (versionId == null)
 6236            {
 06237                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 6238            }
 6239            // Tracing
 16240            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 16241            string _invocationId = null;
 16242            if (_shouldTrace)
 6243            {
 06244                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06245                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06246                tracingParameters.Add("appId", appId);
 06247                tracingParameters.Add("versionId", versionId);
 06248                tracingParameters.Add("prebuiltId", prebuiltId);
 06249                tracingParameters.Add("cancellationToken", cancellationToken);
 06250                ServiceClientTracing.Enter(_invocationId, this, "GetPrebuilt", tracingParameters);
 6251            }
 6252            // Construct URL
 16253            var _baseUrl = Client.BaseUri;
 16254            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{pr
 16255            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 16256            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 16257            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 16258            _url = _url.Replace("{prebuiltId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize
 6259            // Create HTTP transport objects
 16260            var _httpRequest = new HttpRequestMessage();
 16261            HttpResponseMessage _httpResponse = null;
 16262            _httpRequest.Method = new HttpMethod("GET");
 16263            _httpRequest.RequestUri = new System.Uri(_url);
 6264            // Set Headers
 6265
 6266
 16267            if (customHeaders != null)
 6268            {
 06269                foreach(var _header in customHeaders)
 6270                {
 06271                    if (_httpRequest.Headers.Contains(_header.Key))
 6272                    {
 06273                        _httpRequest.Headers.Remove(_header.Key);
 6274                    }
 06275                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6276                }
 6277            }
 6278
 6279            // Serialize Request
 16280            string _requestContent = null;
 6281            // Set Credentials
 16282            if (Client.Credentials != null)
 6283            {
 16284                cancellationToken.ThrowIfCancellationRequested();
 16285                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6286            }
 6287            // Send Request
 16288            if (_shouldTrace)
 6289            {
 06290                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6291            }
 16292            cancellationToken.ThrowIfCancellationRequested();
 16293            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 16294            if (_shouldTrace)
 6295            {
 06296                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6297            }
 16298            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 16299            cancellationToken.ThrowIfCancellationRequested();
 16300            string _responseContent = null;
 16301            if ((int)_statusCode != 200)
 6302            {
 06303                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 6304                try
 6305                {
 06306                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06307                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 06308                    if (_errorBody != null)
 6309                    {
 06310                        ex.Body = _errorBody;
 6311                    }
 06312                }
 06313                catch (JsonException)
 6314                {
 6315                    // Ignore the exception
 06316                }
 06317                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06318                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06319                if (_shouldTrace)
 6320                {
 06321                    ServiceClientTracing.Error(_invocationId, ex);
 6322                }
 06323                _httpRequest.Dispose();
 06324                if (_httpResponse != null)
 6325                {
 06326                    _httpResponse.Dispose();
 6327                }
 06328                throw ex;
 6329            }
 6330            // Create Result
 16331            var _result = new HttpOperationResponse<PrebuiltEntityExtractor>();
 16332            _result.Request = _httpRequest;
 16333            _result.Response = _httpResponse;
 6334            // Deserialize Response
 16335            if ((int)_statusCode == 200)
 6336            {
 16337                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6338                try
 6339                {
 16340                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<PrebuiltEntityExtractor>(_respon
 16341                }
 06342                catch (JsonException ex)
 6343                {
 06344                    _httpRequest.Dispose();
 06345                    if (_httpResponse != null)
 6346                    {
 06347                        _httpResponse.Dispose();
 6348                    }
 06349                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6350                }
 6351            }
 16352            if (_shouldTrace)
 6353            {
 06354                ServiceClientTracing.Exit(_invocationId, _result);
 6355            }
 16356            return _result;
 16357        }
 6358
 6359        /// <summary>
 6360        /// Deletes a prebuilt entity extractor from a version of the application.
 6361        /// </summary>
 6362        /// <param name='appId'>
 6363        /// The application ID.
 6364        /// </param>
 6365        /// <param name='versionId'>
 6366        /// The version ID.
 6367        /// </param>
 6368        /// <param name='prebuiltId'>
 6369        /// The prebuilt entity extractor ID.
 6370        /// </param>
 6371        /// <param name='customHeaders'>
 6372        /// Headers that will be added to request.
 6373        /// </param>
 6374        /// <param name='cancellationToken'>
 6375        /// The cancellation token.
 6376        /// </param>
 6377        /// <exception cref="ErrorResponseException">
 6378        /// Thrown when the operation returned an invalid status code
 6379        /// </exception>
 6380        /// <exception cref="SerializationException">
 6381        /// Thrown when unable to deserialize the response
 6382        /// </exception>
 6383        /// <exception cref="ValidationException">
 6384        /// Thrown when a required parameter is null
 6385        /// </exception>
 6386        /// <exception cref="System.ArgumentNullException">
 6387        /// Thrown when a required parameter is null
 6388        /// </exception>
 6389        /// <return>
 6390        /// A response object containing the response body and response headers.
 6391        /// </return>
 6392        public async Task<HttpOperationResponse<OperationStatus>> DeletePrebuiltWithHttpMessagesAsync(System.Guid appId,
 6393        {
 266394            if (Client.Endpoint == null)
 6395            {
 06396                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 6397            }
 266398            if (versionId == null)
 6399            {
 06400                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 6401            }
 6402            // Tracing
 266403            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 266404            string _invocationId = null;
 266405            if (_shouldTrace)
 6406            {
 06407                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06408                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06409                tracingParameters.Add("appId", appId);
 06410                tracingParameters.Add("versionId", versionId);
 06411                tracingParameters.Add("prebuiltId", prebuiltId);
 06412                tracingParameters.Add("cancellationToken", cancellationToken);
 06413                ServiceClientTracing.Enter(_invocationId, this, "DeletePrebuilt", tracingParameters);
 6414            }
 6415            // Construct URL
 266416            var _baseUrl = Client.BaseUri;
 266417            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{pr
 266418            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 266419            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 266420            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 266421            _url = _url.Replace("{prebuiltId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize
 6422            // Create HTTP transport objects
 266423            var _httpRequest = new HttpRequestMessage();
 266424            HttpResponseMessage _httpResponse = null;
 266425            _httpRequest.Method = new HttpMethod("DELETE");
 266426            _httpRequest.RequestUri = new System.Uri(_url);
 6427            // Set Headers
 6428
 6429
 266430            if (customHeaders != null)
 6431            {
 06432                foreach(var _header in customHeaders)
 6433                {
 06434                    if (_httpRequest.Headers.Contains(_header.Key))
 6435                    {
 06436                        _httpRequest.Headers.Remove(_header.Key);
 6437                    }
 06438                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6439                }
 6440            }
 6441
 6442            // Serialize Request
 266443            string _requestContent = null;
 6444            // Set Credentials
 266445            if (Client.Credentials != null)
 6446            {
 266447                cancellationToken.ThrowIfCancellationRequested();
 266448                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6449            }
 6450            // Send Request
 266451            if (_shouldTrace)
 6452            {
 06453                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6454            }
 266455            cancellationToken.ThrowIfCancellationRequested();
 266456            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 266457            if (_shouldTrace)
 6458            {
 06459                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6460            }
 266461            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 266462            cancellationToken.ThrowIfCancellationRequested();
 266463            string _responseContent = null;
 266464            if ((int)_statusCode != 200)
 6465            {
 06466                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 6467                try
 6468                {
 06469                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06470                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 06471                    if (_errorBody != null)
 6472                    {
 06473                        ex.Body = _errorBody;
 6474                    }
 06475                }
 06476                catch (JsonException)
 6477                {
 6478                    // Ignore the exception
 06479                }
 06480                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06481                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06482                if (_shouldTrace)
 6483                {
 06484                    ServiceClientTracing.Error(_invocationId, ex);
 6485                }
 06486                _httpRequest.Dispose();
 06487                if (_httpResponse != null)
 6488                {
 06489                    _httpResponse.Dispose();
 6490                }
 06491                throw ex;
 6492            }
 6493            // Create Result
 266494            var _result = new HttpOperationResponse<OperationStatus>();
 266495            _result.Request = _httpRequest;
 266496            _result.Response = _httpResponse;
 6497            // Deserialize Response
 266498            if ((int)_statusCode == 200)
 6499            {
 266500                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6501                try
 6502                {
 266503                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 266504                }
 06505                catch (JsonException ex)
 6506                {
 06507                    _httpRequest.Dispose();
 06508                    if (_httpResponse != null)
 6509                    {
 06510                        _httpResponse.Dispose();
 6511                    }
 06512                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6513                }
 6514            }
 266515            if (_shouldTrace)
 6516            {
 06517                ServiceClientTracing.Exit(_invocationId, _result);
 6518            }
 266519            return _result;
 266520        }
 6521
 6522        /// <summary>
 6523        /// Deletes a sublist of a specific list entity model from a version of the
 6524        /// application.
 6525        /// </summary>
 6526        /// <param name='appId'>
 6527        /// The application ID.
 6528        /// </param>
 6529        /// <param name='versionId'>
 6530        /// The version ID.
 6531        /// </param>
 6532        /// <param name='clEntityId'>
 6533        /// The list entity extractor ID.
 6534        /// </param>
 6535        /// <param name='subListId'>
 6536        /// The sublist ID.
 6537        /// </param>
 6538        /// <param name='customHeaders'>
 6539        /// Headers that will be added to request.
 6540        /// </param>
 6541        /// <param name='cancellationToken'>
 6542        /// The cancellation token.
 6543        /// </param>
 6544        /// <exception cref="ErrorResponseException">
 6545        /// Thrown when the operation returned an invalid status code
 6546        /// </exception>
 6547        /// <exception cref="SerializationException">
 6548        /// Thrown when unable to deserialize the response
 6549        /// </exception>
 6550        /// <exception cref="ValidationException">
 6551        /// Thrown when a required parameter is null
 6552        /// </exception>
 6553        /// <exception cref="System.ArgumentNullException">
 6554        /// Thrown when a required parameter is null
 6555        /// </exception>
 6556        /// <return>
 6557        /// A response object containing the response body and response headers.
 6558        /// </return>
 6559        public async Task<HttpOperationResponse<OperationStatus>> DeleteSubListWithHttpMessagesAsync(System.Guid appId, 
 6560        {
 16561            if (Client.Endpoint == null)
 6562            {
 06563                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 6564            }
 16565            if (versionId == null)
 6566            {
 06567                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 6568            }
 6569            // Tracing
 16570            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 16571            string _invocationId = null;
 16572            if (_shouldTrace)
 6573            {
 06574                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06575                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06576                tracingParameters.Add("appId", appId);
 06577                tracingParameters.Add("versionId", versionId);
 06578                tracingParameters.Add("clEntityId", clEntityId);
 06579                tracingParameters.Add("subListId", subListId);
 06580                tracingParameters.Add("cancellationToken", cancellationToken);
 06581                ServiceClientTracing.Enter(_invocationId, this, "DeleteSubList", tracingParameters);
 6582            }
 6583            // Construct URL
 16584            var _baseUrl = Client.BaseUri;
 16585            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 16586            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 16587            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 16588            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 16589            _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize
 16590            _url = _url.Replace("{subListId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 6591            // Create HTTP transport objects
 16592            var _httpRequest = new HttpRequestMessage();
 16593            HttpResponseMessage _httpResponse = null;
 16594            _httpRequest.Method = new HttpMethod("DELETE");
 16595            _httpRequest.RequestUri = new System.Uri(_url);
 6596            // Set Headers
 6597
 6598
 16599            if (customHeaders != null)
 6600            {
 06601                foreach(var _header in customHeaders)
 6602                {
 06603                    if (_httpRequest.Headers.Contains(_header.Key))
 6604                    {
 06605                        _httpRequest.Headers.Remove(_header.Key);
 6606                    }
 06607                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6608                }
 6609            }
 6610
 6611            // Serialize Request
 16612            string _requestContent = null;
 6613            // Set Credentials
 16614            if (Client.Credentials != null)
 6615            {
 16616                cancellationToken.ThrowIfCancellationRequested();
 16617                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6618            }
 6619            // Send Request
 16620            if (_shouldTrace)
 6621            {
 06622                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6623            }
 16624            cancellationToken.ThrowIfCancellationRequested();
 16625            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 16626            if (_shouldTrace)
 6627            {
 06628                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6629            }
 16630            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 16631            cancellationToken.ThrowIfCancellationRequested();
 16632            string _responseContent = null;
 16633            if ((int)_statusCode != 200)
 6634            {
 06635                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 6636                try
 6637                {
 06638                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06639                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 06640                    if (_errorBody != null)
 6641                    {
 06642                        ex.Body = _errorBody;
 6643                    }
 06644                }
 06645                catch (JsonException)
 6646                {
 6647                    // Ignore the exception
 06648                }
 06649                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06650                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06651                if (_shouldTrace)
 6652                {
 06653                    ServiceClientTracing.Error(_invocationId, ex);
 6654                }
 06655                _httpRequest.Dispose();
 06656                if (_httpResponse != null)
 6657                {
 06658                    _httpResponse.Dispose();
 6659                }
 06660                throw ex;
 6661            }
 6662            // Create Result
 16663            var _result = new HttpOperationResponse<OperationStatus>();
 16664            _result.Request = _httpRequest;
 16665            _result.Response = _httpResponse;
 6666            // Deserialize Response
 16667            if ((int)_statusCode == 200)
 6668            {
 16669                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6670                try
 6671                {
 16672                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 16673                }
 06674                catch (JsonException ex)
 6675                {
 06676                    _httpRequest.Dispose();
 06677                    if (_httpResponse != null)
 6678                    {
 06679                        _httpResponse.Dispose();
 6680                    }
 06681                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6682                }
 6683            }
 16684            if (_shouldTrace)
 6685            {
 06686                ServiceClientTracing.Exit(_invocationId, _result);
 6687            }
 16688            return _result;
 16689        }
 6690
 6691        /// <summary>
 6692        /// Updates one of the list entity's sublists in a version of the application.
 6693        /// </summary>
 6694        /// <param name='appId'>
 6695        /// The application ID.
 6696        /// </param>
 6697        /// <param name='versionId'>
 6698        /// The version ID.
 6699        /// </param>
 6700        /// <param name='clEntityId'>
 6701        /// The list entity extractor ID.
 6702        /// </param>
 6703        /// <param name='subListId'>
 6704        /// The sublist ID.
 6705        /// </param>
 6706        /// <param name='wordListBaseUpdateObject'>
 6707        /// A sublist update object containing the new canonical form and the list of
 6708        /// words.
 6709        /// </param>
 6710        /// <param name='customHeaders'>
 6711        /// Headers that will be added to request.
 6712        /// </param>
 6713        /// <param name='cancellationToken'>
 6714        /// The cancellation token.
 6715        /// </param>
 6716        /// <exception cref="ErrorResponseException">
 6717        /// Thrown when the operation returned an invalid status code
 6718        /// </exception>
 6719        /// <exception cref="SerializationException">
 6720        /// Thrown when unable to deserialize the response
 6721        /// </exception>
 6722        /// <exception cref="ValidationException">
 6723        /// Thrown when a required parameter is null
 6724        /// </exception>
 6725        /// <exception cref="System.ArgumentNullException">
 6726        /// Thrown when a required parameter is null
 6727        /// </exception>
 6728        /// <return>
 6729        /// A response object containing the response body and response headers.
 6730        /// </return>
 6731        public async Task<HttpOperationResponse<OperationStatus>> UpdateSubListWithHttpMessagesAsync(System.Guid appId, 
 6732        {
 16733            if (Client.Endpoint == null)
 6734            {
 06735                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 6736            }
 16737            if (versionId == null)
 6738            {
 06739                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 6740            }
 16741            if (wordListBaseUpdateObject == null)
 6742            {
 06743                throw new ValidationException(ValidationRules.CannotBeNull, "wordListBaseUpdateObject");
 6744            }
 6745            // Tracing
 16746            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 16747            string _invocationId = null;
 16748            if (_shouldTrace)
 6749            {
 06750                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06751                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06752                tracingParameters.Add("appId", appId);
 06753                tracingParameters.Add("versionId", versionId);
 06754                tracingParameters.Add("clEntityId", clEntityId);
 06755                tracingParameters.Add("subListId", subListId);
 06756                tracingParameters.Add("wordListBaseUpdateObject", wordListBaseUpdateObject);
 06757                tracingParameters.Add("cancellationToken", cancellationToken);
 06758                ServiceClientTracing.Enter(_invocationId, this, "UpdateSubList", tracingParameters);
 6759            }
 6760            // Construct URL
 16761            var _baseUrl = Client.BaseUri;
 16762            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 16763            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 16764            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 16765            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 16766            _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize
 16767            _url = _url.Replace("{subListId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 6768            // Create HTTP transport objects
 16769            var _httpRequest = new HttpRequestMessage();
 16770            HttpResponseMessage _httpResponse = null;
 16771            _httpRequest.Method = new HttpMethod("PUT");
 16772            _httpRequest.RequestUri = new System.Uri(_url);
 6773            // Set Headers
 6774
 6775
 16776            if (customHeaders != null)
 6777            {
 06778                foreach(var _header in customHeaders)
 6779                {
 06780                    if (_httpRequest.Headers.Contains(_header.Key))
 6781                    {
 06782                        _httpRequest.Headers.Remove(_header.Key);
 6783                    }
 06784                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6785                }
 6786            }
 6787
 6788            // Serialize Request
 16789            string _requestContent = null;
 16790            if(wordListBaseUpdateObject != null)
 6791            {
 16792                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(wordListBaseUpdateObject, Client.Se
 16793                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 16794                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 6795            }
 6796            // Set Credentials
 16797            if (Client.Credentials != null)
 6798            {
 16799                cancellationToken.ThrowIfCancellationRequested();
 16800                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6801            }
 6802            // Send Request
 16803            if (_shouldTrace)
 6804            {
 06805                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6806            }
 16807            cancellationToken.ThrowIfCancellationRequested();
 16808            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 16809            if (_shouldTrace)
 6810            {
 06811                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6812            }
 16813            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 16814            cancellationToken.ThrowIfCancellationRequested();
 16815            string _responseContent = null;
 16816            if ((int)_statusCode != 200)
 6817            {
 06818                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 6819                try
 6820                {
 06821                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06822                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 06823                    if (_errorBody != null)
 6824                    {
 06825                        ex.Body = _errorBody;
 6826                    }
 06827                }
 06828                catch (JsonException)
 6829                {
 6830                    // Ignore the exception
 06831                }
 06832                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06833                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06834                if (_shouldTrace)
 6835                {
 06836                    ServiceClientTracing.Error(_invocationId, ex);
 6837                }
 06838                _httpRequest.Dispose();
 06839                if (_httpResponse != null)
 6840                {
 06841                    _httpResponse.Dispose();
 6842                }
 06843                throw ex;
 6844            }
 6845            // Create Result
 16846            var _result = new HttpOperationResponse<OperationStatus>();
 16847            _result.Request = _httpRequest;
 16848            _result.Response = _httpResponse;
 6849            // Deserialize Response
 16850            if ((int)_statusCode == 200)
 6851            {
 16852                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6853                try
 6854                {
 16855                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 16856                }
 06857                catch (JsonException ex)
 6858                {
 06859                    _httpRequest.Dispose();
 06860                    if (_httpResponse != null)
 6861                    {
 06862                        _httpResponse.Dispose();
 6863                    }
 06864                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6865                }
 6866            }
 16867            if (_shouldTrace)
 6868            {
 06869                ServiceClientTracing.Exit(_invocationId, _result);
 6870            }
 16871            return _result;
 16872        }
 6873
 6874        /// <summary>
 6875        /// Suggests example utterances that would improve the accuracy of the intent
 6876        /// model in a version of the application.
 6877        /// </summary>
 6878        /// <param name='appId'>
 6879        /// The application ID.
 6880        /// </param>
 6881        /// <param name='versionId'>
 6882        /// The version ID.
 6883        /// </param>
 6884        /// <param name='intentId'>
 6885        /// The intent classifier ID.
 6886        /// </param>
 6887        /// <param name='take'>
 6888        /// The number of entries to return. Maximum page size is 500. Default is 100.
 6889        /// </param>
 6890        /// <param name='enableNestedChildren'>
 6891        /// Toggles nested/flat format
 6892        /// </param>
 6893        /// <param name='customHeaders'>
 6894        /// Headers that will be added to request.
 6895        /// </param>
 6896        /// <param name='cancellationToken'>
 6897        /// The cancellation token.
 6898        /// </param>
 6899        /// <exception cref="ErrorResponseException">
 6900        /// Thrown when the operation returned an invalid status code
 6901        /// </exception>
 6902        /// <exception cref="SerializationException">
 6903        /// Thrown when unable to deserialize the response
 6904        /// </exception>
 6905        /// <exception cref="ValidationException">
 6906        /// Thrown when a required parameter is null
 6907        /// </exception>
 6908        /// <exception cref="System.ArgumentNullException">
 6909        /// Thrown when a required parameter is null
 6910        /// </exception>
 6911        /// <return>
 6912        /// A response object containing the response body and response headers.
 6913        /// </return>
 6914        public async Task<HttpOperationResponse<IList<IntentsSuggestionExample>>> ListIntentSuggestionsWithHttpMessagesA
 6915        {
 06916            if (Client.Endpoint == null)
 6917            {
 06918                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 6919            }
 06920            if (versionId == null)
 6921            {
 06922                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 6923            }
 06924            if (take > 500)
 6925            {
 06926                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 6927            }
 06928            if (take < 0)
 6929            {
 06930                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 6931            }
 6932            // Tracing
 06933            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 06934            string _invocationId = null;
 06935            if (_shouldTrace)
 6936            {
 06937                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06938                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06939                tracingParameters.Add("appId", appId);
 06940                tracingParameters.Add("versionId", versionId);
 06941                tracingParameters.Add("intentId", intentId);
 06942                tracingParameters.Add("take", take);
 06943                tracingParameters.Add("enableNestedChildren", enableNestedChildren);
 06944                tracingParameters.Add("cancellationToken", cancellationToken);
 06945                ServiceClientTracing.Enter(_invocationId, this, "ListIntentSuggestions", tracingParameters);
 6946            }
 6947            // Construct URL
 06948            var _baseUrl = Client.BaseUri;
 06949            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte
 06950            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 06951            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 06952            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 06953            _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 06954            List<string> _queryParameters = new List<string>();
 06955            if (take != null)
 6956            {
 06957                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 6958            }
 06959            if (enableNestedChildren != null)
 6960            {
 06961                _queryParameters.Add(string.Format("enableNestedChildren={0}", System.Uri.EscapeDataString(Rest.Serializ
 6962            }
 06963            if (_queryParameters.Count > 0)
 6964            {
 06965                _url += "?" + string.Join("&", _queryParameters);
 6966            }
 6967            // Create HTTP transport objects
 06968            var _httpRequest = new HttpRequestMessage();
 06969            HttpResponseMessage _httpResponse = null;
 06970            _httpRequest.Method = new HttpMethod("GET");
 06971            _httpRequest.RequestUri = new System.Uri(_url);
 6972            // Set Headers
 6973
 6974
 06975            if (customHeaders != null)
 6976            {
 06977                foreach(var _header in customHeaders)
 6978                {
 06979                    if (_httpRequest.Headers.Contains(_header.Key))
 6980                    {
 06981                        _httpRequest.Headers.Remove(_header.Key);
 6982                    }
 06983                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6984                }
 6985            }
 6986
 6987            // Serialize Request
 06988            string _requestContent = null;
 6989            // Set Credentials
 06990            if (Client.Credentials != null)
 6991            {
 06992                cancellationToken.ThrowIfCancellationRequested();
 06993                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6994            }
 6995            // Send Request
 06996            if (_shouldTrace)
 6997            {
 06998                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6999            }
 07000            cancellationToken.ThrowIfCancellationRequested();
 07001            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 07002            if (_shouldTrace)
 7003            {
 07004                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7005            }
 07006            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 07007            cancellationToken.ThrowIfCancellationRequested();
 07008            string _responseContent = null;
 07009            if ((int)_statusCode != 200)
 7010            {
 07011                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 7012                try
 7013                {
 07014                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07015                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 07016                    if (_errorBody != null)
 7017                    {
 07018                        ex.Body = _errorBody;
 7019                    }
 07020                }
 07021                catch (JsonException)
 7022                {
 7023                    // Ignore the exception
 07024                }
 07025                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07026                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07027                if (_shouldTrace)
 7028                {
 07029                    ServiceClientTracing.Error(_invocationId, ex);
 7030                }
 07031                _httpRequest.Dispose();
 07032                if (_httpResponse != null)
 7033                {
 07034                    _httpResponse.Dispose();
 7035                }
 07036                throw ex;
 7037            }
 7038            // Create Result
 07039            var _result = new HttpOperationResponse<IList<IntentsSuggestionExample>>();
 07040            _result.Request = _httpRequest;
 07041            _result.Response = _httpResponse;
 7042            // Deserialize Response
 07043            if ((int)_statusCode == 200)
 7044            {
 07045                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7046                try
 7047                {
 07048                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<IntentsSuggestionExample>>
 07049                }
 07050                catch (JsonException ex)
 7051                {
 07052                    _httpRequest.Dispose();
 07053                    if (_httpResponse != null)
 7054                    {
 07055                        _httpResponse.Dispose();
 7056                    }
 07057                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7058                }
 7059            }
 07060            if (_shouldTrace)
 7061            {
 07062                ServiceClientTracing.Exit(_invocationId, _result);
 7063            }
 07064            return _result;
 07065        }
 7066
 7067        /// <summary>
 7068        /// Get suggested example utterances that would improve the accuracy of the
 7069        /// entity model in a version of the application.
 7070        /// </summary>
 7071        /// <param name='appId'>
 7072        /// The application ID.
 7073        /// </param>
 7074        /// <param name='versionId'>
 7075        /// The version ID.
 7076        /// </param>
 7077        /// <param name='entityId'>
 7078        /// The target entity extractor model to enhance.
 7079        /// </param>
 7080        /// <param name='take'>
 7081        /// The number of entries to return. Maximum page size is 500. Default is 100.
 7082        /// </param>
 7083        /// <param name='enableNestedChildren'>
 7084        /// Toggles nested/flat format
 7085        /// </param>
 7086        /// <param name='customHeaders'>
 7087        /// Headers that will be added to request.
 7088        /// </param>
 7089        /// <param name='cancellationToken'>
 7090        /// The cancellation token.
 7091        /// </param>
 7092        /// <exception cref="ErrorResponseException">
 7093        /// Thrown when the operation returned an invalid status code
 7094        /// </exception>
 7095        /// <exception cref="SerializationException">
 7096        /// Thrown when unable to deserialize the response
 7097        /// </exception>
 7098        /// <exception cref="ValidationException">
 7099        /// Thrown when a required parameter is null
 7100        /// </exception>
 7101        /// <exception cref="System.ArgumentNullException">
 7102        /// Thrown when a required parameter is null
 7103        /// </exception>
 7104        /// <return>
 7105        /// A response object containing the response body and response headers.
 7106        /// </return>
 7107        public async Task<HttpOperationResponse<IList<EntitiesSuggestionExample>>> ListEntitySuggestionsWithHttpMessages
 7108        {
 17109            if (Client.Endpoint == null)
 7110            {
 07111                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 7112            }
 17113            if (versionId == null)
 7114            {
 07115                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 7116            }
 17117            if (take > 500)
 7118            {
 07119                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 7120            }
 17121            if (take < 0)
 7122            {
 07123                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 7124            }
 7125            // Tracing
 17126            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 17127            string _invocationId = null;
 17128            if (_shouldTrace)
 7129            {
 07130                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07131                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07132                tracingParameters.Add("appId", appId);
 07133                tracingParameters.Add("versionId", versionId);
 07134                tracingParameters.Add("entityId", entityId);
 07135                tracingParameters.Add("take", take);
 07136                tracingParameters.Add("enableNestedChildren", enableNestedChildren);
 07137                tracingParameters.Add("cancellationToken", cancellationToken);
 07138                ServiceClientTracing.Enter(_invocationId, this, "ListEntitySuggestions", tracingParameters);
 7139            }
 7140            // Construct URL
 17141            var _baseUrl = Client.BaseUri;
 17142            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 17143            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 17144            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 17145            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 17146            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 17147            List<string> _queryParameters = new List<string>();
 17148            if (take != null)
 7149            {
 17150                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 7151            }
 17152            if (enableNestedChildren != null)
 7153            {
 17154                _queryParameters.Add(string.Format("enableNestedChildren={0}", System.Uri.EscapeDataString(Rest.Serializ
 7155            }
 17156            if (_queryParameters.Count > 0)
 7157            {
 17158                _url += "?" + string.Join("&", _queryParameters);
 7159            }
 7160            // Create HTTP transport objects
 17161            var _httpRequest = new HttpRequestMessage();
 17162            HttpResponseMessage _httpResponse = null;
 17163            _httpRequest.Method = new HttpMethod("GET");
 17164            _httpRequest.RequestUri = new System.Uri(_url);
 7165            // Set Headers
 7166
 7167
 17168            if (customHeaders != null)
 7169            {
 07170                foreach(var _header in customHeaders)
 7171                {
 07172                    if (_httpRequest.Headers.Contains(_header.Key))
 7173                    {
 07174                        _httpRequest.Headers.Remove(_header.Key);
 7175                    }
 07176                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7177                }
 7178            }
 7179
 7180            // Serialize Request
 17181            string _requestContent = null;
 7182            // Set Credentials
 17183            if (Client.Credentials != null)
 7184            {
 17185                cancellationToken.ThrowIfCancellationRequested();
 17186                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7187            }
 7188            // Send Request
 17189            if (_shouldTrace)
 7190            {
 07191                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7192            }
 17193            cancellationToken.ThrowIfCancellationRequested();
 17194            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 17195            if (_shouldTrace)
 7196            {
 07197                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7198            }
 17199            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 17200            cancellationToken.ThrowIfCancellationRequested();
 17201            string _responseContent = null;
 17202            if ((int)_statusCode != 200)
 7203            {
 07204                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 7205                try
 7206                {
 07207                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07208                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 07209                    if (_errorBody != null)
 7210                    {
 07211                        ex.Body = _errorBody;
 7212                    }
 07213                }
 07214                catch (JsonException)
 7215                {
 7216                    // Ignore the exception
 07217                }
 07218                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07219                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07220                if (_shouldTrace)
 7221                {
 07222                    ServiceClientTracing.Error(_invocationId, ex);
 7223                }
 07224                _httpRequest.Dispose();
 07225                if (_httpResponse != null)
 7226                {
 07227                    _httpResponse.Dispose();
 7228                }
 07229                throw ex;
 7230            }
 7231            // Create Result
 17232            var _result = new HttpOperationResponse<IList<EntitiesSuggestionExample>>();
 17233            _result.Request = _httpRequest;
 17234            _result.Response = _httpResponse;
 7235            // Deserialize Response
 17236            if ((int)_statusCode == 200)
 7237            {
 17238                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7239                try
 7240                {
 17241                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntitiesSuggestionExample>
 17242                }
 07243                catch (JsonException ex)
 7244                {
 07245                    _httpRequest.Dispose();
 07246                    if (_httpResponse != null)
 7247                    {
 07248                        _httpResponse.Dispose();
 7249                    }
 07250                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7251                }
 7252            }
 17253            if (_shouldTrace)
 7254            {
 07255                ServiceClientTracing.Exit(_invocationId, _result);
 7256            }
 17257            return _result;
 17258        }
 7259
 7260        /// <summary>
 7261        /// Adds a sublist to an existing list entity in a version of the application.
 7262        /// </summary>
 7263        /// <param name='appId'>
 7264        /// The application ID.
 7265        /// </param>
 7266        /// <param name='versionId'>
 7267        /// The version ID.
 7268        /// </param>
 7269        /// <param name='clEntityId'>
 7270        /// The list entity extractor ID.
 7271        /// </param>
 7272        /// <param name='wordListCreateObject'>
 7273        /// Words list.
 7274        /// </param>
 7275        /// <param name='customHeaders'>
 7276        /// Headers that will be added to request.
 7277        /// </param>
 7278        /// <param name='cancellationToken'>
 7279        /// The cancellation token.
 7280        /// </param>
 7281        /// <exception cref="ErrorResponseException">
 7282        /// Thrown when the operation returned an invalid status code
 7283        /// </exception>
 7284        /// <exception cref="SerializationException">
 7285        /// Thrown when unable to deserialize the response
 7286        /// </exception>
 7287        /// <exception cref="ValidationException">
 7288        /// Thrown when a required parameter is null
 7289        /// </exception>
 7290        /// <exception cref="System.ArgumentNullException">
 7291        /// Thrown when a required parameter is null
 7292        /// </exception>
 7293        /// <return>
 7294        /// A response object containing the response body and response headers.
 7295        /// </return>
 7296        public async Task<HttpOperationResponse<long?>> AddSubListWithHttpMessagesAsync(System.Guid appId, string versio
 7297        {
 17298            if (Client.Endpoint == null)
 7299            {
 07300                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 7301            }
 17302            if (versionId == null)
 7303            {
 07304                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 7305            }
 17306            if (wordListCreateObject == null)
 7307            {
 07308                throw new ValidationException(ValidationRules.CannotBeNull, "wordListCreateObject");
 7309            }
 7310            // Tracing
 17311            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 17312            string _invocationId = null;
 17313            if (_shouldTrace)
 7314            {
 07315                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07316                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07317                tracingParameters.Add("appId", appId);
 07318                tracingParameters.Add("versionId", versionId);
 07319                tracingParameters.Add("clEntityId", clEntityId);
 07320                tracingParameters.Add("wordListCreateObject", wordListCreateObject);
 07321                tracingParameters.Add("cancellationToken", cancellationToken);
 07322                ServiceClientTracing.Enter(_invocationId, this, "AddSubList", tracingParameters);
 7323            }
 7324            // Construct URL
 17325            var _baseUrl = Client.BaseUri;
 17326            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 17327            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 17328            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 17329            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 17330            _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize
 7331            // Create HTTP transport objects
 17332            var _httpRequest = new HttpRequestMessage();
 17333            HttpResponseMessage _httpResponse = null;
 17334            _httpRequest.Method = new HttpMethod("POST");
 17335            _httpRequest.RequestUri = new System.Uri(_url);
 7336            // Set Headers
 7337
 7338
 17339            if (customHeaders != null)
 7340            {
 07341                foreach(var _header in customHeaders)
 7342                {
 07343                    if (_httpRequest.Headers.Contains(_header.Key))
 7344                    {
 07345                        _httpRequest.Headers.Remove(_header.Key);
 7346                    }
 07347                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7348                }
 7349            }
 7350
 7351            // Serialize Request
 17352            string _requestContent = null;
 17353            if(wordListCreateObject != null)
 7354            {
 17355                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(wordListCreateObject, Client.Serial
 17356                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 17357                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 7358            }
 7359            // Set Credentials
 17360            if (Client.Credentials != null)
 7361            {
 17362                cancellationToken.ThrowIfCancellationRequested();
 17363                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7364            }
 7365            // Send Request
 17366            if (_shouldTrace)
 7367            {
 07368                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7369            }
 17370            cancellationToken.ThrowIfCancellationRequested();
 17371            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 17372            if (_shouldTrace)
 7373            {
 07374                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7375            }
 17376            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 17377            cancellationToken.ThrowIfCancellationRequested();
 17378            string _responseContent = null;
 17379            if ((int)_statusCode != 201)
 7380            {
 07381                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 7382                try
 7383                {
 07384                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07385                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 07386                    if (_errorBody != null)
 7387                    {
 07388                        ex.Body = _errorBody;
 7389                    }
 07390                }
 07391                catch (JsonException)
 7392                {
 7393                    // Ignore the exception
 07394                }
 07395                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07396                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07397                if (_shouldTrace)
 7398                {
 07399                    ServiceClientTracing.Error(_invocationId, ex);
 7400                }
 07401                _httpRequest.Dispose();
 07402                if (_httpResponse != null)
 7403                {
 07404                    _httpResponse.Dispose();
 7405                }
 07406                throw ex;
 7407            }
 7408            // Create Result
 17409            var _result = new HttpOperationResponse<long?>();
 17410            _result.Request = _httpRequest;
 17411            _result.Response = _httpResponse;
 7412            // Deserialize Response
 17413            if ((int)_statusCode == 201)
 7414            {
 17415                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7416                try
 7417                {
 17418                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<long?>(_responseContent, Client.
 17419                }
 07420                catch (JsonException ex)
 7421                {
 07422                    _httpRequest.Dispose();
 07423                    if (_httpResponse != null)
 7424                    {
 07425                        _httpResponse.Dispose();
 7426                    }
 07427                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7428                }
 7429            }
 17430            if (_shouldTrace)
 7431            {
 07432                ServiceClientTracing.Exit(_invocationId, _result);
 7433            }
 17434            return _result;
 17435        }
 7436
 7437        /// <summary>
 7438        /// Adds a customizable prebuilt domain along with all of its intent and entity
 7439        /// models in a version of the application.
 7440        /// </summary>
 7441        /// <param name='appId'>
 7442        /// The application ID.
 7443        /// </param>
 7444        /// <param name='versionId'>
 7445        /// The version ID.
 7446        /// </param>
 7447        /// <param name='prebuiltDomainObject'>
 7448        /// A prebuilt domain create object containing the name of the domain.
 7449        /// </param>
 7450        /// <param name='customHeaders'>
 7451        /// Headers that will be added to request.
 7452        /// </param>
 7453        /// <param name='cancellationToken'>
 7454        /// The cancellation token.
 7455        /// </param>
 7456        /// <exception cref="ErrorResponseException">
 7457        /// Thrown when the operation returned an invalid status code
 7458        /// </exception>
 7459        /// <exception cref="SerializationException">
 7460        /// Thrown when unable to deserialize the response
 7461        /// </exception>
 7462        /// <exception cref="ValidationException">
 7463        /// Thrown when a required parameter is null
 7464        /// </exception>
 7465        /// <exception cref="System.ArgumentNullException">
 7466        /// Thrown when a required parameter is null
 7467        /// </exception>
 7468        /// <return>
 7469        /// A response object containing the response body and response headers.
 7470        /// </return>
 7471        public async Task<HttpOperationResponse<IList<System.Guid?>>> AddCustomPrebuiltDomainWithHttpMessagesAsync(Syste
 7472        {
 57473            if (Client.Endpoint == null)
 7474            {
 07475                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 7476            }
 57477            if (versionId == null)
 7478            {
 07479                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 7480            }
 57481            if (prebuiltDomainObject == null)
 7482            {
 07483                throw new ValidationException(ValidationRules.CannotBeNull, "prebuiltDomainObject");
 7484            }
 7485            // Tracing
 57486            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 57487            string _invocationId = null;
 57488            if (_shouldTrace)
 7489            {
 07490                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07491                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07492                tracingParameters.Add("appId", appId);
 07493                tracingParameters.Add("versionId", versionId);
 07494                tracingParameters.Add("prebuiltDomainObject", prebuiltDomainObject);
 07495                tracingParameters.Add("cancellationToken", cancellationToken);
 07496                ServiceClientTracing.Enter(_invocationId, this, "AddCustomPrebuiltDomain", tracingParameters);
 7497            }
 7498            // Construct URL
 57499            var _baseUrl = Client.BaseUri;
 57500            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 57501            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 57502            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 57503            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 7504            // Create HTTP transport objects
 57505            var _httpRequest = new HttpRequestMessage();
 57506            HttpResponseMessage _httpResponse = null;
 57507            _httpRequest.Method = new HttpMethod("POST");
 57508            _httpRequest.RequestUri = new System.Uri(_url);
 7509            // Set Headers
 7510
 7511
 57512            if (customHeaders != null)
 7513            {
 07514                foreach(var _header in customHeaders)
 7515                {
 07516                    if (_httpRequest.Headers.Contains(_header.Key))
 7517                    {
 07518                        _httpRequest.Headers.Remove(_header.Key);
 7519                    }
 07520                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7521                }
 7522            }
 7523
 7524            // Serialize Request
 57525            string _requestContent = null;
 57526            if(prebuiltDomainObject != null)
 7527            {
 57528                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(prebuiltDomainObject, Client.Serial
 57529                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 57530                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 7531            }
 7532            // Set Credentials
 57533            if (Client.Credentials != null)
 7534            {
 57535                cancellationToken.ThrowIfCancellationRequested();
 57536                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7537            }
 7538            // Send Request
 57539            if (_shouldTrace)
 7540            {
 07541                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7542            }
 57543            cancellationToken.ThrowIfCancellationRequested();
 57544            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 57545            if (_shouldTrace)
 7546            {
 07547                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7548            }
 57549            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 57550            cancellationToken.ThrowIfCancellationRequested();
 57551            string _responseContent = null;
 57552            if ((int)_statusCode != 201)
 7553            {
 07554                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 7555                try
 7556                {
 07557                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07558                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 07559                    if (_errorBody != null)
 7560                    {
 07561                        ex.Body = _errorBody;
 7562                    }
 07563                }
 07564                catch (JsonException)
 7565                {
 7566                    // Ignore the exception
 07567                }
 07568                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07569                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07570                if (_shouldTrace)
 7571                {
 07572                    ServiceClientTracing.Error(_invocationId, ex);
 7573                }
 07574                _httpRequest.Dispose();
 07575                if (_httpResponse != null)
 7576                {
 07577                    _httpResponse.Dispose();
 7578                }
 07579                throw ex;
 7580            }
 7581            // Create Result
 57582            var _result = new HttpOperationResponse<IList<System.Guid?>>();
 57583            _result.Request = _httpRequest;
 57584            _result.Response = _httpResponse;
 7585            // Deserialize Response
 57586            if ((int)_statusCode == 201)
 7587            {
 57588                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7589                try
 7590                {
 57591                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<System.Guid?>>(_responseCo
 57592                }
 07593                catch (JsonException ex)
 7594                {
 07595                    _httpRequest.Dispose();
 07596                    if (_httpResponse != null)
 7597                    {
 07598                        _httpResponse.Dispose();
 7599                    }
 07600                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7601                }
 7602            }
 57603            if (_shouldTrace)
 7604            {
 07605                ServiceClientTracing.Exit(_invocationId, _result);
 7606            }
 57607            return _result;
 57608        }
 7609
 7610        /// <summary>
 7611        /// Adds a customizable prebuilt intent model to a version of the application.
 7612        /// </summary>
 7613        /// <param name='appId'>
 7614        /// The application ID.
 7615        /// </param>
 7616        /// <param name='versionId'>
 7617        /// The version ID.
 7618        /// </param>
 7619        /// <param name='prebuiltDomainModelCreateObject'>
 7620        /// A model object containing the name of the customizable prebuilt intent and
 7621        /// the name of the domain to which this model belongs.
 7622        /// </param>
 7623        /// <param name='customHeaders'>
 7624        /// Headers that will be added to request.
 7625        /// </param>
 7626        /// <param name='cancellationToken'>
 7627        /// The cancellation token.
 7628        /// </param>
 7629        /// <exception cref="ErrorResponseException">
 7630        /// Thrown when the operation returned an invalid status code
 7631        /// </exception>
 7632        /// <exception cref="SerializationException">
 7633        /// Thrown when unable to deserialize the response
 7634        /// </exception>
 7635        /// <exception cref="ValidationException">
 7636        /// Thrown when a required parameter is null
 7637        /// </exception>
 7638        /// <exception cref="System.ArgumentNullException">
 7639        /// Thrown when a required parameter is null
 7640        /// </exception>
 7641        /// <return>
 7642        /// A response object containing the response body and response headers.
 7643        /// </return>
 7644        public async Task<HttpOperationResponse<System.Guid>> AddCustomPrebuiltIntentWithHttpMessagesAsync(System.Guid a
 7645        {
 17646            if (Client.Endpoint == null)
 7647            {
 07648                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 7649            }
 17650            if (versionId == null)
 7651            {
 07652                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 7653            }
 17654            if (prebuiltDomainModelCreateObject == null)
 7655            {
 07656                throw new ValidationException(ValidationRules.CannotBeNull, "prebuiltDomainModelCreateObject");
 7657            }
 7658            // Tracing
 17659            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 17660            string _invocationId = null;
 17661            if (_shouldTrace)
 7662            {
 07663                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07664                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07665                tracingParameters.Add("appId", appId);
 07666                tracingParameters.Add("versionId", versionId);
 07667                tracingParameters.Add("prebuiltDomainModelCreateObject", prebuiltDomainModelCreateObject);
 07668                tracingParameters.Add("cancellationToken", cancellationToken);
 07669                ServiceClientTracing.Enter(_invocationId, this, "AddCustomPrebuiltIntent", tracingParameters);
 7670            }
 7671            // Construct URL
 17672            var _baseUrl = Client.BaseUri;
 17673            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 17674            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 17675            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 17676            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 7677            // Create HTTP transport objects
 17678            var _httpRequest = new HttpRequestMessage();
 17679            HttpResponseMessage _httpResponse = null;
 17680            _httpRequest.Method = new HttpMethod("POST");
 17681            _httpRequest.RequestUri = new System.Uri(_url);
 7682            // Set Headers
 7683
 7684
 17685            if (customHeaders != null)
 7686            {
 07687                foreach(var _header in customHeaders)
 7688                {
 07689                    if (_httpRequest.Headers.Contains(_header.Key))
 7690                    {
 07691                        _httpRequest.Headers.Remove(_header.Key);
 7692                    }
 07693                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7694                }
 7695            }
 7696
 7697            // Serialize Request
 17698            string _requestContent = null;
 17699            if(prebuiltDomainModelCreateObject != null)
 7700            {
 17701                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(prebuiltDomainModelCreateObject, Cl
 17702                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 17703                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 7704            }
 7705            // Set Credentials
 17706            if (Client.Credentials != null)
 7707            {
 17708                cancellationToken.ThrowIfCancellationRequested();
 17709                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7710            }
 7711            // Send Request
 17712            if (_shouldTrace)
 7713            {
 07714                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7715            }
 17716            cancellationToken.ThrowIfCancellationRequested();
 17717            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 17718            if (_shouldTrace)
 7719            {
 07720                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7721            }
 17722            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 17723            cancellationToken.ThrowIfCancellationRequested();
 17724            string _responseContent = null;
 17725            if ((int)_statusCode != 201)
 7726            {
 07727                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 7728                try
 7729                {
 07730                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07731                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 07732                    if (_errorBody != null)
 7733                    {
 07734                        ex.Body = _errorBody;
 7735                    }
 07736                }
 07737                catch (JsonException)
 7738                {
 7739                    // Ignore the exception
 07740                }
 07741                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07742                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07743                if (_shouldTrace)
 7744                {
 07745                    ServiceClientTracing.Error(_invocationId, ex);
 7746                }
 07747                _httpRequest.Dispose();
 07748                if (_httpResponse != null)
 7749                {
 07750                    _httpResponse.Dispose();
 7751                }
 07752                throw ex;
 7753            }
 7754            // Create Result
 17755            var _result = new HttpOperationResponse<System.Guid>();
 17756            _result.Request = _httpRequest;
 17757            _result.Response = _httpResponse;
 7758            // Deserialize Response
 17759            if ((int)_statusCode == 201)
 7760            {
 17761                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7762                try
 7763                {
 17764                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 17765                }
 07766                catch (JsonException ex)
 7767                {
 07768                    _httpRequest.Dispose();
 07769                    if (_httpResponse != null)
 7770                    {
 07771                        _httpResponse.Dispose();
 7772                    }
 07773                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7774                }
 7775            }
 17776            if (_shouldTrace)
 7777            {
 07778                ServiceClientTracing.Exit(_invocationId, _result);
 7779            }
 17780            return _result;
 17781        }
 7782
 7783        /// <summary>
 7784        /// Gets information about customizable prebuilt intents added to a version of
 7785        /// the application.
 7786        /// </summary>
 7787        /// <param name='appId'>
 7788        /// The application ID.
 7789        /// </param>
 7790        /// <param name='versionId'>
 7791        /// The version ID.
 7792        /// </param>
 7793        /// <param name='customHeaders'>
 7794        /// Headers that will be added to request.
 7795        /// </param>
 7796        /// <param name='cancellationToken'>
 7797        /// The cancellation token.
 7798        /// </param>
 7799        /// <exception cref="ErrorResponseException">
 7800        /// Thrown when the operation returned an invalid status code
 7801        /// </exception>
 7802        /// <exception cref="SerializationException">
 7803        /// Thrown when unable to deserialize the response
 7804        /// </exception>
 7805        /// <exception cref="ValidationException">
 7806        /// Thrown when a required parameter is null
 7807        /// </exception>
 7808        /// <exception cref="System.ArgumentNullException">
 7809        /// Thrown when a required parameter is null
 7810        /// </exception>
 7811        /// <return>
 7812        /// A response object containing the response body and response headers.
 7813        /// </return>
 7814        public async Task<HttpOperationResponse<IList<IntentClassifier>>> ListCustomPrebuiltIntentsWithHttpMessagesAsync
 7815        {
 27816            if (Client.Endpoint == null)
 7817            {
 07818                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 7819            }
 27820            if (versionId == null)
 7821            {
 07822                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 7823            }
 7824            // Tracing
 27825            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 27826            string _invocationId = null;
 27827            if (_shouldTrace)
 7828            {
 07829                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07830                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07831                tracingParameters.Add("appId", appId);
 07832                tracingParameters.Add("versionId", versionId);
 07833                tracingParameters.Add("cancellationToken", cancellationToken);
 07834                ServiceClientTracing.Enter(_invocationId, this, "ListCustomPrebuiltIntents", tracingParameters);
 7835            }
 7836            // Construct URL
 27837            var _baseUrl = Client.BaseUri;
 27838            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 27839            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 27840            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 27841            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 7842            // Create HTTP transport objects
 27843            var _httpRequest = new HttpRequestMessage();
 27844            HttpResponseMessage _httpResponse = null;
 27845            _httpRequest.Method = new HttpMethod("GET");
 27846            _httpRequest.RequestUri = new System.Uri(_url);
 7847            // Set Headers
 7848
 7849
 27850            if (customHeaders != null)
 7851            {
 07852                foreach(var _header in customHeaders)
 7853                {
 07854                    if (_httpRequest.Headers.Contains(_header.Key))
 7855                    {
 07856                        _httpRequest.Headers.Remove(_header.Key);
 7857                    }
 07858                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7859                }
 7860            }
 7861
 7862            // Serialize Request
 27863            string _requestContent = null;
 7864            // Set Credentials
 27865            if (Client.Credentials != null)
 7866            {
 27867                cancellationToken.ThrowIfCancellationRequested();
 27868                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7869            }
 7870            // Send Request
 27871            if (_shouldTrace)
 7872            {
 07873                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7874            }
 27875            cancellationToken.ThrowIfCancellationRequested();
 27876            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 27877            if (_shouldTrace)
 7878            {
 07879                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7880            }
 27881            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 27882            cancellationToken.ThrowIfCancellationRequested();
 27883            string _responseContent = null;
 27884            if ((int)_statusCode != 200)
 7885            {
 07886                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 7887                try
 7888                {
 07889                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07890                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 07891                    if (_errorBody != null)
 7892                    {
 07893                        ex.Body = _errorBody;
 7894                    }
 07895                }
 07896                catch (JsonException)
 7897                {
 7898                    // Ignore the exception
 07899                }
 07900                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07901                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07902                if (_shouldTrace)
 7903                {
 07904                    ServiceClientTracing.Error(_invocationId, ex);
 7905                }
 07906                _httpRequest.Dispose();
 07907                if (_httpResponse != null)
 7908                {
 07909                    _httpResponse.Dispose();
 7910                }
 07911                throw ex;
 7912            }
 7913            // Create Result
 27914            var _result = new HttpOperationResponse<IList<IntentClassifier>>();
 27915            _result.Request = _httpRequest;
 27916            _result.Response = _httpResponse;
 7917            // Deserialize Response
 27918            if ((int)_statusCode == 200)
 7919            {
 27920                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7921                try
 7922                {
 27923                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<IntentClassifier>>(_respon
 27924                }
 07925                catch (JsonException ex)
 7926                {
 07927                    _httpRequest.Dispose();
 07928                    if (_httpResponse != null)
 7929                    {
 07930                        _httpResponse.Dispose();
 7931                    }
 07932                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7933                }
 7934            }
 27935            if (_shouldTrace)
 7936            {
 07937                ServiceClientTracing.Exit(_invocationId, _result);
 7938            }
 27939            return _result;
 27940        }
 7941
 7942        /// <summary>
 7943        /// Adds a prebuilt entity model to a version of the application.
 7944        /// </summary>
 7945        /// <param name='appId'>
 7946        /// The application ID.
 7947        /// </param>
 7948        /// <param name='versionId'>
 7949        /// The version ID.
 7950        /// </param>
 7951        /// <param name='prebuiltDomainModelCreateObject'>
 7952        /// A model object containing the name of the prebuilt entity and the name of
 7953        /// the domain to which this model belongs.
 7954        /// </param>
 7955        /// <param name='customHeaders'>
 7956        /// Headers that will be added to request.
 7957        /// </param>
 7958        /// <param name='cancellationToken'>
 7959        /// The cancellation token.
 7960        /// </param>
 7961        /// <exception cref="ErrorResponseException">
 7962        /// Thrown when the operation returned an invalid status code
 7963        /// </exception>
 7964        /// <exception cref="SerializationException">
 7965        /// Thrown when unable to deserialize the response
 7966        /// </exception>
 7967        /// <exception cref="ValidationException">
 7968        /// Thrown when a required parameter is null
 7969        /// </exception>
 7970        /// <exception cref="System.ArgumentNullException">
 7971        /// Thrown when a required parameter is null
 7972        /// </exception>
 7973        /// <return>
 7974        /// A response object containing the response body and response headers.
 7975        /// </return>
 7976        public async Task<HttpOperationResponse<System.Guid>> AddCustomPrebuiltEntityWithHttpMessagesAsync(System.Guid a
 7977        {
 67978            if (Client.Endpoint == null)
 7979            {
 07980                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 7981            }
 67982            if (versionId == null)
 7983            {
 07984                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 7985            }
 67986            if (prebuiltDomainModelCreateObject == null)
 7987            {
 07988                throw new ValidationException(ValidationRules.CannotBeNull, "prebuiltDomainModelCreateObject");
 7989            }
 7990            // Tracing
 67991            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 67992            string _invocationId = null;
 67993            if (_shouldTrace)
 7994            {
 07995                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07996                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07997                tracingParameters.Add("appId", appId);
 07998                tracingParameters.Add("versionId", versionId);
 07999                tracingParameters.Add("prebuiltDomainModelCreateObject", prebuiltDomainModelCreateObject);
 08000                tracingParameters.Add("cancellationToken", cancellationToken);
 08001                ServiceClientTracing.Enter(_invocationId, this, "AddCustomPrebuiltEntity", tracingParameters);
 8002            }
 8003            // Construct URL
 68004            var _baseUrl = Client.BaseUri;
 68005            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 68006            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 68007            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 68008            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 8009            // Create HTTP transport objects
 68010            var _httpRequest = new HttpRequestMessage();
 68011            HttpResponseMessage _httpResponse = null;
 68012            _httpRequest.Method = new HttpMethod("POST");
 68013            _httpRequest.RequestUri = new System.Uri(_url);
 8014            // Set Headers
 8015
 8016
 68017            if (customHeaders != null)
 8018            {
 08019                foreach(var _header in customHeaders)
 8020                {
 08021                    if (_httpRequest.Headers.Contains(_header.Key))
 8022                    {
 08023                        _httpRequest.Headers.Remove(_header.Key);
 8024                    }
 08025                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8026                }
 8027            }
 8028
 8029            // Serialize Request
 68030            string _requestContent = null;
 68031            if(prebuiltDomainModelCreateObject != null)
 8032            {
 68033                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(prebuiltDomainModelCreateObject, Cl
 68034                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 68035                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 8036            }
 8037            // Set Credentials
 68038            if (Client.Credentials != null)
 8039            {
 68040                cancellationToken.ThrowIfCancellationRequested();
 68041                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8042            }
 8043            // Send Request
 68044            if (_shouldTrace)
 8045            {
 08046                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8047            }
 68048            cancellationToken.ThrowIfCancellationRequested();
 68049            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 68050            if (_shouldTrace)
 8051            {
 08052                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8053            }
 68054            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 68055            cancellationToken.ThrowIfCancellationRequested();
 68056            string _responseContent = null;
 68057            if ((int)_statusCode != 201)
 8058            {
 08059                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 8060                try
 8061                {
 08062                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08063                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 08064                    if (_errorBody != null)
 8065                    {
 08066                        ex.Body = _errorBody;
 8067                    }
 08068                }
 08069                catch (JsonException)
 8070                {
 8071                    // Ignore the exception
 08072                }
 08073                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08074                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08075                if (_shouldTrace)
 8076                {
 08077                    ServiceClientTracing.Error(_invocationId, ex);
 8078                }
 08079                _httpRequest.Dispose();
 08080                if (_httpResponse != null)
 8081                {
 08082                    _httpResponse.Dispose();
 8083                }
 08084                throw ex;
 8085            }
 8086            // Create Result
 68087            var _result = new HttpOperationResponse<System.Guid>();
 68088            _result.Request = _httpRequest;
 68089            _result.Response = _httpResponse;
 8090            // Deserialize Response
 68091            if ((int)_statusCode == 201)
 8092            {
 68093                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8094                try
 8095                {
 68096                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 68097                }
 08098                catch (JsonException ex)
 8099                {
 08100                    _httpRequest.Dispose();
 08101                    if (_httpResponse != null)
 8102                    {
 08103                        _httpResponse.Dispose();
 8104                    }
 08105                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8106                }
 8107            }
 68108            if (_shouldTrace)
 8109            {
 08110                ServiceClientTracing.Exit(_invocationId, _result);
 8111            }
 68112            return _result;
 68113        }
 8114
 8115        /// <summary>
 8116        /// Gets all prebuilt entities used in a version of the application.
 8117        /// </summary>
 8118        /// <param name='appId'>
 8119        /// The application ID.
 8120        /// </param>
 8121        /// <param name='versionId'>
 8122        /// The version ID.
 8123        /// </param>
 8124        /// <param name='customHeaders'>
 8125        /// Headers that will be added to request.
 8126        /// </param>
 8127        /// <param name='cancellationToken'>
 8128        /// The cancellation token.
 8129        /// </param>
 8130        /// <exception cref="ErrorResponseException">
 8131        /// Thrown when the operation returned an invalid status code
 8132        /// </exception>
 8133        /// <exception cref="SerializationException">
 8134        /// Thrown when unable to deserialize the response
 8135        /// </exception>
 8136        /// <exception cref="ValidationException">
 8137        /// Thrown when a required parameter is null
 8138        /// </exception>
 8139        /// <exception cref="System.ArgumentNullException">
 8140        /// Thrown when a required parameter is null
 8141        /// </exception>
 8142        /// <return>
 8143        /// A response object containing the response body and response headers.
 8144        /// </return>
 8145        public async Task<HttpOperationResponse<IList<EntityExtractor>>> ListCustomPrebuiltEntitiesWithHttpMessagesAsync
 8146        {
 28147            if (Client.Endpoint == null)
 8148            {
 08149                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 8150            }
 28151            if (versionId == null)
 8152            {
 08153                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 8154            }
 8155            // Tracing
 28156            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 28157            string _invocationId = null;
 28158            if (_shouldTrace)
 8159            {
 08160                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08161                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08162                tracingParameters.Add("appId", appId);
 08163                tracingParameters.Add("versionId", versionId);
 08164                tracingParameters.Add("cancellationToken", cancellationToken);
 08165                ServiceClientTracing.Enter(_invocationId, this, "ListCustomPrebuiltEntities", tracingParameters);
 8166            }
 8167            // Construct URL
 28168            var _baseUrl = Client.BaseUri;
 28169            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 28170            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 28171            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 28172            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 8173            // Create HTTP transport objects
 28174            var _httpRequest = new HttpRequestMessage();
 28175            HttpResponseMessage _httpResponse = null;
 28176            _httpRequest.Method = new HttpMethod("GET");
 28177            _httpRequest.RequestUri = new System.Uri(_url);
 8178            // Set Headers
 8179
 8180
 28181            if (customHeaders != null)
 8182            {
 08183                foreach(var _header in customHeaders)
 8184                {
 08185                    if (_httpRequest.Headers.Contains(_header.Key))
 8186                    {
 08187                        _httpRequest.Headers.Remove(_header.Key);
 8188                    }
 08189                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8190                }
 8191            }
 8192
 8193            // Serialize Request
 28194            string _requestContent = null;
 8195            // Set Credentials
 28196            if (Client.Credentials != null)
 8197            {
 28198                cancellationToken.ThrowIfCancellationRequested();
 28199                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8200            }
 8201            // Send Request
 28202            if (_shouldTrace)
 8203            {
 08204                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8205            }
 28206            cancellationToken.ThrowIfCancellationRequested();
 28207            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 28208            if (_shouldTrace)
 8209            {
 08210                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8211            }
 28212            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 28213            cancellationToken.ThrowIfCancellationRequested();
 28214            string _responseContent = null;
 28215            if ((int)_statusCode != 200)
 8216            {
 08217                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 8218                try
 8219                {
 08220                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08221                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 08222                    if (_errorBody != null)
 8223                    {
 08224                        ex.Body = _errorBody;
 8225                    }
 08226                }
 08227                catch (JsonException)
 8228                {
 8229                    // Ignore the exception
 08230                }
 08231                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08232                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08233                if (_shouldTrace)
 8234                {
 08235                    ServiceClientTracing.Error(_invocationId, ex);
 8236                }
 08237                _httpRequest.Dispose();
 08238                if (_httpResponse != null)
 8239                {
 08240                    _httpResponse.Dispose();
 8241                }
 08242                throw ex;
 8243            }
 8244            // Create Result
 28245            var _result = new HttpOperationResponse<IList<EntityExtractor>>();
 28246            _result.Request = _httpRequest;
 28247            _result.Response = _httpResponse;
 8248            // Deserialize Response
 28249            if ((int)_statusCode == 200)
 8250            {
 28251                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8252                try
 8253                {
 28254                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityExtractor>>(_respons
 28255                }
 08256                catch (JsonException ex)
 8257                {
 08258                    _httpRequest.Dispose();
 08259                    if (_httpResponse != null)
 8260                    {
 08261                        _httpResponse.Dispose();
 8262                    }
 08263                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8264                }
 8265            }
 28266            if (_shouldTrace)
 8267            {
 08268                ServiceClientTracing.Exit(_invocationId, _result);
 8269            }
 28270            return _result;
 28271        }
 8272
 8273        /// <summary>
 8274        /// Gets all prebuilt intent and entity model information used in a version of
 8275        /// this application.
 8276        /// </summary>
 8277        /// <param name='appId'>
 8278        /// The application ID.
 8279        /// </param>
 8280        /// <param name='versionId'>
 8281        /// The version ID.
 8282        /// </param>
 8283        /// <param name='customHeaders'>
 8284        /// Headers that will be added to request.
 8285        /// </param>
 8286        /// <param name='cancellationToken'>
 8287        /// The cancellation token.
 8288        /// </param>
 8289        /// <exception cref="ErrorResponseException">
 8290        /// Thrown when the operation returned an invalid status code
 8291        /// </exception>
 8292        /// <exception cref="SerializationException">
 8293        /// Thrown when unable to deserialize the response
 8294        /// </exception>
 8295        /// <exception cref="ValidationException">
 8296        /// Thrown when a required parameter is null
 8297        /// </exception>
 8298        /// <exception cref="System.ArgumentNullException">
 8299        /// Thrown when a required parameter is null
 8300        /// </exception>
 8301        /// <return>
 8302        /// A response object containing the response body and response headers.
 8303        /// </return>
 8304        public async Task<HttpOperationResponse<IList<CustomPrebuiltModel>>> ListCustomPrebuiltModelsWithHttpMessagesAsy
 8305        {
 48306            if (Client.Endpoint == null)
 8307            {
 08308                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 8309            }
 48310            if (versionId == null)
 8311            {
 08312                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 8313            }
 8314            // Tracing
 48315            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 48316            string _invocationId = null;
 48317            if (_shouldTrace)
 8318            {
 08319                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08320                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08321                tracingParameters.Add("appId", appId);
 08322                tracingParameters.Add("versionId", versionId);
 08323                tracingParameters.Add("cancellationToken", cancellationToken);
 08324                ServiceClientTracing.Enter(_invocationId, this, "ListCustomPrebuiltModels", tracingParameters);
 8325            }
 8326            // Construct URL
 48327            var _baseUrl = Client.BaseUri;
 48328            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 48329            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 48330            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 48331            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 8332            // Create HTTP transport objects
 48333            var _httpRequest = new HttpRequestMessage();
 48334            HttpResponseMessage _httpResponse = null;
 48335            _httpRequest.Method = new HttpMethod("GET");
 48336            _httpRequest.RequestUri = new System.Uri(_url);
 8337            // Set Headers
 8338
 8339
 48340            if (customHeaders != null)
 8341            {
 08342                foreach(var _header in customHeaders)
 8343                {
 08344                    if (_httpRequest.Headers.Contains(_header.Key))
 8345                    {
 08346                        _httpRequest.Headers.Remove(_header.Key);
 8347                    }
 08348                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8349                }
 8350            }
 8351
 8352            // Serialize Request
 48353            string _requestContent = null;
 8354            // Set Credentials
 48355            if (Client.Credentials != null)
 8356            {
 48357                cancellationToken.ThrowIfCancellationRequested();
 48358                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8359            }
 8360            // Send Request
 48361            if (_shouldTrace)
 8362            {
 08363                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8364            }
 48365            cancellationToken.ThrowIfCancellationRequested();
 48366            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 48367            if (_shouldTrace)
 8368            {
 08369                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8370            }
 48371            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 48372            cancellationToken.ThrowIfCancellationRequested();
 48373            string _responseContent = null;
 48374            if ((int)_statusCode != 200)
 8375            {
 08376                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 8377                try
 8378                {
 08379                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08380                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 08381                    if (_errorBody != null)
 8382                    {
 08383                        ex.Body = _errorBody;
 8384                    }
 08385                }
 08386                catch (JsonException)
 8387                {
 8388                    // Ignore the exception
 08389                }
 08390                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08391                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08392                if (_shouldTrace)
 8393                {
 08394                    ServiceClientTracing.Error(_invocationId, ex);
 8395                }
 08396                _httpRequest.Dispose();
 08397                if (_httpResponse != null)
 8398                {
 08399                    _httpResponse.Dispose();
 8400                }
 08401                throw ex;
 8402            }
 8403            // Create Result
 48404            var _result = new HttpOperationResponse<IList<CustomPrebuiltModel>>();
 48405            _result.Request = _httpRequest;
 48406            _result.Response = _httpResponse;
 8407            // Deserialize Response
 48408            if ((int)_statusCode == 200)
 8409            {
 48410                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8411                try
 8412                {
 48413                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<CustomPrebuiltModel>>(_res
 48414                }
 08415                catch (JsonException ex)
 8416                {
 08417                    _httpRequest.Dispose();
 08418                    if (_httpResponse != null)
 8419                    {
 08420                        _httpResponse.Dispose();
 8421                    }
 08422                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8423                }
 8424            }
 48425            if (_shouldTrace)
 8426            {
 08427                ServiceClientTracing.Exit(_invocationId, _result);
 8428            }
 48429            return _result;
 48430        }
 8431
 8432        /// <summary>
 8433        /// Deletes a prebuilt domain's models in a version of the application.
 8434        /// </summary>
 8435        /// <param name='appId'>
 8436        /// The application ID.
 8437        /// </param>
 8438        /// <param name='versionId'>
 8439        /// The version ID.
 8440        /// </param>
 8441        /// <param name='domainName'>
 8442        /// Domain name.
 8443        /// </param>
 8444        /// <param name='customHeaders'>
 8445        /// Headers that will be added to request.
 8446        /// </param>
 8447        /// <param name='cancellationToken'>
 8448        /// The cancellation token.
 8449        /// </param>
 8450        /// <exception cref="ErrorResponseException">
 8451        /// Thrown when the operation returned an invalid status code
 8452        /// </exception>
 8453        /// <exception cref="SerializationException">
 8454        /// Thrown when unable to deserialize the response
 8455        /// </exception>
 8456        /// <exception cref="ValidationException">
 8457        /// Thrown when a required parameter is null
 8458        /// </exception>
 8459        /// <exception cref="System.ArgumentNullException">
 8460        /// Thrown when a required parameter is null
 8461        /// </exception>
 8462        /// <return>
 8463        /// A response object containing the response body and response headers.
 8464        /// </return>
 8465        public async Task<HttpOperationResponse<OperationStatus>> DeleteCustomPrebuiltDomainWithHttpMessagesAsync(System
 8466        {
 58467            if (Client.Endpoint == null)
 8468            {
 08469                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 8470            }
 58471            if (versionId == null)
 8472            {
 08473                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 8474            }
 58475            if (domainName == null)
 8476            {
 08477                throw new ValidationException(ValidationRules.CannotBeNull, "domainName");
 8478            }
 8479            // Tracing
 58480            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 58481            string _invocationId = null;
 58482            if (_shouldTrace)
 8483            {
 08484                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08485                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08486                tracingParameters.Add("appId", appId);
 08487                tracingParameters.Add("versionId", versionId);
 08488                tracingParameters.Add("domainName", domainName);
 08489                tracingParameters.Add("cancellationToken", cancellationToken);
 08490                ServiceClientTracing.Enter(_invocationId, this, "DeleteCustomPrebuiltDomain", tracingParameters);
 8491            }
 8492            // Construct URL
 58493            var _baseUrl = Client.BaseUri;
 58494            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 58495            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 58496            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 58497            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 58498            _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName));
 8499            // Create HTTP transport objects
 58500            var _httpRequest = new HttpRequestMessage();
 58501            HttpResponseMessage _httpResponse = null;
 58502            _httpRequest.Method = new HttpMethod("DELETE");
 58503            _httpRequest.RequestUri = new System.Uri(_url);
 8504            // Set Headers
 8505
 8506
 58507            if (customHeaders != null)
 8508            {
 08509                foreach(var _header in customHeaders)
 8510                {
 08511                    if (_httpRequest.Headers.Contains(_header.Key))
 8512                    {
 08513                        _httpRequest.Headers.Remove(_header.Key);
 8514                    }
 08515                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8516                }
 8517            }
 8518
 8519            // Serialize Request
 58520            string _requestContent = null;
 8521            // Set Credentials
 58522            if (Client.Credentials != null)
 8523            {
 58524                cancellationToken.ThrowIfCancellationRequested();
 58525                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8526            }
 8527            // Send Request
 58528            if (_shouldTrace)
 8529            {
 08530                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8531            }
 58532            cancellationToken.ThrowIfCancellationRequested();
 58533            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 58534            if (_shouldTrace)
 8535            {
 08536                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8537            }
 58538            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 58539            cancellationToken.ThrowIfCancellationRequested();
 58540            string _responseContent = null;
 58541            if ((int)_statusCode != 200)
 8542            {
 08543                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 8544                try
 8545                {
 08546                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08547                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 08548                    if (_errorBody != null)
 8549                    {
 08550                        ex.Body = _errorBody;
 8551                    }
 08552                }
 08553                catch (JsonException)
 8554                {
 8555                    // Ignore the exception
 08556                }
 08557                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08558                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08559                if (_shouldTrace)
 8560                {
 08561                    ServiceClientTracing.Error(_invocationId, ex);
 8562                }
 08563                _httpRequest.Dispose();
 08564                if (_httpResponse != null)
 8565                {
 08566                    _httpResponse.Dispose();
 8567                }
 08568                throw ex;
 8569            }
 8570            // Create Result
 58571            var _result = new HttpOperationResponse<OperationStatus>();
 58572            _result.Request = _httpRequest;
 58573            _result.Response = _httpResponse;
 8574            // Deserialize Response
 58575            if ((int)_statusCode == 200)
 8576            {
 58577                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8578                try
 8579                {
 58580                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 58581                }
 08582                catch (JsonException ex)
 8583                {
 08584                    _httpRequest.Dispose();
 08585                    if (_httpResponse != null)
 8586                    {
 08587                        _httpResponse.Dispose();
 8588                    }
 08589                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8590                }
 8591            }
 58592            if (_shouldTrace)
 8593            {
 08594                ServiceClientTracing.Exit(_invocationId, _result);
 8595            }
 58596            return _result;
 58597        }
 8598
 8599        /// <summary>
 8600        /// Creates a single child in an existing entity model hierarchy in a version
 8601        /// of the application.
 8602        /// </summary>
 8603        /// <param name='appId'>
 8604        /// The application ID.
 8605        /// </param>
 8606        /// <param name='versionId'>
 8607        /// The version ID.
 8608        /// </param>
 8609        /// <param name='entityId'>
 8610        /// The entity extractor ID.
 8611        /// </param>
 8612        /// <param name='childEntityModelCreateObject'>
 8613        /// A model object containing the name of the new child model and its children.
 8614        /// </param>
 8615        /// <param name='customHeaders'>
 8616        /// Headers that will be added to request.
 8617        /// </param>
 8618        /// <param name='cancellationToken'>
 8619        /// The cancellation token.
 8620        /// </param>
 8621        /// <exception cref="ErrorResponseException">
 8622        /// Thrown when the operation returned an invalid status code
 8623        /// </exception>
 8624        /// <exception cref="SerializationException">
 8625        /// Thrown when unable to deserialize the response
 8626        /// </exception>
 8627        /// <exception cref="ValidationException">
 8628        /// Thrown when a required parameter is null
 8629        /// </exception>
 8630        /// <exception cref="System.ArgumentNullException">
 8631        /// Thrown when a required parameter is null
 8632        /// </exception>
 8633        /// <return>
 8634        /// A response object containing the response body and response headers.
 8635        /// </return>
 8636        public async Task<HttpOperationResponse<System.Guid>> AddEntityChildWithHttpMessagesAsync(System.Guid appId, str
 8637        {
 38638            if (Client.Endpoint == null)
 8639            {
 08640                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 8641            }
 38642            if (versionId == null)
 8643            {
 08644                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 8645            }
 38646            if (childEntityModelCreateObject == null)
 8647            {
 08648                throw new ValidationException(ValidationRules.CannotBeNull, "childEntityModelCreateObject");
 8649            }
 8650            // Tracing
 38651            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 38652            string _invocationId = null;
 38653            if (_shouldTrace)
 8654            {
 08655                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08656                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08657                tracingParameters.Add("appId", appId);
 08658                tracingParameters.Add("versionId", versionId);
 08659                tracingParameters.Add("entityId", entityId);
 08660                tracingParameters.Add("childEntityModelCreateObject", childEntityModelCreateObject);
 08661                tracingParameters.Add("cancellationToken", cancellationToken);
 08662                ServiceClientTracing.Enter(_invocationId, this, "AddEntityChild", tracingParameters);
 8663            }
 8664            // Construct URL
 38665            var _baseUrl = Client.BaseUri;
 38666            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 38667            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 38668            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 38669            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 38670            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 8671            // Create HTTP transport objects
 38672            var _httpRequest = new HttpRequestMessage();
 38673            HttpResponseMessage _httpResponse = null;
 38674            _httpRequest.Method = new HttpMethod("POST");
 38675            _httpRequest.RequestUri = new System.Uri(_url);
 8676            // Set Headers
 8677
 8678
 38679            if (customHeaders != null)
 8680            {
 08681                foreach(var _header in customHeaders)
 8682                {
 08683                    if (_httpRequest.Headers.Contains(_header.Key))
 8684                    {
 08685                        _httpRequest.Headers.Remove(_header.Key);
 8686                    }
 08687                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8688                }
 8689            }
 8690
 8691            // Serialize Request
 38692            string _requestContent = null;
 38693            if(childEntityModelCreateObject != null)
 8694            {
 38695                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(childEntityModelCreateObject, Clien
 38696                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 38697                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 8698            }
 8699            // Set Credentials
 38700            if (Client.Credentials != null)
 8701            {
 38702                cancellationToken.ThrowIfCancellationRequested();
 38703                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8704            }
 8705            // Send Request
 38706            if (_shouldTrace)
 8707            {
 08708                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8709            }
 38710            cancellationToken.ThrowIfCancellationRequested();
 38711            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 38712            if (_shouldTrace)
 8713            {
 08714                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8715            }
 38716            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 38717            cancellationToken.ThrowIfCancellationRequested();
 38718            string _responseContent = null;
 38719            if ((int)_statusCode != 201)
 8720            {
 08721                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 8722                try
 8723                {
 08724                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08725                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 08726                    if (_errorBody != null)
 8727                    {
 08728                        ex.Body = _errorBody;
 8729                    }
 08730                }
 08731                catch (JsonException)
 8732                {
 8733                    // Ignore the exception
 08734                }
 08735                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08736                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08737                if (_shouldTrace)
 8738                {
 08739                    ServiceClientTracing.Error(_invocationId, ex);
 8740                }
 08741                _httpRequest.Dispose();
 08742                if (_httpResponse != null)
 8743                {
 08744                    _httpResponse.Dispose();
 8745                }
 08746                throw ex;
 8747            }
 8748            // Create Result
 38749            var _result = new HttpOperationResponse<System.Guid>();
 38750            _result.Request = _httpRequest;
 38751            _result.Response = _httpResponse;
 8752            // Deserialize Response
 38753            if ((int)_statusCode == 201)
 8754            {
 38755                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8756                try
 8757                {
 38758                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 38759                }
 08760                catch (JsonException ex)
 8761                {
 08762                    _httpRequest.Dispose();
 08763                    if (_httpResponse != null)
 8764                    {
 08765                        _httpResponse.Dispose();
 8766                    }
 08767                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8768                }
 8769            }
 38770            if (_shouldTrace)
 8771            {
 08772                ServiceClientTracing.Exit(_invocationId, _result);
 8773            }
 38774            return _result;
 38775        }
 8776
 8777        /// <summary>
 8778        /// Gets information about the child's model contained in an hierarchical
 8779        /// entity child model in a version of the application.
 8780        /// </summary>
 8781        /// <param name='appId'>
 8782        /// The application ID.
 8783        /// </param>
 8784        /// <param name='versionId'>
 8785        /// The version ID.
 8786        /// </param>
 8787        /// <param name='hEntityId'>
 8788        /// The hierarchical entity extractor ID.
 8789        /// </param>
 8790        /// <param name='hChildId'>
 8791        /// The hierarchical entity extractor child ID.
 8792        /// </param>
 8793        /// <param name='customHeaders'>
 8794        /// Headers that will be added to request.
 8795        /// </param>
 8796        /// <param name='cancellationToken'>
 8797        /// The cancellation token.
 8798        /// </param>
 8799        /// <exception cref="ErrorResponseException">
 8800        /// Thrown when the operation returned an invalid status code
 8801        /// </exception>
 8802        /// <exception cref="SerializationException">
 8803        /// Thrown when unable to deserialize the response
 8804        /// </exception>
 8805        /// <exception cref="ValidationException">
 8806        /// Thrown when a required parameter is null
 8807        /// </exception>
 8808        /// <exception cref="System.ArgumentNullException">
 8809        /// Thrown when a required parameter is null
 8810        /// </exception>
 8811        /// <return>
 8812        /// A response object containing the response body and response headers.
 8813        /// </return>
 8814        public async Task<HttpOperationResponse<HierarchicalChildEntity>> GetHierarchicalEntityChildWithHttpMessagesAsyn
 8815        {
 08816            if (Client.Endpoint == null)
 8817            {
 08818                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 8819            }
 08820            if (versionId == null)
 8821            {
 08822                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 8823            }
 8824            // Tracing
 08825            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 08826            string _invocationId = null;
 08827            if (_shouldTrace)
 8828            {
 08829                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08830                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08831                tracingParameters.Add("appId", appId);
 08832                tracingParameters.Add("versionId", versionId);
 08833                tracingParameters.Add("hEntityId", hEntityId);
 08834                tracingParameters.Add("hChildId", hChildId);
 08835                tracingParameters.Add("cancellationToken", cancellationToken);
 08836                ServiceClientTracing.Enter(_invocationId, this, "GetHierarchicalEntityChild", tracingParameters);
 8837            }
 8838            // Construct URL
 08839            var _baseUrl = Client.BaseUri;
 08840            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 08841            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 08842            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 08843            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 08844            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 08845            _url = _url.Replace("{hChildId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 8846            // Create HTTP transport objects
 08847            var _httpRequest = new HttpRequestMessage();
 08848            HttpResponseMessage _httpResponse = null;
 08849            _httpRequest.Method = new HttpMethod("GET");
 08850            _httpRequest.RequestUri = new System.Uri(_url);
 8851            // Set Headers
 8852
 8853
 08854            if (customHeaders != null)
 8855            {
 08856                foreach(var _header in customHeaders)
 8857                {
 08858                    if (_httpRequest.Headers.Contains(_header.Key))
 8859                    {
 08860                        _httpRequest.Headers.Remove(_header.Key);
 8861                    }
 08862                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8863                }
 8864            }
 8865
 8866            // Serialize Request
 08867            string _requestContent = null;
 8868            // Set Credentials
 08869            if (Client.Credentials != null)
 8870            {
 08871                cancellationToken.ThrowIfCancellationRequested();
 08872                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8873            }
 8874            // Send Request
 08875            if (_shouldTrace)
 8876            {
 08877                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8878            }
 08879            cancellationToken.ThrowIfCancellationRequested();
 08880            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 08881            if (_shouldTrace)
 8882            {
 08883                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8884            }
 08885            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 08886            cancellationToken.ThrowIfCancellationRequested();
 08887            string _responseContent = null;
 08888            if ((int)_statusCode != 200)
 8889            {
 08890                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 8891                try
 8892                {
 08893                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08894                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 08895                    if (_errorBody != null)
 8896                    {
 08897                        ex.Body = _errorBody;
 8898                    }
 08899                }
 08900                catch (JsonException)
 8901                {
 8902                    // Ignore the exception
 08903                }
 08904                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08905                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08906                if (_shouldTrace)
 8907                {
 08908                    ServiceClientTracing.Error(_invocationId, ex);
 8909                }
 08910                _httpRequest.Dispose();
 08911                if (_httpResponse != null)
 8912                {
 08913                    _httpResponse.Dispose();
 8914                }
 08915                throw ex;
 8916            }
 8917            // Create Result
 08918            var _result = new HttpOperationResponse<HierarchicalChildEntity>();
 08919            _result.Request = _httpRequest;
 08920            _result.Response = _httpResponse;
 8921            // Deserialize Response
 08922            if ((int)_statusCode == 200)
 8923            {
 08924                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8925                try
 8926                {
 08927                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<HierarchicalChildEntity>(_respon
 08928                }
 08929                catch (JsonException ex)
 8930                {
 08931                    _httpRequest.Dispose();
 08932                    if (_httpResponse != null)
 8933                    {
 08934                        _httpResponse.Dispose();
 8935                    }
 08936                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8937                }
 8938            }
 08939            if (_shouldTrace)
 8940            {
 08941                ServiceClientTracing.Exit(_invocationId, _result);
 8942            }
 08943            return _result;
 08944        }
 8945
 8946        /// <summary>
 8947        /// Renames a single child in an existing hierarchical entity model in a
 8948        /// version of the application.
 8949        /// </summary>
 8950        /// <param name='appId'>
 8951        /// The application ID.
 8952        /// </param>
 8953        /// <param name='versionId'>
 8954        /// The version ID.
 8955        /// </param>
 8956        /// <param name='hEntityId'>
 8957        /// The hierarchical entity extractor ID.
 8958        /// </param>
 8959        /// <param name='hChildId'>
 8960        /// The hierarchical entity extractor child ID.
 8961        /// </param>
 8962        /// <param name='hierarchicalChildModelUpdateObject'>
 8963        /// Model object containing new name of the hierarchical entity child.
 8964        /// </param>
 8965        /// <param name='customHeaders'>
 8966        /// Headers that will be added to request.
 8967        /// </param>
 8968        /// <param name='cancellationToken'>
 8969        /// The cancellation token.
 8970        /// </param>
 8971        /// <exception cref="ErrorResponseException">
 8972        /// Thrown when the operation returned an invalid status code
 8973        /// </exception>
 8974        /// <exception cref="SerializationException">
 8975        /// Thrown when unable to deserialize the response
 8976        /// </exception>
 8977        /// <exception cref="ValidationException">
 8978        /// Thrown when a required parameter is null
 8979        /// </exception>
 8980        /// <exception cref="System.ArgumentNullException">
 8981        /// Thrown when a required parameter is null
 8982        /// </exception>
 8983        /// <return>
 8984        /// A response object containing the response body and response headers.
 8985        /// </return>
 8986        public async Task<HttpOperationResponse<OperationStatus>> UpdateHierarchicalEntityChildWithHttpMessagesAsync(Sys
 8987        {
 08988            if (Client.Endpoint == null)
 8989            {
 08990                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 8991            }
 08992            if (versionId == null)
 8993            {
 08994                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 8995            }
 08996            if (hierarchicalChildModelUpdateObject == null)
 8997            {
 08998                throw new ValidationException(ValidationRules.CannotBeNull, "hierarchicalChildModelUpdateObject");
 8999            }
 9000            // Tracing
 09001            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 09002            string _invocationId = null;
 09003            if (_shouldTrace)
 9004            {
 09005                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 09006                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 09007                tracingParameters.Add("appId", appId);
 09008                tracingParameters.Add("versionId", versionId);
 09009                tracingParameters.Add("hEntityId", hEntityId);
 09010                tracingParameters.Add("hChildId", hChildId);
 09011                tracingParameters.Add("hierarchicalChildModelUpdateObject", hierarchicalChildModelUpdateObject);
 09012                tracingParameters.Add("cancellationToken", cancellationToken);
 09013                ServiceClientTracing.Enter(_invocationId, this, "UpdateHierarchicalEntityChild", tracingParameters);
 9014            }
 9015            // Construct URL
 09016            var _baseUrl = Client.BaseUri;
 09017            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 09018            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 09019            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 09020            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 09021            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 09022            _url = _url.Replace("{hChildId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 9023            // Create HTTP transport objects
 09024            var _httpRequest = new HttpRequestMessage();
 09025            HttpResponseMessage _httpResponse = null;
 09026            _httpRequest.Method = new HttpMethod("PATCH");
 09027            _httpRequest.RequestUri = new System.Uri(_url);
 9028            // Set Headers
 9029
 9030
 09031            if (customHeaders != null)
 9032            {
 09033                foreach(var _header in customHeaders)
 9034                {
 09035                    if (_httpRequest.Headers.Contains(_header.Key))
 9036                    {
 09037                        _httpRequest.Headers.Remove(_header.Key);
 9038                    }
 09039                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 9040                }
 9041            }
 9042
 9043            // Serialize Request
 09044            string _requestContent = null;
 09045            if(hierarchicalChildModelUpdateObject != null)
 9046            {
 09047                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(hierarchicalChildModelUpdateObject,
 09048                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 09049                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 9050            }
 9051            // Set Credentials
 09052            if (Client.Credentials != null)
 9053            {
 09054                cancellationToken.ThrowIfCancellationRequested();
 09055                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 9056            }
 9057            // Send Request
 09058            if (_shouldTrace)
 9059            {
 09060                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 9061            }
 09062            cancellationToken.ThrowIfCancellationRequested();
 09063            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 09064            if (_shouldTrace)
 9065            {
 09066                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 9067            }
 09068            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 09069            cancellationToken.ThrowIfCancellationRequested();
 09070            string _responseContent = null;
 09071            if ((int)_statusCode != 200)
 9072            {
 09073                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 9074                try
 9075                {
 09076                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 09077                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 09078                    if (_errorBody != null)
 9079                    {
 09080                        ex.Body = _errorBody;
 9081                    }
 09082                }
 09083                catch (JsonException)
 9084                {
 9085                    // Ignore the exception
 09086                }
 09087                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 09088                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 09089                if (_shouldTrace)
 9090                {
 09091                    ServiceClientTracing.Error(_invocationId, ex);
 9092                }
 09093                _httpRequest.Dispose();
 09094                if (_httpResponse != null)
 9095                {
 09096                    _httpResponse.Dispose();
 9097                }
 09098                throw ex;
 9099            }
 9100            // Create Result
 09101            var _result = new HttpOperationResponse<OperationStatus>();
 09102            _result.Request = _httpRequest;
 09103            _result.Response = _httpResponse;
 9104            // Deserialize Response
 09105            if ((int)_statusCode == 200)
 9106            {
 09107                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 9108                try
 9109                {
 09110                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 09111                }
 09112                catch (JsonException ex)
 9113                {
 09114                    _httpRequest.Dispose();
 09115                    if (_httpResponse != null)
 9116                    {
 09117                        _httpResponse.Dispose();
 9118                    }
 09119                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 9120                }
 9121            }
 09122            if (_shouldTrace)
 9123            {
 09124                ServiceClientTracing.Exit(_invocationId, _result);
 9125            }
 09126            return _result;
 09127        }
 9128
 9129        /// <summary>
 9130        /// Deletes a hierarchical entity extractor child in a version of the
 9131        /// application.
 9132        /// </summary>
 9133        /// <param name='appId'>
 9134        /// The application ID.
 9135        /// </param>
 9136        /// <param name='versionId'>
 9137        /// The version ID.
 9138        /// </param>
 9139        /// <param name='hEntityId'>
 9140        /// The hierarchical entity extractor ID.
 9141        /// </param>
 9142        /// <param name='hChildId'>
 9143        /// The hierarchical entity extractor child ID.
 9144        /// </param>
 9145        /// <param name='customHeaders'>
 9146        /// Headers that will be added to request.
 9147        /// </param>
 9148        /// <param name='cancellationToken'>
 9149        /// The cancellation token.
 9150        /// </param>
 9151        /// <exception cref="ErrorResponseException">
 9152        /// Thrown when the operation returned an invalid status code
 9153        /// </exception>
 9154        /// <exception cref="SerializationException">
 9155        /// Thrown when unable to deserialize the response
 9156        /// </exception>
 9157        /// <exception cref="ValidationException">
 9158        /// Thrown when a required parameter is null
 9159        /// </exception>
 9160        /// <exception cref="System.ArgumentNullException">
 9161        /// Thrown when a required parameter is null
 9162        /// </exception>
 9163        /// <return>
 9164        /// A response object containing the response body and response headers.
 9165        /// </return>
 9166        public async Task<HttpOperationResponse<OperationStatus>> DeleteHierarchicalEntityChildWithHttpMessagesAsync(Sys
 9167        {
 09168            if (Client.Endpoint == null)
 9169            {
 09170                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 9171            }
 09172            if (versionId == null)
 9173            {
 09174                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 9175            }
 9176            // Tracing
 09177            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 09178            string _invocationId = null;
 09179            if (_shouldTrace)
 9180            {
 09181                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 09182                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 09183                tracingParameters.Add("appId", appId);
 09184                tracingParameters.Add("versionId", versionId);
 09185                tracingParameters.Add("hEntityId", hEntityId);
 09186                tracingParameters.Add("hChildId", hChildId);
 09187                tracingParameters.Add("cancellationToken", cancellationToken);
 09188                ServiceClientTracing.Enter(_invocationId, this, "DeleteHierarchicalEntityChild", tracingParameters);
 9189            }
 9190            // Construct URL
 09191            var _baseUrl = Client.BaseUri;
 09192            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 09193            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 09194            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 09195            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 09196            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 09197            _url = _url.Replace("{hChildId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 9198            // Create HTTP transport objects
 09199            var _httpRequest = new HttpRequestMessage();
 09200            HttpResponseMessage _httpResponse = null;
 09201            _httpRequest.Method = new HttpMethod("DELETE");
 09202            _httpRequest.RequestUri = new System.Uri(_url);
 9203            // Set Headers
 9204
 9205
 09206            if (customHeaders != null)
 9207            {
 09208                foreach(var _header in customHeaders)
 9209                {
 09210                    if (_httpRequest.Headers.Contains(_header.Key))
 9211                    {
 09212                        _httpRequest.Headers.Remove(_header.Key);
 9213                    }
 09214                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 9215                }
 9216            }
 9217
 9218            // Serialize Request
 09219            string _requestContent = null;
 9220            // Set Credentials
 09221            if (Client.Credentials != null)
 9222            {
 09223                cancellationToken.ThrowIfCancellationRequested();
 09224                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 9225            }
 9226            // Send Request
 09227            if (_shouldTrace)
 9228            {
 09229                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 9230            }
 09231            cancellationToken.ThrowIfCancellationRequested();
 09232            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 09233            if (_shouldTrace)
 9234            {
 09235                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 9236            }
 09237            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 09238            cancellationToken.ThrowIfCancellationRequested();
 09239            string _responseContent = null;
 09240            if ((int)_statusCode != 200)
 9241            {
 09242                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 9243                try
 9244                {
 09245                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 09246                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 09247                    if (_errorBody != null)
 9248                    {
 09249                        ex.Body = _errorBody;
 9250                    }
 09251                }
 09252                catch (JsonException)
 9253                {
 9254                    // Ignore the exception
 09255                }
 09256                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 09257                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 09258                if (_shouldTrace)
 9259                {
 09260                    ServiceClientTracing.Error(_invocationId, ex);
 9261                }
 09262                _httpRequest.Dispose();
 09263                if (_httpResponse != null)
 9264                {
 09265                    _httpResponse.Dispose();
 9266                }
 09267                throw ex;
 9268            }
 9269            // Create Result
 09270            var _result = new HttpOperationResponse<OperationStatus>();
 09271            _result.Request = _httpRequest;
 09272            _result.Response = _httpResponse;
 9273            // Deserialize Response
 09274            if ((int)_statusCode == 200)
 9275            {
 09276                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 9277                try
 9278                {
 09279                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 09280                }
 09281                catch (JsonException ex)
 9282                {
 09283                    _httpRequest.Dispose();
 09284                    if (_httpResponse != null)
 9285                    {
 09286                        _httpResponse.Dispose();
 9287                    }
 09288                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 9289                }
 9290            }
 09291            if (_shouldTrace)
 9292            {
 09293                ServiceClientTracing.Exit(_invocationId, _result);
 9294            }
 09295            return _result;
 09296        }
 9297
 9298        /// <summary>
 9299        /// Creates a single child in an existing composite entity model in a version
 9300        /// of the application.
 9301        /// </summary>
 9302        /// <param name='appId'>
 9303        /// The application ID.
 9304        /// </param>
 9305        /// <param name='versionId'>
 9306        /// The version ID.
 9307        /// </param>
 9308        /// <param name='cEntityId'>
 9309        /// The composite entity extractor ID.
 9310        /// </param>
 9311        /// <param name='compositeChildModelCreateObject'>
 9312        /// A model object containing the name of the new composite child model.
 9313        /// </param>
 9314        /// <param name='customHeaders'>
 9315        /// Headers that will be added to request.
 9316        /// </param>
 9317        /// <param name='cancellationToken'>
 9318        /// The cancellation token.
 9319        /// </param>
 9320        /// <exception cref="ErrorResponseException">
 9321        /// Thrown when the operation returned an invalid status code
 9322        /// </exception>
 9323        /// <exception cref="SerializationException">
 9324        /// Thrown when unable to deserialize the response
 9325        /// </exception>
 9326        /// <exception cref="ValidationException">
 9327        /// Thrown when a required parameter is null
 9328        /// </exception>
 9329        /// <exception cref="System.ArgumentNullException">
 9330        /// Thrown when a required parameter is null
 9331        /// </exception>
 9332        /// <return>
 9333        /// A response object containing the response body and response headers.
 9334        /// </return>
 9335        public async Task<HttpOperationResponse<System.Guid>> AddCompositeEntityChildWithHttpMessagesAsync(System.Guid a
 9336        {
 09337            if (Client.Endpoint == null)
 9338            {
 09339                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 9340            }
 09341            if (versionId == null)
 9342            {
 09343                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 9344            }
 09345            if (compositeChildModelCreateObject == null)
 9346            {
 09347                throw new ValidationException(ValidationRules.CannotBeNull, "compositeChildModelCreateObject");
 9348            }
 9349            // Tracing
 09350            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 09351            string _invocationId = null;
 09352            if (_shouldTrace)
 9353            {
 09354                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 09355                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 09356                tracingParameters.Add("appId", appId);
 09357                tracingParameters.Add("versionId", versionId);
 09358                tracingParameters.Add("cEntityId", cEntityId);
 09359                tracingParameters.Add("compositeChildModelCreateObject", compositeChildModelCreateObject);
 09360                tracingParameters.Add("cancellationToken", cancellationToken);
 09361                ServiceClientTracing.Enter(_invocationId, this, "AddCompositeEntityChild", tracingParameters);
 9362            }
 9363            // Construct URL
 09364            var _baseUrl = Client.BaseUri;
 09365            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 09366            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 09367            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 09368            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 09369            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 9370            // Create HTTP transport objects
 09371            var _httpRequest = new HttpRequestMessage();
 09372            HttpResponseMessage _httpResponse = null;
 09373            _httpRequest.Method = new HttpMethod("POST");
 09374            _httpRequest.RequestUri = new System.Uri(_url);
 9375            // Set Headers
 9376
 9377
 09378            if (customHeaders != null)
 9379            {
 09380                foreach(var _header in customHeaders)
 9381                {
 09382                    if (_httpRequest.Headers.Contains(_header.Key))
 9383                    {
 09384                        _httpRequest.Headers.Remove(_header.Key);
 9385                    }
 09386                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 9387                }
 9388            }
 9389
 9390            // Serialize Request
 09391            string _requestContent = null;
 09392            if(compositeChildModelCreateObject != null)
 9393            {
 09394                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(compositeChildModelCreateObject, Cl
 09395                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 09396                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 9397            }
 9398            // Set Credentials
 09399            if (Client.Credentials != null)
 9400            {
 09401                cancellationToken.ThrowIfCancellationRequested();
 09402                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 9403            }
 9404            // Send Request
 09405            if (_shouldTrace)
 9406            {
 09407                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 9408            }
 09409            cancellationToken.ThrowIfCancellationRequested();
 09410            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 09411            if (_shouldTrace)
 9412            {
 09413                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 9414            }
 09415            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 09416            cancellationToken.ThrowIfCancellationRequested();
 09417            string _responseContent = null;
 09418            if ((int)_statusCode != 201)
 9419            {
 09420                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 9421                try
 9422                {
 09423                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 09424                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 09425                    if (_errorBody != null)
 9426                    {
 09427                        ex.Body = _errorBody;
 9428                    }
 09429                }
 09430                catch (JsonException)
 9431                {
 9432                    // Ignore the exception
 09433                }
 09434                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 09435                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 09436                if (_shouldTrace)
 9437                {
 09438                    ServiceClientTracing.Error(_invocationId, ex);
 9439                }
 09440                _httpRequest.Dispose();
 09441                if (_httpResponse != null)
 9442                {
 09443                    _httpResponse.Dispose();
 9444                }
 09445                throw ex;
 9446            }
 9447            // Create Result
 09448            var _result = new HttpOperationResponse<System.Guid>();
 09449            _result.Request = _httpRequest;
 09450            _result.Response = _httpResponse;
 9451            // Deserialize Response
 09452            if ((int)_statusCode == 201)
 9453            {
 09454                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 9455                try
 9456                {
 09457                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 09458                }
 09459                catch (JsonException ex)
 9460                {
 09461                    _httpRequest.Dispose();
 09462                    if (_httpResponse != null)
 9463                    {
 09464                        _httpResponse.Dispose();
 9465                    }
 09466                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 9467                }
 9468            }
 09469            if (_shouldTrace)
 9470            {
 09471                ServiceClientTracing.Exit(_invocationId, _result);
 9472            }
 09473            return _result;
 09474        }
 9475
 9476        /// <summary>
 9477        /// Deletes a composite entity extractor child from a version of the
 9478        /// application.
 9479        /// </summary>
 9480        /// <param name='appId'>
 9481        /// The application ID.
 9482        /// </param>
 9483        /// <param name='versionId'>
 9484        /// The version ID.
 9485        /// </param>
 9486        /// <param name='cEntityId'>
 9487        /// The composite entity extractor ID.
 9488        /// </param>
 9489        /// <param name='cChildId'>
 9490        /// The hierarchical entity extractor child ID.
 9491        /// </param>
 9492        /// <param name='customHeaders'>
 9493        /// Headers that will be added to request.
 9494        /// </param>
 9495        /// <param name='cancellationToken'>
 9496        /// The cancellation token.
 9497        /// </param>
 9498        /// <exception cref="ErrorResponseException">
 9499        /// Thrown when the operation returned an invalid status code
 9500        /// </exception>
 9501        /// <exception cref="SerializationException">
 9502        /// Thrown when unable to deserialize the response
 9503        /// </exception>
 9504        /// <exception cref="ValidationException">
 9505        /// Thrown when a required parameter is null
 9506        /// </exception>
 9507        /// <exception cref="System.ArgumentNullException">
 9508        /// Thrown when a required parameter is null
 9509        /// </exception>
 9510        /// <return>
 9511        /// A response object containing the response body and response headers.
 9512        /// </return>
 9513        public async Task<HttpOperationResponse<OperationStatus>> DeleteCompositeEntityChildWithHttpMessagesAsync(System
 9514        {
 09515            if (Client.Endpoint == null)
 9516            {
 09517                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 9518            }
 09519            if (versionId == null)
 9520            {
 09521                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 9522            }
 9523            // Tracing
 09524            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 09525            string _invocationId = null;
 09526            if (_shouldTrace)
 9527            {
 09528                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 09529                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 09530                tracingParameters.Add("appId", appId);
 09531                tracingParameters.Add("versionId", versionId);
 09532                tracingParameters.Add("cEntityId", cEntityId);
 09533                tracingParameters.Add("cChildId", cChildId);
 09534                tracingParameters.Add("cancellationToken", cancellationToken);
 09535                ServiceClientTracing.Enter(_invocationId, this, "DeleteCompositeEntityChild", tracingParameters);
 9536            }
 9537            // Construct URL
 09538            var _baseUrl = Client.BaseUri;
 09539            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 09540            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 09541            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 09542            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 09543            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 09544            _url = _url.Replace("{cChildId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 9545            // Create HTTP transport objects
 09546            var _httpRequest = new HttpRequestMessage();
 09547            HttpResponseMessage _httpResponse = null;
 09548            _httpRequest.Method = new HttpMethod("DELETE");
 09549            _httpRequest.RequestUri = new System.Uri(_url);
 9550            // Set Headers
 9551
 9552
 09553            if (customHeaders != null)
 9554            {
 09555                foreach(var _header in customHeaders)
 9556                {
 09557                    if (_httpRequest.Headers.Contains(_header.Key))
 9558                    {
 09559                        _httpRequest.Headers.Remove(_header.Key);
 9560                    }
 09561                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 9562                }
 9563            }
 9564
 9565            // Serialize Request
 09566            string _requestContent = null;
 9567            // Set Credentials
 09568            if (Client.Credentials != null)
 9569            {
 09570                cancellationToken.ThrowIfCancellationRequested();
 09571                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 9572            }
 9573            // Send Request
 09574            if (_shouldTrace)
 9575            {
 09576                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 9577            }
 09578            cancellationToken.ThrowIfCancellationRequested();
 09579            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 09580            if (_shouldTrace)
 9581            {
 09582                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 9583            }
 09584            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 09585            cancellationToken.ThrowIfCancellationRequested();
 09586            string _responseContent = null;
 09587            if ((int)_statusCode != 200)
 9588            {
 09589                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 9590                try
 9591                {
 09592                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 09593                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 09594                    if (_errorBody != null)
 9595                    {
 09596                        ex.Body = _errorBody;
 9597                    }
 09598                }
 09599                catch (JsonException)
 9600                {
 9601                    // Ignore the exception
 09602                }
 09603                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 09604                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 09605                if (_shouldTrace)
 9606                {
 09607                    ServiceClientTracing.Error(_invocationId, ex);
 9608                }
 09609                _httpRequest.Dispose();
 09610                if (_httpResponse != null)
 9611                {
 09612                    _httpResponse.Dispose();
 9613                }
 09614                throw ex;
 9615            }
 9616            // Create Result
 09617            var _result = new HttpOperationResponse<OperationStatus>();
 09618            _result.Request = _httpRequest;
 09619            _result.Response = _httpResponse;
 9620            // Deserialize Response
 09621            if ((int)_statusCode == 200)
 9622            {
 09623                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 9624                try
 9625                {
 09626                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 09627                }
 09628                catch (JsonException ex)
 9629                {
 09630                    _httpRequest.Dispose();
 09631                    if (_httpResponse != null)
 9632                    {
 09633                        _httpResponse.Dispose();
 9634                    }
 09635                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 9636                }
 9637            }
 09638            if (_shouldTrace)
 9639            {
 09640                ServiceClientTracing.Exit(_invocationId, _result);
 9641            }
 09642            return _result;
 09643        }
 9644
 9645        /// <summary>
 9646        /// Gets information about the regular expression entity models in a version of
 9647        /// the application.
 9648        /// </summary>
 9649        /// <param name='appId'>
 9650        /// The application ID.
 9651        /// </param>
 9652        /// <param name='versionId'>
 9653        /// The version ID.
 9654        /// </param>
 9655        /// <param name='skip'>
 9656        /// The number of entries to skip. Default value is 0.
 9657        /// </param>
 9658        /// <param name='take'>
 9659        /// The number of entries to return. Maximum page size is 500. Default is 100.
 9660        /// </param>
 9661        /// <param name='customHeaders'>
 9662        /// Headers that will be added to request.
 9663        /// </param>
 9664        /// <param name='cancellationToken'>
 9665        /// The cancellation token.
 9666        /// </param>
 9667        /// <exception cref="ErrorResponseException">
 9668        /// Thrown when the operation returned an invalid status code
 9669        /// </exception>
 9670        /// <exception cref="SerializationException">
 9671        /// Thrown when unable to deserialize the response
 9672        /// </exception>
 9673        /// <exception cref="ValidationException">
 9674        /// Thrown when a required parameter is null
 9675        /// </exception>
 9676        /// <exception cref="System.ArgumentNullException">
 9677        /// Thrown when a required parameter is null
 9678        /// </exception>
 9679        /// <return>
 9680        /// A response object containing the response body and response headers.
 9681        /// </return>
 9682        public async Task<HttpOperationResponse<IList<RegexEntityExtractor>>> ListRegexEntityInfosWithHttpMessagesAsync(
 9683        {
 29684            if (Client.Endpoint == null)
 9685            {
 09686                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 9687            }
 29688            if (versionId == null)
 9689            {
 09690                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 9691            }
 29692            if (skip < 0)
 9693            {
 09694                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 9695            }
 29696            if (take > 500)
 9697            {
 09698                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 9699            }
 29700            if (take < 0)
 9701            {
 09702                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 9703            }
 9704            // Tracing
 29705            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 29706            string _invocationId = null;
 29707            if (_shouldTrace)
 9708            {
 09709                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 09710                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 09711                tracingParameters.Add("appId", appId);
 09712                tracingParameters.Add("versionId", versionId);
 09713                tracingParameters.Add("skip", skip);
 09714                tracingParameters.Add("take", take);
 09715                tracingParameters.Add("cancellationToken", cancellationToken);
 09716                ServiceClientTracing.Enter(_invocationId, this, "ListRegexEntityInfos", tracingParameters);
 9717            }
 9718            // Construct URL
 29719            var _baseUrl = Client.BaseUri;
 29720            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 29721            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 29722            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 29723            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 29724            List<string> _queryParameters = new List<string>();
 29725            if (skip != null)
 9726            {
 29727                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 9728            }
 29729            if (take != null)
 9730            {
 29731                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 9732            }
 29733            if (_queryParameters.Count > 0)
 9734            {
 29735                _url += "?" + string.Join("&", _queryParameters);
 9736            }
 9737            // Create HTTP transport objects
 29738            var _httpRequest = new HttpRequestMessage();
 29739            HttpResponseMessage _httpResponse = null;
 29740            _httpRequest.Method = new HttpMethod("GET");
 29741            _httpRequest.RequestUri = new System.Uri(_url);
 9742            // Set Headers
 9743
 9744
 29745            if (customHeaders != null)
 9746            {
 09747                foreach(var _header in customHeaders)
 9748                {
 09749                    if (_httpRequest.Headers.Contains(_header.Key))
 9750                    {
 09751                        _httpRequest.Headers.Remove(_header.Key);
 9752                    }
 09753                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 9754                }
 9755            }
 9756
 9757            // Serialize Request
 29758            string _requestContent = null;
 9759            // Set Credentials
 29760            if (Client.Credentials != null)
 9761            {
 29762                cancellationToken.ThrowIfCancellationRequested();
 29763                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 9764            }
 9765            // Send Request
 29766            if (_shouldTrace)
 9767            {
 09768                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 9769            }
 29770            cancellationToken.ThrowIfCancellationRequested();
 29771            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 29772            if (_shouldTrace)
 9773            {
 09774                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 9775            }
 29776            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 29777            cancellationToken.ThrowIfCancellationRequested();
 29778            string _responseContent = null;
 29779            if ((int)_statusCode != 200)
 9780            {
 09781                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 9782                try
 9783                {
 09784                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 09785                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 09786                    if (_errorBody != null)
 9787                    {
 09788                        ex.Body = _errorBody;
 9789                    }
 09790                }
 09791                catch (JsonException)
 9792                {
 9793                    // Ignore the exception
 09794                }
 09795                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 09796                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 09797                if (_shouldTrace)
 9798                {
 09799                    ServiceClientTracing.Error(_invocationId, ex);
 9800                }
 09801                _httpRequest.Dispose();
 09802                if (_httpResponse != null)
 9803                {
 09804                    _httpResponse.Dispose();
 9805                }
 09806                throw ex;
 9807            }
 9808            // Create Result
 29809            var _result = new HttpOperationResponse<IList<RegexEntityExtractor>>();
 29810            _result.Request = _httpRequest;
 29811            _result.Response = _httpResponse;
 9812            // Deserialize Response
 29813            if ((int)_statusCode == 200)
 9814            {
 29815                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 9816                try
 9817                {
 29818                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<RegexEntityExtractor>>(_re
 29819                }
 09820                catch (JsonException ex)
 9821                {
 09822                    _httpRequest.Dispose();
 09823                    if (_httpResponse != null)
 9824                    {
 09825                        _httpResponse.Dispose();
 9826                    }
 09827                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 9828                }
 9829            }
 29830            if (_shouldTrace)
 9831            {
 09832                ServiceClientTracing.Exit(_invocationId, _result);
 9833            }
 29834            return _result;
 29835        }
 9836
 9837        /// <summary>
 9838        /// Adds a regular expression entity model to a version of the application.
 9839        /// </summary>
 9840        /// <param name='appId'>
 9841        /// The application ID.
 9842        /// </param>
 9843        /// <param name='versionId'>
 9844        /// The version ID.
 9845        /// </param>
 9846        /// <param name='regexEntityExtractorCreateObj'>
 9847        /// A model object containing the name and regex pattern for the new regular
 9848        /// expression entity extractor.
 9849        /// </param>
 9850        /// <param name='customHeaders'>
 9851        /// Headers that will be added to request.
 9852        /// </param>
 9853        /// <param name='cancellationToken'>
 9854        /// The cancellation token.
 9855        /// </param>
 9856        /// <exception cref="ErrorResponseException">
 9857        /// Thrown when the operation returned an invalid status code
 9858        /// </exception>
 9859        /// <exception cref="SerializationException">
 9860        /// Thrown when unable to deserialize the response
 9861        /// </exception>
 9862        /// <exception cref="ValidationException">
 9863        /// Thrown when a required parameter is null
 9864        /// </exception>
 9865        /// <exception cref="System.ArgumentNullException">
 9866        /// Thrown when a required parameter is null
 9867        /// </exception>
 9868        /// <return>
 9869        /// A response object containing the response body and response headers.
 9870        /// </return>
 9871        public async Task<HttpOperationResponse<System.Guid>> CreateRegexEntityModelWithHttpMessagesAsync(System.Guid ap
 9872        {
 109873            if (Client.Endpoint == null)
 9874            {
 09875                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 9876            }
 109877            if (versionId == null)
 9878            {
 09879                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 9880            }
 109881            if (regexEntityExtractorCreateObj == null)
 9882            {
 09883                throw new ValidationException(ValidationRules.CannotBeNull, "regexEntityExtractorCreateObj");
 9884            }
 9885            // Tracing
 109886            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 109887            string _invocationId = null;
 109888            if (_shouldTrace)
 9889            {
 09890                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 09891                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 09892                tracingParameters.Add("appId", appId);
 09893                tracingParameters.Add("versionId", versionId);
 09894                tracingParameters.Add("regexEntityExtractorCreateObj", regexEntityExtractorCreateObj);
 09895                tracingParameters.Add("cancellationToken", cancellationToken);
 09896                ServiceClientTracing.Enter(_invocationId, this, "CreateRegexEntityModel", tracingParameters);
 9897            }
 9898            // Construct URL
 109899            var _baseUrl = Client.BaseUri;
 109900            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 109901            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 109902            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 109903            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 9904            // Create HTTP transport objects
 109905            var _httpRequest = new HttpRequestMessage();
 109906            HttpResponseMessage _httpResponse = null;
 109907            _httpRequest.Method = new HttpMethod("POST");
 109908            _httpRequest.RequestUri = new System.Uri(_url);
 9909            // Set Headers
 9910
 9911
 109912            if (customHeaders != null)
 9913            {
 09914                foreach(var _header in customHeaders)
 9915                {
 09916                    if (_httpRequest.Headers.Contains(_header.Key))
 9917                    {
 09918                        _httpRequest.Headers.Remove(_header.Key);
 9919                    }
 09920                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 9921                }
 9922            }
 9923
 9924            // Serialize Request
 109925            string _requestContent = null;
 109926            if(regexEntityExtractorCreateObj != null)
 9927            {
 109928                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(regexEntityExtractorCreateObj, Clie
 109929                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 109930                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 9931            }
 9932            // Set Credentials
 109933            if (Client.Credentials != null)
 9934            {
 109935                cancellationToken.ThrowIfCancellationRequested();
 109936                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 9937            }
 9938            // Send Request
 109939            if (_shouldTrace)
 9940            {
 09941                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 9942            }
 109943            cancellationToken.ThrowIfCancellationRequested();
 109944            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 109945            if (_shouldTrace)
 9946            {
 09947                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 9948            }
 109949            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 109950            cancellationToken.ThrowIfCancellationRequested();
 109951            string _responseContent = null;
 109952            if ((int)_statusCode != 201)
 9953            {
 09954                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 9955                try
 9956                {
 09957                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 09958                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 09959                    if (_errorBody != null)
 9960                    {
 09961                        ex.Body = _errorBody;
 9962                    }
 09963                }
 09964                catch (JsonException)
 9965                {
 9966                    // Ignore the exception
 09967                }
 09968                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 09969                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 09970                if (_shouldTrace)
 9971                {
 09972                    ServiceClientTracing.Error(_invocationId, ex);
 9973                }
 09974                _httpRequest.Dispose();
 09975                if (_httpResponse != null)
 9976                {
 09977                    _httpResponse.Dispose();
 9978                }
 09979                throw ex;
 9980            }
 9981            // Create Result
 109982            var _result = new HttpOperationResponse<System.Guid>();
 109983            _result.Request = _httpRequest;
 109984            _result.Response = _httpResponse;
 9985            // Deserialize Response
 109986            if ((int)_statusCode == 201)
 9987            {
 109988                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 9989                try
 9990                {
 109991                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 109992                }
 09993                catch (JsonException ex)
 9994                {
 09995                    _httpRequest.Dispose();
 09996                    if (_httpResponse != null)
 9997                    {
 09998                        _httpResponse.Dispose();
 9999                    }
 010000                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 10001                }
 10002            }
 1010003            if (_shouldTrace)
 10004            {
 010005                ServiceClientTracing.Exit(_invocationId, _result);
 10006            }
 1010007            return _result;
 1010008        }
 10009
 10010        /// <summary>
 10011        /// Get information about the Pattern.Any entity models in a version of the
 10012        /// application.
 10013        /// </summary>
 10014        /// <param name='appId'>
 10015        /// The application ID.
 10016        /// </param>
 10017        /// <param name='versionId'>
 10018        /// The version ID.
 10019        /// </param>
 10020        /// <param name='skip'>
 10021        /// The number of entries to skip. Default value is 0.
 10022        /// </param>
 10023        /// <param name='take'>
 10024        /// The number of entries to return. Maximum page size is 500. Default is 100.
 10025        /// </param>
 10026        /// <param name='customHeaders'>
 10027        /// Headers that will be added to request.
 10028        /// </param>
 10029        /// <param name='cancellationToken'>
 10030        /// The cancellation token.
 10031        /// </param>
 10032        /// <exception cref="ErrorResponseException">
 10033        /// Thrown when the operation returned an invalid status code
 10034        /// </exception>
 10035        /// <exception cref="SerializationException">
 10036        /// Thrown when unable to deserialize the response
 10037        /// </exception>
 10038        /// <exception cref="ValidationException">
 10039        /// Thrown when a required parameter is null
 10040        /// </exception>
 10041        /// <exception cref="System.ArgumentNullException">
 10042        /// Thrown when a required parameter is null
 10043        /// </exception>
 10044        /// <return>
 10045        /// A response object containing the response body and response headers.
 10046        /// </return>
 10047        public async Task<HttpOperationResponse<IList<PatternAnyEntityExtractor>>> ListPatternAnyEntityInfosWithHttpMess
 10048        {
 210049            if (Client.Endpoint == null)
 10050            {
 010051                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 10052            }
 210053            if (versionId == null)
 10054            {
 010055                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 10056            }
 210057            if (skip < 0)
 10058            {
 010059                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 10060            }
 210061            if (take > 500)
 10062            {
 010063                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 10064            }
 210065            if (take < 0)
 10066            {
 010067                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 10068            }
 10069            // Tracing
 210070            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 210071            string _invocationId = null;
 210072            if (_shouldTrace)
 10073            {
 010074                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 010075                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 010076                tracingParameters.Add("appId", appId);
 010077                tracingParameters.Add("versionId", versionId);
 010078                tracingParameters.Add("skip", skip);
 010079                tracingParameters.Add("take", take);
 010080                tracingParameters.Add("cancellationToken", cancellationToken);
 010081                ServiceClientTracing.Enter(_invocationId, this, "ListPatternAnyEntityInfos", tracingParameters);
 10082            }
 10083            // Construct URL
 210084            var _baseUrl = Client.BaseUri;
 210085            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 210086            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 210087            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 210088            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 210089            List<string> _queryParameters = new List<string>();
 210090            if (skip != null)
 10091            {
 210092                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 10093            }
 210094            if (take != null)
 10095            {
 210096                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 10097            }
 210098            if (_queryParameters.Count > 0)
 10099            {
 210100                _url += "?" + string.Join("&", _queryParameters);
 10101            }
 10102            // Create HTTP transport objects
 210103            var _httpRequest = new HttpRequestMessage();
 210104            HttpResponseMessage _httpResponse = null;
 210105            _httpRequest.Method = new HttpMethod("GET");
 210106            _httpRequest.RequestUri = new System.Uri(_url);
 10107            // Set Headers
 10108
 10109
 210110            if (customHeaders != null)
 10111            {
 010112                foreach(var _header in customHeaders)
 10113                {
 010114                    if (_httpRequest.Headers.Contains(_header.Key))
 10115                    {
 010116                        _httpRequest.Headers.Remove(_header.Key);
 10117                    }
 010118                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 10119                }
 10120            }
 10121
 10122            // Serialize Request
 210123            string _requestContent = null;
 10124            // Set Credentials
 210125            if (Client.Credentials != null)
 10126            {
 210127                cancellationToken.ThrowIfCancellationRequested();
 210128                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 10129            }
 10130            // Send Request
 210131            if (_shouldTrace)
 10132            {
 010133                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 10134            }
 210135            cancellationToken.ThrowIfCancellationRequested();
 210136            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 210137            if (_shouldTrace)
 10138            {
 010139                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 10140            }
 210141            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 210142            cancellationToken.ThrowIfCancellationRequested();
 210143            string _responseContent = null;
 210144            if ((int)_statusCode != 200)
 10145            {
 010146                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 10147                try
 10148                {
 010149                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 010150                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 010151                    if (_errorBody != null)
 10152                    {
 010153                        ex.Body = _errorBody;
 10154                    }
 010155                }
 010156                catch (JsonException)
 10157                {
 10158                    // Ignore the exception
 010159                }
 010160                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 010161                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 010162                if (_shouldTrace)
 10163                {
 010164                    ServiceClientTracing.Error(_invocationId, ex);
 10165                }
 010166                _httpRequest.Dispose();
 010167                if (_httpResponse != null)
 10168                {
 010169                    _httpResponse.Dispose();
 10170                }
 010171                throw ex;
 10172            }
 10173            // Create Result
 210174            var _result = new HttpOperationResponse<IList<PatternAnyEntityExtractor>>();
 210175            _result.Request = _httpRequest;
 210176            _result.Response = _httpResponse;
 10177            // Deserialize Response
 210178            if ((int)_statusCode == 200)
 10179            {
 210180                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 10181                try
 10182                {
 210183                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<PatternAnyEntityExtractor>
 210184                }
 010185                catch (JsonException ex)
 10186                {
 010187                    _httpRequest.Dispose();
 010188                    if (_httpResponse != null)
 10189                    {
 010190                        _httpResponse.Dispose();
 10191                    }
 010192                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 10193                }
 10194            }
 210195            if (_shouldTrace)
 10196            {
 010197                ServiceClientTracing.Exit(_invocationId, _result);
 10198            }
 210199            return _result;
 210200        }
 10201
 10202        /// <summary>
 10203        /// Adds a pattern.any entity extractor to a version of the application.
 10204        /// </summary>
 10205        /// <param name='appId'>
 10206        /// The application ID.
 10207        /// </param>
 10208        /// <param name='versionId'>
 10209        /// The version ID.
 10210        /// </param>
 10211        /// <param name='extractorCreateObject'>
 10212        /// A model object containing the name and explicit list for the new
 10213        /// Pattern.Any entity extractor.
 10214        /// </param>
 10215        /// <param name='customHeaders'>
 10216        /// Headers that will be added to request.
 10217        /// </param>
 10218        /// <param name='cancellationToken'>
 10219        /// The cancellation token.
 10220        /// </param>
 10221        /// <exception cref="ErrorResponseException">
 10222        /// Thrown when the operation returned an invalid status code
 10223        /// </exception>
 10224        /// <exception cref="SerializationException">
 10225        /// Thrown when unable to deserialize the response
 10226        /// </exception>
 10227        /// <exception cref="ValidationException">
 10228        /// Thrown when a required parameter is null
 10229        /// </exception>
 10230        /// <exception cref="System.ArgumentNullException">
 10231        /// Thrown when a required parameter is null
 10232        /// </exception>
 10233        /// <return>
 10234        /// A response object containing the response body and response headers.
 10235        /// </return>
 10236        public async Task<HttpOperationResponse<System.Guid>> CreatePatternAnyEntityModelWithHttpMessagesAsync(System.Gu
 10237        {
 1510238            if (Client.Endpoint == null)
 10239            {
 010240                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 10241            }
 1510242            if (versionId == null)
 10243            {
 010244                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 10245            }
 1510246            if (extractorCreateObject == null)
 10247            {
 010248                throw new ValidationException(ValidationRules.CannotBeNull, "extractorCreateObject");
 10249            }
 10250            // Tracing
 1510251            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 1510252            string _invocationId = null;
 1510253            if (_shouldTrace)
 10254            {
 010255                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 010256                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 010257                tracingParameters.Add("appId", appId);
 010258                tracingParameters.Add("versionId", versionId);
 010259                tracingParameters.Add("extractorCreateObject", extractorCreateObject);
 010260                tracingParameters.Add("cancellationToken", cancellationToken);
 010261                ServiceClientTracing.Enter(_invocationId, this, "CreatePatternAnyEntityModel", tracingParameters);
 10262            }
 10263            // Construct URL
 1510264            var _baseUrl = Client.BaseUri;
 1510265            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 1510266            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 1510267            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 1510268            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 10269            // Create HTTP transport objects
 1510270            var _httpRequest = new HttpRequestMessage();
 1510271            HttpResponseMessage _httpResponse = null;
 1510272            _httpRequest.Method = new HttpMethod("POST");
 1510273            _httpRequest.RequestUri = new System.Uri(_url);
 10274            // Set Headers
 10275
 10276
 1510277            if (customHeaders != null)
 10278            {
 010279                foreach(var _header in customHeaders)
 10280                {
 010281                    if (_httpRequest.Headers.Contains(_header.Key))
 10282                    {
 010283                        _httpRequest.Headers.Remove(_header.Key);
 10284                    }
 010285                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 10286                }
 10287            }
 10288
 10289            // Serialize Request
 1510290            string _requestContent = null;
 1510291            if(extractorCreateObject != null)
 10292            {
 1510293                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(extractorCreateObject, Client.Seria
 1510294                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 1510295                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 10296            }
 10297            // Set Credentials
 1510298            if (Client.Credentials != null)
 10299            {
 1510300                cancellationToken.ThrowIfCancellationRequested();
 1510301                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 10302            }
 10303            // Send Request
 1510304            if (_shouldTrace)
 10305            {
 010306                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 10307            }
 1510308            cancellationToken.ThrowIfCancellationRequested();
 1510309            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1510310            if (_shouldTrace)
 10311            {
 010312                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 10313            }
 1510314            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 1510315            cancellationToken.ThrowIfCancellationRequested();
 1510316            string _responseContent = null;
 1510317            if ((int)_statusCode != 201)
 10318            {
 010319                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 10320                try
 10321                {
 010322                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 010323                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 010324                    if (_errorBody != null)
 10325                    {
 010326                        ex.Body = _errorBody;
 10327                    }
 010328                }
 010329                catch (JsonException)
 10330                {
 10331                    // Ignore the exception
 010332                }
 010333                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 010334                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 010335                if (_shouldTrace)
 10336                {
 010337                    ServiceClientTracing.Error(_invocationId, ex);
 10338                }
 010339                _httpRequest.Dispose();
 010340                if (_httpResponse != null)
 10341                {
 010342                    _httpResponse.Dispose();
 10343                }
 010344                throw ex;
 10345            }
 10346            // Create Result
 1510347            var _result = new HttpOperationResponse<System.Guid>();
 1510348            _result.Request = _httpRequest;
 1510349            _result.Response = _httpResponse;
 10350            // Deserialize Response
 1510351            if ((int)_statusCode == 201)
 10352            {
 1510353                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 10354                try
 10355                {
 1510356                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 1510357                }
 010358                catch (JsonException ex)
 10359                {
 010360                    _httpRequest.Dispose();
 010361                    if (_httpResponse != null)
 10362                    {
 010363                        _httpResponse.Dispose();
 10364                    }
 010365                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 10366                }
 10367            }
 1510368            if (_shouldTrace)
 10369            {
 010370                ServiceClientTracing.Exit(_invocationId, _result);
 10371            }
 1510372            return _result;
 1510373        }
 10374
 10375        /// <summary>
 10376        /// Get all roles for an entity in a version of the application
 10377        /// </summary>
 10378        /// <param name='appId'>
 10379        /// The application ID.
 10380        /// </param>
 10381        /// <param name='versionId'>
 10382        /// The version ID.
 10383        /// </param>
 10384        /// <param name='entityId'>
 10385        /// entity Id
 10386        /// </param>
 10387        /// <param name='customHeaders'>
 10388        /// Headers that will be added to request.
 10389        /// </param>
 10390        /// <param name='cancellationToken'>
 10391        /// The cancellation token.
 10392        /// </param>
 10393        /// <exception cref="ErrorResponseException">
 10394        /// Thrown when the operation returned an invalid status code
 10395        /// </exception>
 10396        /// <exception cref="SerializationException">
 10397        /// Thrown when unable to deserialize the response
 10398        /// </exception>
 10399        /// <exception cref="ValidationException">
 10400        /// Thrown when a required parameter is null
 10401        /// </exception>
 10402        /// <exception cref="System.ArgumentNullException">
 10403        /// Thrown when a required parameter is null
 10404        /// </exception>
 10405        /// <return>
 10406        /// A response object containing the response body and response headers.
 10407        /// </return>
 10408        public async Task<HttpOperationResponse<IList<EntityRole>>> ListEntityRolesWithHttpMessagesAsync(System.Guid app
 10409        {
 310410            if (Client.Endpoint == null)
 10411            {
 010412                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 10413            }
 310414            if (versionId == null)
 10415            {
 010416                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 10417            }
 10418            // Tracing
 310419            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 310420            string _invocationId = null;
 310421            if (_shouldTrace)
 10422            {
 010423                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 010424                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 010425                tracingParameters.Add("appId", appId);
 010426                tracingParameters.Add("versionId", versionId);
 010427                tracingParameters.Add("entityId", entityId);
 010428                tracingParameters.Add("cancellationToken", cancellationToken);
 010429                ServiceClientTracing.Enter(_invocationId, this, "ListEntityRoles", tracingParameters);
 10430            }
 10431            // Construct URL
 310432            var _baseUrl = Client.BaseUri;
 310433            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 310434            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 310435            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 310436            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 310437            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 10438            // Create HTTP transport objects
 310439            var _httpRequest = new HttpRequestMessage();
 310440            HttpResponseMessage _httpResponse = null;
 310441            _httpRequest.Method = new HttpMethod("GET");
 310442            _httpRequest.RequestUri = new System.Uri(_url);
 10443            // Set Headers
 10444
 10445
 310446            if (customHeaders != null)
 10447            {
 010448                foreach(var _header in customHeaders)
 10449                {
 010450                    if (_httpRequest.Headers.Contains(_header.Key))
 10451                    {
 010452                        _httpRequest.Headers.Remove(_header.Key);
 10453                    }
 010454                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 10455                }
 10456            }
 10457
 10458            // Serialize Request
 310459            string _requestContent = null;
 10460            // Set Credentials
 310461            if (Client.Credentials != null)
 10462            {
 310463                cancellationToken.ThrowIfCancellationRequested();
 310464                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 10465            }
 10466            // Send Request
 310467            if (_shouldTrace)
 10468            {
 010469                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 10470            }
 310471            cancellationToken.ThrowIfCancellationRequested();
 310472            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 310473            if (_shouldTrace)
 10474            {
 010475                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 10476            }
 310477            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 310478            cancellationToken.ThrowIfCancellationRequested();
 310479            string _responseContent = null;
 310480            if ((int)_statusCode != 200)
 10481            {
 010482                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 10483                try
 10484                {
 010485                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 010486                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 010487                    if (_errorBody != null)
 10488                    {
 010489                        ex.Body = _errorBody;
 10490                    }
 010491                }
 010492                catch (JsonException)
 10493                {
 10494                    // Ignore the exception
 010495                }
 010496                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 010497                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 010498                if (_shouldTrace)
 10499                {
 010500                    ServiceClientTracing.Error(_invocationId, ex);
 10501                }
 010502                _httpRequest.Dispose();
 010503                if (_httpResponse != null)
 10504                {
 010505                    _httpResponse.Dispose();
 10506                }
 010507                throw ex;
 10508            }
 10509            // Create Result
 310510            var _result = new HttpOperationResponse<IList<EntityRole>>();
 310511            _result.Request = _httpRequest;
 310512            _result.Response = _httpResponse;
 10513            // Deserialize Response
 310514            if ((int)_statusCode == 200)
 10515            {
 310516                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 10517                try
 10518                {
 310519                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont
 310520                }
 010521                catch (JsonException ex)
 10522                {
 010523                    _httpRequest.Dispose();
 010524                    if (_httpResponse != null)
 10525                    {
 010526                        _httpResponse.Dispose();
 10527                    }
 010528                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 10529                }
 10530            }
 310531            if (_shouldTrace)
 10532            {
 010533                ServiceClientTracing.Exit(_invocationId, _result);
 10534            }
 310535            return _result;
 310536        }
 10537
 10538        /// <summary>
 10539        /// Create an entity role in a version of the application.
 10540        /// </summary>
 10541        /// <param name='appId'>
 10542        /// The application ID.
 10543        /// </param>
 10544        /// <param name='versionId'>
 10545        /// The version ID.
 10546        /// </param>
 10547        /// <param name='entityId'>
 10548        /// The entity model ID.
 10549        /// </param>
 10550        /// <param name='entityRoleCreateObject'>
 10551        /// An entity role object containing the name of role.
 10552        /// </param>
 10553        /// <param name='customHeaders'>
 10554        /// Headers that will be added to request.
 10555        /// </param>
 10556        /// <param name='cancellationToken'>
 10557        /// The cancellation token.
 10558        /// </param>
 10559        /// <exception cref="ErrorResponseException">
 10560        /// Thrown when the operation returned an invalid status code
 10561        /// </exception>
 10562        /// <exception cref="SerializationException">
 10563        /// Thrown when unable to deserialize the response
 10564        /// </exception>
 10565        /// <exception cref="ValidationException">
 10566        /// Thrown when a required parameter is null
 10567        /// </exception>
 10568        /// <exception cref="System.ArgumentNullException">
 10569        /// Thrown when a required parameter is null
 10570        /// </exception>
 10571        /// <return>
 10572        /// A response object containing the response body and response headers.
 10573        /// </return>
 10574        public async Task<HttpOperationResponse<System.Guid>> CreateEntityRoleWithHttpMessagesAsync(System.Guid appId, s
 10575        {
 510576            if (Client.Endpoint == null)
 10577            {
 010578                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 10579            }
 510580            if (versionId == null)
 10581            {
 010582                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 10583            }
 510584            if (entityRoleCreateObject == null)
 10585            {
 010586                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject");
 10587            }
 10588            // Tracing
 510589            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 510590            string _invocationId = null;
 510591            if (_shouldTrace)
 10592            {
 010593                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 010594                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 010595                tracingParameters.Add("appId", appId);
 010596                tracingParameters.Add("versionId", versionId);
 010597                tracingParameters.Add("entityId", entityId);
 010598                tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject);
 010599                tracingParameters.Add("cancellationToken", cancellationToken);
 010600                ServiceClientTracing.Enter(_invocationId, this, "CreateEntityRole", tracingParameters);
 10601            }
 10602            // Construct URL
 510603            var _baseUrl = Client.BaseUri;
 510604            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 510605            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 510606            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 510607            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 510608            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 10609            // Create HTTP transport objects
 510610            var _httpRequest = new HttpRequestMessage();
 510611            HttpResponseMessage _httpResponse = null;
 510612            _httpRequest.Method = new HttpMethod("POST");
 510613            _httpRequest.RequestUri = new System.Uri(_url);
 10614            // Set Headers
 10615
 10616
 510617            if (customHeaders != null)
 10618            {
 010619                foreach(var _header in customHeaders)
 10620                {
 010621                    if (_httpRequest.Headers.Contains(_header.Key))
 10622                    {
 010623                        _httpRequest.Headers.Remove(_header.Key);
 10624                    }
 010625                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 10626                }
 10627            }
 10628
 10629            // Serialize Request
 510630            string _requestContent = null;
 510631            if(entityRoleCreateObject != null)
 10632            {
 510633                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri
 510634                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 510635                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 10636            }
 10637            // Set Credentials
 510638            if (Client.Credentials != null)
 10639            {
 510640                cancellationToken.ThrowIfCancellationRequested();
 510641                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 10642            }
 10643            // Send Request
 510644            if (_shouldTrace)
 10645            {
 010646                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 10647            }
 510648            cancellationToken.ThrowIfCancellationRequested();
 510649            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 510650            if (_shouldTrace)
 10651            {
 010652                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 10653            }
 510654            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 510655            cancellationToken.ThrowIfCancellationRequested();
 510656            string _responseContent = null;
 510657            if ((int)_statusCode != 201)
 10658            {
 010659                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 10660                try
 10661                {
 010662                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 010663                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 010664                    if (_errorBody != null)
 10665                    {
 010666                        ex.Body = _errorBody;
 10667                    }
 010668                }
 010669                catch (JsonException)
 10670                {
 10671                    // Ignore the exception
 010672                }
 010673                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 010674                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 010675                if (_shouldTrace)
 10676                {
 010677                    ServiceClientTracing.Error(_invocationId, ex);
 10678                }
 010679                _httpRequest.Dispose();
 010680                if (_httpResponse != null)
 10681                {
 010682                    _httpResponse.Dispose();
 10683                }
 010684                throw ex;
 10685            }
 10686            // Create Result
 510687            var _result = new HttpOperationResponse<System.Guid>();
 510688            _result.Request = _httpRequest;
 510689            _result.Response = _httpResponse;
 10690            // Deserialize Response
 510691            if ((int)_statusCode == 201)
 10692            {
 510693                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 10694                try
 10695                {
 510696                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 510697                }
 010698                catch (JsonException ex)
 10699                {
 010700                    _httpRequest.Dispose();
 010701                    if (_httpResponse != null)
 10702                    {
 010703                        _httpResponse.Dispose();
 10704                    }
 010705                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 10706                }
 10707            }
 510708            if (_shouldTrace)
 10709            {
 010710                ServiceClientTracing.Exit(_invocationId, _result);
 10711            }
 510712            return _result;
 510713        }
 10714
 10715        /// <summary>
 10716        /// Get a prebuilt entity's roles in a version of the application.
 10717        /// </summary>
 10718        /// <param name='appId'>
 10719        /// The application ID.
 10720        /// </param>
 10721        /// <param name='versionId'>
 10722        /// The version ID.
 10723        /// </param>
 10724        /// <param name='entityId'>
 10725        /// entity Id
 10726        /// </param>
 10727        /// <param name='customHeaders'>
 10728        /// Headers that will be added to request.
 10729        /// </param>
 10730        /// <param name='cancellationToken'>
 10731        /// The cancellation token.
 10732        /// </param>
 10733        /// <exception cref="ErrorResponseException">
 10734        /// Thrown when the operation returned an invalid status code
 10735        /// </exception>
 10736        /// <exception cref="SerializationException">
 10737        /// Thrown when unable to deserialize the response
 10738        /// </exception>
 10739        /// <exception cref="ValidationException">
 10740        /// Thrown when a required parameter is null
 10741        /// </exception>
 10742        /// <exception cref="System.ArgumentNullException">
 10743        /// Thrown when a required parameter is null
 10744        /// </exception>
 10745        /// <return>
 10746        /// A response object containing the response body and response headers.
 10747        /// </return>
 10748        public async Task<HttpOperationResponse<IList<EntityRole>>> ListPrebuiltEntityRolesWithHttpMessagesAsync(System.
 10749        {
 310750            if (Client.Endpoint == null)
 10751            {
 010752                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 10753            }
 310754            if (versionId == null)
 10755            {
 010756                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 10757            }
 10758            // Tracing
 310759            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 310760            string _invocationId = null;
 310761            if (_shouldTrace)
 10762            {
 010763                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 010764                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 010765                tracingParameters.Add("appId", appId);
 010766                tracingParameters.Add("versionId", versionId);
 010767                tracingParameters.Add("entityId", entityId);
 010768                tracingParameters.Add("cancellationToken", cancellationToken);
 010769                ServiceClientTracing.Enter(_invocationId, this, "ListPrebuiltEntityRoles", tracingParameters);
 10770            }
 10771            // Construct URL
 310772            var _baseUrl = Client.BaseUri;
 310773            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en
 310774            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 310775            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 310776            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 310777            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 10778            // Create HTTP transport objects
 310779            var _httpRequest = new HttpRequestMessage();
 310780            HttpResponseMessage _httpResponse = null;
 310781            _httpRequest.Method = new HttpMethod("GET");
 310782            _httpRequest.RequestUri = new System.Uri(_url);
 10783            // Set Headers
 10784
 10785
 310786            if (customHeaders != null)
 10787            {
 010788                foreach(var _header in customHeaders)
 10789                {
 010790                    if (_httpRequest.Headers.Contains(_header.Key))
 10791                    {
 010792                        _httpRequest.Headers.Remove(_header.Key);
 10793                    }
 010794                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 10795                }
 10796            }
 10797
 10798            // Serialize Request
 310799            string _requestContent = null;
 10800            // Set Credentials
 310801            if (Client.Credentials != null)
 10802            {
 310803                cancellationToken.ThrowIfCancellationRequested();
 310804                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 10805            }
 10806            // Send Request
 310807            if (_shouldTrace)
 10808            {
 010809                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 10810            }
 310811            cancellationToken.ThrowIfCancellationRequested();
 310812            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 310813            if (_shouldTrace)
 10814            {
 010815                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 10816            }
 310817            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 310818            cancellationToken.ThrowIfCancellationRequested();
 310819            string _responseContent = null;
 310820            if ((int)_statusCode != 200)
 10821            {
 010822                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 10823                try
 10824                {
 010825                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 010826                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 010827                    if (_errorBody != null)
 10828                    {
 010829                        ex.Body = _errorBody;
 10830                    }
 010831                }
 010832                catch (JsonException)
 10833                {
 10834                    // Ignore the exception
 010835                }
 010836                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 010837                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 010838                if (_shouldTrace)
 10839                {
 010840                    ServiceClientTracing.Error(_invocationId, ex);
 10841                }
 010842                _httpRequest.Dispose();
 010843                if (_httpResponse != null)
 10844                {
 010845                    _httpResponse.Dispose();
 10846                }
 010847                throw ex;
 10848            }
 10849            // Create Result
 310850            var _result = new HttpOperationResponse<IList<EntityRole>>();
 310851            _result.Request = _httpRequest;
 310852            _result.Response = _httpResponse;
 10853            // Deserialize Response
 310854            if ((int)_statusCode == 200)
 10855            {
 310856                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 10857                try
 10858                {
 310859                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont
 310860                }
 010861                catch (JsonException ex)
 10862                {
 010863                    _httpRequest.Dispose();
 010864                    if (_httpResponse != null)
 10865                    {
 010866                        _httpResponse.Dispose();
 10867                    }
 010868                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 10869                }
 10870            }
 310871            if (_shouldTrace)
 10872            {
 010873                ServiceClientTracing.Exit(_invocationId, _result);
 10874            }
 310875            return _result;
 310876        }
 10877
 10878        /// <summary>
 10879        /// Create a role for a prebuilt entity in a version of the application.
 10880        /// </summary>
 10881        /// <param name='appId'>
 10882        /// The application ID.
 10883        /// </param>
 10884        /// <param name='versionId'>
 10885        /// The version ID.
 10886        /// </param>
 10887        /// <param name='entityId'>
 10888        /// The entity model ID.
 10889        /// </param>
 10890        /// <param name='entityRoleCreateObject'>
 10891        /// An entity role object containing the name of role.
 10892        /// </param>
 10893        /// <param name='customHeaders'>
 10894        /// Headers that will be added to request.
 10895        /// </param>
 10896        /// <param name='cancellationToken'>
 10897        /// The cancellation token.
 10898        /// </param>
 10899        /// <exception cref="ErrorResponseException">
 10900        /// Thrown when the operation returned an invalid status code
 10901        /// </exception>
 10902        /// <exception cref="SerializationException">
 10903        /// Thrown when unable to deserialize the response
 10904        /// </exception>
 10905        /// <exception cref="ValidationException">
 10906        /// Thrown when a required parameter is null
 10907        /// </exception>
 10908        /// <exception cref="System.ArgumentNullException">
 10909        /// Thrown when a required parameter is null
 10910        /// </exception>
 10911        /// <return>
 10912        /// A response object containing the response body and response headers.
 10913        /// </return>
 10914        public async Task<HttpOperationResponse<System.Guid>> CreatePrebuiltEntityRoleWithHttpMessagesAsync(System.Guid 
 10915        {
 510916            if (Client.Endpoint == null)
 10917            {
 010918                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 10919            }
 510920            if (versionId == null)
 10921            {
 010922                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 10923            }
 510924            if (entityRoleCreateObject == null)
 10925            {
 010926                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject");
 10927            }
 10928            // Tracing
 510929            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 510930            string _invocationId = null;
 510931            if (_shouldTrace)
 10932            {
 010933                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 010934                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 010935                tracingParameters.Add("appId", appId);
 010936                tracingParameters.Add("versionId", versionId);
 010937                tracingParameters.Add("entityId", entityId);
 010938                tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject);
 010939                tracingParameters.Add("cancellationToken", cancellationToken);
 010940                ServiceClientTracing.Enter(_invocationId, this, "CreatePrebuiltEntityRole", tracingParameters);
 10941            }
 10942            // Construct URL
 510943            var _baseUrl = Client.BaseUri;
 510944            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en
 510945            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 510946            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 510947            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 510948            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 10949            // Create HTTP transport objects
 510950            var _httpRequest = new HttpRequestMessage();
 510951            HttpResponseMessage _httpResponse = null;
 510952            _httpRequest.Method = new HttpMethod("POST");
 510953            _httpRequest.RequestUri = new System.Uri(_url);
 10954            // Set Headers
 10955
 10956
 510957            if (customHeaders != null)
 10958            {
 010959                foreach(var _header in customHeaders)
 10960                {
 010961                    if (_httpRequest.Headers.Contains(_header.Key))
 10962                    {
 010963                        _httpRequest.Headers.Remove(_header.Key);
 10964                    }
 010965                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 10966                }
 10967            }
 10968
 10969            // Serialize Request
 510970            string _requestContent = null;
 510971            if(entityRoleCreateObject != null)
 10972            {
 510973                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri
 510974                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 510975                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 10976            }
 10977            // Set Credentials
 510978            if (Client.Credentials != null)
 10979            {
 510980                cancellationToken.ThrowIfCancellationRequested();
 510981                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 10982            }
 10983            // Send Request
 510984            if (_shouldTrace)
 10985            {
 010986                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 10987            }
 510988            cancellationToken.ThrowIfCancellationRequested();
 510989            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 510990            if (_shouldTrace)
 10991            {
 010992                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 10993            }
 510994            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 510995            cancellationToken.ThrowIfCancellationRequested();
 510996            string _responseContent = null;
 510997            if ((int)_statusCode != 201)
 10998            {
 010999                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 11000                try
 11001                {
 011002                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 011003                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 011004                    if (_errorBody != null)
 11005                    {
 011006                        ex.Body = _errorBody;
 11007                    }
 011008                }
 011009                catch (JsonException)
 11010                {
 11011                    // Ignore the exception
 011012                }
 011013                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 011014                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 011015                if (_shouldTrace)
 11016                {
 011017                    ServiceClientTracing.Error(_invocationId, ex);
 11018                }
 011019                _httpRequest.Dispose();
 011020                if (_httpResponse != null)
 11021                {
 011022                    _httpResponse.Dispose();
 11023                }
 011024                throw ex;
 11025            }
 11026            // Create Result
 511027            var _result = new HttpOperationResponse<System.Guid>();
 511028            _result.Request = _httpRequest;
 511029            _result.Response = _httpResponse;
 11030            // Deserialize Response
 511031            if ((int)_statusCode == 201)
 11032            {
 511033                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 11034                try
 11035                {
 511036                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 511037                }
 011038                catch (JsonException ex)
 11039                {
 011040                    _httpRequest.Dispose();
 011041                    if (_httpResponse != null)
 11042                    {
 011043                        _httpResponse.Dispose();
 11044                    }
 011045                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 11046                }
 11047            }
 511048            if (_shouldTrace)
 11049            {
 011050                ServiceClientTracing.Exit(_invocationId, _result);
 11051            }
 511052            return _result;
 511053        }
 11054
 11055        /// <summary>
 11056        /// Get all roles for a list entity in a version of the application.
 11057        /// </summary>
 11058        /// <param name='appId'>
 11059        /// The application ID.
 11060        /// </param>
 11061        /// <param name='versionId'>
 11062        /// The version ID.
 11063        /// </param>
 11064        /// <param name='entityId'>
 11065        /// entity Id
 11066        /// </param>
 11067        /// <param name='customHeaders'>
 11068        /// Headers that will be added to request.
 11069        /// </param>
 11070        /// <param name='cancellationToken'>
 11071        /// The cancellation token.
 11072        /// </param>
 11073        /// <exception cref="ErrorResponseException">
 11074        /// Thrown when the operation returned an invalid status code
 11075        /// </exception>
 11076        /// <exception cref="SerializationException">
 11077        /// Thrown when unable to deserialize the response
 11078        /// </exception>
 11079        /// <exception cref="ValidationException">
 11080        /// Thrown when a required parameter is null
 11081        /// </exception>
 11082        /// <exception cref="System.ArgumentNullException">
 11083        /// Thrown when a required parameter is null
 11084        /// </exception>
 11085        /// <return>
 11086        /// A response object containing the response body and response headers.
 11087        /// </return>
 11088        public async Task<HttpOperationResponse<IList<EntityRole>>> ListClosedListEntityRolesWithHttpMessagesAsync(Syste
 11089        {
 311090            if (Client.Endpoint == null)
 11091            {
 011092                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 11093            }
 311094            if (versionId == null)
 11095            {
 011096                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 11097            }
 11098            // Tracing
 311099            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 311100            string _invocationId = null;
 311101            if (_shouldTrace)
 11102            {
 011103                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 011104                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 011105                tracingParameters.Add("appId", appId);
 011106                tracingParameters.Add("versionId", versionId);
 011107                tracingParameters.Add("entityId", entityId);
 011108                tracingParameters.Add("cancellationToken", cancellationToken);
 011109                ServiceClientTracing.Enter(_invocationId, this, "ListClosedListEntityRoles", tracingParameters);
 11110            }
 11111            // Construct URL
 311112            var _baseUrl = Client.BaseUri;
 311113            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 311114            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 311115            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 311116            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 311117            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 11118            // Create HTTP transport objects
 311119            var _httpRequest = new HttpRequestMessage();
 311120            HttpResponseMessage _httpResponse = null;
 311121            _httpRequest.Method = new HttpMethod("GET");
 311122            _httpRequest.RequestUri = new System.Uri(_url);
 11123            // Set Headers
 11124
 11125
 311126            if (customHeaders != null)
 11127            {
 011128                foreach(var _header in customHeaders)
 11129                {
 011130                    if (_httpRequest.Headers.Contains(_header.Key))
 11131                    {
 011132                        _httpRequest.Headers.Remove(_header.Key);
 11133                    }
 011134                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 11135                }
 11136            }
 11137
 11138            // Serialize Request
 311139            string _requestContent = null;
 11140            // Set Credentials
 311141            if (Client.Credentials != null)
 11142            {
 311143                cancellationToken.ThrowIfCancellationRequested();
 311144                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11145            }
 11146            // Send Request
 311147            if (_shouldTrace)
 11148            {
 011149                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 11150            }
 311151            cancellationToken.ThrowIfCancellationRequested();
 311152            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 311153            if (_shouldTrace)
 11154            {
 011155                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 11156            }
 311157            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 311158            cancellationToken.ThrowIfCancellationRequested();
 311159            string _responseContent = null;
 311160            if ((int)_statusCode != 200)
 11161            {
 011162                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 11163                try
 11164                {
 011165                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 011166                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 011167                    if (_errorBody != null)
 11168                    {
 011169                        ex.Body = _errorBody;
 11170                    }
 011171                }
 011172                catch (JsonException)
 11173                {
 11174                    // Ignore the exception
 011175                }
 011176                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 011177                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 011178                if (_shouldTrace)
 11179                {
 011180                    ServiceClientTracing.Error(_invocationId, ex);
 11181                }
 011182                _httpRequest.Dispose();
 011183                if (_httpResponse != null)
 11184                {
 011185                    _httpResponse.Dispose();
 11186                }
 011187                throw ex;
 11188            }
 11189            // Create Result
 311190            var _result = new HttpOperationResponse<IList<EntityRole>>();
 311191            _result.Request = _httpRequest;
 311192            _result.Response = _httpResponse;
 11193            // Deserialize Response
 311194            if ((int)_statusCode == 200)
 11195            {
 311196                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 11197                try
 11198                {
 311199                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont
 311200                }
 011201                catch (JsonException ex)
 11202                {
 011203                    _httpRequest.Dispose();
 011204                    if (_httpResponse != null)
 11205                    {
 011206                        _httpResponse.Dispose();
 11207                    }
 011208                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 11209                }
 11210            }
 311211            if (_shouldTrace)
 11212            {
 011213                ServiceClientTracing.Exit(_invocationId, _result);
 11214            }
 311215            return _result;
 311216        }
 11217
 11218        /// <summary>
 11219        /// Create a role for a list entity in a version of the application.
 11220        /// </summary>
 11221        /// <param name='appId'>
 11222        /// The application ID.
 11223        /// </param>
 11224        /// <param name='versionId'>
 11225        /// The version ID.
 11226        /// </param>
 11227        /// <param name='entityId'>
 11228        /// The entity model ID.
 11229        /// </param>
 11230        /// <param name='entityRoleCreateObject'>
 11231        /// An entity role object containing the name of role.
 11232        /// </param>
 11233        /// <param name='customHeaders'>
 11234        /// Headers that will be added to request.
 11235        /// </param>
 11236        /// <param name='cancellationToken'>
 11237        /// The cancellation token.
 11238        /// </param>
 11239        /// <exception cref="ErrorResponseException">
 11240        /// Thrown when the operation returned an invalid status code
 11241        /// </exception>
 11242        /// <exception cref="SerializationException">
 11243        /// Thrown when unable to deserialize the response
 11244        /// </exception>
 11245        /// <exception cref="ValidationException">
 11246        /// Thrown when a required parameter is null
 11247        /// </exception>
 11248        /// <exception cref="System.ArgumentNullException">
 11249        /// Thrown when a required parameter is null
 11250        /// </exception>
 11251        /// <return>
 11252        /// A response object containing the response body and response headers.
 11253        /// </return>
 11254        public async Task<HttpOperationResponse<System.Guid>> CreateClosedListEntityRoleWithHttpMessagesAsync(System.Gui
 11255        {
 511256            if (Client.Endpoint == null)
 11257            {
 011258                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 11259            }
 511260            if (versionId == null)
 11261            {
 011262                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 11263            }
 511264            if (entityRoleCreateObject == null)
 11265            {
 011266                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject");
 11267            }
 11268            // Tracing
 511269            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 511270            string _invocationId = null;
 511271            if (_shouldTrace)
 11272            {
 011273                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 011274                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 011275                tracingParameters.Add("appId", appId);
 011276                tracingParameters.Add("versionId", versionId);
 011277                tracingParameters.Add("entityId", entityId);
 011278                tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject);
 011279                tracingParameters.Add("cancellationToken", cancellationToken);
 011280                ServiceClientTracing.Enter(_invocationId, this, "CreateClosedListEntityRole", tracingParameters);
 11281            }
 11282            // Construct URL
 511283            var _baseUrl = Client.BaseUri;
 511284            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 511285            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 511286            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 511287            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 511288            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 11289            // Create HTTP transport objects
 511290            var _httpRequest = new HttpRequestMessage();
 511291            HttpResponseMessage _httpResponse = null;
 511292            _httpRequest.Method = new HttpMethod("POST");
 511293            _httpRequest.RequestUri = new System.Uri(_url);
 11294            // Set Headers
 11295
 11296
 511297            if (customHeaders != null)
 11298            {
 011299                foreach(var _header in customHeaders)
 11300                {
 011301                    if (_httpRequest.Headers.Contains(_header.Key))
 11302                    {
 011303                        _httpRequest.Headers.Remove(_header.Key);
 11304                    }
 011305                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 11306                }
 11307            }
 11308
 11309            // Serialize Request
 511310            string _requestContent = null;
 511311            if(entityRoleCreateObject != null)
 11312            {
 511313                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri
 511314                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 511315                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 11316            }
 11317            // Set Credentials
 511318            if (Client.Credentials != null)
 11319            {
 511320                cancellationToken.ThrowIfCancellationRequested();
 511321                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11322            }
 11323            // Send Request
 511324            if (_shouldTrace)
 11325            {
 011326                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 11327            }
 511328            cancellationToken.ThrowIfCancellationRequested();
 511329            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 511330            if (_shouldTrace)
 11331            {
 011332                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 11333            }
 511334            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 511335            cancellationToken.ThrowIfCancellationRequested();
 511336            string _responseContent = null;
 511337            if ((int)_statusCode != 201)
 11338            {
 011339                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 11340                try
 11341                {
 011342                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 011343                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 011344                    if (_errorBody != null)
 11345                    {
 011346                        ex.Body = _errorBody;
 11347                    }
 011348                }
 011349                catch (JsonException)
 11350                {
 11351                    // Ignore the exception
 011352                }
 011353                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 011354                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 011355                if (_shouldTrace)
 11356                {
 011357                    ServiceClientTracing.Error(_invocationId, ex);
 11358                }
 011359                _httpRequest.Dispose();
 011360                if (_httpResponse != null)
 11361                {
 011362                    _httpResponse.Dispose();
 11363                }
 011364                throw ex;
 11365            }
 11366            // Create Result
 511367            var _result = new HttpOperationResponse<System.Guid>();
 511368            _result.Request = _httpRequest;
 511369            _result.Response = _httpResponse;
 11370            // Deserialize Response
 511371            if ((int)_statusCode == 201)
 11372            {
 511373                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 11374                try
 11375                {
 511376                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 511377                }
 011378                catch (JsonException ex)
 11379                {
 011380                    _httpRequest.Dispose();
 011381                    if (_httpResponse != null)
 11382                    {
 011383                        _httpResponse.Dispose();
 11384                    }
 011385                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 11386                }
 11387            }
 511388            if (_shouldTrace)
 11389            {
 011390                ServiceClientTracing.Exit(_invocationId, _result);
 11391            }
 511392            return _result;
 511393        }
 11394
 11395        /// <summary>
 11396        /// Get all roles for a regular expression entity in a version of the
 11397        /// application.
 11398        /// </summary>
 11399        /// <param name='appId'>
 11400        /// The application ID.
 11401        /// </param>
 11402        /// <param name='versionId'>
 11403        /// The version ID.
 11404        /// </param>
 11405        /// <param name='entityId'>
 11406        /// entity Id
 11407        /// </param>
 11408        /// <param name='customHeaders'>
 11409        /// Headers that will be added to request.
 11410        /// </param>
 11411        /// <param name='cancellationToken'>
 11412        /// The cancellation token.
 11413        /// </param>
 11414        /// <exception cref="ErrorResponseException">
 11415        /// Thrown when the operation returned an invalid status code
 11416        /// </exception>
 11417        /// <exception cref="SerializationException">
 11418        /// Thrown when unable to deserialize the response
 11419        /// </exception>
 11420        /// <exception cref="ValidationException">
 11421        /// Thrown when a required parameter is null
 11422        /// </exception>
 11423        /// <exception cref="System.ArgumentNullException">
 11424        /// Thrown when a required parameter is null
 11425        /// </exception>
 11426        /// <return>
 11427        /// A response object containing the response body and response headers.
 11428        /// </return>
 11429        public async Task<HttpOperationResponse<IList<EntityRole>>> ListRegexEntityRolesWithHttpMessagesAsync(System.Gui
 11430        {
 311431            if (Client.Endpoint == null)
 11432            {
 011433                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 11434            }
 311435            if (versionId == null)
 11436            {
 011437                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 11438            }
 11439            // Tracing
 311440            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 311441            string _invocationId = null;
 311442            if (_shouldTrace)
 11443            {
 011444                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 011445                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 011446                tracingParameters.Add("appId", appId);
 011447                tracingParameters.Add("versionId", versionId);
 011448                tracingParameters.Add("entityId", entityId);
 011449                tracingParameters.Add("cancellationToken", cancellationToken);
 011450                ServiceClientTracing.Enter(_invocationId, this, "ListRegexEntityRoles", tracingParameters);
 11451            }
 11452            // Construct URL
 311453            var _baseUrl = Client.BaseUri;
 311454            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 311455            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 311456            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 311457            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 311458            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 11459            // Create HTTP transport objects
 311460            var _httpRequest = new HttpRequestMessage();
 311461            HttpResponseMessage _httpResponse = null;
 311462            _httpRequest.Method = new HttpMethod("GET");
 311463            _httpRequest.RequestUri = new System.Uri(_url);
 11464            // Set Headers
 11465
 11466
 311467            if (customHeaders != null)
 11468            {
 011469                foreach(var _header in customHeaders)
 11470                {
 011471                    if (_httpRequest.Headers.Contains(_header.Key))
 11472                    {
 011473                        _httpRequest.Headers.Remove(_header.Key);
 11474                    }
 011475                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 11476                }
 11477            }
 11478
 11479            // Serialize Request
 311480            string _requestContent = null;
 11481            // Set Credentials
 311482            if (Client.Credentials != null)
 11483            {
 311484                cancellationToken.ThrowIfCancellationRequested();
 311485                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11486            }
 11487            // Send Request
 311488            if (_shouldTrace)
 11489            {
 011490                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 11491            }
 311492            cancellationToken.ThrowIfCancellationRequested();
 311493            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 311494            if (_shouldTrace)
 11495            {
 011496                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 11497            }
 311498            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 311499            cancellationToken.ThrowIfCancellationRequested();
 311500            string _responseContent = null;
 311501            if ((int)_statusCode != 200)
 11502            {
 011503                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 11504                try
 11505                {
 011506                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 011507                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 011508                    if (_errorBody != null)
 11509                    {
 011510                        ex.Body = _errorBody;
 11511                    }
 011512                }
 011513                catch (JsonException)
 11514                {
 11515                    // Ignore the exception
 011516                }
 011517                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 011518                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 011519                if (_shouldTrace)
 11520                {
 011521                    ServiceClientTracing.Error(_invocationId, ex);
 11522                }
 011523                _httpRequest.Dispose();
 011524                if (_httpResponse != null)
 11525                {
 011526                    _httpResponse.Dispose();
 11527                }
 011528                throw ex;
 11529            }
 11530            // Create Result
 311531            var _result = new HttpOperationResponse<IList<EntityRole>>();
 311532            _result.Request = _httpRequest;
 311533            _result.Response = _httpResponse;
 11534            // Deserialize Response
 311535            if ((int)_statusCode == 200)
 11536            {
 311537                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 11538                try
 11539                {
 311540                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont
 311541                }
 011542                catch (JsonException ex)
 11543                {
 011544                    _httpRequest.Dispose();
 011545                    if (_httpResponse != null)
 11546                    {
 011547                        _httpResponse.Dispose();
 11548                    }
 011549                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 11550                }
 11551            }
 311552            if (_shouldTrace)
 11553            {
 011554                ServiceClientTracing.Exit(_invocationId, _result);
 11555            }
 311556            return _result;
 311557        }
 11558
 11559        /// <summary>
 11560        /// Create a role for an regular expression entity in a version of the
 11561        /// application.
 11562        /// </summary>
 11563        /// <param name='appId'>
 11564        /// The application ID.
 11565        /// </param>
 11566        /// <param name='versionId'>
 11567        /// The version ID.
 11568        /// </param>
 11569        /// <param name='entityId'>
 11570        /// The entity model ID.
 11571        /// </param>
 11572        /// <param name='entityRoleCreateObject'>
 11573        /// An entity role object containing the name of role.
 11574        /// </param>
 11575        /// <param name='customHeaders'>
 11576        /// Headers that will be added to request.
 11577        /// </param>
 11578        /// <param name='cancellationToken'>
 11579        /// The cancellation token.
 11580        /// </param>
 11581        /// <exception cref="ErrorResponseException">
 11582        /// Thrown when the operation returned an invalid status code
 11583        /// </exception>
 11584        /// <exception cref="SerializationException">
 11585        /// Thrown when unable to deserialize the response
 11586        /// </exception>
 11587        /// <exception cref="ValidationException">
 11588        /// Thrown when a required parameter is null
 11589        /// </exception>
 11590        /// <exception cref="System.ArgumentNullException">
 11591        /// Thrown when a required parameter is null
 11592        /// </exception>
 11593        /// <return>
 11594        /// A response object containing the response body and response headers.
 11595        /// </return>
 11596        public async Task<HttpOperationResponse<System.Guid>> CreateRegexEntityRoleWithHttpMessagesAsync(System.Guid app
 11597        {
 511598            if (Client.Endpoint == null)
 11599            {
 011600                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 11601            }
 511602            if (versionId == null)
 11603            {
 011604                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 11605            }
 511606            if (entityRoleCreateObject == null)
 11607            {
 011608                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject");
 11609            }
 11610            // Tracing
 511611            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 511612            string _invocationId = null;
 511613            if (_shouldTrace)
 11614            {
 011615                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 011616                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 011617                tracingParameters.Add("appId", appId);
 011618                tracingParameters.Add("versionId", versionId);
 011619                tracingParameters.Add("entityId", entityId);
 011620                tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject);
 011621                tracingParameters.Add("cancellationToken", cancellationToken);
 011622                ServiceClientTracing.Enter(_invocationId, this, "CreateRegexEntityRole", tracingParameters);
 11623            }
 11624            // Construct URL
 511625            var _baseUrl = Client.BaseUri;
 511626            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 511627            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 511628            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 511629            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 511630            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 11631            // Create HTTP transport objects
 511632            var _httpRequest = new HttpRequestMessage();
 511633            HttpResponseMessage _httpResponse = null;
 511634            _httpRequest.Method = new HttpMethod("POST");
 511635            _httpRequest.RequestUri = new System.Uri(_url);
 11636            // Set Headers
 11637
 11638
 511639            if (customHeaders != null)
 11640            {
 011641                foreach(var _header in customHeaders)
 11642                {
 011643                    if (_httpRequest.Headers.Contains(_header.Key))
 11644                    {
 011645                        _httpRequest.Headers.Remove(_header.Key);
 11646                    }
 011647                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 11648                }
 11649            }
 11650
 11651            // Serialize Request
 511652            string _requestContent = null;
 511653            if(entityRoleCreateObject != null)
 11654            {
 511655                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri
 511656                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 511657                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 11658            }
 11659            // Set Credentials
 511660            if (Client.Credentials != null)
 11661            {
 511662                cancellationToken.ThrowIfCancellationRequested();
 511663                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11664            }
 11665            // Send Request
 511666            if (_shouldTrace)
 11667            {
 011668                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 11669            }
 511670            cancellationToken.ThrowIfCancellationRequested();
 511671            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 511672            if (_shouldTrace)
 11673            {
 011674                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 11675            }
 511676            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 511677            cancellationToken.ThrowIfCancellationRequested();
 511678            string _responseContent = null;
 511679            if ((int)_statusCode != 201)
 11680            {
 011681                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 11682                try
 11683                {
 011684                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 011685                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 011686                    if (_errorBody != null)
 11687                    {
 011688                        ex.Body = _errorBody;
 11689                    }
 011690                }
 011691                catch (JsonException)
 11692                {
 11693                    // Ignore the exception
 011694                }
 011695                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 011696                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 011697                if (_shouldTrace)
 11698                {
 011699                    ServiceClientTracing.Error(_invocationId, ex);
 11700                }
 011701                _httpRequest.Dispose();
 011702                if (_httpResponse != null)
 11703                {
 011704                    _httpResponse.Dispose();
 11705                }
 011706                throw ex;
 11707            }
 11708            // Create Result
 511709            var _result = new HttpOperationResponse<System.Guid>();
 511710            _result.Request = _httpRequest;
 511711            _result.Response = _httpResponse;
 11712            // Deserialize Response
 511713            if ((int)_statusCode == 201)
 11714            {
 511715                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 11716                try
 11717                {
 511718                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 511719                }
 011720                catch (JsonException ex)
 11721                {
 011722                    _httpRequest.Dispose();
 011723                    if (_httpResponse != null)
 11724                    {
 011725                        _httpResponse.Dispose();
 11726                    }
 011727                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 11728                }
 11729            }
 511730            if (_shouldTrace)
 11731            {
 011732                ServiceClientTracing.Exit(_invocationId, _result);
 11733            }
 511734            return _result;
 511735        }
 11736
 11737        /// <summary>
 11738        /// Get all roles for a composite entity in a version of the application
 11739        /// </summary>
 11740        /// <param name='appId'>
 11741        /// The application ID.
 11742        /// </param>
 11743        /// <param name='versionId'>
 11744        /// The version ID.
 11745        /// </param>
 11746        /// <param name='cEntityId'>
 11747        /// The composite entity extractor ID.
 11748        /// </param>
 11749        /// <param name='customHeaders'>
 11750        /// Headers that will be added to request.
 11751        /// </param>
 11752        /// <param name='cancellationToken'>
 11753        /// The cancellation token.
 11754        /// </param>
 11755        /// <exception cref="ErrorResponseException">
 11756        /// Thrown when the operation returned an invalid status code
 11757        /// </exception>
 11758        /// <exception cref="SerializationException">
 11759        /// Thrown when unable to deserialize the response
 11760        /// </exception>
 11761        /// <exception cref="ValidationException">
 11762        /// Thrown when a required parameter is null
 11763        /// </exception>
 11764        /// <exception cref="System.ArgumentNullException">
 11765        /// Thrown when a required parameter is null
 11766        /// </exception>
 11767        /// <return>
 11768        /// A response object containing the response body and response headers.
 11769        /// </return>
 11770        public async Task<HttpOperationResponse<IList<EntityRole>>> ListCompositeEntityRolesWithHttpMessagesAsync(System
 11771        {
 011772            if (Client.Endpoint == null)
 11773            {
 011774                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 11775            }
 011776            if (versionId == null)
 11777            {
 011778                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 11779            }
 11780            // Tracing
 011781            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 011782            string _invocationId = null;
 011783            if (_shouldTrace)
 11784            {
 011785                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 011786                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 011787                tracingParameters.Add("appId", appId);
 011788                tracingParameters.Add("versionId", versionId);
 011789                tracingParameters.Add("cEntityId", cEntityId);
 011790                tracingParameters.Add("cancellationToken", cancellationToken);
 011791                ServiceClientTracing.Enter(_invocationId, this, "ListCompositeEntityRoles", tracingParameters);
 11792            }
 11793            // Construct URL
 011794            var _baseUrl = Client.BaseUri;
 011795            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 011796            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 011797            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 011798            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 011799            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 11800            // Create HTTP transport objects
 011801            var _httpRequest = new HttpRequestMessage();
 011802            HttpResponseMessage _httpResponse = null;
 011803            _httpRequest.Method = new HttpMethod("GET");
 011804            _httpRequest.RequestUri = new System.Uri(_url);
 11805            // Set Headers
 11806
 11807
 011808            if (customHeaders != null)
 11809            {
 011810                foreach(var _header in customHeaders)
 11811                {
 011812                    if (_httpRequest.Headers.Contains(_header.Key))
 11813                    {
 011814                        _httpRequest.Headers.Remove(_header.Key);
 11815                    }
 011816                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 11817                }
 11818            }
 11819
 11820            // Serialize Request
 011821            string _requestContent = null;
 11822            // Set Credentials
 011823            if (Client.Credentials != null)
 11824            {
 011825                cancellationToken.ThrowIfCancellationRequested();
 011826                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 11827            }
 11828            // Send Request
 011829            if (_shouldTrace)
 11830            {
 011831                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 11832            }
 011833            cancellationToken.ThrowIfCancellationRequested();
 011834            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 011835            if (_shouldTrace)
 11836            {
 011837                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 11838            }
 011839            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 011840            cancellationToken.ThrowIfCancellationRequested();
 011841            string _responseContent = null;
 011842            if ((int)_statusCode != 200)
 11843            {
 011844                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 11845                try
 11846                {
 011847                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 011848                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 011849                    if (_errorBody != null)
 11850                    {
 011851                        ex.Body = _errorBody;
 11852                    }
 011853                }
 011854                catch (JsonException)
 11855                {
 11856                    // Ignore the exception
 011857                }
 011858                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 011859                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 011860                if (_shouldTrace)
 11861                {
 011862                    ServiceClientTracing.Error(_invocationId, ex);
 11863                }
 011864                _httpRequest.Dispose();
 011865                if (_httpResponse != null)
 11866                {
 011867                    _httpResponse.Dispose();
 11868                }
 011869                throw ex;
 11870            }
 11871            // Create Result
 011872            var _result = new HttpOperationResponse<IList<EntityRole>>();
 011873            _result.Request = _httpRequest;
 011874            _result.Response = _httpResponse;
 11875            // Deserialize Response
 011876            if ((int)_statusCode == 200)
 11877            {
 011878                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 11879                try
 11880                {
 011881                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont
 011882                }
 011883                catch (JsonException ex)
 11884                {
 011885                    _httpRequest.Dispose();
 011886                    if (_httpResponse != null)
 11887                    {
 011888                        _httpResponse.Dispose();
 11889                    }
 011890                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 11891                }
 11892            }
 011893            if (_shouldTrace)
 11894            {
 011895                ServiceClientTracing.Exit(_invocationId, _result);
 11896            }
 011897            return _result;
 011898        }
 11899
 11900        /// <summary>
 11901        /// Create a role for a composite entity in a version of the application.
 11902        /// </summary>
 11903        /// <param name='appId'>
 11904        /// The application ID.
 11905        /// </param>
 11906        /// <param name='versionId'>
 11907        /// The version ID.
 11908        /// </param>
 11909        /// <param name='cEntityId'>
 11910        /// The composite entity extractor ID.
 11911        /// </param>
 11912        /// <param name='entityRoleCreateObject'>
 11913        /// An entity role object containing the name of role.
 11914        /// </param>
 11915        /// <param name='customHeaders'>
 11916        /// Headers that will be added to request.
 11917        /// </param>
 11918        /// <param name='cancellationToken'>
 11919        /// The cancellation token.
 11920        /// </param>
 11921        /// <exception cref="ErrorResponseException">
 11922        /// Thrown when the operation returned an invalid status code
 11923        /// </exception>
 11924        /// <exception cref="SerializationException">
 11925        /// Thrown when unable to deserialize the response
 11926        /// </exception>
 11927        /// <exception cref="ValidationException">
 11928        /// Thrown when a required parameter is null
 11929        /// </exception>
 11930        /// <exception cref="System.ArgumentNullException">
 11931        /// Thrown when a required parameter is null
 11932        /// </exception>
 11933        /// <return>
 11934        /// A response object containing the response body and response headers.
 11935        /// </return>
 11936        public async Task<HttpOperationResponse<System.Guid>> CreateCompositeEntityRoleWithHttpMessagesAsync(System.Guid
 11937        {
 011938            if (Client.Endpoint == null)
 11939            {
 011940                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 11941            }
 011942            if (versionId == null)
 11943            {
 011944                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 11945            }
 011946            if (entityRoleCreateObject == null)
 11947            {
 011948                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject");
 11949            }
 11950            // Tracing
 011951            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 011952            string _invocationId = null;
 011953            if (_shouldTrace)
 11954            {
 011955                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 011956                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 011957                tracingParameters.Add("appId", appId);
 011958                tracingParameters.Add("versionId", versionId);
 011959                tracingParameters.Add("cEntityId", cEntityId);
 011960                tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject);
 011961                tracingParameters.Add("cancellationToken", cancellationToken);
 011962                ServiceClientTracing.Enter(_invocationId, this, "CreateCompositeEntityRole", tracingParameters);
 11963            }
 11964            // Construct URL
 011965            var _baseUrl = Client.BaseUri;
 011966            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 011967            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 011968            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 011969            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 011970            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 11971            // Create HTTP transport objects
 011972            var _httpRequest = new HttpRequestMessage();
 011973            HttpResponseMessage _httpResponse = null;
 011974            _httpRequest.Method = new HttpMethod("POST");
 011975            _httpRequest.RequestUri = new System.Uri(_url);
 11976            // Set Headers
 11977
 11978
 011979            if (customHeaders != null)
 11980            {
 011981                foreach(var _header in customHeaders)
 11982                {
 011983                    if (_httpRequest.Headers.Contains(_header.Key))
 11984                    {
 011985                        _httpRequest.Headers.Remove(_header.Key);
 11986                    }
 011987                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 11988                }
 11989            }
 11990
 11991            // Serialize Request
 011992            string _requestContent = null;
 011993            if(entityRoleCreateObject != null)
 11994            {
 011995                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri
 011996                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 011997                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 11998            }
 11999            // Set Credentials
 012000            if (Client.Credentials != null)
 12001            {
 012002                cancellationToken.ThrowIfCancellationRequested();
 012003                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12004            }
 12005            // Send Request
 012006            if (_shouldTrace)
 12007            {
 012008                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 12009            }
 012010            cancellationToken.ThrowIfCancellationRequested();
 012011            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 012012            if (_shouldTrace)
 12013            {
 012014                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 12015            }
 012016            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 012017            cancellationToken.ThrowIfCancellationRequested();
 012018            string _responseContent = null;
 012019            if ((int)_statusCode != 201)
 12020            {
 012021                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 12022                try
 12023                {
 012024                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 012025                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 012026                    if (_errorBody != null)
 12027                    {
 012028                        ex.Body = _errorBody;
 12029                    }
 012030                }
 012031                catch (JsonException)
 12032                {
 12033                    // Ignore the exception
 012034                }
 012035                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 012036                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 012037                if (_shouldTrace)
 12038                {
 012039                    ServiceClientTracing.Error(_invocationId, ex);
 12040                }
 012041                _httpRequest.Dispose();
 012042                if (_httpResponse != null)
 12043                {
 012044                    _httpResponse.Dispose();
 12045                }
 012046                throw ex;
 12047            }
 12048            // Create Result
 012049            var _result = new HttpOperationResponse<System.Guid>();
 012050            _result.Request = _httpRequest;
 012051            _result.Response = _httpResponse;
 12052            // Deserialize Response
 012053            if ((int)_statusCode == 201)
 12054            {
 012055                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 12056                try
 12057                {
 012058                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 012059                }
 012060                catch (JsonException ex)
 12061                {
 012062                    _httpRequest.Dispose();
 012063                    if (_httpResponse != null)
 12064                    {
 012065                        _httpResponse.Dispose();
 12066                    }
 012067                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 12068                }
 12069            }
 012070            if (_shouldTrace)
 12071            {
 012072                ServiceClientTracing.Exit(_invocationId, _result);
 12073            }
 012074            return _result;
 012075        }
 12076
 12077        /// <summary>
 12078        /// Get all roles for a Pattern.any entity in a version of the application
 12079        /// </summary>
 12080        /// <param name='appId'>
 12081        /// The application ID.
 12082        /// </param>
 12083        /// <param name='versionId'>
 12084        /// The version ID.
 12085        /// </param>
 12086        /// <param name='entityId'>
 12087        /// entity Id
 12088        /// </param>
 12089        /// <param name='customHeaders'>
 12090        /// Headers that will be added to request.
 12091        /// </param>
 12092        /// <param name='cancellationToken'>
 12093        /// The cancellation token.
 12094        /// </param>
 12095        /// <exception cref="ErrorResponseException">
 12096        /// Thrown when the operation returned an invalid status code
 12097        /// </exception>
 12098        /// <exception cref="SerializationException">
 12099        /// Thrown when unable to deserialize the response
 12100        /// </exception>
 12101        /// <exception cref="ValidationException">
 12102        /// Thrown when a required parameter is null
 12103        /// </exception>
 12104        /// <exception cref="System.ArgumentNullException">
 12105        /// Thrown when a required parameter is null
 12106        /// </exception>
 12107        /// <return>
 12108        /// A response object containing the response body and response headers.
 12109        /// </return>
 12110        public async Task<HttpOperationResponse<IList<EntityRole>>> ListPatternAnyEntityRolesWithHttpMessagesAsync(Syste
 12111        {
 312112            if (Client.Endpoint == null)
 12113            {
 012114                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 12115            }
 312116            if (versionId == null)
 12117            {
 012118                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 12119            }
 12120            // Tracing
 312121            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 312122            string _invocationId = null;
 312123            if (_shouldTrace)
 12124            {
 012125                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 012126                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 012127                tracingParameters.Add("appId", appId);
 012128                tracingParameters.Add("versionId", versionId);
 012129                tracingParameters.Add("entityId", entityId);
 012130                tracingParameters.Add("cancellationToken", cancellationToken);
 012131                ServiceClientTracing.Enter(_invocationId, this, "ListPatternAnyEntityRoles", tracingParameters);
 12132            }
 12133            // Construct URL
 312134            var _baseUrl = Client.BaseUri;
 312135            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 312136            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 312137            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 312138            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 312139            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 12140            // Create HTTP transport objects
 312141            var _httpRequest = new HttpRequestMessage();
 312142            HttpResponseMessage _httpResponse = null;
 312143            _httpRequest.Method = new HttpMethod("GET");
 312144            _httpRequest.RequestUri = new System.Uri(_url);
 12145            // Set Headers
 12146
 12147
 312148            if (customHeaders != null)
 12149            {
 012150                foreach(var _header in customHeaders)
 12151                {
 012152                    if (_httpRequest.Headers.Contains(_header.Key))
 12153                    {
 012154                        _httpRequest.Headers.Remove(_header.Key);
 12155                    }
 012156                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 12157                }
 12158            }
 12159
 12160            // Serialize Request
 312161            string _requestContent = null;
 12162            // Set Credentials
 312163            if (Client.Credentials != null)
 12164            {
 312165                cancellationToken.ThrowIfCancellationRequested();
 312166                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12167            }
 12168            // Send Request
 312169            if (_shouldTrace)
 12170            {
 012171                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 12172            }
 312173            cancellationToken.ThrowIfCancellationRequested();
 312174            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 312175            if (_shouldTrace)
 12176            {
 012177                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 12178            }
 312179            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 312180            cancellationToken.ThrowIfCancellationRequested();
 312181            string _responseContent = null;
 312182            if ((int)_statusCode != 200)
 12183            {
 012184                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 12185                try
 12186                {
 012187                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 012188                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 012189                    if (_errorBody != null)
 12190                    {
 012191                        ex.Body = _errorBody;
 12192                    }
 012193                }
 012194                catch (JsonException)
 12195                {
 12196                    // Ignore the exception
 012197                }
 012198                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 012199                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 012200                if (_shouldTrace)
 12201                {
 012202                    ServiceClientTracing.Error(_invocationId, ex);
 12203                }
 012204                _httpRequest.Dispose();
 012205                if (_httpResponse != null)
 12206                {
 012207                    _httpResponse.Dispose();
 12208                }
 012209                throw ex;
 12210            }
 12211            // Create Result
 312212            var _result = new HttpOperationResponse<IList<EntityRole>>();
 312213            _result.Request = _httpRequest;
 312214            _result.Response = _httpResponse;
 12215            // Deserialize Response
 312216            if ((int)_statusCode == 200)
 12217            {
 312218                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 12219                try
 12220                {
 312221                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont
 312222                }
 012223                catch (JsonException ex)
 12224                {
 012225                    _httpRequest.Dispose();
 012226                    if (_httpResponse != null)
 12227                    {
 012228                        _httpResponse.Dispose();
 12229                    }
 012230                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 12231                }
 12232            }
 312233            if (_shouldTrace)
 12234            {
 012235                ServiceClientTracing.Exit(_invocationId, _result);
 12236            }
 312237            return _result;
 312238        }
 12239
 12240        /// <summary>
 12241        /// Create a role for an Pattern.any entity in a version of the application.
 12242        /// </summary>
 12243        /// <param name='appId'>
 12244        /// The application ID.
 12245        /// </param>
 12246        /// <param name='versionId'>
 12247        /// The version ID.
 12248        /// </param>
 12249        /// <param name='entityId'>
 12250        /// The entity model ID.
 12251        /// </param>
 12252        /// <param name='entityRoleCreateObject'>
 12253        /// An entity role object containing the name of role.
 12254        /// </param>
 12255        /// <param name='customHeaders'>
 12256        /// Headers that will be added to request.
 12257        /// </param>
 12258        /// <param name='cancellationToken'>
 12259        /// The cancellation token.
 12260        /// </param>
 12261        /// <exception cref="ErrorResponseException">
 12262        /// Thrown when the operation returned an invalid status code
 12263        /// </exception>
 12264        /// <exception cref="SerializationException">
 12265        /// Thrown when unable to deserialize the response
 12266        /// </exception>
 12267        /// <exception cref="ValidationException">
 12268        /// Thrown when a required parameter is null
 12269        /// </exception>
 12270        /// <exception cref="System.ArgumentNullException">
 12271        /// Thrown when a required parameter is null
 12272        /// </exception>
 12273        /// <return>
 12274        /// A response object containing the response body and response headers.
 12275        /// </return>
 12276        public async Task<HttpOperationResponse<System.Guid>> CreatePatternAnyEntityRoleWithHttpMessagesAsync(System.Gui
 12277        {
 512278            if (Client.Endpoint == null)
 12279            {
 012280                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 12281            }
 512282            if (versionId == null)
 12283            {
 012284                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 12285            }
 512286            if (entityRoleCreateObject == null)
 12287            {
 012288                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject");
 12289            }
 12290            // Tracing
 512291            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 512292            string _invocationId = null;
 512293            if (_shouldTrace)
 12294            {
 012295                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 012296                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 012297                tracingParameters.Add("appId", appId);
 012298                tracingParameters.Add("versionId", versionId);
 012299                tracingParameters.Add("entityId", entityId);
 012300                tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject);
 012301                tracingParameters.Add("cancellationToken", cancellationToken);
 012302                ServiceClientTracing.Enter(_invocationId, this, "CreatePatternAnyEntityRole", tracingParameters);
 12303            }
 12304            // Construct URL
 512305            var _baseUrl = Client.BaseUri;
 512306            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 512307            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 512308            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 512309            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 512310            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 12311            // Create HTTP transport objects
 512312            var _httpRequest = new HttpRequestMessage();
 512313            HttpResponseMessage _httpResponse = null;
 512314            _httpRequest.Method = new HttpMethod("POST");
 512315            _httpRequest.RequestUri = new System.Uri(_url);
 12316            // Set Headers
 12317
 12318
 512319            if (customHeaders != null)
 12320            {
 012321                foreach(var _header in customHeaders)
 12322                {
 012323                    if (_httpRequest.Headers.Contains(_header.Key))
 12324                    {
 012325                        _httpRequest.Headers.Remove(_header.Key);
 12326                    }
 012327                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 12328                }
 12329            }
 12330
 12331            // Serialize Request
 512332            string _requestContent = null;
 512333            if(entityRoleCreateObject != null)
 12334            {
 512335                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri
 512336                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 512337                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 12338            }
 12339            // Set Credentials
 512340            if (Client.Credentials != null)
 12341            {
 512342                cancellationToken.ThrowIfCancellationRequested();
 512343                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12344            }
 12345            // Send Request
 512346            if (_shouldTrace)
 12347            {
 012348                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 12349            }
 512350            cancellationToken.ThrowIfCancellationRequested();
 512351            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 512352            if (_shouldTrace)
 12353            {
 012354                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 12355            }
 512356            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 512357            cancellationToken.ThrowIfCancellationRequested();
 512358            string _responseContent = null;
 512359            if ((int)_statusCode != 201)
 12360            {
 012361                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 12362                try
 12363                {
 012364                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 012365                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 012366                    if (_errorBody != null)
 12367                    {
 012368                        ex.Body = _errorBody;
 12369                    }
 012370                }
 012371                catch (JsonException)
 12372                {
 12373                    // Ignore the exception
 012374                }
 012375                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 012376                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 012377                if (_shouldTrace)
 12378                {
 012379                    ServiceClientTracing.Error(_invocationId, ex);
 12380                }
 012381                _httpRequest.Dispose();
 012382                if (_httpResponse != null)
 12383                {
 012384                    _httpResponse.Dispose();
 12385                }
 012386                throw ex;
 12387            }
 12388            // Create Result
 512389            var _result = new HttpOperationResponse<System.Guid>();
 512390            _result.Request = _httpRequest;
 512391            _result.Response = _httpResponse;
 12392            // Deserialize Response
 512393            if ((int)_statusCode == 201)
 12394            {
 512395                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 12396                try
 12397                {
 512398                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 512399                }
 012400                catch (JsonException ex)
 12401                {
 012402                    _httpRequest.Dispose();
 012403                    if (_httpResponse != null)
 12404                    {
 012405                        _httpResponse.Dispose();
 12406                    }
 012407                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 12408                }
 12409            }
 512410            if (_shouldTrace)
 12411            {
 012412                ServiceClientTracing.Exit(_invocationId, _result);
 12413            }
 512414            return _result;
 512415        }
 12416
 12417        /// <summary>
 12418        /// Get all roles for a hierarchical entity in a version of the application
 12419        /// </summary>
 12420        /// <param name='appId'>
 12421        /// The application ID.
 12422        /// </param>
 12423        /// <param name='versionId'>
 12424        /// The version ID.
 12425        /// </param>
 12426        /// <param name='hEntityId'>
 12427        /// The hierarchical entity extractor ID.
 12428        /// </param>
 12429        /// <param name='customHeaders'>
 12430        /// Headers that will be added to request.
 12431        /// </param>
 12432        /// <param name='cancellationToken'>
 12433        /// The cancellation token.
 12434        /// </param>
 12435        /// <exception cref="ErrorResponseException">
 12436        /// Thrown when the operation returned an invalid status code
 12437        /// </exception>
 12438        /// <exception cref="SerializationException">
 12439        /// Thrown when unable to deserialize the response
 12440        /// </exception>
 12441        /// <exception cref="ValidationException">
 12442        /// Thrown when a required parameter is null
 12443        /// </exception>
 12444        /// <exception cref="System.ArgumentNullException">
 12445        /// Thrown when a required parameter is null
 12446        /// </exception>
 12447        /// <return>
 12448        /// A response object containing the response body and response headers.
 12449        /// </return>
 12450        public async Task<HttpOperationResponse<IList<EntityRole>>> ListHierarchicalEntityRolesWithHttpMessagesAsync(Sys
 12451        {
 012452            if (Client.Endpoint == null)
 12453            {
 012454                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 12455            }
 012456            if (versionId == null)
 12457            {
 012458                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 12459            }
 12460            // Tracing
 012461            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 012462            string _invocationId = null;
 012463            if (_shouldTrace)
 12464            {
 012465                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 012466                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 012467                tracingParameters.Add("appId", appId);
 012468                tracingParameters.Add("versionId", versionId);
 012469                tracingParameters.Add("hEntityId", hEntityId);
 012470                tracingParameters.Add("cancellationToken", cancellationToken);
 012471                ServiceClientTracing.Enter(_invocationId, this, "ListHierarchicalEntityRoles", tracingParameters);
 12472            }
 12473            // Construct URL
 012474            var _baseUrl = Client.BaseUri;
 012475            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 012476            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 012477            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 012478            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 012479            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 12480            // Create HTTP transport objects
 012481            var _httpRequest = new HttpRequestMessage();
 012482            HttpResponseMessage _httpResponse = null;
 012483            _httpRequest.Method = new HttpMethod("GET");
 012484            _httpRequest.RequestUri = new System.Uri(_url);
 12485            // Set Headers
 12486
 12487
 012488            if (customHeaders != null)
 12489            {
 012490                foreach(var _header in customHeaders)
 12491                {
 012492                    if (_httpRequest.Headers.Contains(_header.Key))
 12493                    {
 012494                        _httpRequest.Headers.Remove(_header.Key);
 12495                    }
 012496                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 12497                }
 12498            }
 12499
 12500            // Serialize Request
 012501            string _requestContent = null;
 12502            // Set Credentials
 012503            if (Client.Credentials != null)
 12504            {
 012505                cancellationToken.ThrowIfCancellationRequested();
 012506                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12507            }
 12508            // Send Request
 012509            if (_shouldTrace)
 12510            {
 012511                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 12512            }
 012513            cancellationToken.ThrowIfCancellationRequested();
 012514            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 012515            if (_shouldTrace)
 12516            {
 012517                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 12518            }
 012519            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 012520            cancellationToken.ThrowIfCancellationRequested();
 012521            string _responseContent = null;
 012522            if ((int)_statusCode != 200)
 12523            {
 012524                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 12525                try
 12526                {
 012527                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 012528                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 012529                    if (_errorBody != null)
 12530                    {
 012531                        ex.Body = _errorBody;
 12532                    }
 012533                }
 012534                catch (JsonException)
 12535                {
 12536                    // Ignore the exception
 012537                }
 012538                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 012539                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 012540                if (_shouldTrace)
 12541                {
 012542                    ServiceClientTracing.Error(_invocationId, ex);
 12543                }
 012544                _httpRequest.Dispose();
 012545                if (_httpResponse != null)
 12546                {
 012547                    _httpResponse.Dispose();
 12548                }
 012549                throw ex;
 12550            }
 12551            // Create Result
 012552            var _result = new HttpOperationResponse<IList<EntityRole>>();
 012553            _result.Request = _httpRequest;
 012554            _result.Response = _httpResponse;
 12555            // Deserialize Response
 012556            if ((int)_statusCode == 200)
 12557            {
 012558                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 12559                try
 12560                {
 012561                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont
 012562                }
 012563                catch (JsonException ex)
 12564                {
 012565                    _httpRequest.Dispose();
 012566                    if (_httpResponse != null)
 12567                    {
 012568                        _httpResponse.Dispose();
 12569                    }
 012570                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 12571                }
 12572            }
 012573            if (_shouldTrace)
 12574            {
 012575                ServiceClientTracing.Exit(_invocationId, _result);
 12576            }
 012577            return _result;
 012578        }
 12579
 12580        /// <summary>
 12581        /// Create a role for an hierarchical entity in a version of the application.
 12582        /// </summary>
 12583        /// <param name='appId'>
 12584        /// The application ID.
 12585        /// </param>
 12586        /// <param name='versionId'>
 12587        /// The version ID.
 12588        /// </param>
 12589        /// <param name='hEntityId'>
 12590        /// The hierarchical entity extractor ID.
 12591        /// </param>
 12592        /// <param name='entityRoleCreateObject'>
 12593        /// An entity role object containing the name of role.
 12594        /// </param>
 12595        /// <param name='customHeaders'>
 12596        /// Headers that will be added to request.
 12597        /// </param>
 12598        /// <param name='cancellationToken'>
 12599        /// The cancellation token.
 12600        /// </param>
 12601        /// <exception cref="ErrorResponseException">
 12602        /// Thrown when the operation returned an invalid status code
 12603        /// </exception>
 12604        /// <exception cref="SerializationException">
 12605        /// Thrown when unable to deserialize the response
 12606        /// </exception>
 12607        /// <exception cref="ValidationException">
 12608        /// Thrown when a required parameter is null
 12609        /// </exception>
 12610        /// <exception cref="System.ArgumentNullException">
 12611        /// Thrown when a required parameter is null
 12612        /// </exception>
 12613        /// <return>
 12614        /// A response object containing the response body and response headers.
 12615        /// </return>
 12616        public async Task<HttpOperationResponse<System.Guid>> CreateHierarchicalEntityRoleWithHttpMessagesAsync(System.G
 12617        {
 012618            if (Client.Endpoint == null)
 12619            {
 012620                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 12621            }
 012622            if (versionId == null)
 12623            {
 012624                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 12625            }
 012626            if (entityRoleCreateObject == null)
 12627            {
 012628                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject");
 12629            }
 12630            // Tracing
 012631            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 012632            string _invocationId = null;
 012633            if (_shouldTrace)
 12634            {
 012635                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 012636                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 012637                tracingParameters.Add("appId", appId);
 012638                tracingParameters.Add("versionId", versionId);
 012639                tracingParameters.Add("hEntityId", hEntityId);
 012640                tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject);
 012641                tracingParameters.Add("cancellationToken", cancellationToken);
 012642                ServiceClientTracing.Enter(_invocationId, this, "CreateHierarchicalEntityRole", tracingParameters);
 12643            }
 12644            // Construct URL
 012645            var _baseUrl = Client.BaseUri;
 012646            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 012647            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 012648            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 012649            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 012650            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 12651            // Create HTTP transport objects
 012652            var _httpRequest = new HttpRequestMessage();
 012653            HttpResponseMessage _httpResponse = null;
 012654            _httpRequest.Method = new HttpMethod("POST");
 012655            _httpRequest.RequestUri = new System.Uri(_url);
 12656            // Set Headers
 12657
 12658
 012659            if (customHeaders != null)
 12660            {
 012661                foreach(var _header in customHeaders)
 12662                {
 012663                    if (_httpRequest.Headers.Contains(_header.Key))
 12664                    {
 012665                        _httpRequest.Headers.Remove(_header.Key);
 12666                    }
 012667                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 12668                }
 12669            }
 12670
 12671            // Serialize Request
 012672            string _requestContent = null;
 012673            if(entityRoleCreateObject != null)
 12674            {
 012675                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri
 012676                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 012677                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 12678            }
 12679            // Set Credentials
 012680            if (Client.Credentials != null)
 12681            {
 012682                cancellationToken.ThrowIfCancellationRequested();
 012683                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12684            }
 12685            // Send Request
 012686            if (_shouldTrace)
 12687            {
 012688                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 12689            }
 012690            cancellationToken.ThrowIfCancellationRequested();
 012691            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 012692            if (_shouldTrace)
 12693            {
 012694                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 12695            }
 012696            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 012697            cancellationToken.ThrowIfCancellationRequested();
 012698            string _responseContent = null;
 012699            if ((int)_statusCode != 201)
 12700            {
 012701                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 12702                try
 12703                {
 012704                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 012705                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 012706                    if (_errorBody != null)
 12707                    {
 012708                        ex.Body = _errorBody;
 12709                    }
 012710                }
 012711                catch (JsonException)
 12712                {
 12713                    // Ignore the exception
 012714                }
 012715                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 012716                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 012717                if (_shouldTrace)
 12718                {
 012719                    ServiceClientTracing.Error(_invocationId, ex);
 12720                }
 012721                _httpRequest.Dispose();
 012722                if (_httpResponse != null)
 12723                {
 012724                    _httpResponse.Dispose();
 12725                }
 012726                throw ex;
 12727            }
 12728            // Create Result
 012729            var _result = new HttpOperationResponse<System.Guid>();
 012730            _result.Request = _httpRequest;
 012731            _result.Response = _httpResponse;
 12732            // Deserialize Response
 012733            if ((int)_statusCode == 201)
 12734            {
 012735                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 12736                try
 12737                {
 012738                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 012739                }
 012740                catch (JsonException ex)
 12741                {
 012742                    _httpRequest.Dispose();
 012743                    if (_httpResponse != null)
 12744                    {
 012745                        _httpResponse.Dispose();
 12746                    }
 012747                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 12748                }
 12749            }
 012750            if (_shouldTrace)
 12751            {
 012752                ServiceClientTracing.Exit(_invocationId, _result);
 12753            }
 012754            return _result;
 012755        }
 12756
 12757        /// <summary>
 12758        /// Get all roles for a prebuilt entity in a version of the application
 12759        /// </summary>
 12760        /// <param name='appId'>
 12761        /// The application ID.
 12762        /// </param>
 12763        /// <param name='versionId'>
 12764        /// The version ID.
 12765        /// </param>
 12766        /// <param name='entityId'>
 12767        /// entity Id
 12768        /// </param>
 12769        /// <param name='customHeaders'>
 12770        /// Headers that will be added to request.
 12771        /// </param>
 12772        /// <param name='cancellationToken'>
 12773        /// The cancellation token.
 12774        /// </param>
 12775        /// <exception cref="ErrorResponseException">
 12776        /// Thrown when the operation returned an invalid status code
 12777        /// </exception>
 12778        /// <exception cref="SerializationException">
 12779        /// Thrown when unable to deserialize the response
 12780        /// </exception>
 12781        /// <exception cref="ValidationException">
 12782        /// Thrown when a required parameter is null
 12783        /// </exception>
 12784        /// <exception cref="System.ArgumentNullException">
 12785        /// Thrown when a required parameter is null
 12786        /// </exception>
 12787        /// <return>
 12788        /// A response object containing the response body and response headers.
 12789        /// </return>
 12790        public async Task<HttpOperationResponse<IList<EntityRole>>> ListCustomPrebuiltEntityRolesWithHttpMessagesAsync(S
 12791        {
 312792            if (Client.Endpoint == null)
 12793            {
 012794                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 12795            }
 312796            if (versionId == null)
 12797            {
 012798                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 12799            }
 12800            // Tracing
 312801            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 312802            string _invocationId = null;
 312803            if (_shouldTrace)
 12804            {
 012805                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 012806                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 012807                tracingParameters.Add("appId", appId);
 012808                tracingParameters.Add("versionId", versionId);
 012809                tracingParameters.Add("entityId", entityId);
 012810                tracingParameters.Add("cancellationToken", cancellationToken);
 012811                ServiceClientTracing.Enter(_invocationId, this, "ListCustomPrebuiltEntityRoles", tracingParameters);
 12812            }
 12813            // Construct URL
 312814            var _baseUrl = Client.BaseUri;
 312815            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 312816            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 312817            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 312818            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 312819            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 12820            // Create HTTP transport objects
 312821            var _httpRequest = new HttpRequestMessage();
 312822            HttpResponseMessage _httpResponse = null;
 312823            _httpRequest.Method = new HttpMethod("GET");
 312824            _httpRequest.RequestUri = new System.Uri(_url);
 12825            // Set Headers
 12826
 12827
 312828            if (customHeaders != null)
 12829            {
 012830                foreach(var _header in customHeaders)
 12831                {
 012832                    if (_httpRequest.Headers.Contains(_header.Key))
 12833                    {
 012834                        _httpRequest.Headers.Remove(_header.Key);
 12835                    }
 012836                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 12837                }
 12838            }
 12839
 12840            // Serialize Request
 312841            string _requestContent = null;
 12842            // Set Credentials
 312843            if (Client.Credentials != null)
 12844            {
 312845                cancellationToken.ThrowIfCancellationRequested();
 312846                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 12847            }
 12848            // Send Request
 312849            if (_shouldTrace)
 12850            {
 012851                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 12852            }
 312853            cancellationToken.ThrowIfCancellationRequested();
 312854            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 312855            if (_shouldTrace)
 12856            {
 012857                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 12858            }
 312859            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 312860            cancellationToken.ThrowIfCancellationRequested();
 312861            string _responseContent = null;
 312862            if ((int)_statusCode != 200)
 12863            {
 012864                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 12865                try
 12866                {
 012867                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 012868                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 012869                    if (_errorBody != null)
 12870                    {
 012871                        ex.Body = _errorBody;
 12872                    }
 012873                }
 012874                catch (JsonException)
 12875                {
 12876                    // Ignore the exception
 012877                }
 012878                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 012879                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 012880                if (_shouldTrace)
 12881                {
 012882                    ServiceClientTracing.Error(_invocationId, ex);
 12883                }
 012884                _httpRequest.Dispose();
 012885                if (_httpResponse != null)
 12886                {
 012887                    _httpResponse.Dispose();
 12888                }
 012889                throw ex;
 12890            }
 12891            // Create Result
 312892            var _result = new HttpOperationResponse<IList<EntityRole>>();
 312893            _result.Request = _httpRequest;
 312894            _result.Response = _httpResponse;
 12895            // Deserialize Response
 312896            if ((int)_statusCode == 200)
 12897            {
 312898                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 12899                try
 12900                {
 312901                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont
 312902                }
 012903                catch (JsonException ex)
 12904                {
 012905                    _httpRequest.Dispose();
 012906                    if (_httpResponse != null)
 12907                    {
 012908                        _httpResponse.Dispose();
 12909                    }
 012910                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 12911                }
 12912            }
 312913            if (_shouldTrace)
 12914            {
 012915                ServiceClientTracing.Exit(_invocationId, _result);
 12916            }
 312917            return _result;
 312918        }
 12919
 12920        /// <summary>
 12921        /// Create a role for a prebuilt entity in a version of the application.
 12922        /// </summary>
 12923        /// <param name='appId'>
 12924        /// The application ID.
 12925        /// </param>
 12926        /// <param name='versionId'>
 12927        /// The version ID.
 12928        /// </param>
 12929        /// <param name='entityId'>
 12930        /// The entity model ID.
 12931        /// </param>
 12932        /// <param name='entityRoleCreateObject'>
 12933        /// An entity role object containing the name of role.
 12934        /// </param>
 12935        /// <param name='customHeaders'>
 12936        /// Headers that will be added to request.
 12937        /// </param>
 12938        /// <param name='cancellationToken'>
 12939        /// The cancellation token.
 12940        /// </param>
 12941        /// <exception cref="ErrorResponseException">
 12942        /// Thrown when the operation returned an invalid status code
 12943        /// </exception>
 12944        /// <exception cref="SerializationException">
 12945        /// Thrown when unable to deserialize the response
 12946        /// </exception>
 12947        /// <exception cref="ValidationException">
 12948        /// Thrown when a required parameter is null
 12949        /// </exception>
 12950        /// <exception cref="System.ArgumentNullException">
 12951        /// Thrown when a required parameter is null
 12952        /// </exception>
 12953        /// <return>
 12954        /// A response object containing the response body and response headers.
 12955        /// </return>
 12956        public async Task<HttpOperationResponse<System.Guid>> CreateCustomPrebuiltEntityRoleWithHttpMessagesAsync(System
 12957        {
 512958            if (Client.Endpoint == null)
 12959            {
 012960                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 12961            }
 512962            if (versionId == null)
 12963            {
 012964                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 12965            }
 512966            if (entityRoleCreateObject == null)
 12967            {
 012968                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject");
 12969            }
 12970            // Tracing
 512971            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 512972            string _invocationId = null;
 512973            if (_shouldTrace)
 12974            {
 012975                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 012976                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 012977                tracingParameters.Add("appId", appId);
 012978                tracingParameters.Add("versionId", versionId);
 012979                tracingParameters.Add("entityId", entityId);
 012980                tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject);
 012981                tracingParameters.Add("cancellationToken", cancellationToken);
 012982                ServiceClientTracing.Enter(_invocationId, this, "CreateCustomPrebuiltEntityRole", tracingParameters);
 12983            }
 12984            // Construct URL
 512985            var _baseUrl = Client.BaseUri;
 512986            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 512987            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 512988            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 512989            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 512990            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 12991            // Create HTTP transport objects
 512992            var _httpRequest = new HttpRequestMessage();
 512993            HttpResponseMessage _httpResponse = null;
 512994            _httpRequest.Method = new HttpMethod("POST");
 512995            _httpRequest.RequestUri = new System.Uri(_url);
 12996            // Set Headers
 12997
 12998
 512999            if (customHeaders != null)
 13000            {
 013001                foreach(var _header in customHeaders)
 13002                {
 013003                    if (_httpRequest.Headers.Contains(_header.Key))
 13004                    {
 013005                        _httpRequest.Headers.Remove(_header.Key);
 13006                    }
 013007                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 13008                }
 13009            }
 13010
 13011            // Serialize Request
 513012            string _requestContent = null;
 513013            if(entityRoleCreateObject != null)
 13014            {
 513015                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri
 513016                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 513017                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 13018            }
 13019            // Set Credentials
 513020            if (Client.Credentials != null)
 13021            {
 513022                cancellationToken.ThrowIfCancellationRequested();
 513023                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13024            }
 13025            // Send Request
 513026            if (_shouldTrace)
 13027            {
 013028                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 13029            }
 513030            cancellationToken.ThrowIfCancellationRequested();
 513031            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 513032            if (_shouldTrace)
 13033            {
 013034                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 13035            }
 513036            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 513037            cancellationToken.ThrowIfCancellationRequested();
 513038            string _responseContent = null;
 513039            if ((int)_statusCode != 201)
 13040            {
 013041                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 13042                try
 13043                {
 013044                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 013045                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 013046                    if (_errorBody != null)
 13047                    {
 013048                        ex.Body = _errorBody;
 13049                    }
 013050                }
 013051                catch (JsonException)
 13052                {
 13053                    // Ignore the exception
 013054                }
 013055                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 013056                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 013057                if (_shouldTrace)
 13058                {
 013059                    ServiceClientTracing.Error(_invocationId, ex);
 13060                }
 013061                _httpRequest.Dispose();
 013062                if (_httpResponse != null)
 13063                {
 013064                    _httpResponse.Dispose();
 13065                }
 013066                throw ex;
 13067            }
 13068            // Create Result
 513069            var _result = new HttpOperationResponse<System.Guid>();
 513070            _result.Request = _httpRequest;
 513071            _result.Response = _httpResponse;
 13072            // Deserialize Response
 513073            if ((int)_statusCode == 201)
 13074            {
 513075                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 13076                try
 13077                {
 513078                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C
 513079                }
 013080                catch (JsonException ex)
 13081                {
 013082                    _httpRequest.Dispose();
 013083                    if (_httpResponse != null)
 13084                    {
 013085                        _httpResponse.Dispose();
 13086                    }
 013087                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 13088                }
 13089            }
 513090            if (_shouldTrace)
 13091            {
 013092                ServiceClientTracing.Exit(_invocationId, _result);
 13093            }
 513094            return _result;
 513095        }
 13096
 13097        /// <summary>
 13098        /// Get the explicit (exception) list of the pattern.any entity in a version of
 13099        /// the application.
 13100        /// </summary>
 13101        /// <param name='appId'>
 13102        /// The application ID.
 13103        /// </param>
 13104        /// <param name='versionId'>
 13105        /// The version ID.
 13106        /// </param>
 13107        /// <param name='entityId'>
 13108        /// The Pattern.Any entity id.
 13109        /// </param>
 13110        /// <param name='customHeaders'>
 13111        /// Headers that will be added to request.
 13112        /// </param>
 13113        /// <param name='cancellationToken'>
 13114        /// The cancellation token.
 13115        /// </param>
 13116        /// <exception cref="ErrorResponseException">
 13117        /// Thrown when the operation returned an invalid status code
 13118        /// </exception>
 13119        /// <exception cref="SerializationException">
 13120        /// Thrown when unable to deserialize the response
 13121        /// </exception>
 13122        /// <exception cref="ValidationException">
 13123        /// Thrown when a required parameter is null
 13124        /// </exception>
 13125        /// <exception cref="System.ArgumentNullException">
 13126        /// Thrown when a required parameter is null
 13127        /// </exception>
 13128        /// <return>
 13129        /// A response object containing the response body and response headers.
 13130        /// </return>
 13131        public async Task<HttpOperationResponse<IList<ExplicitListItem>>> GetExplicitListWithHttpMessagesAsync(System.Gu
 13132        {
 213133            if (Client.Endpoint == null)
 13134            {
 013135                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 13136            }
 213137            if (versionId == null)
 13138            {
 013139                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 13140            }
 13141            // Tracing
 213142            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 213143            string _invocationId = null;
 213144            if (_shouldTrace)
 13145            {
 013146                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 013147                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 013148                tracingParameters.Add("appId", appId);
 013149                tracingParameters.Add("versionId", versionId);
 013150                tracingParameters.Add("entityId", entityId);
 013151                tracingParameters.Add("cancellationToken", cancellationToken);
 013152                ServiceClientTracing.Enter(_invocationId, this, "GetExplicitList", tracingParameters);
 13153            }
 13154            // Construct URL
 213155            var _baseUrl = Client.BaseUri;
 213156            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 213157            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 213158            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 213159            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 213160            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 13161            // Create HTTP transport objects
 213162            var _httpRequest = new HttpRequestMessage();
 213163            HttpResponseMessage _httpResponse = null;
 213164            _httpRequest.Method = new HttpMethod("GET");
 213165            _httpRequest.RequestUri = new System.Uri(_url);
 13166            // Set Headers
 13167
 13168
 213169            if (customHeaders != null)
 13170            {
 013171                foreach(var _header in customHeaders)
 13172                {
 013173                    if (_httpRequest.Headers.Contains(_header.Key))
 13174                    {
 013175                        _httpRequest.Headers.Remove(_header.Key);
 13176                    }
 013177                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 13178                }
 13179            }
 13180
 13181            // Serialize Request
 213182            string _requestContent = null;
 13183            // Set Credentials
 213184            if (Client.Credentials != null)
 13185            {
 213186                cancellationToken.ThrowIfCancellationRequested();
 213187                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13188            }
 13189            // Send Request
 213190            if (_shouldTrace)
 13191            {
 013192                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 13193            }
 213194            cancellationToken.ThrowIfCancellationRequested();
 213195            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 213196            if (_shouldTrace)
 13197            {
 013198                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 13199            }
 213200            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 213201            cancellationToken.ThrowIfCancellationRequested();
 213202            string _responseContent = null;
 213203            if ((int)_statusCode != 200)
 13204            {
 013205                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 13206                try
 13207                {
 013208                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 013209                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 013210                    if (_errorBody != null)
 13211                    {
 013212                        ex.Body = _errorBody;
 13213                    }
 013214                }
 013215                catch (JsonException)
 13216                {
 13217                    // Ignore the exception
 013218                }
 013219                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 013220                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 013221                if (_shouldTrace)
 13222                {
 013223                    ServiceClientTracing.Error(_invocationId, ex);
 13224                }
 013225                _httpRequest.Dispose();
 013226                if (_httpResponse != null)
 13227                {
 013228                    _httpResponse.Dispose();
 13229                }
 013230                throw ex;
 13231            }
 13232            // Create Result
 213233            var _result = new HttpOperationResponse<IList<ExplicitListItem>>();
 213234            _result.Request = _httpRequest;
 213235            _result.Response = _httpResponse;
 13236            // Deserialize Response
 213237            if ((int)_statusCode == 200)
 13238            {
 213239                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 13240                try
 13241                {
 213242                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ExplicitListItem>>(_respon
 213243                }
 013244                catch (JsonException ex)
 13245                {
 013246                    _httpRequest.Dispose();
 013247                    if (_httpResponse != null)
 13248                    {
 013249                        _httpResponse.Dispose();
 13250                    }
 013251                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 13252                }
 13253            }
 213254            if (_shouldTrace)
 13255            {
 013256                ServiceClientTracing.Exit(_invocationId, _result);
 13257            }
 213258            return _result;
 213259        }
 13260
 13261        /// <summary>
 13262        /// Add a new exception to the explicit list for the Pattern.Any entity in a
 13263        /// version of the application.
 13264        /// </summary>
 13265        /// <param name='appId'>
 13266        /// The application ID.
 13267        /// </param>
 13268        /// <param name='versionId'>
 13269        /// The version ID.
 13270        /// </param>
 13271        /// <param name='entityId'>
 13272        /// The Pattern.Any entity extractor ID.
 13273        /// </param>
 13274        /// <param name='item'>
 13275        /// The new explicit list item.
 13276        /// </param>
 13277        /// <param name='customHeaders'>
 13278        /// Headers that will be added to request.
 13279        /// </param>
 13280        /// <param name='cancellationToken'>
 13281        /// The cancellation token.
 13282        /// </param>
 13283        /// <exception cref="ErrorResponseException">
 13284        /// Thrown when the operation returned an invalid status code
 13285        /// </exception>
 13286        /// <exception cref="SerializationException">
 13287        /// Thrown when unable to deserialize the response
 13288        /// </exception>
 13289        /// <exception cref="ValidationException">
 13290        /// Thrown when a required parameter is null
 13291        /// </exception>
 13292        /// <exception cref="System.ArgumentNullException">
 13293        /// Thrown when a required parameter is null
 13294        /// </exception>
 13295        /// <return>
 13296        /// A response object containing the response body and response headers.
 13297        /// </return>
 13298        public async Task<HttpOperationResponse<int?>> AddExplicitListItemWithHttpMessagesAsync(System.Guid appId, strin
 13299        {
 413300            if (Client.Endpoint == null)
 13301            {
 013302                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 13303            }
 413304            if (versionId == null)
 13305            {
 013306                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 13307            }
 413308            if (item == null)
 13309            {
 013310                throw new ValidationException(ValidationRules.CannotBeNull, "item");
 13311            }
 13312            // Tracing
 413313            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 413314            string _invocationId = null;
 413315            if (_shouldTrace)
 13316            {
 013317                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 013318                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 013319                tracingParameters.Add("appId", appId);
 013320                tracingParameters.Add("versionId", versionId);
 013321                tracingParameters.Add("entityId", entityId);
 013322                tracingParameters.Add("item", item);
 013323                tracingParameters.Add("cancellationToken", cancellationToken);
 013324                ServiceClientTracing.Enter(_invocationId, this, "AddExplicitListItem", tracingParameters);
 13325            }
 13326            // Construct URL
 413327            var _baseUrl = Client.BaseUri;
 413328            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 413329            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 413330            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 413331            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 413332            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 13333            // Create HTTP transport objects
 413334            var _httpRequest = new HttpRequestMessage();
 413335            HttpResponseMessage _httpResponse = null;
 413336            _httpRequest.Method = new HttpMethod("POST");
 413337            _httpRequest.RequestUri = new System.Uri(_url);
 13338            // Set Headers
 13339
 13340
 413341            if (customHeaders != null)
 13342            {
 013343                foreach(var _header in customHeaders)
 13344                {
 013345                    if (_httpRequest.Headers.Contains(_header.Key))
 13346                    {
 013347                        _httpRequest.Headers.Remove(_header.Key);
 13348                    }
 013349                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 13350                }
 13351            }
 13352
 13353            // Serialize Request
 413354            string _requestContent = null;
 413355            if(item != null)
 13356            {
 413357                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(item, Client.SerializationSettings)
 413358                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 413359                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 13360            }
 13361            // Set Credentials
 413362            if (Client.Credentials != null)
 13363            {
 413364                cancellationToken.ThrowIfCancellationRequested();
 413365                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13366            }
 13367            // Send Request
 413368            if (_shouldTrace)
 13369            {
 013370                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 13371            }
 413372            cancellationToken.ThrowIfCancellationRequested();
 413373            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 413374            if (_shouldTrace)
 13375            {
 013376                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 13377            }
 413378            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 413379            cancellationToken.ThrowIfCancellationRequested();
 413380            string _responseContent = null;
 413381            if ((int)_statusCode != 201)
 13382            {
 013383                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 13384                try
 13385                {
 013386                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 013387                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 013388                    if (_errorBody != null)
 13389                    {
 013390                        ex.Body = _errorBody;
 13391                    }
 013392                }
 013393                catch (JsonException)
 13394                {
 13395                    // Ignore the exception
 013396                }
 013397                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 013398                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 013399                if (_shouldTrace)
 13400                {
 013401                    ServiceClientTracing.Error(_invocationId, ex);
 13402                }
 013403                _httpRequest.Dispose();
 013404                if (_httpResponse != null)
 13405                {
 013406                    _httpResponse.Dispose();
 13407                }
 013408                throw ex;
 13409            }
 13410            // Create Result
 413411            var _result = new HttpOperationResponse<int?>();
 413412            _result.Request = _httpRequest;
 413413            _result.Response = _httpResponse;
 13414            // Deserialize Response
 413415            if ((int)_statusCode == 201)
 13416            {
 413417                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 13418                try
 13419                {
 413420                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<int?>(_responseContent, Client.D
 413421                }
 013422                catch (JsonException ex)
 13423                {
 013424                    _httpRequest.Dispose();
 013425                    if (_httpResponse != null)
 13426                    {
 013427                        _httpResponse.Dispose();
 13428                    }
 013429                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 13430                }
 13431            }
 413432            if (_shouldTrace)
 13433            {
 013434                ServiceClientTracing.Exit(_invocationId, _result);
 13435            }
 413436            return _result;
 413437        }
 13438
 13439        /// <summary>
 13440        /// Gets information about a regular expression entity in a version of the
 13441        /// application.
 13442        /// </summary>
 13443        /// <param name='appId'>
 13444        /// The application ID.
 13445        /// </param>
 13446        /// <param name='versionId'>
 13447        /// The version ID.
 13448        /// </param>
 13449        /// <param name='regexEntityId'>
 13450        /// The regular expression entity model ID.
 13451        /// </param>
 13452        /// <param name='customHeaders'>
 13453        /// Headers that will be added to request.
 13454        /// </param>
 13455        /// <param name='cancellationToken'>
 13456        /// The cancellation token.
 13457        /// </param>
 13458        /// <exception cref="ErrorResponseException">
 13459        /// Thrown when the operation returned an invalid status code
 13460        /// </exception>
 13461        /// <exception cref="SerializationException">
 13462        /// Thrown when unable to deserialize the response
 13463        /// </exception>
 13464        /// <exception cref="ValidationException">
 13465        /// Thrown when a required parameter is null
 13466        /// </exception>
 13467        /// <exception cref="System.ArgumentNullException">
 13468        /// Thrown when a required parameter is null
 13469        /// </exception>
 13470        /// <return>
 13471        /// A response object containing the response body and response headers.
 13472        /// </return>
 13473        public async Task<HttpOperationResponse<RegexEntityExtractor>> GetRegexEntityEntityInfoWithHttpMessagesAsync(Sys
 13474        {
 213475            if (Client.Endpoint == null)
 13476            {
 013477                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 13478            }
 213479            if (versionId == null)
 13480            {
 013481                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 13482            }
 13483            // Tracing
 213484            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 213485            string _invocationId = null;
 213486            if (_shouldTrace)
 13487            {
 013488                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 013489                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 013490                tracingParameters.Add("appId", appId);
 013491                tracingParameters.Add("versionId", versionId);
 013492                tracingParameters.Add("regexEntityId", regexEntityId);
 013493                tracingParameters.Add("cancellationToken", cancellationToken);
 013494                ServiceClientTracing.Enter(_invocationId, this, "GetRegexEntityEntityInfo", tracingParameters);
 13495            }
 13496            // Construct URL
 213497            var _baseUrl = Client.BaseUri;
 213498            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 213499            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 213500            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 213501            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 213502            _url = _url.Replace("{regexEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serial
 13503            // Create HTTP transport objects
 213504            var _httpRequest = new HttpRequestMessage();
 213505            HttpResponseMessage _httpResponse = null;
 213506            _httpRequest.Method = new HttpMethod("GET");
 213507            _httpRequest.RequestUri = new System.Uri(_url);
 13508            // Set Headers
 13509
 13510
 213511            if (customHeaders != null)
 13512            {
 013513                foreach(var _header in customHeaders)
 13514                {
 013515                    if (_httpRequest.Headers.Contains(_header.Key))
 13516                    {
 013517                        _httpRequest.Headers.Remove(_header.Key);
 13518                    }
 013519                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 13520                }
 13521            }
 13522
 13523            // Serialize Request
 213524            string _requestContent = null;
 13525            // Set Credentials
 213526            if (Client.Credentials != null)
 13527            {
 213528                cancellationToken.ThrowIfCancellationRequested();
 213529                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13530            }
 13531            // Send Request
 213532            if (_shouldTrace)
 13533            {
 013534                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 13535            }
 213536            cancellationToken.ThrowIfCancellationRequested();
 213537            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 213538            if (_shouldTrace)
 13539            {
 013540                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 13541            }
 213542            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 213543            cancellationToken.ThrowIfCancellationRequested();
 213544            string _responseContent = null;
 213545            if ((int)_statusCode != 200)
 13546            {
 013547                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 13548                try
 13549                {
 013550                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 013551                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 013552                    if (_errorBody != null)
 13553                    {
 013554                        ex.Body = _errorBody;
 13555                    }
 013556                }
 013557                catch (JsonException)
 13558                {
 13559                    // Ignore the exception
 013560                }
 013561                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 013562                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 013563                if (_shouldTrace)
 13564                {
 013565                    ServiceClientTracing.Error(_invocationId, ex);
 13566                }
 013567                _httpRequest.Dispose();
 013568                if (_httpResponse != null)
 13569                {
 013570                    _httpResponse.Dispose();
 13571                }
 013572                throw ex;
 13573            }
 13574            // Create Result
 213575            var _result = new HttpOperationResponse<RegexEntityExtractor>();
 213576            _result.Request = _httpRequest;
 213577            _result.Response = _httpResponse;
 13578            // Deserialize Response
 213579            if ((int)_statusCode == 200)
 13580            {
 213581                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 13582                try
 13583                {
 213584                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<RegexEntityExtractor>(_responseC
 213585                }
 013586                catch (JsonException ex)
 13587                {
 013588                    _httpRequest.Dispose();
 013589                    if (_httpResponse != null)
 13590                    {
 013591                        _httpResponse.Dispose();
 13592                    }
 013593                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 13594                }
 13595            }
 213596            if (_shouldTrace)
 13597            {
 013598                ServiceClientTracing.Exit(_invocationId, _result);
 13599            }
 213600            return _result;
 213601        }
 13602
 13603        /// <summary>
 13604        /// Updates the regular expression entity in a version of the application.
 13605        /// </summary>
 13606        /// <param name='appId'>
 13607        /// The application ID.
 13608        /// </param>
 13609        /// <param name='versionId'>
 13610        /// The version ID.
 13611        /// </param>
 13612        /// <param name='regexEntityId'>
 13613        /// The regular expression entity extractor ID.
 13614        /// </param>
 13615        /// <param name='regexEntityUpdateObject'>
 13616        /// An object containing the new entity name and regex pattern.
 13617        /// </param>
 13618        /// <param name='customHeaders'>
 13619        /// Headers that will be added to request.
 13620        /// </param>
 13621        /// <param name='cancellationToken'>
 13622        /// The cancellation token.
 13623        /// </param>
 13624        /// <exception cref="ErrorResponseException">
 13625        /// Thrown when the operation returned an invalid status code
 13626        /// </exception>
 13627        /// <exception cref="SerializationException">
 13628        /// Thrown when unable to deserialize the response
 13629        /// </exception>
 13630        /// <exception cref="ValidationException">
 13631        /// Thrown when a required parameter is null
 13632        /// </exception>
 13633        /// <exception cref="System.ArgumentNullException">
 13634        /// Thrown when a required parameter is null
 13635        /// </exception>
 13636        /// <return>
 13637        /// A response object containing the response body and response headers.
 13638        /// </return>
 13639        public async Task<HttpOperationResponse<OperationStatus>> UpdateRegexEntityModelWithHttpMessagesAsync(System.Gui
 13640        {
 113641            if (Client.Endpoint == null)
 13642            {
 013643                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 13644            }
 113645            if (versionId == null)
 13646            {
 013647                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 13648            }
 113649            if (regexEntityUpdateObject == null)
 13650            {
 013651                throw new ValidationException(ValidationRules.CannotBeNull, "regexEntityUpdateObject");
 13652            }
 13653            // Tracing
 113654            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 113655            string _invocationId = null;
 113656            if (_shouldTrace)
 13657            {
 013658                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 013659                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 013660                tracingParameters.Add("appId", appId);
 013661                tracingParameters.Add("versionId", versionId);
 013662                tracingParameters.Add("regexEntityId", regexEntityId);
 013663                tracingParameters.Add("regexEntityUpdateObject", regexEntityUpdateObject);
 013664                tracingParameters.Add("cancellationToken", cancellationToken);
 013665                ServiceClientTracing.Enter(_invocationId, this, "UpdateRegexEntityModel", tracingParameters);
 13666            }
 13667            // Construct URL
 113668            var _baseUrl = Client.BaseUri;
 113669            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 113670            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 113671            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 113672            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 113673            _url = _url.Replace("{regexEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serial
 13674            // Create HTTP transport objects
 113675            var _httpRequest = new HttpRequestMessage();
 113676            HttpResponseMessage _httpResponse = null;
 113677            _httpRequest.Method = new HttpMethod("PUT");
 113678            _httpRequest.RequestUri = new System.Uri(_url);
 13679            // Set Headers
 13680
 13681
 113682            if (customHeaders != null)
 13683            {
 013684                foreach(var _header in customHeaders)
 13685                {
 013686                    if (_httpRequest.Headers.Contains(_header.Key))
 13687                    {
 013688                        _httpRequest.Headers.Remove(_header.Key);
 13689                    }
 013690                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 13691                }
 13692            }
 13693
 13694            // Serialize Request
 113695            string _requestContent = null;
 113696            if(regexEntityUpdateObject != null)
 13697            {
 113698                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(regexEntityUpdateObject, Client.Ser
 113699                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 113700                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 13701            }
 13702            // Set Credentials
 113703            if (Client.Credentials != null)
 13704            {
 113705                cancellationToken.ThrowIfCancellationRequested();
 113706                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13707            }
 13708            // Send Request
 113709            if (_shouldTrace)
 13710            {
 013711                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 13712            }
 113713            cancellationToken.ThrowIfCancellationRequested();
 113714            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 113715            if (_shouldTrace)
 13716            {
 013717                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 13718            }
 113719            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 113720            cancellationToken.ThrowIfCancellationRequested();
 113721            string _responseContent = null;
 113722            if ((int)_statusCode != 200)
 13723            {
 013724                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 13725                try
 13726                {
 013727                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 013728                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 013729                    if (_errorBody != null)
 13730                    {
 013731                        ex.Body = _errorBody;
 13732                    }
 013733                }
 013734                catch (JsonException)
 13735                {
 13736                    // Ignore the exception
 013737                }
 013738                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 013739                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 013740                if (_shouldTrace)
 13741                {
 013742                    ServiceClientTracing.Error(_invocationId, ex);
 13743                }
 013744                _httpRequest.Dispose();
 013745                if (_httpResponse != null)
 13746                {
 013747                    _httpResponse.Dispose();
 13748                }
 013749                throw ex;
 13750            }
 13751            // Create Result
 113752            var _result = new HttpOperationResponse<OperationStatus>();
 113753            _result.Request = _httpRequest;
 113754            _result.Response = _httpResponse;
 13755            // Deserialize Response
 113756            if ((int)_statusCode == 200)
 13757            {
 113758                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 13759                try
 13760                {
 113761                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 113762                }
 013763                catch (JsonException ex)
 13764                {
 013765                    _httpRequest.Dispose();
 013766                    if (_httpResponse != null)
 13767                    {
 013768                        _httpResponse.Dispose();
 13769                    }
 013770                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 13771                }
 13772            }
 113773            if (_shouldTrace)
 13774            {
 013775                ServiceClientTracing.Exit(_invocationId, _result);
 13776            }
 113777            return _result;
 113778        }
 13779
 13780        /// <summary>
 13781        /// Deletes a regular expression entity from a version of the application.
 13782        /// </summary>
 13783        /// <param name='appId'>
 13784        /// The application ID.
 13785        /// </param>
 13786        /// <param name='versionId'>
 13787        /// The version ID.
 13788        /// </param>
 13789        /// <param name='regexEntityId'>
 13790        /// The regular expression entity extractor ID.
 13791        /// </param>
 13792        /// <param name='customHeaders'>
 13793        /// Headers that will be added to request.
 13794        /// </param>
 13795        /// <param name='cancellationToken'>
 13796        /// The cancellation token.
 13797        /// </param>
 13798        /// <exception cref="ErrorResponseException">
 13799        /// Thrown when the operation returned an invalid status code
 13800        /// </exception>
 13801        /// <exception cref="SerializationException">
 13802        /// Thrown when unable to deserialize the response
 13803        /// </exception>
 13804        /// <exception cref="ValidationException">
 13805        /// Thrown when a required parameter is null
 13806        /// </exception>
 13807        /// <exception cref="System.ArgumentNullException">
 13808        /// Thrown when a required parameter is null
 13809        /// </exception>
 13810        /// <return>
 13811        /// A response object containing the response body and response headers.
 13812        /// </return>
 13813        public async Task<HttpOperationResponse<OperationStatus>> DeleteRegexEntityModelWithHttpMessagesAsync(System.Gui
 13814        {
 1013815            if (Client.Endpoint == null)
 13816            {
 013817                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 13818            }
 1013819            if (versionId == null)
 13820            {
 013821                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 13822            }
 13823            // Tracing
 1013824            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 1013825            string _invocationId = null;
 1013826            if (_shouldTrace)
 13827            {
 013828                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 013829                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 013830                tracingParameters.Add("appId", appId);
 013831                tracingParameters.Add("versionId", versionId);
 013832                tracingParameters.Add("regexEntityId", regexEntityId);
 013833                tracingParameters.Add("cancellationToken", cancellationToken);
 013834                ServiceClientTracing.Enter(_invocationId, this, "DeleteRegexEntityModel", tracingParameters);
 13835            }
 13836            // Construct URL
 1013837            var _baseUrl = Client.BaseUri;
 1013838            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 1013839            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 1013840            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 1013841            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 1013842            _url = _url.Replace("{regexEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serial
 13843            // Create HTTP transport objects
 1013844            var _httpRequest = new HttpRequestMessage();
 1013845            HttpResponseMessage _httpResponse = null;
 1013846            _httpRequest.Method = new HttpMethod("DELETE");
 1013847            _httpRequest.RequestUri = new System.Uri(_url);
 13848            // Set Headers
 13849
 13850
 1013851            if (customHeaders != null)
 13852            {
 013853                foreach(var _header in customHeaders)
 13854                {
 013855                    if (_httpRequest.Headers.Contains(_header.Key))
 13856                    {
 013857                        _httpRequest.Headers.Remove(_header.Key);
 13858                    }
 013859                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 13860                }
 13861            }
 13862
 13863            // Serialize Request
 1013864            string _requestContent = null;
 13865            // Set Credentials
 1013866            if (Client.Credentials != null)
 13867            {
 1013868                cancellationToken.ThrowIfCancellationRequested();
 1013869                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 13870            }
 13871            // Send Request
 1013872            if (_shouldTrace)
 13873            {
 013874                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 13875            }
 1013876            cancellationToken.ThrowIfCancellationRequested();
 1013877            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1013878            if (_shouldTrace)
 13879            {
 013880                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 13881            }
 1013882            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 1013883            cancellationToken.ThrowIfCancellationRequested();
 1013884            string _responseContent = null;
 1013885            if ((int)_statusCode != 200)
 13886            {
 013887                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 13888                try
 13889                {
 013890                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 013891                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 013892                    if (_errorBody != null)
 13893                    {
 013894                        ex.Body = _errorBody;
 13895                    }
 013896                }
 013897                catch (JsonException)
 13898                {
 13899                    // Ignore the exception
 013900                }
 013901                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 013902                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 013903                if (_shouldTrace)
 13904                {
 013905                    ServiceClientTracing.Error(_invocationId, ex);
 13906                }
 013907                _httpRequest.Dispose();
 013908                if (_httpResponse != null)
 13909                {
 013910                    _httpResponse.Dispose();
 13911                }
 013912                throw ex;
 13913            }
 13914            // Create Result
 1013915            var _result = new HttpOperationResponse<OperationStatus>();
 1013916            _result.Request = _httpRequest;
 1013917            _result.Response = _httpResponse;
 13918            // Deserialize Response
 1013919            if ((int)_statusCode == 200)
 13920            {
 1013921                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 13922                try
 13923                {
 1013924                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 1013925                }
 013926                catch (JsonException ex)
 13927                {
 013928                    _httpRequest.Dispose();
 013929                    if (_httpResponse != null)
 13930                    {
 013931                        _httpResponse.Dispose();
 13932                    }
 013933                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 13934                }
 13935            }
 1013936            if (_shouldTrace)
 13937            {
 013938                ServiceClientTracing.Exit(_invocationId, _result);
 13939            }
 1013940            return _result;
 1013941        }
 13942
 13943        /// <summary>
 13944        /// Gets information about the Pattern.Any model in a version of the
 13945        /// application.
 13946        /// </summary>
 13947        /// <param name='appId'>
 13948        /// The application ID.
 13949        /// </param>
 13950        /// <param name='versionId'>
 13951        /// The version ID.
 13952        /// </param>
 13953        /// <param name='entityId'>
 13954        /// The entity extractor ID.
 13955        /// </param>
 13956        /// <param name='customHeaders'>
 13957        /// Headers that will be added to request.
 13958        /// </param>
 13959        /// <param name='cancellationToken'>
 13960        /// The cancellation token.
 13961        /// </param>
 13962        /// <exception cref="ErrorResponseException">
 13963        /// Thrown when the operation returned an invalid status code
 13964        /// </exception>
 13965        /// <exception cref="SerializationException">
 13966        /// Thrown when unable to deserialize the response
 13967        /// </exception>
 13968        /// <exception cref="ValidationException">
 13969        /// Thrown when a required parameter is null
 13970        /// </exception>
 13971        /// <exception cref="System.ArgumentNullException">
 13972        /// Thrown when a required parameter is null
 13973        /// </exception>
 13974        /// <return>
 13975        /// A response object containing the response body and response headers.
 13976        /// </return>
 13977        public async Task<HttpOperationResponse<PatternAnyEntityExtractor>> GetPatternAnyEntityInfoWithHttpMessagesAsync
 13978        {
 313979            if (Client.Endpoint == null)
 13980            {
 013981                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 13982            }
 313983            if (versionId == null)
 13984            {
 013985                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 13986            }
 13987            // Tracing
 313988            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 313989            string _invocationId = null;
 313990            if (_shouldTrace)
 13991            {
 013992                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 013993                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 013994                tracingParameters.Add("appId", appId);
 013995                tracingParameters.Add("versionId", versionId);
 013996                tracingParameters.Add("entityId", entityId);
 013997                tracingParameters.Add("cancellationToken", cancellationToken);
 013998                ServiceClientTracing.Enter(_invocationId, this, "GetPatternAnyEntityInfo", tracingParameters);
 13999            }
 14000            // Construct URL
 314001            var _baseUrl = Client.BaseUri;
 314002            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 314003            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 314004            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 314005            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 314006            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 14007            // Create HTTP transport objects
 314008            var _httpRequest = new HttpRequestMessage();
 314009            HttpResponseMessage _httpResponse = null;
 314010            _httpRequest.Method = new HttpMethod("GET");
 314011            _httpRequest.RequestUri = new System.Uri(_url);
 14012            // Set Headers
 14013
 14014
 314015            if (customHeaders != null)
 14016            {
 014017                foreach(var _header in customHeaders)
 14018                {
 014019                    if (_httpRequest.Headers.Contains(_header.Key))
 14020                    {
 014021                        _httpRequest.Headers.Remove(_header.Key);
 14022                    }
 014023                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 14024                }
 14025            }
 14026
 14027            // Serialize Request
 314028            string _requestContent = null;
 14029            // Set Credentials
 314030            if (Client.Credentials != null)
 14031            {
 314032                cancellationToken.ThrowIfCancellationRequested();
 314033                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 14034            }
 14035            // Send Request
 314036            if (_shouldTrace)
 14037            {
 014038                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 14039            }
 314040            cancellationToken.ThrowIfCancellationRequested();
 314041            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 314042            if (_shouldTrace)
 14043            {
 014044                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 14045            }
 314046            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 314047            cancellationToken.ThrowIfCancellationRequested();
 314048            string _responseContent = null;
 314049            if ((int)_statusCode != 200)
 14050            {
 014051                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 14052                try
 14053                {
 014054                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 014055                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 014056                    if (_errorBody != null)
 14057                    {
 014058                        ex.Body = _errorBody;
 14059                    }
 014060                }
 014061                catch (JsonException)
 14062                {
 14063                    // Ignore the exception
 014064                }
 014065                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 014066                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 014067                if (_shouldTrace)
 14068                {
 014069                    ServiceClientTracing.Error(_invocationId, ex);
 14070                }
 014071                _httpRequest.Dispose();
 014072                if (_httpResponse != null)
 14073                {
 014074                    _httpResponse.Dispose();
 14075                }
 014076                throw ex;
 14077            }
 14078            // Create Result
 314079            var _result = new HttpOperationResponse<PatternAnyEntityExtractor>();
 314080            _result.Request = _httpRequest;
 314081            _result.Response = _httpResponse;
 14082            // Deserialize Response
 314083            if ((int)_statusCode == 200)
 14084            {
 314085                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 14086                try
 14087                {
 314088                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<PatternAnyEntityExtractor>(_resp
 314089                }
 014090                catch (JsonException ex)
 14091                {
 014092                    _httpRequest.Dispose();
 014093                    if (_httpResponse != null)
 14094                    {
 014095                        _httpResponse.Dispose();
 14096                    }
 014097                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 14098                }
 14099            }
 314100            if (_shouldTrace)
 14101            {
 014102                ServiceClientTracing.Exit(_invocationId, _result);
 14103            }
 314104            return _result;
 314105        }
 14106
 14107        /// <summary>
 14108        /// Updates the name and explicit (exception) list of a Pattern.Any entity
 14109        /// model in a version of the application.
 14110        /// </summary>
 14111        /// <param name='appId'>
 14112        /// The application ID.
 14113        /// </param>
 14114        /// <param name='versionId'>
 14115        /// The version ID.
 14116        /// </param>
 14117        /// <param name='entityId'>
 14118        /// The Pattern.Any entity extractor ID.
 14119        /// </param>
 14120        /// <param name='patternAnyUpdateObject'>
 14121        /// An object containing the explicit list of the Pattern.Any entity.
 14122        /// </param>
 14123        /// <param name='customHeaders'>
 14124        /// Headers that will be added to request.
 14125        /// </param>
 14126        /// <param name='cancellationToken'>
 14127        /// The cancellation token.
 14128        /// </param>
 14129        /// <exception cref="ErrorResponseException">
 14130        /// Thrown when the operation returned an invalid status code
 14131        /// </exception>
 14132        /// <exception cref="SerializationException">
 14133        /// Thrown when unable to deserialize the response
 14134        /// </exception>
 14135        /// <exception cref="ValidationException">
 14136        /// Thrown when a required parameter is null
 14137        /// </exception>
 14138        /// <exception cref="System.ArgumentNullException">
 14139        /// Thrown when a required parameter is null
 14140        /// </exception>
 14141        /// <return>
 14142        /// A response object containing the response body and response headers.
 14143        /// </return>
 14144        public async Task<HttpOperationResponse<OperationStatus>> UpdatePatternAnyEntityModelWithHttpMessagesAsync(Syste
 14145        {
 114146            if (Client.Endpoint == null)
 14147            {
 014148                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 14149            }
 114150            if (versionId == null)
 14151            {
 014152                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 14153            }
 114154            if (patternAnyUpdateObject == null)
 14155            {
 014156                throw new ValidationException(ValidationRules.CannotBeNull, "patternAnyUpdateObject");
 14157            }
 14158            // Tracing
 114159            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 114160            string _invocationId = null;
 114161            if (_shouldTrace)
 14162            {
 014163                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 014164                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 014165                tracingParameters.Add("appId", appId);
 014166                tracingParameters.Add("versionId", versionId);
 014167                tracingParameters.Add("entityId", entityId);
 014168                tracingParameters.Add("patternAnyUpdateObject", patternAnyUpdateObject);
 014169                tracingParameters.Add("cancellationToken", cancellationToken);
 014170                ServiceClientTracing.Enter(_invocationId, this, "UpdatePatternAnyEntityModel", tracingParameters);
 14171            }
 14172            // Construct URL
 114173            var _baseUrl = Client.BaseUri;
 114174            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 114175            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 114176            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 114177            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 114178            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 14179            // Create HTTP transport objects
 114180            var _httpRequest = new HttpRequestMessage();
 114181            HttpResponseMessage _httpResponse = null;
 114182            _httpRequest.Method = new HttpMethod("PUT");
 114183            _httpRequest.RequestUri = new System.Uri(_url);
 14184            // Set Headers
 14185
 14186
 114187            if (customHeaders != null)
 14188            {
 014189                foreach(var _header in customHeaders)
 14190                {
 014191                    if (_httpRequest.Headers.Contains(_header.Key))
 14192                    {
 014193                        _httpRequest.Headers.Remove(_header.Key);
 14194                    }
 014195                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 14196                }
 14197            }
 14198
 14199            // Serialize Request
 114200            string _requestContent = null;
 114201            if(patternAnyUpdateObject != null)
 14202            {
 114203                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(patternAnyUpdateObject, Client.Seri
 114204                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 114205                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 14206            }
 14207            // Set Credentials
 114208            if (Client.Credentials != null)
 14209            {
 114210                cancellationToken.ThrowIfCancellationRequested();
 114211                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 14212            }
 14213            // Send Request
 114214            if (_shouldTrace)
 14215            {
 014216                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 14217            }
 114218            cancellationToken.ThrowIfCancellationRequested();
 114219            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 114220            if (_shouldTrace)
 14221            {
 014222                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 14223            }
 114224            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 114225            cancellationToken.ThrowIfCancellationRequested();
 114226            string _responseContent = null;
 114227            if ((int)_statusCode != 200)
 14228            {
 014229                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 14230                try
 14231                {
 014232                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 014233                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 014234                    if (_errorBody != null)
 14235                    {
 014236                        ex.Body = _errorBody;
 14237                    }
 014238                }
 014239                catch (JsonException)
 14240                {
 14241                    // Ignore the exception
 014242                }
 014243                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 014244                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 014245                if (_shouldTrace)
 14246                {
 014247                    ServiceClientTracing.Error(_invocationId, ex);
 14248                }
 014249                _httpRequest.Dispose();
 014250                if (_httpResponse != null)
 14251                {
 014252                    _httpResponse.Dispose();
 14253                }
 014254                throw ex;
 14255            }
 14256            // Create Result
 114257            var _result = new HttpOperationResponse<OperationStatus>();
 114258            _result.Request = _httpRequest;
 114259            _result.Response = _httpResponse;
 14260            // Deserialize Response
 114261            if ((int)_statusCode == 200)
 14262            {
 114263                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 14264                try
 14265                {
 114266                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 114267                }
 014268                catch (JsonException ex)
 14269                {
 014270                    _httpRequest.Dispose();
 014271                    if (_httpResponse != null)
 14272                    {
 014273                        _httpResponse.Dispose();
 14274                    }
 014275                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 14276                }
 14277            }
 114278            if (_shouldTrace)
 14279            {
 014280                ServiceClientTracing.Exit(_invocationId, _result);
 14281            }
 114282            return _result;
 114283        }
 14284
 14285        /// <summary>
 14286        /// Deletes a Pattern.Any entity extractor from a version of the application.
 14287        /// </summary>
 14288        /// <param name='appId'>
 14289        /// The application ID.
 14290        /// </param>
 14291        /// <param name='versionId'>
 14292        /// The version ID.
 14293        /// </param>
 14294        /// <param name='entityId'>
 14295        /// The Pattern.Any entity extractor ID.
 14296        /// </param>
 14297        /// <param name='customHeaders'>
 14298        /// Headers that will be added to request.
 14299        /// </param>
 14300        /// <param name='cancellationToken'>
 14301        /// The cancellation token.
 14302        /// </param>
 14303        /// <exception cref="ErrorResponseException">
 14304        /// Thrown when the operation returned an invalid status code
 14305        /// </exception>
 14306        /// <exception cref="SerializationException">
 14307        /// Thrown when unable to deserialize the response
 14308        /// </exception>
 14309        /// <exception cref="ValidationException">
 14310        /// Thrown when a required parameter is null
 14311        /// </exception>
 14312        /// <exception cref="System.ArgumentNullException">
 14313        /// Thrown when a required parameter is null
 14314        /// </exception>
 14315        /// <return>
 14316        /// A response object containing the response body and response headers.
 14317        /// </return>
 14318        public async Task<HttpOperationResponse<OperationStatus>> DeletePatternAnyEntityModelWithHttpMessagesAsync(Syste
 14319        {
 1514320            if (Client.Endpoint == null)
 14321            {
 014322                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 14323            }
 1514324            if (versionId == null)
 14325            {
 014326                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 14327            }
 14328            // Tracing
 1514329            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 1514330            string _invocationId = null;
 1514331            if (_shouldTrace)
 14332            {
 014333                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 014334                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 014335                tracingParameters.Add("appId", appId);
 014336                tracingParameters.Add("versionId", versionId);
 014337                tracingParameters.Add("entityId", entityId);
 014338                tracingParameters.Add("cancellationToken", cancellationToken);
 014339                ServiceClientTracing.Enter(_invocationId, this, "DeletePatternAnyEntityModel", tracingParameters);
 14340            }
 14341            // Construct URL
 1514342            var _baseUrl = Client.BaseUri;
 1514343            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 1514344            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 1514345            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 1514346            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 1514347            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 14348            // Create HTTP transport objects
 1514349            var _httpRequest = new HttpRequestMessage();
 1514350            HttpResponseMessage _httpResponse = null;
 1514351            _httpRequest.Method = new HttpMethod("DELETE");
 1514352            _httpRequest.RequestUri = new System.Uri(_url);
 14353            // Set Headers
 14354
 14355
 1514356            if (customHeaders != null)
 14357            {
 014358                foreach(var _header in customHeaders)
 14359                {
 014360                    if (_httpRequest.Headers.Contains(_header.Key))
 14361                    {
 014362                        _httpRequest.Headers.Remove(_header.Key);
 14363                    }
 014364                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 14365                }
 14366            }
 14367
 14368            // Serialize Request
 1514369            string _requestContent = null;
 14370            // Set Credentials
 1514371            if (Client.Credentials != null)
 14372            {
 1514373                cancellationToken.ThrowIfCancellationRequested();
 1514374                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 14375            }
 14376            // Send Request
 1514377            if (_shouldTrace)
 14378            {
 014379                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 14380            }
 1514381            cancellationToken.ThrowIfCancellationRequested();
 1514382            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1514383            if (_shouldTrace)
 14384            {
 014385                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 14386            }
 1514387            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 1514388            cancellationToken.ThrowIfCancellationRequested();
 1514389            string _responseContent = null;
 1514390            if ((int)_statusCode != 200)
 14391            {
 014392                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 14393                try
 14394                {
 014395                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 014396                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 014397                    if (_errorBody != null)
 14398                    {
 014399                        ex.Body = _errorBody;
 14400                    }
 014401                }
 014402                catch (JsonException)
 14403                {
 14404                    // Ignore the exception
 014405                }
 014406                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 014407                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 014408                if (_shouldTrace)
 14409                {
 014410                    ServiceClientTracing.Error(_invocationId, ex);
 14411                }
 014412                _httpRequest.Dispose();
 014413                if (_httpResponse != null)
 14414                {
 014415                    _httpResponse.Dispose();
 14416                }
 014417                throw ex;
 14418            }
 14419            // Create Result
 1514420            var _result = new HttpOperationResponse<OperationStatus>();
 1514421            _result.Request = _httpRequest;
 1514422            _result.Response = _httpResponse;
 14423            // Deserialize Response
 1514424            if ((int)_statusCode == 200)
 14425            {
 1514426                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 14427                try
 14428                {
 1514429                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 1514430                }
 014431                catch (JsonException ex)
 14432                {
 014433                    _httpRequest.Dispose();
 014434                    if (_httpResponse != null)
 14435                    {
 014436                        _httpResponse.Dispose();
 14437                    }
 014438                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 14439                }
 14440            }
 1514441            if (_shouldTrace)
 14442            {
 014443                ServiceClientTracing.Exit(_invocationId, _result);
 14444            }
 1514445            return _result;
 1514446        }
 14447
 14448        /// <summary>
 14449        /// Get one role for a given entity in a version of the application
 14450        /// </summary>
 14451        /// <param name='appId'>
 14452        /// The application ID.
 14453        /// </param>
 14454        /// <param name='versionId'>
 14455        /// The version ID.
 14456        /// </param>
 14457        /// <param name='entityId'>
 14458        /// entity ID.
 14459        /// </param>
 14460        /// <param name='roleId'>
 14461        /// entity role ID.
 14462        /// </param>
 14463        /// <param name='customHeaders'>
 14464        /// Headers that will be added to request.
 14465        /// </param>
 14466        /// <param name='cancellationToken'>
 14467        /// The cancellation token.
 14468        /// </param>
 14469        /// <exception cref="ErrorResponseException">
 14470        /// Thrown when the operation returned an invalid status code
 14471        /// </exception>
 14472        /// <exception cref="SerializationException">
 14473        /// Thrown when unable to deserialize the response
 14474        /// </exception>
 14475        /// <exception cref="ValidationException">
 14476        /// Thrown when a required parameter is null
 14477        /// </exception>
 14478        /// <exception cref="System.ArgumentNullException">
 14479        /// Thrown when a required parameter is null
 14480        /// </exception>
 14481        /// <return>
 14482        /// A response object containing the response body and response headers.
 14483        /// </return>
 14484        public async Task<HttpOperationResponse<EntityRole>> GetEntityRoleWithHttpMessagesAsync(System.Guid appId, strin
 14485        {
 214486            if (Client.Endpoint == null)
 14487            {
 014488                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 14489            }
 214490            if (versionId == null)
 14491            {
 014492                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 14493            }
 14494            // Tracing
 214495            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 214496            string _invocationId = null;
 214497            if (_shouldTrace)
 14498            {
 014499                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 014500                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 014501                tracingParameters.Add("appId", appId);
 014502                tracingParameters.Add("versionId", versionId);
 014503                tracingParameters.Add("entityId", entityId);
 014504                tracingParameters.Add("roleId", roleId);
 014505                tracingParameters.Add("cancellationToken", cancellationToken);
 014506                ServiceClientTracing.Enter(_invocationId, this, "GetEntityRole", tracingParameters);
 14507            }
 14508            // Construct URL
 214509            var _baseUrl = Client.BaseUri;
 214510            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 214511            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 214512            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 214513            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 214514            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 214515            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 14516            // Create HTTP transport objects
 214517            var _httpRequest = new HttpRequestMessage();
 214518            HttpResponseMessage _httpResponse = null;
 214519            _httpRequest.Method = new HttpMethod("GET");
 214520            _httpRequest.RequestUri = new System.Uri(_url);
 14521            // Set Headers
 14522
 14523
 214524            if (customHeaders != null)
 14525            {
 014526                foreach(var _header in customHeaders)
 14527                {
 014528                    if (_httpRequest.Headers.Contains(_header.Key))
 14529                    {
 014530                        _httpRequest.Headers.Remove(_header.Key);
 14531                    }
 014532                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 14533                }
 14534            }
 14535
 14536            // Serialize Request
 214537            string _requestContent = null;
 14538            // Set Credentials
 214539            if (Client.Credentials != null)
 14540            {
 214541                cancellationToken.ThrowIfCancellationRequested();
 214542                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 14543            }
 14544            // Send Request
 214545            if (_shouldTrace)
 14546            {
 014547                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 14548            }
 214549            cancellationToken.ThrowIfCancellationRequested();
 214550            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 214551            if (_shouldTrace)
 14552            {
 014553                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 14554            }
 214555            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 214556            cancellationToken.ThrowIfCancellationRequested();
 214557            string _responseContent = null;
 214558            if ((int)_statusCode != 200)
 14559            {
 014560                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 14561                try
 14562                {
 014563                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 014564                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 014565                    if (_errorBody != null)
 14566                    {
 014567                        ex.Body = _errorBody;
 14568                    }
 014569                }
 014570                catch (JsonException)
 14571                {
 14572                    // Ignore the exception
 014573                }
 014574                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 014575                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 014576                if (_shouldTrace)
 14577                {
 014578                    ServiceClientTracing.Error(_invocationId, ex);
 14579                }
 014580                _httpRequest.Dispose();
 014581                if (_httpResponse != null)
 14582                {
 014583                    _httpResponse.Dispose();
 14584                }
 014585                throw ex;
 14586            }
 14587            // Create Result
 214588            var _result = new HttpOperationResponse<EntityRole>();
 214589            _result.Request = _httpRequest;
 214590            _result.Response = _httpResponse;
 14591            // Deserialize Response
 214592            if ((int)_statusCode == 200)
 14593            {
 214594                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 14595                try
 14596                {
 214597                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl
 214598                }
 014599                catch (JsonException ex)
 14600                {
 014601                    _httpRequest.Dispose();
 014602                    if (_httpResponse != null)
 14603                    {
 014604                        _httpResponse.Dispose();
 14605                    }
 014606                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 14607                }
 14608            }
 214609            if (_shouldTrace)
 14610            {
 014611                ServiceClientTracing.Exit(_invocationId, _result);
 14612            }
 214613            return _result;
 214614        }
 14615
 14616        /// <summary>
 14617        /// Update a role for a given entity in a version of the application.
 14618        /// </summary>
 14619        /// <param name='appId'>
 14620        /// The application ID.
 14621        /// </param>
 14622        /// <param name='versionId'>
 14623        /// The version ID.
 14624        /// </param>
 14625        /// <param name='entityId'>
 14626        /// The entity ID.
 14627        /// </param>
 14628        /// <param name='roleId'>
 14629        /// The entity role ID.
 14630        /// </param>
 14631        /// <param name='entityRoleUpdateObject'>
 14632        /// The new entity role.
 14633        /// </param>
 14634        /// <param name='customHeaders'>
 14635        /// Headers that will be added to request.
 14636        /// </param>
 14637        /// <param name='cancellationToken'>
 14638        /// The cancellation token.
 14639        /// </param>
 14640        /// <exception cref="ErrorResponseException">
 14641        /// Thrown when the operation returned an invalid status code
 14642        /// </exception>
 14643        /// <exception cref="SerializationException">
 14644        /// Thrown when unable to deserialize the response
 14645        /// </exception>
 14646        /// <exception cref="ValidationException">
 14647        /// Thrown when a required parameter is null
 14648        /// </exception>
 14649        /// <exception cref="System.ArgumentNullException">
 14650        /// Thrown when a required parameter is null
 14651        /// </exception>
 14652        /// <return>
 14653        /// A response object containing the response body and response headers.
 14654        /// </return>
 14655        public async Task<HttpOperationResponse<OperationStatus>> UpdateEntityRoleWithHttpMessagesAsync(System.Guid appI
 14656        {
 114657            if (Client.Endpoint == null)
 14658            {
 014659                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 14660            }
 114661            if (versionId == null)
 14662            {
 014663                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 14664            }
 114665            if (entityRoleUpdateObject == null)
 14666            {
 014667                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject");
 14668            }
 14669            // Tracing
 114670            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 114671            string _invocationId = null;
 114672            if (_shouldTrace)
 14673            {
 014674                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 014675                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 014676                tracingParameters.Add("appId", appId);
 014677                tracingParameters.Add("versionId", versionId);
 014678                tracingParameters.Add("entityId", entityId);
 014679                tracingParameters.Add("roleId", roleId);
 014680                tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject);
 014681                tracingParameters.Add("cancellationToken", cancellationToken);
 014682                ServiceClientTracing.Enter(_invocationId, this, "UpdateEntityRole", tracingParameters);
 14683            }
 14684            // Construct URL
 114685            var _baseUrl = Client.BaseUri;
 114686            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 114687            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 114688            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 114689            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 114690            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 114691            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 14692            // Create HTTP transport objects
 114693            var _httpRequest = new HttpRequestMessage();
 114694            HttpResponseMessage _httpResponse = null;
 114695            _httpRequest.Method = new HttpMethod("PUT");
 114696            _httpRequest.RequestUri = new System.Uri(_url);
 14697            // Set Headers
 14698
 14699
 114700            if (customHeaders != null)
 14701            {
 014702                foreach(var _header in customHeaders)
 14703                {
 014704                    if (_httpRequest.Headers.Contains(_header.Key))
 14705                    {
 014706                        _httpRequest.Headers.Remove(_header.Key);
 14707                    }
 014708                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 14709                }
 14710            }
 14711
 14712            // Serialize Request
 114713            string _requestContent = null;
 114714            if(entityRoleUpdateObject != null)
 14715            {
 114716                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri
 114717                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 114718                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 14719            }
 14720            // Set Credentials
 114721            if (Client.Credentials != null)
 14722            {
 114723                cancellationToken.ThrowIfCancellationRequested();
 114724                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 14725            }
 14726            // Send Request
 114727            if (_shouldTrace)
 14728            {
 014729                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 14730            }
 114731            cancellationToken.ThrowIfCancellationRequested();
 114732            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 114733            if (_shouldTrace)
 14734            {
 014735                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 14736            }
 114737            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 114738            cancellationToken.ThrowIfCancellationRequested();
 114739            string _responseContent = null;
 114740            if ((int)_statusCode != 200)
 14741            {
 014742                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 14743                try
 14744                {
 014745                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 014746                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 014747                    if (_errorBody != null)
 14748                    {
 014749                        ex.Body = _errorBody;
 14750                    }
 014751                }
 014752                catch (JsonException)
 14753                {
 14754                    // Ignore the exception
 014755                }
 014756                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 014757                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 014758                if (_shouldTrace)
 14759                {
 014760                    ServiceClientTracing.Error(_invocationId, ex);
 14761                }
 014762                _httpRequest.Dispose();
 014763                if (_httpResponse != null)
 14764                {
 014765                    _httpResponse.Dispose();
 14766                }
 014767                throw ex;
 14768            }
 14769            // Create Result
 114770            var _result = new HttpOperationResponse<OperationStatus>();
 114771            _result.Request = _httpRequest;
 114772            _result.Response = _httpResponse;
 14773            // Deserialize Response
 114774            if ((int)_statusCode == 200)
 14775            {
 114776                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 14777                try
 14778                {
 114779                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 114780                }
 014781                catch (JsonException ex)
 14782                {
 014783                    _httpRequest.Dispose();
 014784                    if (_httpResponse != null)
 14785                    {
 014786                        _httpResponse.Dispose();
 14787                    }
 014788                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 14789                }
 14790            }
 114791            if (_shouldTrace)
 14792            {
 014793                ServiceClientTracing.Exit(_invocationId, _result);
 14794            }
 114795            return _result;
 114796        }
 14797
 14798        /// <summary>
 14799        /// Delete an entity role in a version of the application.
 14800        /// </summary>
 14801        /// <param name='appId'>
 14802        /// The application ID.
 14803        /// </param>
 14804        /// <param name='versionId'>
 14805        /// The version ID.
 14806        /// </param>
 14807        /// <param name='entityId'>
 14808        /// The entity ID.
 14809        /// </param>
 14810        /// <param name='roleId'>
 14811        /// The entity role Id.
 14812        /// </param>
 14813        /// <param name='customHeaders'>
 14814        /// Headers that will be added to request.
 14815        /// </param>
 14816        /// <param name='cancellationToken'>
 14817        /// The cancellation token.
 14818        /// </param>
 14819        /// <exception cref="ErrorResponseException">
 14820        /// Thrown when the operation returned an invalid status code
 14821        /// </exception>
 14822        /// <exception cref="SerializationException">
 14823        /// Thrown when unable to deserialize the response
 14824        /// </exception>
 14825        /// <exception cref="ValidationException">
 14826        /// Thrown when a required parameter is null
 14827        /// </exception>
 14828        /// <exception cref="System.ArgumentNullException">
 14829        /// Thrown when a required parameter is null
 14830        /// </exception>
 14831        /// <return>
 14832        /// A response object containing the response body and response headers.
 14833        /// </return>
 14834        public async Task<HttpOperationResponse<OperationStatus>> DeleteEntityRoleWithHttpMessagesAsync(System.Guid appI
 14835        {
 114836            if (Client.Endpoint == null)
 14837            {
 014838                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 14839            }
 114840            if (versionId == null)
 14841            {
 014842                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 14843            }
 14844            // Tracing
 114845            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 114846            string _invocationId = null;
 114847            if (_shouldTrace)
 14848            {
 014849                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 014850                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 014851                tracingParameters.Add("appId", appId);
 014852                tracingParameters.Add("versionId", versionId);
 014853                tracingParameters.Add("entityId", entityId);
 014854                tracingParameters.Add("roleId", roleId);
 014855                tracingParameters.Add("cancellationToken", cancellationToken);
 014856                ServiceClientTracing.Enter(_invocationId, this, "DeleteEntityRole", tracingParameters);
 14857            }
 14858            // Construct URL
 114859            var _baseUrl = Client.BaseUri;
 114860            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent
 114861            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 114862            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 114863            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 114864            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 114865            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 14866            // Create HTTP transport objects
 114867            var _httpRequest = new HttpRequestMessage();
 114868            HttpResponseMessage _httpResponse = null;
 114869            _httpRequest.Method = new HttpMethod("DELETE");
 114870            _httpRequest.RequestUri = new System.Uri(_url);
 14871            // Set Headers
 14872
 14873
 114874            if (customHeaders != null)
 14875            {
 014876                foreach(var _header in customHeaders)
 14877                {
 014878                    if (_httpRequest.Headers.Contains(_header.Key))
 14879                    {
 014880                        _httpRequest.Headers.Remove(_header.Key);
 14881                    }
 014882                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 14883                }
 14884            }
 14885
 14886            // Serialize Request
 114887            string _requestContent = null;
 14888            // Set Credentials
 114889            if (Client.Credentials != null)
 14890            {
 114891                cancellationToken.ThrowIfCancellationRequested();
 114892                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 14893            }
 14894            // Send Request
 114895            if (_shouldTrace)
 14896            {
 014897                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 14898            }
 114899            cancellationToken.ThrowIfCancellationRequested();
 114900            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 114901            if (_shouldTrace)
 14902            {
 014903                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 14904            }
 114905            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 114906            cancellationToken.ThrowIfCancellationRequested();
 114907            string _responseContent = null;
 114908            if ((int)_statusCode != 200)
 14909            {
 014910                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 14911                try
 14912                {
 014913                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 014914                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 014915                    if (_errorBody != null)
 14916                    {
 014917                        ex.Body = _errorBody;
 14918                    }
 014919                }
 014920                catch (JsonException)
 14921                {
 14922                    // Ignore the exception
 014923                }
 014924                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 014925                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 014926                if (_shouldTrace)
 14927                {
 014928                    ServiceClientTracing.Error(_invocationId, ex);
 14929                }
 014930                _httpRequest.Dispose();
 014931                if (_httpResponse != null)
 14932                {
 014933                    _httpResponse.Dispose();
 14934                }
 014935                throw ex;
 14936            }
 14937            // Create Result
 114938            var _result = new HttpOperationResponse<OperationStatus>();
 114939            _result.Request = _httpRequest;
 114940            _result.Response = _httpResponse;
 14941            // Deserialize Response
 114942            if ((int)_statusCode == 200)
 14943            {
 114944                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 14945                try
 14946                {
 114947                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 114948                }
 014949                catch (JsonException ex)
 14950                {
 014951                    _httpRequest.Dispose();
 014952                    if (_httpResponse != null)
 14953                    {
 014954                        _httpResponse.Dispose();
 14955                    }
 014956                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 14957                }
 14958            }
 114959            if (_shouldTrace)
 14960            {
 014961                ServiceClientTracing.Exit(_invocationId, _result);
 14962            }
 114963            return _result;
 114964        }
 14965
 14966        /// <summary>
 14967        /// Get one role for a given prebuilt entity in a version of the application
 14968        /// </summary>
 14969        /// <param name='appId'>
 14970        /// The application ID.
 14971        /// </param>
 14972        /// <param name='versionId'>
 14973        /// The version ID.
 14974        /// </param>
 14975        /// <param name='entityId'>
 14976        /// entity ID.
 14977        /// </param>
 14978        /// <param name='roleId'>
 14979        /// entity role ID.
 14980        /// </param>
 14981        /// <param name='customHeaders'>
 14982        /// Headers that will be added to request.
 14983        /// </param>
 14984        /// <param name='cancellationToken'>
 14985        /// The cancellation token.
 14986        /// </param>
 14987        /// <exception cref="ErrorResponseException">
 14988        /// Thrown when the operation returned an invalid status code
 14989        /// </exception>
 14990        /// <exception cref="SerializationException">
 14991        /// Thrown when unable to deserialize the response
 14992        /// </exception>
 14993        /// <exception cref="ValidationException">
 14994        /// Thrown when a required parameter is null
 14995        /// </exception>
 14996        /// <exception cref="System.ArgumentNullException">
 14997        /// Thrown when a required parameter is null
 14998        /// </exception>
 14999        /// <return>
 15000        /// A response object containing the response body and response headers.
 15001        /// </return>
 15002        public async Task<HttpOperationResponse<EntityRole>> GetPrebuiltEntityRoleWithHttpMessagesAsync(System.Guid appI
 15003        {
 215004            if (Client.Endpoint == null)
 15005            {
 015006                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 15007            }
 215008            if (versionId == null)
 15009            {
 015010                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 15011            }
 15012            // Tracing
 215013            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 215014            string _invocationId = null;
 215015            if (_shouldTrace)
 15016            {
 015017                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 015018                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 015019                tracingParameters.Add("appId", appId);
 015020                tracingParameters.Add("versionId", versionId);
 015021                tracingParameters.Add("entityId", entityId);
 015022                tracingParameters.Add("roleId", roleId);
 015023                tracingParameters.Add("cancellationToken", cancellationToken);
 015024                ServiceClientTracing.Enter(_invocationId, this, "GetPrebuiltEntityRole", tracingParameters);
 15025            }
 15026            // Construct URL
 215027            var _baseUrl = Client.BaseUri;
 215028            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en
 215029            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 215030            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 215031            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 215032            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 215033            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 15034            // Create HTTP transport objects
 215035            var _httpRequest = new HttpRequestMessage();
 215036            HttpResponseMessage _httpResponse = null;
 215037            _httpRequest.Method = new HttpMethod("GET");
 215038            _httpRequest.RequestUri = new System.Uri(_url);
 15039            // Set Headers
 15040
 15041
 215042            if (customHeaders != null)
 15043            {
 015044                foreach(var _header in customHeaders)
 15045                {
 015046                    if (_httpRequest.Headers.Contains(_header.Key))
 15047                    {
 015048                        _httpRequest.Headers.Remove(_header.Key);
 15049                    }
 015050                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 15051                }
 15052            }
 15053
 15054            // Serialize Request
 215055            string _requestContent = null;
 15056            // Set Credentials
 215057            if (Client.Credentials != null)
 15058            {
 215059                cancellationToken.ThrowIfCancellationRequested();
 215060                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 15061            }
 15062            // Send Request
 215063            if (_shouldTrace)
 15064            {
 015065                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 15066            }
 215067            cancellationToken.ThrowIfCancellationRequested();
 215068            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 215069            if (_shouldTrace)
 15070            {
 015071                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 15072            }
 215073            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 215074            cancellationToken.ThrowIfCancellationRequested();
 215075            string _responseContent = null;
 215076            if ((int)_statusCode != 200)
 15077            {
 015078                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 15079                try
 15080                {
 015081                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 015082                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 015083                    if (_errorBody != null)
 15084                    {
 015085                        ex.Body = _errorBody;
 15086                    }
 015087                }
 015088                catch (JsonException)
 15089                {
 15090                    // Ignore the exception
 015091                }
 015092                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 015093                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 015094                if (_shouldTrace)
 15095                {
 015096                    ServiceClientTracing.Error(_invocationId, ex);
 15097                }
 015098                _httpRequest.Dispose();
 015099                if (_httpResponse != null)
 15100                {
 015101                    _httpResponse.Dispose();
 15102                }
 015103                throw ex;
 15104            }
 15105            // Create Result
 215106            var _result = new HttpOperationResponse<EntityRole>();
 215107            _result.Request = _httpRequest;
 215108            _result.Response = _httpResponse;
 15109            // Deserialize Response
 215110            if ((int)_statusCode == 200)
 15111            {
 215112                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 15113                try
 15114                {
 215115                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl
 215116                }
 015117                catch (JsonException ex)
 15118                {
 015119                    _httpRequest.Dispose();
 015120                    if (_httpResponse != null)
 15121                    {
 015122                        _httpResponse.Dispose();
 15123                    }
 015124                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 15125                }
 15126            }
 215127            if (_shouldTrace)
 15128            {
 015129                ServiceClientTracing.Exit(_invocationId, _result);
 15130            }
 215131            return _result;
 215132        }
 15133
 15134        /// <summary>
 15135        /// Update a role for a given prebuilt entity in a version of the application
 15136        /// </summary>
 15137        /// <param name='appId'>
 15138        /// The application ID.
 15139        /// </param>
 15140        /// <param name='versionId'>
 15141        /// The version ID.
 15142        /// </param>
 15143        /// <param name='entityId'>
 15144        /// The entity ID.
 15145        /// </param>
 15146        /// <param name='roleId'>
 15147        /// The entity role ID.
 15148        /// </param>
 15149        /// <param name='entityRoleUpdateObject'>
 15150        /// The new entity role.
 15151        /// </param>
 15152        /// <param name='customHeaders'>
 15153        /// Headers that will be added to request.
 15154        /// </param>
 15155        /// <param name='cancellationToken'>
 15156        /// The cancellation token.
 15157        /// </param>
 15158        /// <exception cref="ErrorResponseException">
 15159        /// Thrown when the operation returned an invalid status code
 15160        /// </exception>
 15161        /// <exception cref="SerializationException">
 15162        /// Thrown when unable to deserialize the response
 15163        /// </exception>
 15164        /// <exception cref="ValidationException">
 15165        /// Thrown when a required parameter is null
 15166        /// </exception>
 15167        /// <exception cref="System.ArgumentNullException">
 15168        /// Thrown when a required parameter is null
 15169        /// </exception>
 15170        /// <return>
 15171        /// A response object containing the response body and response headers.
 15172        /// </return>
 15173        public async Task<HttpOperationResponse<OperationStatus>> UpdatePrebuiltEntityRoleWithHttpMessagesAsync(System.G
 15174        {
 115175            if (Client.Endpoint == null)
 15176            {
 015177                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 15178            }
 115179            if (versionId == null)
 15180            {
 015181                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 15182            }
 115183            if (entityRoleUpdateObject == null)
 15184            {
 015185                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject");
 15186            }
 15187            // Tracing
 115188            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 115189            string _invocationId = null;
 115190            if (_shouldTrace)
 15191            {
 015192                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 015193                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 015194                tracingParameters.Add("appId", appId);
 015195                tracingParameters.Add("versionId", versionId);
 015196                tracingParameters.Add("entityId", entityId);
 015197                tracingParameters.Add("roleId", roleId);
 015198                tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject);
 015199                tracingParameters.Add("cancellationToken", cancellationToken);
 015200                ServiceClientTracing.Enter(_invocationId, this, "UpdatePrebuiltEntityRole", tracingParameters);
 15201            }
 15202            // Construct URL
 115203            var _baseUrl = Client.BaseUri;
 115204            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en
 115205            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 115206            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 115207            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 115208            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 115209            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 15210            // Create HTTP transport objects
 115211            var _httpRequest = new HttpRequestMessage();
 115212            HttpResponseMessage _httpResponse = null;
 115213            _httpRequest.Method = new HttpMethod("PUT");
 115214            _httpRequest.RequestUri = new System.Uri(_url);
 15215            // Set Headers
 15216
 15217
 115218            if (customHeaders != null)
 15219            {
 015220                foreach(var _header in customHeaders)
 15221                {
 015222                    if (_httpRequest.Headers.Contains(_header.Key))
 15223                    {
 015224                        _httpRequest.Headers.Remove(_header.Key);
 15225                    }
 015226                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 15227                }
 15228            }
 15229
 15230            // Serialize Request
 115231            string _requestContent = null;
 115232            if(entityRoleUpdateObject != null)
 15233            {
 115234                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri
 115235                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 115236                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 15237            }
 15238            // Set Credentials
 115239            if (Client.Credentials != null)
 15240            {
 115241                cancellationToken.ThrowIfCancellationRequested();
 115242                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 15243            }
 15244            // Send Request
 115245            if (_shouldTrace)
 15246            {
 015247                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 15248            }
 115249            cancellationToken.ThrowIfCancellationRequested();
 115250            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 115251            if (_shouldTrace)
 15252            {
 015253                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 15254            }
 115255            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 115256            cancellationToken.ThrowIfCancellationRequested();
 115257            string _responseContent = null;
 115258            if ((int)_statusCode != 200)
 15259            {
 015260                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 15261                try
 15262                {
 015263                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 015264                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 015265                    if (_errorBody != null)
 15266                    {
 015267                        ex.Body = _errorBody;
 15268                    }
 015269                }
 015270                catch (JsonException)
 15271                {
 15272                    // Ignore the exception
 015273                }
 015274                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 015275                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 015276                if (_shouldTrace)
 15277                {
 015278                    ServiceClientTracing.Error(_invocationId, ex);
 15279                }
 015280                _httpRequest.Dispose();
 015281                if (_httpResponse != null)
 15282                {
 015283                    _httpResponse.Dispose();
 15284                }
 015285                throw ex;
 15286            }
 15287            // Create Result
 115288            var _result = new HttpOperationResponse<OperationStatus>();
 115289            _result.Request = _httpRequest;
 115290            _result.Response = _httpResponse;
 15291            // Deserialize Response
 115292            if ((int)_statusCode == 200)
 15293            {
 115294                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 15295                try
 15296                {
 115297                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 115298                }
 015299                catch (JsonException ex)
 15300                {
 015301                    _httpRequest.Dispose();
 015302                    if (_httpResponse != null)
 15303                    {
 015304                        _httpResponse.Dispose();
 15305                    }
 015306                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 15307                }
 15308            }
 115309            if (_shouldTrace)
 15310            {
 015311                ServiceClientTracing.Exit(_invocationId, _result);
 15312            }
 115313            return _result;
 115314        }
 15315
 15316        /// <summary>
 15317        /// Delete a role in a prebuilt entity in a version of the application.
 15318        /// </summary>
 15319        /// <param name='appId'>
 15320        /// The application ID.
 15321        /// </param>
 15322        /// <param name='versionId'>
 15323        /// The version ID.
 15324        /// </param>
 15325        /// <param name='entityId'>
 15326        /// The entity ID.
 15327        /// </param>
 15328        /// <param name='roleId'>
 15329        /// The entity role Id.
 15330        /// </param>
 15331        /// <param name='customHeaders'>
 15332        /// Headers that will be added to request.
 15333        /// </param>
 15334        /// <param name='cancellationToken'>
 15335        /// The cancellation token.
 15336        /// </param>
 15337        /// <exception cref="ErrorResponseException">
 15338        /// Thrown when the operation returned an invalid status code
 15339        /// </exception>
 15340        /// <exception cref="SerializationException">
 15341        /// Thrown when unable to deserialize the response
 15342        /// </exception>
 15343        /// <exception cref="ValidationException">
 15344        /// Thrown when a required parameter is null
 15345        /// </exception>
 15346        /// <exception cref="System.ArgumentNullException">
 15347        /// Thrown when a required parameter is null
 15348        /// </exception>
 15349        /// <return>
 15350        /// A response object containing the response body and response headers.
 15351        /// </return>
 15352        public async Task<HttpOperationResponse<OperationStatus>> DeletePrebuiltEntityRoleWithHttpMessagesAsync(System.G
 15353        {
 115354            if (Client.Endpoint == null)
 15355            {
 015356                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 15357            }
 115358            if (versionId == null)
 15359            {
 015360                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 15361            }
 15362            // Tracing
 115363            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 115364            string _invocationId = null;
 115365            if (_shouldTrace)
 15366            {
 015367                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 015368                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 015369                tracingParameters.Add("appId", appId);
 015370                tracingParameters.Add("versionId", versionId);
 015371                tracingParameters.Add("entityId", entityId);
 015372                tracingParameters.Add("roleId", roleId);
 015373                tracingParameters.Add("cancellationToken", cancellationToken);
 015374                ServiceClientTracing.Enter(_invocationId, this, "DeletePrebuiltEntityRole", tracingParameters);
 15375            }
 15376            // Construct URL
 115377            var _baseUrl = Client.BaseUri;
 115378            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en
 115379            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 115380            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 115381            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 115382            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 115383            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 15384            // Create HTTP transport objects
 115385            var _httpRequest = new HttpRequestMessage();
 115386            HttpResponseMessage _httpResponse = null;
 115387            _httpRequest.Method = new HttpMethod("DELETE");
 115388            _httpRequest.RequestUri = new System.Uri(_url);
 15389            // Set Headers
 15390
 15391
 115392            if (customHeaders != null)
 15393            {
 015394                foreach(var _header in customHeaders)
 15395                {
 015396                    if (_httpRequest.Headers.Contains(_header.Key))
 15397                    {
 015398                        _httpRequest.Headers.Remove(_header.Key);
 15399                    }
 015400                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 15401                }
 15402            }
 15403
 15404            // Serialize Request
 115405            string _requestContent = null;
 15406            // Set Credentials
 115407            if (Client.Credentials != null)
 15408            {
 115409                cancellationToken.ThrowIfCancellationRequested();
 115410                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 15411            }
 15412            // Send Request
 115413            if (_shouldTrace)
 15414            {
 015415                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 15416            }
 115417            cancellationToken.ThrowIfCancellationRequested();
 115418            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 115419            if (_shouldTrace)
 15420            {
 015421                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 15422            }
 115423            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 115424            cancellationToken.ThrowIfCancellationRequested();
 115425            string _responseContent = null;
 115426            if ((int)_statusCode != 200)
 15427            {
 015428                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 15429                try
 15430                {
 015431                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 015432                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 015433                    if (_errorBody != null)
 15434                    {
 015435                        ex.Body = _errorBody;
 15436                    }
 015437                }
 015438                catch (JsonException)
 15439                {
 15440                    // Ignore the exception
 015441                }
 015442                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 015443                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 015444                if (_shouldTrace)
 15445                {
 015446                    ServiceClientTracing.Error(_invocationId, ex);
 15447                }
 015448                _httpRequest.Dispose();
 015449                if (_httpResponse != null)
 15450                {
 015451                    _httpResponse.Dispose();
 15452                }
 015453                throw ex;
 15454            }
 15455            // Create Result
 115456            var _result = new HttpOperationResponse<OperationStatus>();
 115457            _result.Request = _httpRequest;
 115458            _result.Response = _httpResponse;
 15459            // Deserialize Response
 115460            if ((int)_statusCode == 200)
 15461            {
 115462                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 15463                try
 15464                {
 115465                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 115466                }
 015467                catch (JsonException ex)
 15468                {
 015469                    _httpRequest.Dispose();
 015470                    if (_httpResponse != null)
 15471                    {
 015472                        _httpResponse.Dispose();
 15473                    }
 015474                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 15475                }
 15476            }
 115477            if (_shouldTrace)
 15478            {
 015479                ServiceClientTracing.Exit(_invocationId, _result);
 15480            }
 115481            return _result;
 115482        }
 15483
 15484        /// <summary>
 15485        /// Get one role for a given list entity in a version of the application.
 15486        /// </summary>
 15487        /// <param name='appId'>
 15488        /// The application ID.
 15489        /// </param>
 15490        /// <param name='versionId'>
 15491        /// The version ID.
 15492        /// </param>
 15493        /// <param name='entityId'>
 15494        /// entity ID.
 15495        /// </param>
 15496        /// <param name='roleId'>
 15497        /// entity role ID.
 15498        /// </param>
 15499        /// <param name='customHeaders'>
 15500        /// Headers that will be added to request.
 15501        /// </param>
 15502        /// <param name='cancellationToken'>
 15503        /// The cancellation token.
 15504        /// </param>
 15505        /// <exception cref="ErrorResponseException">
 15506        /// Thrown when the operation returned an invalid status code
 15507        /// </exception>
 15508        /// <exception cref="SerializationException">
 15509        /// Thrown when unable to deserialize the response
 15510        /// </exception>
 15511        /// <exception cref="ValidationException">
 15512        /// Thrown when a required parameter is null
 15513        /// </exception>
 15514        /// <exception cref="System.ArgumentNullException">
 15515        /// Thrown when a required parameter is null
 15516        /// </exception>
 15517        /// <return>
 15518        /// A response object containing the response body and response headers.
 15519        /// </return>
 15520        public async Task<HttpOperationResponse<EntityRole>> GetClosedListEntityRoleWithHttpMessagesAsync(System.Guid ap
 15521        {
 215522            if (Client.Endpoint == null)
 15523            {
 015524                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 15525            }
 215526            if (versionId == null)
 15527            {
 015528                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 15529            }
 15530            // Tracing
 215531            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 215532            string _invocationId = null;
 215533            if (_shouldTrace)
 15534            {
 015535                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 015536                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 015537                tracingParameters.Add("appId", appId);
 015538                tracingParameters.Add("versionId", versionId);
 015539                tracingParameters.Add("entityId", entityId);
 015540                tracingParameters.Add("roleId", roleId);
 015541                tracingParameters.Add("cancellationToken", cancellationToken);
 015542                ServiceClientTracing.Enter(_invocationId, this, "GetClosedListEntityRole", tracingParameters);
 15543            }
 15544            // Construct URL
 215545            var _baseUrl = Client.BaseUri;
 215546            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 215547            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 215548            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 215549            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 215550            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 215551            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 15552            // Create HTTP transport objects
 215553            var _httpRequest = new HttpRequestMessage();
 215554            HttpResponseMessage _httpResponse = null;
 215555            _httpRequest.Method = new HttpMethod("GET");
 215556            _httpRequest.RequestUri = new System.Uri(_url);
 15557            // Set Headers
 15558
 15559
 215560            if (customHeaders != null)
 15561            {
 015562                foreach(var _header in customHeaders)
 15563                {
 015564                    if (_httpRequest.Headers.Contains(_header.Key))
 15565                    {
 015566                        _httpRequest.Headers.Remove(_header.Key);
 15567                    }
 015568                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 15569                }
 15570            }
 15571
 15572            // Serialize Request
 215573            string _requestContent = null;
 15574            // Set Credentials
 215575            if (Client.Credentials != null)
 15576            {
 215577                cancellationToken.ThrowIfCancellationRequested();
 215578                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 15579            }
 15580            // Send Request
 215581            if (_shouldTrace)
 15582            {
 015583                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 15584            }
 215585            cancellationToken.ThrowIfCancellationRequested();
 215586            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 215587            if (_shouldTrace)
 15588            {
 015589                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 15590            }
 215591            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 215592            cancellationToken.ThrowIfCancellationRequested();
 215593            string _responseContent = null;
 215594            if ((int)_statusCode != 200)
 15595            {
 015596                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 15597                try
 15598                {
 015599                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 015600                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 015601                    if (_errorBody != null)
 15602                    {
 015603                        ex.Body = _errorBody;
 15604                    }
 015605                }
 015606                catch (JsonException)
 15607                {
 15608                    // Ignore the exception
 015609                }
 015610                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 015611                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 015612                if (_shouldTrace)
 15613                {
 015614                    ServiceClientTracing.Error(_invocationId, ex);
 15615                }
 015616                _httpRequest.Dispose();
 015617                if (_httpResponse != null)
 15618                {
 015619                    _httpResponse.Dispose();
 15620                }
 015621                throw ex;
 15622            }
 15623            // Create Result
 215624            var _result = new HttpOperationResponse<EntityRole>();
 215625            _result.Request = _httpRequest;
 215626            _result.Response = _httpResponse;
 15627            // Deserialize Response
 215628            if ((int)_statusCode == 200)
 15629            {
 215630                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 15631                try
 15632                {
 215633                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl
 215634                }
 015635                catch (JsonException ex)
 15636                {
 015637                    _httpRequest.Dispose();
 015638                    if (_httpResponse != null)
 15639                    {
 015640                        _httpResponse.Dispose();
 15641                    }
 015642                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 15643                }
 15644            }
 215645            if (_shouldTrace)
 15646            {
 015647                ServiceClientTracing.Exit(_invocationId, _result);
 15648            }
 215649            return _result;
 215650        }
 15651
 15652        /// <summary>
 15653        /// Update a role for a given list entity in a version of the application.
 15654        /// </summary>
 15655        /// <param name='appId'>
 15656        /// The application ID.
 15657        /// </param>
 15658        /// <param name='versionId'>
 15659        /// The version ID.
 15660        /// </param>
 15661        /// <param name='entityId'>
 15662        /// The entity ID.
 15663        /// </param>
 15664        /// <param name='roleId'>
 15665        /// The entity role ID.
 15666        /// </param>
 15667        /// <param name='entityRoleUpdateObject'>
 15668        /// The new entity role.
 15669        /// </param>
 15670        /// <param name='customHeaders'>
 15671        /// Headers that will be added to request.
 15672        /// </param>
 15673        /// <param name='cancellationToken'>
 15674        /// The cancellation token.
 15675        /// </param>
 15676        /// <exception cref="ErrorResponseException">
 15677        /// Thrown when the operation returned an invalid status code
 15678        /// </exception>
 15679        /// <exception cref="SerializationException">
 15680        /// Thrown when unable to deserialize the response
 15681        /// </exception>
 15682        /// <exception cref="ValidationException">
 15683        /// Thrown when a required parameter is null
 15684        /// </exception>
 15685        /// <exception cref="System.ArgumentNullException">
 15686        /// Thrown when a required parameter is null
 15687        /// </exception>
 15688        /// <return>
 15689        /// A response object containing the response body and response headers.
 15690        /// </return>
 15691        public async Task<HttpOperationResponse<OperationStatus>> UpdateClosedListEntityRoleWithHttpMessagesAsync(System
 15692        {
 115693            if (Client.Endpoint == null)
 15694            {
 015695                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 15696            }
 115697            if (versionId == null)
 15698            {
 015699                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 15700            }
 115701            if (entityRoleUpdateObject == null)
 15702            {
 015703                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject");
 15704            }
 15705            // Tracing
 115706            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 115707            string _invocationId = null;
 115708            if (_shouldTrace)
 15709            {
 015710                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 015711                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 015712                tracingParameters.Add("appId", appId);
 015713                tracingParameters.Add("versionId", versionId);
 015714                tracingParameters.Add("entityId", entityId);
 015715                tracingParameters.Add("roleId", roleId);
 015716                tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject);
 015717                tracingParameters.Add("cancellationToken", cancellationToken);
 015718                ServiceClientTracing.Enter(_invocationId, this, "UpdateClosedListEntityRole", tracingParameters);
 15719            }
 15720            // Construct URL
 115721            var _baseUrl = Client.BaseUri;
 115722            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 115723            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 115724            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 115725            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 115726            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 115727            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 15728            // Create HTTP transport objects
 115729            var _httpRequest = new HttpRequestMessage();
 115730            HttpResponseMessage _httpResponse = null;
 115731            _httpRequest.Method = new HttpMethod("PUT");
 115732            _httpRequest.RequestUri = new System.Uri(_url);
 15733            // Set Headers
 15734
 15735
 115736            if (customHeaders != null)
 15737            {
 015738                foreach(var _header in customHeaders)
 15739                {
 015740                    if (_httpRequest.Headers.Contains(_header.Key))
 15741                    {
 015742                        _httpRequest.Headers.Remove(_header.Key);
 15743                    }
 015744                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 15745                }
 15746            }
 15747
 15748            // Serialize Request
 115749            string _requestContent = null;
 115750            if(entityRoleUpdateObject != null)
 15751            {
 115752                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri
 115753                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 115754                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 15755            }
 15756            // Set Credentials
 115757            if (Client.Credentials != null)
 15758            {
 115759                cancellationToken.ThrowIfCancellationRequested();
 115760                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 15761            }
 15762            // Send Request
 115763            if (_shouldTrace)
 15764            {
 015765                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 15766            }
 115767            cancellationToken.ThrowIfCancellationRequested();
 115768            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 115769            if (_shouldTrace)
 15770            {
 015771                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 15772            }
 115773            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 115774            cancellationToken.ThrowIfCancellationRequested();
 115775            string _responseContent = null;
 115776            if ((int)_statusCode != 200)
 15777            {
 015778                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 15779                try
 15780                {
 015781                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 015782                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 015783                    if (_errorBody != null)
 15784                    {
 015785                        ex.Body = _errorBody;
 15786                    }
 015787                }
 015788                catch (JsonException)
 15789                {
 15790                    // Ignore the exception
 015791                }
 015792                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 015793                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 015794                if (_shouldTrace)
 15795                {
 015796                    ServiceClientTracing.Error(_invocationId, ex);
 15797                }
 015798                _httpRequest.Dispose();
 015799                if (_httpResponse != null)
 15800                {
 015801                    _httpResponse.Dispose();
 15802                }
 015803                throw ex;
 15804            }
 15805            // Create Result
 115806            var _result = new HttpOperationResponse<OperationStatus>();
 115807            _result.Request = _httpRequest;
 115808            _result.Response = _httpResponse;
 15809            // Deserialize Response
 115810            if ((int)_statusCode == 200)
 15811            {
 115812                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 15813                try
 15814                {
 115815                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 115816                }
 015817                catch (JsonException ex)
 15818                {
 015819                    _httpRequest.Dispose();
 015820                    if (_httpResponse != null)
 15821                    {
 015822                        _httpResponse.Dispose();
 15823                    }
 015824                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 15825                }
 15826            }
 115827            if (_shouldTrace)
 15828            {
 015829                ServiceClientTracing.Exit(_invocationId, _result);
 15830            }
 115831            return _result;
 115832        }
 15833
 15834        /// <summary>
 15835        /// Delete a role for a given list entity in a version of the application.
 15836        /// </summary>
 15837        /// <param name='appId'>
 15838        /// The application ID.
 15839        /// </param>
 15840        /// <param name='versionId'>
 15841        /// The version ID.
 15842        /// </param>
 15843        /// <param name='entityId'>
 15844        /// The entity ID.
 15845        /// </param>
 15846        /// <param name='roleId'>
 15847        /// The entity role Id.
 15848        /// </param>
 15849        /// <param name='customHeaders'>
 15850        /// Headers that will be added to request.
 15851        /// </param>
 15852        /// <param name='cancellationToken'>
 15853        /// The cancellation token.
 15854        /// </param>
 15855        /// <exception cref="ErrorResponseException">
 15856        /// Thrown when the operation returned an invalid status code
 15857        /// </exception>
 15858        /// <exception cref="SerializationException">
 15859        /// Thrown when unable to deserialize the response
 15860        /// </exception>
 15861        /// <exception cref="ValidationException">
 15862        /// Thrown when a required parameter is null
 15863        /// </exception>
 15864        /// <exception cref="System.ArgumentNullException">
 15865        /// Thrown when a required parameter is null
 15866        /// </exception>
 15867        /// <return>
 15868        /// A response object containing the response body and response headers.
 15869        /// </return>
 15870        public async Task<HttpOperationResponse<OperationStatus>> DeleteClosedListEntityRoleWithHttpMessagesAsync(System
 15871        {
 115872            if (Client.Endpoint == null)
 15873            {
 015874                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 15875            }
 115876            if (versionId == null)
 15877            {
 015878                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 15879            }
 15880            // Tracing
 115881            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 115882            string _invocationId = null;
 115883            if (_shouldTrace)
 15884            {
 015885                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 015886                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 015887                tracingParameters.Add("appId", appId);
 015888                tracingParameters.Add("versionId", versionId);
 015889                tracingParameters.Add("entityId", entityId);
 015890                tracingParameters.Add("roleId", roleId);
 015891                tracingParameters.Add("cancellationToken", cancellationToken);
 015892                ServiceClientTracing.Enter(_invocationId, this, "DeleteClosedListEntityRole", tracingParameters);
 15893            }
 15894            // Construct URL
 115895            var _baseUrl = Client.BaseUri;
 115896            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{
 115897            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 115898            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 115899            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 115900            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 115901            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 15902            // Create HTTP transport objects
 115903            var _httpRequest = new HttpRequestMessage();
 115904            HttpResponseMessage _httpResponse = null;
 115905            _httpRequest.Method = new HttpMethod("DELETE");
 115906            _httpRequest.RequestUri = new System.Uri(_url);
 15907            // Set Headers
 15908
 15909
 115910            if (customHeaders != null)
 15911            {
 015912                foreach(var _header in customHeaders)
 15913                {
 015914                    if (_httpRequest.Headers.Contains(_header.Key))
 15915                    {
 015916                        _httpRequest.Headers.Remove(_header.Key);
 15917                    }
 015918                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 15919                }
 15920            }
 15921
 15922            // Serialize Request
 115923            string _requestContent = null;
 15924            // Set Credentials
 115925            if (Client.Credentials != null)
 15926            {
 115927                cancellationToken.ThrowIfCancellationRequested();
 115928                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 15929            }
 15930            // Send Request
 115931            if (_shouldTrace)
 15932            {
 015933                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 15934            }
 115935            cancellationToken.ThrowIfCancellationRequested();
 115936            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 115937            if (_shouldTrace)
 15938            {
 015939                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 15940            }
 115941            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 115942            cancellationToken.ThrowIfCancellationRequested();
 115943            string _responseContent = null;
 115944            if ((int)_statusCode != 200)
 15945            {
 015946                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 15947                try
 15948                {
 015949                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 015950                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 015951                    if (_errorBody != null)
 15952                    {
 015953                        ex.Body = _errorBody;
 15954                    }
 015955                }
 015956                catch (JsonException)
 15957                {
 15958                    // Ignore the exception
 015959                }
 015960                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 015961                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 015962                if (_shouldTrace)
 15963                {
 015964                    ServiceClientTracing.Error(_invocationId, ex);
 15965                }
 015966                _httpRequest.Dispose();
 015967                if (_httpResponse != null)
 15968                {
 015969                    _httpResponse.Dispose();
 15970                }
 015971                throw ex;
 15972            }
 15973            // Create Result
 115974            var _result = new HttpOperationResponse<OperationStatus>();
 115975            _result.Request = _httpRequest;
 115976            _result.Response = _httpResponse;
 15977            // Deserialize Response
 115978            if ((int)_statusCode == 200)
 15979            {
 115980                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 15981                try
 15982                {
 115983                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 115984                }
 015985                catch (JsonException ex)
 15986                {
 015987                    _httpRequest.Dispose();
 015988                    if (_httpResponse != null)
 15989                    {
 015990                        _httpResponse.Dispose();
 15991                    }
 015992                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 15993                }
 15994            }
 115995            if (_shouldTrace)
 15996            {
 015997                ServiceClientTracing.Exit(_invocationId, _result);
 15998            }
 115999            return _result;
 116000        }
 16001
 16002        /// <summary>
 16003        /// Get one role for a given regular expression entity in a version of the
 16004        /// application.
 16005        /// </summary>
 16006        /// <param name='appId'>
 16007        /// The application ID.
 16008        /// </param>
 16009        /// <param name='versionId'>
 16010        /// The version ID.
 16011        /// </param>
 16012        /// <param name='entityId'>
 16013        /// entity ID.
 16014        /// </param>
 16015        /// <param name='roleId'>
 16016        /// entity role ID.
 16017        /// </param>
 16018        /// <param name='customHeaders'>
 16019        /// Headers that will be added to request.
 16020        /// </param>
 16021        /// <param name='cancellationToken'>
 16022        /// The cancellation token.
 16023        /// </param>
 16024        /// <exception cref="ErrorResponseException">
 16025        /// Thrown when the operation returned an invalid status code
 16026        /// </exception>
 16027        /// <exception cref="SerializationException">
 16028        /// Thrown when unable to deserialize the response
 16029        /// </exception>
 16030        /// <exception cref="ValidationException">
 16031        /// Thrown when a required parameter is null
 16032        /// </exception>
 16033        /// <exception cref="System.ArgumentNullException">
 16034        /// Thrown when a required parameter is null
 16035        /// </exception>
 16036        /// <return>
 16037        /// A response object containing the response body and response headers.
 16038        /// </return>
 16039        public async Task<HttpOperationResponse<EntityRole>> GetRegexEntityRoleWithHttpMessagesAsync(System.Guid appId, 
 16040        {
 216041            if (Client.Endpoint == null)
 16042            {
 016043                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 16044            }
 216045            if (versionId == null)
 16046            {
 016047                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 16048            }
 16049            // Tracing
 216050            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 216051            string _invocationId = null;
 216052            if (_shouldTrace)
 16053            {
 016054                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 016055                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 016056                tracingParameters.Add("appId", appId);
 016057                tracingParameters.Add("versionId", versionId);
 016058                tracingParameters.Add("entityId", entityId);
 016059                tracingParameters.Add("roleId", roleId);
 016060                tracingParameters.Add("cancellationToken", cancellationToken);
 016061                ServiceClientTracing.Enter(_invocationId, this, "GetRegexEntityRole", tracingParameters);
 16062            }
 16063            // Construct URL
 216064            var _baseUrl = Client.BaseUri;
 216065            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 216066            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 216067            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 216068            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 216069            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 216070            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 16071            // Create HTTP transport objects
 216072            var _httpRequest = new HttpRequestMessage();
 216073            HttpResponseMessage _httpResponse = null;
 216074            _httpRequest.Method = new HttpMethod("GET");
 216075            _httpRequest.RequestUri = new System.Uri(_url);
 16076            // Set Headers
 16077
 16078
 216079            if (customHeaders != null)
 16080            {
 016081                foreach(var _header in customHeaders)
 16082                {
 016083                    if (_httpRequest.Headers.Contains(_header.Key))
 16084                    {
 016085                        _httpRequest.Headers.Remove(_header.Key);
 16086                    }
 016087                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 16088                }
 16089            }
 16090
 16091            // Serialize Request
 216092            string _requestContent = null;
 16093            // Set Credentials
 216094            if (Client.Credentials != null)
 16095            {
 216096                cancellationToken.ThrowIfCancellationRequested();
 216097                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 16098            }
 16099            // Send Request
 216100            if (_shouldTrace)
 16101            {
 016102                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 16103            }
 216104            cancellationToken.ThrowIfCancellationRequested();
 216105            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 216106            if (_shouldTrace)
 16107            {
 016108                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 16109            }
 216110            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 216111            cancellationToken.ThrowIfCancellationRequested();
 216112            string _responseContent = null;
 216113            if ((int)_statusCode != 200)
 16114            {
 016115                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 16116                try
 16117                {
 016118                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 016119                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 016120                    if (_errorBody != null)
 16121                    {
 016122                        ex.Body = _errorBody;
 16123                    }
 016124                }
 016125                catch (JsonException)
 16126                {
 16127                    // Ignore the exception
 016128                }
 016129                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 016130                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 016131                if (_shouldTrace)
 16132                {
 016133                    ServiceClientTracing.Error(_invocationId, ex);
 16134                }
 016135                _httpRequest.Dispose();
 016136                if (_httpResponse != null)
 16137                {
 016138                    _httpResponse.Dispose();
 16139                }
 016140                throw ex;
 16141            }
 16142            // Create Result
 216143            var _result = new HttpOperationResponse<EntityRole>();
 216144            _result.Request = _httpRequest;
 216145            _result.Response = _httpResponse;
 16146            // Deserialize Response
 216147            if ((int)_statusCode == 200)
 16148            {
 216149                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 16150                try
 16151                {
 216152                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl
 216153                }
 016154                catch (JsonException ex)
 16155                {
 016156                    _httpRequest.Dispose();
 016157                    if (_httpResponse != null)
 16158                    {
 016159                        _httpResponse.Dispose();
 16160                    }
 016161                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 16162                }
 16163            }
 216164            if (_shouldTrace)
 16165            {
 016166                ServiceClientTracing.Exit(_invocationId, _result);
 16167            }
 216168            return _result;
 216169        }
 16170
 16171        /// <summary>
 16172        /// Update a role for a given regular expression entity in a version of the
 16173        /// application
 16174        /// </summary>
 16175        /// <param name='appId'>
 16176        /// The application ID.
 16177        /// </param>
 16178        /// <param name='versionId'>
 16179        /// The version ID.
 16180        /// </param>
 16181        /// <param name='entityId'>
 16182        /// The entity ID.
 16183        /// </param>
 16184        /// <param name='roleId'>
 16185        /// The entity role ID.
 16186        /// </param>
 16187        /// <param name='entityRoleUpdateObject'>
 16188        /// The new entity role.
 16189        /// </param>
 16190        /// <param name='customHeaders'>
 16191        /// Headers that will be added to request.
 16192        /// </param>
 16193        /// <param name='cancellationToken'>
 16194        /// The cancellation token.
 16195        /// </param>
 16196        /// <exception cref="ErrorResponseException">
 16197        /// Thrown when the operation returned an invalid status code
 16198        /// </exception>
 16199        /// <exception cref="SerializationException">
 16200        /// Thrown when unable to deserialize the response
 16201        /// </exception>
 16202        /// <exception cref="ValidationException">
 16203        /// Thrown when a required parameter is null
 16204        /// </exception>
 16205        /// <exception cref="System.ArgumentNullException">
 16206        /// Thrown when a required parameter is null
 16207        /// </exception>
 16208        /// <return>
 16209        /// A response object containing the response body and response headers.
 16210        /// </return>
 16211        public async Task<HttpOperationResponse<OperationStatus>> UpdateRegexEntityRoleWithHttpMessagesAsync(System.Guid
 16212        {
 116213            if (Client.Endpoint == null)
 16214            {
 016215                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 16216            }
 116217            if (versionId == null)
 16218            {
 016219                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 16220            }
 116221            if (entityRoleUpdateObject == null)
 16222            {
 016223                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject");
 16224            }
 16225            // Tracing
 116226            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 116227            string _invocationId = null;
 116228            if (_shouldTrace)
 16229            {
 016230                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 016231                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 016232                tracingParameters.Add("appId", appId);
 016233                tracingParameters.Add("versionId", versionId);
 016234                tracingParameters.Add("entityId", entityId);
 016235                tracingParameters.Add("roleId", roleId);
 016236                tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject);
 016237                tracingParameters.Add("cancellationToken", cancellationToken);
 016238                ServiceClientTracing.Enter(_invocationId, this, "UpdateRegexEntityRole", tracingParameters);
 16239            }
 16240            // Construct URL
 116241            var _baseUrl = Client.BaseUri;
 116242            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 116243            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 116244            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 116245            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 116246            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 116247            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 16248            // Create HTTP transport objects
 116249            var _httpRequest = new HttpRequestMessage();
 116250            HttpResponseMessage _httpResponse = null;
 116251            _httpRequest.Method = new HttpMethod("PUT");
 116252            _httpRequest.RequestUri = new System.Uri(_url);
 16253            // Set Headers
 16254
 16255
 116256            if (customHeaders != null)
 16257            {
 016258                foreach(var _header in customHeaders)
 16259                {
 016260                    if (_httpRequest.Headers.Contains(_header.Key))
 16261                    {
 016262                        _httpRequest.Headers.Remove(_header.Key);
 16263                    }
 016264                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 16265                }
 16266            }
 16267
 16268            // Serialize Request
 116269            string _requestContent = null;
 116270            if(entityRoleUpdateObject != null)
 16271            {
 116272                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri
 116273                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 116274                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 16275            }
 16276            // Set Credentials
 116277            if (Client.Credentials != null)
 16278            {
 116279                cancellationToken.ThrowIfCancellationRequested();
 116280                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 16281            }
 16282            // Send Request
 116283            if (_shouldTrace)
 16284            {
 016285                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 16286            }
 116287            cancellationToken.ThrowIfCancellationRequested();
 116288            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 116289            if (_shouldTrace)
 16290            {
 016291                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 16292            }
 116293            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 116294            cancellationToken.ThrowIfCancellationRequested();
 116295            string _responseContent = null;
 116296            if ((int)_statusCode != 200)
 16297            {
 016298                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 16299                try
 16300                {
 016301                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 016302                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 016303                    if (_errorBody != null)
 16304                    {
 016305                        ex.Body = _errorBody;
 16306                    }
 016307                }
 016308                catch (JsonException)
 16309                {
 16310                    // Ignore the exception
 016311                }
 016312                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 016313                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 016314                if (_shouldTrace)
 16315                {
 016316                    ServiceClientTracing.Error(_invocationId, ex);
 16317                }
 016318                _httpRequest.Dispose();
 016319                if (_httpResponse != null)
 16320                {
 016321                    _httpResponse.Dispose();
 16322                }
 016323                throw ex;
 16324            }
 16325            // Create Result
 116326            var _result = new HttpOperationResponse<OperationStatus>();
 116327            _result.Request = _httpRequest;
 116328            _result.Response = _httpResponse;
 16329            // Deserialize Response
 116330            if ((int)_statusCode == 200)
 16331            {
 116332                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 16333                try
 16334                {
 116335                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 116336                }
 016337                catch (JsonException ex)
 16338                {
 016339                    _httpRequest.Dispose();
 016340                    if (_httpResponse != null)
 16341                    {
 016342                        _httpResponse.Dispose();
 16343                    }
 016344                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 16345                }
 16346            }
 116347            if (_shouldTrace)
 16348            {
 016349                ServiceClientTracing.Exit(_invocationId, _result);
 16350            }
 116351            return _result;
 116352        }
 16353
 16354        /// <summary>
 16355        /// Delete a role for a given regular expression in a version of the
 16356        /// application.
 16357        /// </summary>
 16358        /// <param name='appId'>
 16359        /// The application ID.
 16360        /// </param>
 16361        /// <param name='versionId'>
 16362        /// The version ID.
 16363        /// </param>
 16364        /// <param name='entityId'>
 16365        /// The entity ID.
 16366        /// </param>
 16367        /// <param name='roleId'>
 16368        /// The entity role Id.
 16369        /// </param>
 16370        /// <param name='customHeaders'>
 16371        /// Headers that will be added to request.
 16372        /// </param>
 16373        /// <param name='cancellationToken'>
 16374        /// The cancellation token.
 16375        /// </param>
 16376        /// <exception cref="ErrorResponseException">
 16377        /// Thrown when the operation returned an invalid status code
 16378        /// </exception>
 16379        /// <exception cref="SerializationException">
 16380        /// Thrown when unable to deserialize the response
 16381        /// </exception>
 16382        /// <exception cref="ValidationException">
 16383        /// Thrown when a required parameter is null
 16384        /// </exception>
 16385        /// <exception cref="System.ArgumentNullException">
 16386        /// Thrown when a required parameter is null
 16387        /// </exception>
 16388        /// <return>
 16389        /// A response object containing the response body and response headers.
 16390        /// </return>
 16391        public async Task<HttpOperationResponse<OperationStatus>> DeleteRegexEntityRoleWithHttpMessagesAsync(System.Guid
 16392        {
 116393            if (Client.Endpoint == null)
 16394            {
 016395                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 16396            }
 116397            if (versionId == null)
 16398            {
 016399                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 16400            }
 16401            // Tracing
 116402            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 116403            string _invocationId = null;
 116404            if (_shouldTrace)
 16405            {
 016406                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 016407                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 016408                tracingParameters.Add("appId", appId);
 016409                tracingParameters.Add("versionId", versionId);
 016410                tracingParameters.Add("entityId", entityId);
 016411                tracingParameters.Add("roleId", roleId);
 016412                tracingParameters.Add("cancellationToken", cancellationToken);
 016413                ServiceClientTracing.Enter(_invocationId, this, "DeleteRegexEntityRole", tracingParameters);
 16414            }
 16415            // Construct URL
 116416            var _baseUrl = Client.BaseUri;
 116417            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities
 116418            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 116419            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 116420            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 116421            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 116422            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 16423            // Create HTTP transport objects
 116424            var _httpRequest = new HttpRequestMessage();
 116425            HttpResponseMessage _httpResponse = null;
 116426            _httpRequest.Method = new HttpMethod("DELETE");
 116427            _httpRequest.RequestUri = new System.Uri(_url);
 16428            // Set Headers
 16429
 16430
 116431            if (customHeaders != null)
 16432            {
 016433                foreach(var _header in customHeaders)
 16434                {
 016435                    if (_httpRequest.Headers.Contains(_header.Key))
 16436                    {
 016437                        _httpRequest.Headers.Remove(_header.Key);
 16438                    }
 016439                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 16440                }
 16441            }
 16442
 16443            // Serialize Request
 116444            string _requestContent = null;
 16445            // Set Credentials
 116446            if (Client.Credentials != null)
 16447            {
 116448                cancellationToken.ThrowIfCancellationRequested();
 116449                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 16450            }
 16451            // Send Request
 116452            if (_shouldTrace)
 16453            {
 016454                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 16455            }
 116456            cancellationToken.ThrowIfCancellationRequested();
 116457            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 116458            if (_shouldTrace)
 16459            {
 016460                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 16461            }
 116462            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 116463            cancellationToken.ThrowIfCancellationRequested();
 116464            string _responseContent = null;
 116465            if ((int)_statusCode != 200)
 16466            {
 016467                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 16468                try
 16469                {
 016470                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 016471                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 016472                    if (_errorBody != null)
 16473                    {
 016474                        ex.Body = _errorBody;
 16475                    }
 016476                }
 016477                catch (JsonException)
 16478                {
 16479                    // Ignore the exception
 016480                }
 016481                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 016482                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 016483                if (_shouldTrace)
 16484                {
 016485                    ServiceClientTracing.Error(_invocationId, ex);
 16486                }
 016487                _httpRequest.Dispose();
 016488                if (_httpResponse != null)
 16489                {
 016490                    _httpResponse.Dispose();
 16491                }
 016492                throw ex;
 16493            }
 16494            // Create Result
 116495            var _result = new HttpOperationResponse<OperationStatus>();
 116496            _result.Request = _httpRequest;
 116497            _result.Response = _httpResponse;
 16498            // Deserialize Response
 116499            if ((int)_statusCode == 200)
 16500            {
 116501                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 16502                try
 16503                {
 116504                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 116505                }
 016506                catch (JsonException ex)
 16507                {
 016508                    _httpRequest.Dispose();
 016509                    if (_httpResponse != null)
 16510                    {
 016511                        _httpResponse.Dispose();
 16512                    }
 016513                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 16514                }
 16515            }
 116516            if (_shouldTrace)
 16517            {
 016518                ServiceClientTracing.Exit(_invocationId, _result);
 16519            }
 116520            return _result;
 116521        }
 16522
 16523        /// <summary>
 16524        /// Get one role for a given composite entity in a version of the application
 16525        /// </summary>
 16526        /// <param name='appId'>
 16527        /// The application ID.
 16528        /// </param>
 16529        /// <param name='versionId'>
 16530        /// The version ID.
 16531        /// </param>
 16532        /// <param name='cEntityId'>
 16533        /// The composite entity extractor ID.
 16534        /// </param>
 16535        /// <param name='roleId'>
 16536        /// entity role ID.
 16537        /// </param>
 16538        /// <param name='customHeaders'>
 16539        /// Headers that will be added to request.
 16540        /// </param>
 16541        /// <param name='cancellationToken'>
 16542        /// The cancellation token.
 16543        /// </param>
 16544        /// <exception cref="ErrorResponseException">
 16545        /// Thrown when the operation returned an invalid status code
 16546        /// </exception>
 16547        /// <exception cref="SerializationException">
 16548        /// Thrown when unable to deserialize the response
 16549        /// </exception>
 16550        /// <exception cref="ValidationException">
 16551        /// Thrown when a required parameter is null
 16552        /// </exception>
 16553        /// <exception cref="System.ArgumentNullException">
 16554        /// Thrown when a required parameter is null
 16555        /// </exception>
 16556        /// <return>
 16557        /// A response object containing the response body and response headers.
 16558        /// </return>
 16559        public async Task<HttpOperationResponse<EntityRole>> GetCompositeEntityRoleWithHttpMessagesAsync(System.Guid app
 16560        {
 016561            if (Client.Endpoint == null)
 16562            {
 016563                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 16564            }
 016565            if (versionId == null)
 16566            {
 016567                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 16568            }
 16569            // Tracing
 016570            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 016571            string _invocationId = null;
 016572            if (_shouldTrace)
 16573            {
 016574                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 016575                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 016576                tracingParameters.Add("appId", appId);
 016577                tracingParameters.Add("versionId", versionId);
 016578                tracingParameters.Add("cEntityId", cEntityId);
 016579                tracingParameters.Add("roleId", roleId);
 016580                tracingParameters.Add("cancellationToken", cancellationToken);
 016581                ServiceClientTracing.Enter(_invocationId, this, "GetCompositeEntityRole", tracingParameters);
 16582            }
 16583            // Construct URL
 016584            var _baseUrl = Client.BaseUri;
 016585            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 016586            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 016587            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 016588            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 016589            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 016590            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 16591            // Create HTTP transport objects
 016592            var _httpRequest = new HttpRequestMessage();
 016593            HttpResponseMessage _httpResponse = null;
 016594            _httpRequest.Method = new HttpMethod("GET");
 016595            _httpRequest.RequestUri = new System.Uri(_url);
 16596            // Set Headers
 16597
 16598
 016599            if (customHeaders != null)
 16600            {
 016601                foreach(var _header in customHeaders)
 16602                {
 016603                    if (_httpRequest.Headers.Contains(_header.Key))
 16604                    {
 016605                        _httpRequest.Headers.Remove(_header.Key);
 16606                    }
 016607                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 16608                }
 16609            }
 16610
 16611            // Serialize Request
 016612            string _requestContent = null;
 16613            // Set Credentials
 016614            if (Client.Credentials != null)
 16615            {
 016616                cancellationToken.ThrowIfCancellationRequested();
 016617                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 16618            }
 16619            // Send Request
 016620            if (_shouldTrace)
 16621            {
 016622                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 16623            }
 016624            cancellationToken.ThrowIfCancellationRequested();
 016625            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 016626            if (_shouldTrace)
 16627            {
 016628                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 16629            }
 016630            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 016631            cancellationToken.ThrowIfCancellationRequested();
 016632            string _responseContent = null;
 016633            if ((int)_statusCode != 200)
 16634            {
 016635                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 16636                try
 16637                {
 016638                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 016639                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 016640                    if (_errorBody != null)
 16641                    {
 016642                        ex.Body = _errorBody;
 16643                    }
 016644                }
 016645                catch (JsonException)
 16646                {
 16647                    // Ignore the exception
 016648                }
 016649                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 016650                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 016651                if (_shouldTrace)
 16652                {
 016653                    ServiceClientTracing.Error(_invocationId, ex);
 16654                }
 016655                _httpRequest.Dispose();
 016656                if (_httpResponse != null)
 16657                {
 016658                    _httpResponse.Dispose();
 16659                }
 016660                throw ex;
 16661            }
 16662            // Create Result
 016663            var _result = new HttpOperationResponse<EntityRole>();
 016664            _result.Request = _httpRequest;
 016665            _result.Response = _httpResponse;
 16666            // Deserialize Response
 016667            if ((int)_statusCode == 200)
 16668            {
 016669                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 16670                try
 16671                {
 016672                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl
 016673                }
 016674                catch (JsonException ex)
 16675                {
 016676                    _httpRequest.Dispose();
 016677                    if (_httpResponse != null)
 16678                    {
 016679                        _httpResponse.Dispose();
 16680                    }
 016681                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 16682                }
 16683            }
 016684            if (_shouldTrace)
 16685            {
 016686                ServiceClientTracing.Exit(_invocationId, _result);
 16687            }
 016688            return _result;
 016689        }
 16690
 16691        /// <summary>
 16692        /// Update a role for a given composite entity in a version of the application
 16693        /// </summary>
 16694        /// <param name='appId'>
 16695        /// The application ID.
 16696        /// </param>
 16697        /// <param name='versionId'>
 16698        /// The version ID.
 16699        /// </param>
 16700        /// <param name='cEntityId'>
 16701        /// The composite entity extractor ID.
 16702        /// </param>
 16703        /// <param name='roleId'>
 16704        /// The entity role ID.
 16705        /// </param>
 16706        /// <param name='entityRoleUpdateObject'>
 16707        /// The new entity role.
 16708        /// </param>
 16709        /// <param name='customHeaders'>
 16710        /// Headers that will be added to request.
 16711        /// </param>
 16712        /// <param name='cancellationToken'>
 16713        /// The cancellation token.
 16714        /// </param>
 16715        /// <exception cref="ErrorResponseException">
 16716        /// Thrown when the operation returned an invalid status code
 16717        /// </exception>
 16718        /// <exception cref="SerializationException">
 16719        /// Thrown when unable to deserialize the response
 16720        /// </exception>
 16721        /// <exception cref="ValidationException">
 16722        /// Thrown when a required parameter is null
 16723        /// </exception>
 16724        /// <exception cref="System.ArgumentNullException">
 16725        /// Thrown when a required parameter is null
 16726        /// </exception>
 16727        /// <return>
 16728        /// A response object containing the response body and response headers.
 16729        /// </return>
 16730        public async Task<HttpOperationResponse<OperationStatus>> UpdateCompositeEntityRoleWithHttpMessagesAsync(System.
 16731        {
 016732            if (Client.Endpoint == null)
 16733            {
 016734                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 16735            }
 016736            if (versionId == null)
 16737            {
 016738                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 16739            }
 016740            if (entityRoleUpdateObject == null)
 16741            {
 016742                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject");
 16743            }
 16744            // Tracing
 016745            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 016746            string _invocationId = null;
 016747            if (_shouldTrace)
 16748            {
 016749                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 016750                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 016751                tracingParameters.Add("appId", appId);
 016752                tracingParameters.Add("versionId", versionId);
 016753                tracingParameters.Add("cEntityId", cEntityId);
 016754                tracingParameters.Add("roleId", roleId);
 016755                tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject);
 016756                tracingParameters.Add("cancellationToken", cancellationToken);
 016757                ServiceClientTracing.Enter(_invocationId, this, "UpdateCompositeEntityRole", tracingParameters);
 16758            }
 16759            // Construct URL
 016760            var _baseUrl = Client.BaseUri;
 016761            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 016762            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 016763            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 016764            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 016765            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 016766            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 16767            // Create HTTP transport objects
 016768            var _httpRequest = new HttpRequestMessage();
 016769            HttpResponseMessage _httpResponse = null;
 016770            _httpRequest.Method = new HttpMethod("PUT");
 016771            _httpRequest.RequestUri = new System.Uri(_url);
 16772            // Set Headers
 16773
 16774
 016775            if (customHeaders != null)
 16776            {
 016777                foreach(var _header in customHeaders)
 16778                {
 016779                    if (_httpRequest.Headers.Contains(_header.Key))
 16780                    {
 016781                        _httpRequest.Headers.Remove(_header.Key);
 16782                    }
 016783                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 16784                }
 16785            }
 16786
 16787            // Serialize Request
 016788            string _requestContent = null;
 016789            if(entityRoleUpdateObject != null)
 16790            {
 016791                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri
 016792                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 016793                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 16794            }
 16795            // Set Credentials
 016796            if (Client.Credentials != null)
 16797            {
 016798                cancellationToken.ThrowIfCancellationRequested();
 016799                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 16800            }
 16801            // Send Request
 016802            if (_shouldTrace)
 16803            {
 016804                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 16805            }
 016806            cancellationToken.ThrowIfCancellationRequested();
 016807            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 016808            if (_shouldTrace)
 16809            {
 016810                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 16811            }
 016812            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 016813            cancellationToken.ThrowIfCancellationRequested();
 016814            string _responseContent = null;
 016815            if ((int)_statusCode != 200)
 16816            {
 016817                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 16818                try
 16819                {
 016820                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 016821                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 016822                    if (_errorBody != null)
 16823                    {
 016824                        ex.Body = _errorBody;
 16825                    }
 016826                }
 016827                catch (JsonException)
 16828                {
 16829                    // Ignore the exception
 016830                }
 016831                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 016832                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 016833                if (_shouldTrace)
 16834                {
 016835                    ServiceClientTracing.Error(_invocationId, ex);
 16836                }
 016837                _httpRequest.Dispose();
 016838                if (_httpResponse != null)
 16839                {
 016840                    _httpResponse.Dispose();
 16841                }
 016842                throw ex;
 16843            }
 16844            // Create Result
 016845            var _result = new HttpOperationResponse<OperationStatus>();
 016846            _result.Request = _httpRequest;
 016847            _result.Response = _httpResponse;
 16848            // Deserialize Response
 016849            if ((int)_statusCode == 200)
 16850            {
 016851                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 16852                try
 16853                {
 016854                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 016855                }
 016856                catch (JsonException ex)
 16857                {
 016858                    _httpRequest.Dispose();
 016859                    if (_httpResponse != null)
 16860                    {
 016861                        _httpResponse.Dispose();
 16862                    }
 016863                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 16864                }
 16865            }
 016866            if (_shouldTrace)
 16867            {
 016868                ServiceClientTracing.Exit(_invocationId, _result);
 16869            }
 016870            return _result;
 016871        }
 16872
 16873        /// <summary>
 16874        /// Delete a role for a given composite entity in a version of the application.
 16875        /// </summary>
 16876        /// <param name='appId'>
 16877        /// The application ID.
 16878        /// </param>
 16879        /// <param name='versionId'>
 16880        /// The version ID.
 16881        /// </param>
 16882        /// <param name='cEntityId'>
 16883        /// The composite entity extractor ID.
 16884        /// </param>
 16885        /// <param name='roleId'>
 16886        /// The entity role Id.
 16887        /// </param>
 16888        /// <param name='customHeaders'>
 16889        /// Headers that will be added to request.
 16890        /// </param>
 16891        /// <param name='cancellationToken'>
 16892        /// The cancellation token.
 16893        /// </param>
 16894        /// <exception cref="ErrorResponseException">
 16895        /// Thrown when the operation returned an invalid status code
 16896        /// </exception>
 16897        /// <exception cref="SerializationException">
 16898        /// Thrown when unable to deserialize the response
 16899        /// </exception>
 16900        /// <exception cref="ValidationException">
 16901        /// Thrown when a required parameter is null
 16902        /// </exception>
 16903        /// <exception cref="System.ArgumentNullException">
 16904        /// Thrown when a required parameter is null
 16905        /// </exception>
 16906        /// <return>
 16907        /// A response object containing the response body and response headers.
 16908        /// </return>
 16909        public async Task<HttpOperationResponse<OperationStatus>> DeleteCompositeEntityRoleWithHttpMessagesAsync(System.
 16910        {
 016911            if (Client.Endpoint == null)
 16912            {
 016913                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 16914            }
 016915            if (versionId == null)
 16916            {
 016917                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 16918            }
 16919            // Tracing
 016920            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 016921            string _invocationId = null;
 016922            if (_shouldTrace)
 16923            {
 016924                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 016925                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 016926                tracingParameters.Add("appId", appId);
 016927                tracingParameters.Add("versionId", versionId);
 016928                tracingParameters.Add("cEntityId", cEntityId);
 016929                tracingParameters.Add("roleId", roleId);
 016930                tracingParameters.Add("cancellationToken", cancellationToken);
 016931                ServiceClientTracing.Enter(_invocationId, this, "DeleteCompositeEntityRole", tracingParameters);
 16932            }
 16933            // Construct URL
 016934            var _baseUrl = Client.BaseUri;
 016935            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti
 016936            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 016937            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 016938            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 016939            _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 016940            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 16941            // Create HTTP transport objects
 016942            var _httpRequest = new HttpRequestMessage();
 016943            HttpResponseMessage _httpResponse = null;
 016944            _httpRequest.Method = new HttpMethod("DELETE");
 016945            _httpRequest.RequestUri = new System.Uri(_url);
 16946            // Set Headers
 16947
 16948
 016949            if (customHeaders != null)
 16950            {
 016951                foreach(var _header in customHeaders)
 16952                {
 016953                    if (_httpRequest.Headers.Contains(_header.Key))
 16954                    {
 016955                        _httpRequest.Headers.Remove(_header.Key);
 16956                    }
 016957                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 16958                }
 16959            }
 16960
 16961            // Serialize Request
 016962            string _requestContent = null;
 16963            // Set Credentials
 016964            if (Client.Credentials != null)
 16965            {
 016966                cancellationToken.ThrowIfCancellationRequested();
 016967                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 16968            }
 16969            // Send Request
 016970            if (_shouldTrace)
 16971            {
 016972                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 16973            }
 016974            cancellationToken.ThrowIfCancellationRequested();
 016975            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 016976            if (_shouldTrace)
 16977            {
 016978                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 16979            }
 016980            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 016981            cancellationToken.ThrowIfCancellationRequested();
 016982            string _responseContent = null;
 016983            if ((int)_statusCode != 200)
 16984            {
 016985                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 16986                try
 16987                {
 016988                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 016989                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 016990                    if (_errorBody != null)
 16991                    {
 016992                        ex.Body = _errorBody;
 16993                    }
 016994                }
 016995                catch (JsonException)
 16996                {
 16997                    // Ignore the exception
 016998                }
 016999                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 017000                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 017001                if (_shouldTrace)
 17002                {
 017003                    ServiceClientTracing.Error(_invocationId, ex);
 17004                }
 017005                _httpRequest.Dispose();
 017006                if (_httpResponse != null)
 17007                {
 017008                    _httpResponse.Dispose();
 17009                }
 017010                throw ex;
 17011            }
 17012            // Create Result
 017013            var _result = new HttpOperationResponse<OperationStatus>();
 017014            _result.Request = _httpRequest;
 017015            _result.Response = _httpResponse;
 17016            // Deserialize Response
 017017            if ((int)_statusCode == 200)
 17018            {
 017019                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 17020                try
 17021                {
 017022                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 017023                }
 017024                catch (JsonException ex)
 17025                {
 017026                    _httpRequest.Dispose();
 017027                    if (_httpResponse != null)
 17028                    {
 017029                        _httpResponse.Dispose();
 17030                    }
 017031                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 17032                }
 17033            }
 017034            if (_shouldTrace)
 17035            {
 017036                ServiceClientTracing.Exit(_invocationId, _result);
 17037            }
 017038            return _result;
 017039        }
 17040
 17041        /// <summary>
 17042        /// Get one role for a given Pattern.any entity in a version of the
 17043        /// application.
 17044        /// </summary>
 17045        /// <param name='appId'>
 17046        /// The application ID.
 17047        /// </param>
 17048        /// <param name='versionId'>
 17049        /// The version ID.
 17050        /// </param>
 17051        /// <param name='entityId'>
 17052        /// entity ID.
 17053        /// </param>
 17054        /// <param name='roleId'>
 17055        /// entity role ID.
 17056        /// </param>
 17057        /// <param name='customHeaders'>
 17058        /// Headers that will be added to request.
 17059        /// </param>
 17060        /// <param name='cancellationToken'>
 17061        /// The cancellation token.
 17062        /// </param>
 17063        /// <exception cref="ErrorResponseException">
 17064        /// Thrown when the operation returned an invalid status code
 17065        /// </exception>
 17066        /// <exception cref="SerializationException">
 17067        /// Thrown when unable to deserialize the response
 17068        /// </exception>
 17069        /// <exception cref="ValidationException">
 17070        /// Thrown when a required parameter is null
 17071        /// </exception>
 17072        /// <exception cref="System.ArgumentNullException">
 17073        /// Thrown when a required parameter is null
 17074        /// </exception>
 17075        /// <return>
 17076        /// A response object containing the response body and response headers.
 17077        /// </return>
 17078        public async Task<HttpOperationResponse<EntityRole>> GetPatternAnyEntityRoleWithHttpMessagesAsync(System.Guid ap
 17079        {
 217080            if (Client.Endpoint == null)
 17081            {
 017082                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 17083            }
 217084            if (versionId == null)
 17085            {
 017086                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 17087            }
 17088            // Tracing
 217089            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 217090            string _invocationId = null;
 217091            if (_shouldTrace)
 17092            {
 017093                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 017094                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 017095                tracingParameters.Add("appId", appId);
 017096                tracingParameters.Add("versionId", versionId);
 017097                tracingParameters.Add("entityId", entityId);
 017098                tracingParameters.Add("roleId", roleId);
 017099                tracingParameters.Add("cancellationToken", cancellationToken);
 017100                ServiceClientTracing.Enter(_invocationId, this, "GetPatternAnyEntityRole", tracingParameters);
 17101            }
 17102            // Construct URL
 217103            var _baseUrl = Client.BaseUri;
 217104            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 217105            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 217106            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 217107            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 217108            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 217109            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 17110            // Create HTTP transport objects
 217111            var _httpRequest = new HttpRequestMessage();
 217112            HttpResponseMessage _httpResponse = null;
 217113            _httpRequest.Method = new HttpMethod("GET");
 217114            _httpRequest.RequestUri = new System.Uri(_url);
 17115            // Set Headers
 17116
 17117
 217118            if (customHeaders != null)
 17119            {
 017120                foreach(var _header in customHeaders)
 17121                {
 017122                    if (_httpRequest.Headers.Contains(_header.Key))
 17123                    {
 017124                        _httpRequest.Headers.Remove(_header.Key);
 17125                    }
 017126                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 17127                }
 17128            }
 17129
 17130            // Serialize Request
 217131            string _requestContent = null;
 17132            // Set Credentials
 217133            if (Client.Credentials != null)
 17134            {
 217135                cancellationToken.ThrowIfCancellationRequested();
 217136                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 17137            }
 17138            // Send Request
 217139            if (_shouldTrace)
 17140            {
 017141                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 17142            }
 217143            cancellationToken.ThrowIfCancellationRequested();
 217144            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 217145            if (_shouldTrace)
 17146            {
 017147                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 17148            }
 217149            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 217150            cancellationToken.ThrowIfCancellationRequested();
 217151            string _responseContent = null;
 217152            if ((int)_statusCode != 200)
 17153            {
 017154                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 17155                try
 17156                {
 017157                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 017158                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 017159                    if (_errorBody != null)
 17160                    {
 017161                        ex.Body = _errorBody;
 17162                    }
 017163                }
 017164                catch (JsonException)
 17165                {
 17166                    // Ignore the exception
 017167                }
 017168                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 017169                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 017170                if (_shouldTrace)
 17171                {
 017172                    ServiceClientTracing.Error(_invocationId, ex);
 17173                }
 017174                _httpRequest.Dispose();
 017175                if (_httpResponse != null)
 17176                {
 017177                    _httpResponse.Dispose();
 17178                }
 017179                throw ex;
 17180            }
 17181            // Create Result
 217182            var _result = new HttpOperationResponse<EntityRole>();
 217183            _result.Request = _httpRequest;
 217184            _result.Response = _httpResponse;
 17185            // Deserialize Response
 217186            if ((int)_statusCode == 200)
 17187            {
 217188                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 17189                try
 17190                {
 217191                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl
 217192                }
 017193                catch (JsonException ex)
 17194                {
 017195                    _httpRequest.Dispose();
 017196                    if (_httpResponse != null)
 17197                    {
 017198                        _httpResponse.Dispose();
 17199                    }
 017200                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 17201                }
 17202            }
 217203            if (_shouldTrace)
 17204            {
 017205                ServiceClientTracing.Exit(_invocationId, _result);
 17206            }
 217207            return _result;
 217208        }
 17209
 17210        /// <summary>
 17211        /// Update a role for a given Pattern.any entity in a version of the
 17212        /// application.
 17213        /// </summary>
 17214        /// <param name='appId'>
 17215        /// The application ID.
 17216        /// </param>
 17217        /// <param name='versionId'>
 17218        /// The version ID.
 17219        /// </param>
 17220        /// <param name='entityId'>
 17221        /// The entity ID.
 17222        /// </param>
 17223        /// <param name='roleId'>
 17224        /// The entity role ID.
 17225        /// </param>
 17226        /// <param name='entityRoleUpdateObject'>
 17227        /// The new entity role.
 17228        /// </param>
 17229        /// <param name='customHeaders'>
 17230        /// Headers that will be added to request.
 17231        /// </param>
 17232        /// <param name='cancellationToken'>
 17233        /// The cancellation token.
 17234        /// </param>
 17235        /// <exception cref="ErrorResponseException">
 17236        /// Thrown when the operation returned an invalid status code
 17237        /// </exception>
 17238        /// <exception cref="SerializationException">
 17239        /// Thrown when unable to deserialize the response
 17240        /// </exception>
 17241        /// <exception cref="ValidationException">
 17242        /// Thrown when a required parameter is null
 17243        /// </exception>
 17244        /// <exception cref="System.ArgumentNullException">
 17245        /// Thrown when a required parameter is null
 17246        /// </exception>
 17247        /// <return>
 17248        /// A response object containing the response body and response headers.
 17249        /// </return>
 17250        public async Task<HttpOperationResponse<OperationStatus>> UpdatePatternAnyEntityRoleWithHttpMessagesAsync(System
 17251        {
 117252            if (Client.Endpoint == null)
 17253            {
 017254                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 17255            }
 117256            if (versionId == null)
 17257            {
 017258                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 17259            }
 117260            if (entityRoleUpdateObject == null)
 17261            {
 017262                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject");
 17263            }
 17264            // Tracing
 117265            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 117266            string _invocationId = null;
 117267            if (_shouldTrace)
 17268            {
 017269                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 017270                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 017271                tracingParameters.Add("appId", appId);
 017272                tracingParameters.Add("versionId", versionId);
 017273                tracingParameters.Add("entityId", entityId);
 017274                tracingParameters.Add("roleId", roleId);
 017275                tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject);
 017276                tracingParameters.Add("cancellationToken", cancellationToken);
 017277                ServiceClientTracing.Enter(_invocationId, this, "UpdatePatternAnyEntityRole", tracingParameters);
 17278            }
 17279            // Construct URL
 117280            var _baseUrl = Client.BaseUri;
 117281            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 117282            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 117283            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 117284            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 117285            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 117286            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 17287            // Create HTTP transport objects
 117288            var _httpRequest = new HttpRequestMessage();
 117289            HttpResponseMessage _httpResponse = null;
 117290            _httpRequest.Method = new HttpMethod("PUT");
 117291            _httpRequest.RequestUri = new System.Uri(_url);
 17292            // Set Headers
 17293
 17294
 117295            if (customHeaders != null)
 17296            {
 017297                foreach(var _header in customHeaders)
 17298                {
 017299                    if (_httpRequest.Headers.Contains(_header.Key))
 17300                    {
 017301                        _httpRequest.Headers.Remove(_header.Key);
 17302                    }
 017303                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 17304                }
 17305            }
 17306
 17307            // Serialize Request
 117308            string _requestContent = null;
 117309            if(entityRoleUpdateObject != null)
 17310            {
 117311                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri
 117312                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 117313                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 17314            }
 17315            // Set Credentials
 117316            if (Client.Credentials != null)
 17317            {
 117318                cancellationToken.ThrowIfCancellationRequested();
 117319                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 17320            }
 17321            // Send Request
 117322            if (_shouldTrace)
 17323            {
 017324                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 17325            }
 117326            cancellationToken.ThrowIfCancellationRequested();
 117327            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 117328            if (_shouldTrace)
 17329            {
 017330                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 17331            }
 117332            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 117333            cancellationToken.ThrowIfCancellationRequested();
 117334            string _responseContent = null;
 117335            if ((int)_statusCode != 200)
 17336            {
 017337                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 17338                try
 17339                {
 017340                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 017341                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 017342                    if (_errorBody != null)
 17343                    {
 017344                        ex.Body = _errorBody;
 17345                    }
 017346                }
 017347                catch (JsonException)
 17348                {
 17349                    // Ignore the exception
 017350                }
 017351                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 017352                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 017353                if (_shouldTrace)
 17354                {
 017355                    ServiceClientTracing.Error(_invocationId, ex);
 17356                }
 017357                _httpRequest.Dispose();
 017358                if (_httpResponse != null)
 17359                {
 017360                    _httpResponse.Dispose();
 17361                }
 017362                throw ex;
 17363            }
 17364            // Create Result
 117365            var _result = new HttpOperationResponse<OperationStatus>();
 117366            _result.Request = _httpRequest;
 117367            _result.Response = _httpResponse;
 17368            // Deserialize Response
 117369            if ((int)_statusCode == 200)
 17370            {
 117371                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 17372                try
 17373                {
 117374                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 117375                }
 017376                catch (JsonException ex)
 17377                {
 017378                    _httpRequest.Dispose();
 017379                    if (_httpResponse != null)
 17380                    {
 017381                        _httpResponse.Dispose();
 17382                    }
 017383                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 17384                }
 17385            }
 117386            if (_shouldTrace)
 17387            {
 017388                ServiceClientTracing.Exit(_invocationId, _result);
 17389            }
 117390            return _result;
 117391        }
 17392
 17393        /// <summary>
 17394        /// Delete a role for a given Pattern.any entity in a version of the
 17395        /// application.
 17396        /// </summary>
 17397        /// <param name='appId'>
 17398        /// The application ID.
 17399        /// </param>
 17400        /// <param name='versionId'>
 17401        /// The version ID.
 17402        /// </param>
 17403        /// <param name='entityId'>
 17404        /// The entity ID.
 17405        /// </param>
 17406        /// <param name='roleId'>
 17407        /// The entity role Id.
 17408        /// </param>
 17409        /// <param name='customHeaders'>
 17410        /// Headers that will be added to request.
 17411        /// </param>
 17412        /// <param name='cancellationToken'>
 17413        /// The cancellation token.
 17414        /// </param>
 17415        /// <exception cref="ErrorResponseException">
 17416        /// Thrown when the operation returned an invalid status code
 17417        /// </exception>
 17418        /// <exception cref="SerializationException">
 17419        /// Thrown when unable to deserialize the response
 17420        /// </exception>
 17421        /// <exception cref="ValidationException">
 17422        /// Thrown when a required parameter is null
 17423        /// </exception>
 17424        /// <exception cref="System.ArgumentNullException">
 17425        /// Thrown when a required parameter is null
 17426        /// </exception>
 17427        /// <return>
 17428        /// A response object containing the response body and response headers.
 17429        /// </return>
 17430        public async Task<HttpOperationResponse<OperationStatus>> DeletePatternAnyEntityRoleWithHttpMessagesAsync(System
 17431        {
 117432            if (Client.Endpoint == null)
 17433            {
 017434                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 17435            }
 117436            if (versionId == null)
 17437            {
 017438                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 17439            }
 17440            // Tracing
 117441            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 117442            string _invocationId = null;
 117443            if (_shouldTrace)
 17444            {
 017445                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 017446                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 017447                tracingParameters.Add("appId", appId);
 017448                tracingParameters.Add("versionId", versionId);
 017449                tracingParameters.Add("entityId", entityId);
 017450                tracingParameters.Add("roleId", roleId);
 017451                tracingParameters.Add("cancellationToken", cancellationToken);
 017452                ServiceClientTracing.Enter(_invocationId, this, "DeletePatternAnyEntityRole", tracingParameters);
 17453            }
 17454            // Construct URL
 117455            var _baseUrl = Client.BaseUri;
 117456            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 117457            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 117458            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 117459            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 117460            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 117461            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 17462            // Create HTTP transport objects
 117463            var _httpRequest = new HttpRequestMessage();
 117464            HttpResponseMessage _httpResponse = null;
 117465            _httpRequest.Method = new HttpMethod("DELETE");
 117466            _httpRequest.RequestUri = new System.Uri(_url);
 17467            // Set Headers
 17468
 17469
 117470            if (customHeaders != null)
 17471            {
 017472                foreach(var _header in customHeaders)
 17473                {
 017474                    if (_httpRequest.Headers.Contains(_header.Key))
 17475                    {
 017476                        _httpRequest.Headers.Remove(_header.Key);
 17477                    }
 017478                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 17479                }
 17480            }
 17481
 17482            // Serialize Request
 117483            string _requestContent = null;
 17484            // Set Credentials
 117485            if (Client.Credentials != null)
 17486            {
 117487                cancellationToken.ThrowIfCancellationRequested();
 117488                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 17489            }
 17490            // Send Request
 117491            if (_shouldTrace)
 17492            {
 017493                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 17494            }
 117495            cancellationToken.ThrowIfCancellationRequested();
 117496            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 117497            if (_shouldTrace)
 17498            {
 017499                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 17500            }
 117501            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 117502            cancellationToken.ThrowIfCancellationRequested();
 117503            string _responseContent = null;
 117504            if ((int)_statusCode != 200)
 17505            {
 017506                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 17507                try
 17508                {
 017509                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 017510                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 017511                    if (_errorBody != null)
 17512                    {
 017513                        ex.Body = _errorBody;
 17514                    }
 017515                }
 017516                catch (JsonException)
 17517                {
 17518                    // Ignore the exception
 017519                }
 017520                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 017521                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 017522                if (_shouldTrace)
 17523                {
 017524                    ServiceClientTracing.Error(_invocationId, ex);
 17525                }
 017526                _httpRequest.Dispose();
 017527                if (_httpResponse != null)
 17528                {
 017529                    _httpResponse.Dispose();
 17530                }
 017531                throw ex;
 17532            }
 17533            // Create Result
 117534            var _result = new HttpOperationResponse<OperationStatus>();
 117535            _result.Request = _httpRequest;
 117536            _result.Response = _httpResponse;
 17537            // Deserialize Response
 117538            if ((int)_statusCode == 200)
 17539            {
 117540                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 17541                try
 17542                {
 117543                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 117544                }
 017545                catch (JsonException ex)
 17546                {
 017547                    _httpRequest.Dispose();
 017548                    if (_httpResponse != null)
 17549                    {
 017550                        _httpResponse.Dispose();
 17551                    }
 017552                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 17553                }
 17554            }
 117555            if (_shouldTrace)
 17556            {
 017557                ServiceClientTracing.Exit(_invocationId, _result);
 17558            }
 117559            return _result;
 117560        }
 17561
 17562        /// <summary>
 17563        /// Get one role for a given hierarchical entity in a version of the
 17564        /// application.
 17565        /// </summary>
 17566        /// <param name='appId'>
 17567        /// The application ID.
 17568        /// </param>
 17569        /// <param name='versionId'>
 17570        /// The version ID.
 17571        /// </param>
 17572        /// <param name='hEntityId'>
 17573        /// The hierarchical entity extractor ID.
 17574        /// </param>
 17575        /// <param name='roleId'>
 17576        /// entity role ID.
 17577        /// </param>
 17578        /// <param name='customHeaders'>
 17579        /// Headers that will be added to request.
 17580        /// </param>
 17581        /// <param name='cancellationToken'>
 17582        /// The cancellation token.
 17583        /// </param>
 17584        /// <exception cref="ErrorResponseException">
 17585        /// Thrown when the operation returned an invalid status code
 17586        /// </exception>
 17587        /// <exception cref="SerializationException">
 17588        /// Thrown when unable to deserialize the response
 17589        /// </exception>
 17590        /// <exception cref="ValidationException">
 17591        /// Thrown when a required parameter is null
 17592        /// </exception>
 17593        /// <exception cref="System.ArgumentNullException">
 17594        /// Thrown when a required parameter is null
 17595        /// </exception>
 17596        /// <return>
 17597        /// A response object containing the response body and response headers.
 17598        /// </return>
 17599        public async Task<HttpOperationResponse<EntityRole>> GetHierarchicalEntityRoleWithHttpMessagesAsync(System.Guid 
 17600        {
 017601            if (Client.Endpoint == null)
 17602            {
 017603                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 17604            }
 017605            if (versionId == null)
 17606            {
 017607                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 17608            }
 17609            // Tracing
 017610            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 017611            string _invocationId = null;
 017612            if (_shouldTrace)
 17613            {
 017614                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 017615                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 017616                tracingParameters.Add("appId", appId);
 017617                tracingParameters.Add("versionId", versionId);
 017618                tracingParameters.Add("hEntityId", hEntityId);
 017619                tracingParameters.Add("roleId", roleId);
 017620                tracingParameters.Add("cancellationToken", cancellationToken);
 017621                ServiceClientTracing.Enter(_invocationId, this, "GetHierarchicalEntityRole", tracingParameters);
 17622            }
 17623            // Construct URL
 017624            var _baseUrl = Client.BaseUri;
 017625            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 017626            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 017627            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 017628            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 017629            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 017630            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 17631            // Create HTTP transport objects
 017632            var _httpRequest = new HttpRequestMessage();
 017633            HttpResponseMessage _httpResponse = null;
 017634            _httpRequest.Method = new HttpMethod("GET");
 017635            _httpRequest.RequestUri = new System.Uri(_url);
 17636            // Set Headers
 17637
 17638
 017639            if (customHeaders != null)
 17640            {
 017641                foreach(var _header in customHeaders)
 17642                {
 017643                    if (_httpRequest.Headers.Contains(_header.Key))
 17644                    {
 017645                        _httpRequest.Headers.Remove(_header.Key);
 17646                    }
 017647                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 17648                }
 17649            }
 17650
 17651            // Serialize Request
 017652            string _requestContent = null;
 17653            // Set Credentials
 017654            if (Client.Credentials != null)
 17655            {
 017656                cancellationToken.ThrowIfCancellationRequested();
 017657                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 17658            }
 17659            // Send Request
 017660            if (_shouldTrace)
 17661            {
 017662                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 17663            }
 017664            cancellationToken.ThrowIfCancellationRequested();
 017665            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 017666            if (_shouldTrace)
 17667            {
 017668                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 17669            }
 017670            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 017671            cancellationToken.ThrowIfCancellationRequested();
 017672            string _responseContent = null;
 017673            if ((int)_statusCode != 200)
 17674            {
 017675                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 17676                try
 17677                {
 017678                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 017679                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 017680                    if (_errorBody != null)
 17681                    {
 017682                        ex.Body = _errorBody;
 17683                    }
 017684                }
 017685                catch (JsonException)
 17686                {
 17687                    // Ignore the exception
 017688                }
 017689                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 017690                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 017691                if (_shouldTrace)
 17692                {
 017693                    ServiceClientTracing.Error(_invocationId, ex);
 17694                }
 017695                _httpRequest.Dispose();
 017696                if (_httpResponse != null)
 17697                {
 017698                    _httpResponse.Dispose();
 17699                }
 017700                throw ex;
 17701            }
 17702            // Create Result
 017703            var _result = new HttpOperationResponse<EntityRole>();
 017704            _result.Request = _httpRequest;
 017705            _result.Response = _httpResponse;
 17706            // Deserialize Response
 017707            if ((int)_statusCode == 200)
 17708            {
 017709                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 17710                try
 17711                {
 017712                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl
 017713                }
 017714                catch (JsonException ex)
 17715                {
 017716                    _httpRequest.Dispose();
 017717                    if (_httpResponse != null)
 17718                    {
 017719                        _httpResponse.Dispose();
 17720                    }
 017721                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 17722                }
 17723            }
 017724            if (_shouldTrace)
 17725            {
 017726                ServiceClientTracing.Exit(_invocationId, _result);
 17727            }
 017728            return _result;
 017729        }
 17730
 17731        /// <summary>
 17732        /// Update a role for a given hierarchical entity in a version of the
 17733        /// application.
 17734        /// </summary>
 17735        /// <param name='appId'>
 17736        /// The application ID.
 17737        /// </param>
 17738        /// <param name='versionId'>
 17739        /// The version ID.
 17740        /// </param>
 17741        /// <param name='hEntityId'>
 17742        /// The hierarchical entity extractor ID.
 17743        /// </param>
 17744        /// <param name='roleId'>
 17745        /// The entity role ID.
 17746        /// </param>
 17747        /// <param name='entityRoleUpdateObject'>
 17748        /// The new entity role.
 17749        /// </param>
 17750        /// <param name='customHeaders'>
 17751        /// Headers that will be added to request.
 17752        /// </param>
 17753        /// <param name='cancellationToken'>
 17754        /// The cancellation token.
 17755        /// </param>
 17756        /// <exception cref="ErrorResponseException">
 17757        /// Thrown when the operation returned an invalid status code
 17758        /// </exception>
 17759        /// <exception cref="SerializationException">
 17760        /// Thrown when unable to deserialize the response
 17761        /// </exception>
 17762        /// <exception cref="ValidationException">
 17763        /// Thrown when a required parameter is null
 17764        /// </exception>
 17765        /// <exception cref="System.ArgumentNullException">
 17766        /// Thrown when a required parameter is null
 17767        /// </exception>
 17768        /// <return>
 17769        /// A response object containing the response body and response headers.
 17770        /// </return>
 17771        public async Task<HttpOperationResponse<OperationStatus>> UpdateHierarchicalEntityRoleWithHttpMessagesAsync(Syst
 17772        {
 017773            if (Client.Endpoint == null)
 17774            {
 017775                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 17776            }
 017777            if (versionId == null)
 17778            {
 017779                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 17780            }
 017781            if (entityRoleUpdateObject == null)
 17782            {
 017783                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject");
 17784            }
 17785            // Tracing
 017786            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 017787            string _invocationId = null;
 017788            if (_shouldTrace)
 17789            {
 017790                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 017791                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 017792                tracingParameters.Add("appId", appId);
 017793                tracingParameters.Add("versionId", versionId);
 017794                tracingParameters.Add("hEntityId", hEntityId);
 017795                tracingParameters.Add("roleId", roleId);
 017796                tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject);
 017797                tracingParameters.Add("cancellationToken", cancellationToken);
 017798                ServiceClientTracing.Enter(_invocationId, this, "UpdateHierarchicalEntityRole", tracingParameters);
 17799            }
 17800            // Construct URL
 017801            var _baseUrl = Client.BaseUri;
 017802            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 017803            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 017804            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 017805            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 017806            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 017807            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 17808            // Create HTTP transport objects
 017809            var _httpRequest = new HttpRequestMessage();
 017810            HttpResponseMessage _httpResponse = null;
 017811            _httpRequest.Method = new HttpMethod("PUT");
 017812            _httpRequest.RequestUri = new System.Uri(_url);
 17813            // Set Headers
 17814
 17815
 017816            if (customHeaders != null)
 17817            {
 017818                foreach(var _header in customHeaders)
 17819                {
 017820                    if (_httpRequest.Headers.Contains(_header.Key))
 17821                    {
 017822                        _httpRequest.Headers.Remove(_header.Key);
 17823                    }
 017824                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 17825                }
 17826            }
 17827
 17828            // Serialize Request
 017829            string _requestContent = null;
 017830            if(entityRoleUpdateObject != null)
 17831            {
 017832                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri
 017833                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 017834                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 17835            }
 17836            // Set Credentials
 017837            if (Client.Credentials != null)
 17838            {
 017839                cancellationToken.ThrowIfCancellationRequested();
 017840                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 17841            }
 17842            // Send Request
 017843            if (_shouldTrace)
 17844            {
 017845                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 17846            }
 017847            cancellationToken.ThrowIfCancellationRequested();
 017848            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 017849            if (_shouldTrace)
 17850            {
 017851                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 17852            }
 017853            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 017854            cancellationToken.ThrowIfCancellationRequested();
 017855            string _responseContent = null;
 017856            if ((int)_statusCode != 200)
 17857            {
 017858                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 17859                try
 17860                {
 017861                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 017862                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 017863                    if (_errorBody != null)
 17864                    {
 017865                        ex.Body = _errorBody;
 17866                    }
 017867                }
 017868                catch (JsonException)
 17869                {
 17870                    // Ignore the exception
 017871                }
 017872                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 017873                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 017874                if (_shouldTrace)
 17875                {
 017876                    ServiceClientTracing.Error(_invocationId, ex);
 17877                }
 017878                _httpRequest.Dispose();
 017879                if (_httpResponse != null)
 17880                {
 017881                    _httpResponse.Dispose();
 17882                }
 017883                throw ex;
 17884            }
 17885            // Create Result
 017886            var _result = new HttpOperationResponse<OperationStatus>();
 017887            _result.Request = _httpRequest;
 017888            _result.Response = _httpResponse;
 17889            // Deserialize Response
 017890            if ((int)_statusCode == 200)
 17891            {
 017892                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 17893                try
 17894                {
 017895                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 017896                }
 017897                catch (JsonException ex)
 17898                {
 017899                    _httpRequest.Dispose();
 017900                    if (_httpResponse != null)
 17901                    {
 017902                        _httpResponse.Dispose();
 17903                    }
 017904                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 17905                }
 17906            }
 017907            if (_shouldTrace)
 17908            {
 017909                ServiceClientTracing.Exit(_invocationId, _result);
 17910            }
 017911            return _result;
 017912        }
 17913
 17914        /// <summary>
 17915        /// Delete a role for a given hierarchical role in a version of the
 17916        /// application.
 17917        /// </summary>
 17918        /// <param name='appId'>
 17919        /// The application ID.
 17920        /// </param>
 17921        /// <param name='versionId'>
 17922        /// The version ID.
 17923        /// </param>
 17924        /// <param name='hEntityId'>
 17925        /// The hierarchical entity extractor ID.
 17926        /// </param>
 17927        /// <param name='roleId'>
 17928        /// The entity role Id.
 17929        /// </param>
 17930        /// <param name='customHeaders'>
 17931        /// Headers that will be added to request.
 17932        /// </param>
 17933        /// <param name='cancellationToken'>
 17934        /// The cancellation token.
 17935        /// </param>
 17936        /// <exception cref="ErrorResponseException">
 17937        /// Thrown when the operation returned an invalid status code
 17938        /// </exception>
 17939        /// <exception cref="SerializationException">
 17940        /// Thrown when unable to deserialize the response
 17941        /// </exception>
 17942        /// <exception cref="ValidationException">
 17943        /// Thrown when a required parameter is null
 17944        /// </exception>
 17945        /// <exception cref="System.ArgumentNullException">
 17946        /// Thrown when a required parameter is null
 17947        /// </exception>
 17948        /// <return>
 17949        /// A response object containing the response body and response headers.
 17950        /// </return>
 17951        public async Task<HttpOperationResponse<OperationStatus>> DeleteHierarchicalEntityRoleWithHttpMessagesAsync(Syst
 17952        {
 017953            if (Client.Endpoint == null)
 17954            {
 017955                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 17956            }
 017957            if (versionId == null)
 17958            {
 017959                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 17960            }
 17961            // Tracing
 017962            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 017963            string _invocationId = null;
 017964            if (_shouldTrace)
 17965            {
 017966                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 017967                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 017968                tracingParameters.Add("appId", appId);
 017969                tracingParameters.Add("versionId", versionId);
 017970                tracingParameters.Add("hEntityId", hEntityId);
 017971                tracingParameters.Add("roleId", roleId);
 017972                tracingParameters.Add("cancellationToken", cancellationToken);
 017973                ServiceClientTracing.Enter(_invocationId, this, "DeleteHierarchicalEntityRole", tracingParameters);
 17974            }
 17975            // Construct URL
 017976            var _baseUrl = Client.BaseUri;
 017977            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale
 017978            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 017979            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 017980            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 017981            _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 017982            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 17983            // Create HTTP transport objects
 017984            var _httpRequest = new HttpRequestMessage();
 017985            HttpResponseMessage _httpResponse = null;
 017986            _httpRequest.Method = new HttpMethod("DELETE");
 017987            _httpRequest.RequestUri = new System.Uri(_url);
 17988            // Set Headers
 17989
 17990
 017991            if (customHeaders != null)
 17992            {
 017993                foreach(var _header in customHeaders)
 17994                {
 017995                    if (_httpRequest.Headers.Contains(_header.Key))
 17996                    {
 017997                        _httpRequest.Headers.Remove(_header.Key);
 17998                    }
 017999                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 18000                }
 18001            }
 18002
 18003            // Serialize Request
 018004            string _requestContent = null;
 18005            // Set Credentials
 018006            if (Client.Credentials != null)
 18007            {
 018008                cancellationToken.ThrowIfCancellationRequested();
 018009                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 18010            }
 18011            // Send Request
 018012            if (_shouldTrace)
 18013            {
 018014                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 18015            }
 018016            cancellationToken.ThrowIfCancellationRequested();
 018017            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 018018            if (_shouldTrace)
 18019            {
 018020                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 18021            }
 018022            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 018023            cancellationToken.ThrowIfCancellationRequested();
 018024            string _responseContent = null;
 018025            if ((int)_statusCode != 200)
 18026            {
 018027                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 18028                try
 18029                {
 018030                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 018031                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 018032                    if (_errorBody != null)
 18033                    {
 018034                        ex.Body = _errorBody;
 18035                    }
 018036                }
 018037                catch (JsonException)
 18038                {
 18039                    // Ignore the exception
 018040                }
 018041                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 018042                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 018043                if (_shouldTrace)
 18044                {
 018045                    ServiceClientTracing.Error(_invocationId, ex);
 18046                }
 018047                _httpRequest.Dispose();
 018048                if (_httpResponse != null)
 18049                {
 018050                    _httpResponse.Dispose();
 18051                }
 018052                throw ex;
 18053            }
 18054            // Create Result
 018055            var _result = new HttpOperationResponse<OperationStatus>();
 018056            _result.Request = _httpRequest;
 018057            _result.Response = _httpResponse;
 18058            // Deserialize Response
 018059            if ((int)_statusCode == 200)
 18060            {
 018061                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 18062                try
 18063                {
 018064                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 018065                }
 018066                catch (JsonException ex)
 18067                {
 018068                    _httpRequest.Dispose();
 018069                    if (_httpResponse != null)
 18070                    {
 018071                        _httpResponse.Dispose();
 18072                    }
 018073                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 18074                }
 18075            }
 018076            if (_shouldTrace)
 18077            {
 018078                ServiceClientTracing.Exit(_invocationId, _result);
 18079            }
 018080            return _result;
 018081        }
 18082
 18083        /// <summary>
 18084        /// Get one role for a given prebuilt entity in a version of the application.
 18085        /// </summary>
 18086        /// <param name='appId'>
 18087        /// The application ID.
 18088        /// </param>
 18089        /// <param name='versionId'>
 18090        /// The version ID.
 18091        /// </param>
 18092        /// <param name='entityId'>
 18093        /// entity ID.
 18094        /// </param>
 18095        /// <param name='roleId'>
 18096        /// entity role ID.
 18097        /// </param>
 18098        /// <param name='customHeaders'>
 18099        /// Headers that will be added to request.
 18100        /// </param>
 18101        /// <param name='cancellationToken'>
 18102        /// The cancellation token.
 18103        /// </param>
 18104        /// <exception cref="ErrorResponseException">
 18105        /// Thrown when the operation returned an invalid status code
 18106        /// </exception>
 18107        /// <exception cref="SerializationException">
 18108        /// Thrown when unable to deserialize the response
 18109        /// </exception>
 18110        /// <exception cref="ValidationException">
 18111        /// Thrown when a required parameter is null
 18112        /// </exception>
 18113        /// <exception cref="System.ArgumentNullException">
 18114        /// Thrown when a required parameter is null
 18115        /// </exception>
 18116        /// <return>
 18117        /// A response object containing the response body and response headers.
 18118        /// </return>
 18119        public async Task<HttpOperationResponse<EntityRole>> GetCustomEntityRoleWithHttpMessagesAsync(System.Guid appId,
 18120        {
 218121            if (Client.Endpoint == null)
 18122            {
 018123                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 18124            }
 218125            if (versionId == null)
 18126            {
 018127                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 18128            }
 18129            // Tracing
 218130            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 218131            string _invocationId = null;
 218132            if (_shouldTrace)
 18133            {
 018134                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 018135                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 018136                tracingParameters.Add("appId", appId);
 018137                tracingParameters.Add("versionId", versionId);
 018138                tracingParameters.Add("entityId", entityId);
 018139                tracingParameters.Add("roleId", roleId);
 018140                tracingParameters.Add("cancellationToken", cancellationToken);
 018141                ServiceClientTracing.Enter(_invocationId, this, "GetCustomEntityRole", tracingParameters);
 18142            }
 18143            // Construct URL
 218144            var _baseUrl = Client.BaseUri;
 218145            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 218146            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 218147            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 218148            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 218149            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 218150            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 18151            // Create HTTP transport objects
 218152            var _httpRequest = new HttpRequestMessage();
 218153            HttpResponseMessage _httpResponse = null;
 218154            _httpRequest.Method = new HttpMethod("GET");
 218155            _httpRequest.RequestUri = new System.Uri(_url);
 18156            // Set Headers
 18157
 18158
 218159            if (customHeaders != null)
 18160            {
 018161                foreach(var _header in customHeaders)
 18162                {
 018163                    if (_httpRequest.Headers.Contains(_header.Key))
 18164                    {
 018165                        _httpRequest.Headers.Remove(_header.Key);
 18166                    }
 018167                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 18168                }
 18169            }
 18170
 18171            // Serialize Request
 218172            string _requestContent = null;
 18173            // Set Credentials
 218174            if (Client.Credentials != null)
 18175            {
 218176                cancellationToken.ThrowIfCancellationRequested();
 218177                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 18178            }
 18179            // Send Request
 218180            if (_shouldTrace)
 18181            {
 018182                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 18183            }
 218184            cancellationToken.ThrowIfCancellationRequested();
 218185            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 218186            if (_shouldTrace)
 18187            {
 018188                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 18189            }
 218190            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 218191            cancellationToken.ThrowIfCancellationRequested();
 218192            string _responseContent = null;
 218193            if ((int)_statusCode != 200)
 18194            {
 018195                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 18196                try
 18197                {
 018198                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 018199                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 018200                    if (_errorBody != null)
 18201                    {
 018202                        ex.Body = _errorBody;
 18203                    }
 018204                }
 018205                catch (JsonException)
 18206                {
 18207                    // Ignore the exception
 018208                }
 018209                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 018210                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 018211                if (_shouldTrace)
 18212                {
 018213                    ServiceClientTracing.Error(_invocationId, ex);
 18214                }
 018215                _httpRequest.Dispose();
 018216                if (_httpResponse != null)
 18217                {
 018218                    _httpResponse.Dispose();
 18219                }
 018220                throw ex;
 18221            }
 18222            // Create Result
 218223            var _result = new HttpOperationResponse<EntityRole>();
 218224            _result.Request = _httpRequest;
 218225            _result.Response = _httpResponse;
 18226            // Deserialize Response
 218227            if ((int)_statusCode == 200)
 18228            {
 218229                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 18230                try
 18231                {
 218232                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl
 218233                }
 018234                catch (JsonException ex)
 18235                {
 018236                    _httpRequest.Dispose();
 018237                    if (_httpResponse != null)
 18238                    {
 018239                        _httpResponse.Dispose();
 18240                    }
 018241                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 18242                }
 18243            }
 218244            if (_shouldTrace)
 18245            {
 018246                ServiceClientTracing.Exit(_invocationId, _result);
 18247            }
 218248            return _result;
 218249        }
 18250
 18251        /// <summary>
 18252        /// Update a role for a given prebuilt entity in a version of the application.
 18253        /// </summary>
 18254        /// <param name='appId'>
 18255        /// The application ID.
 18256        /// </param>
 18257        /// <param name='versionId'>
 18258        /// The version ID.
 18259        /// </param>
 18260        /// <param name='entityId'>
 18261        /// The entity ID.
 18262        /// </param>
 18263        /// <param name='roleId'>
 18264        /// The entity role ID.
 18265        /// </param>
 18266        /// <param name='entityRoleUpdateObject'>
 18267        /// The new entity role.
 18268        /// </param>
 18269        /// <param name='customHeaders'>
 18270        /// Headers that will be added to request.
 18271        /// </param>
 18272        /// <param name='cancellationToken'>
 18273        /// The cancellation token.
 18274        /// </param>
 18275        /// <exception cref="ErrorResponseException">
 18276        /// Thrown when the operation returned an invalid status code
 18277        /// </exception>
 18278        /// <exception cref="SerializationException">
 18279        /// Thrown when unable to deserialize the response
 18280        /// </exception>
 18281        /// <exception cref="ValidationException">
 18282        /// Thrown when a required parameter is null
 18283        /// </exception>
 18284        /// <exception cref="System.ArgumentNullException">
 18285        /// Thrown when a required parameter is null
 18286        /// </exception>
 18287        /// <return>
 18288        /// A response object containing the response body and response headers.
 18289        /// </return>
 18290        public async Task<HttpOperationResponse<OperationStatus>> UpdateCustomPrebuiltEntityRoleWithHttpMessagesAsync(Sy
 18291        {
 118292            if (Client.Endpoint == null)
 18293            {
 018294                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 18295            }
 118296            if (versionId == null)
 18297            {
 018298                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 18299            }
 118300            if (entityRoleUpdateObject == null)
 18301            {
 018302                throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject");
 18303            }
 18304            // Tracing
 118305            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 118306            string _invocationId = null;
 118307            if (_shouldTrace)
 18308            {
 018309                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 018310                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 018311                tracingParameters.Add("appId", appId);
 018312                tracingParameters.Add("versionId", versionId);
 018313                tracingParameters.Add("entityId", entityId);
 018314                tracingParameters.Add("roleId", roleId);
 018315                tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject);
 018316                tracingParameters.Add("cancellationToken", cancellationToken);
 018317                ServiceClientTracing.Enter(_invocationId, this, "UpdateCustomPrebuiltEntityRole", tracingParameters);
 18318            }
 18319            // Construct URL
 118320            var _baseUrl = Client.BaseUri;
 118321            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 118322            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 118323            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 118324            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 118325            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 118326            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 18327            // Create HTTP transport objects
 118328            var _httpRequest = new HttpRequestMessage();
 118329            HttpResponseMessage _httpResponse = null;
 118330            _httpRequest.Method = new HttpMethod("PUT");
 118331            _httpRequest.RequestUri = new System.Uri(_url);
 18332            // Set Headers
 18333
 18334
 118335            if (customHeaders != null)
 18336            {
 018337                foreach(var _header in customHeaders)
 18338                {
 018339                    if (_httpRequest.Headers.Contains(_header.Key))
 18340                    {
 018341                        _httpRequest.Headers.Remove(_header.Key);
 18342                    }
 018343                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 18344                }
 18345            }
 18346
 18347            // Serialize Request
 118348            string _requestContent = null;
 118349            if(entityRoleUpdateObject != null)
 18350            {
 118351                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri
 118352                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 118353                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 18354            }
 18355            // Set Credentials
 118356            if (Client.Credentials != null)
 18357            {
 118358                cancellationToken.ThrowIfCancellationRequested();
 118359                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 18360            }
 18361            // Send Request
 118362            if (_shouldTrace)
 18363            {
 018364                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 18365            }
 118366            cancellationToken.ThrowIfCancellationRequested();
 118367            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 118368            if (_shouldTrace)
 18369            {
 018370                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 18371            }
 118372            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 118373            cancellationToken.ThrowIfCancellationRequested();
 118374            string _responseContent = null;
 118375            if ((int)_statusCode != 200)
 18376            {
 018377                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 18378                try
 18379                {
 018380                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 018381                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 018382                    if (_errorBody != null)
 18383                    {
 018384                        ex.Body = _errorBody;
 18385                    }
 018386                }
 018387                catch (JsonException)
 18388                {
 18389                    // Ignore the exception
 018390                }
 018391                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 018392                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 018393                if (_shouldTrace)
 18394                {
 018395                    ServiceClientTracing.Error(_invocationId, ex);
 18396                }
 018397                _httpRequest.Dispose();
 018398                if (_httpResponse != null)
 18399                {
 018400                    _httpResponse.Dispose();
 18401                }
 018402                throw ex;
 18403            }
 18404            // Create Result
 118405            var _result = new HttpOperationResponse<OperationStatus>();
 118406            _result.Request = _httpRequest;
 118407            _result.Response = _httpResponse;
 18408            // Deserialize Response
 118409            if ((int)_statusCode == 200)
 18410            {
 118411                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 18412                try
 18413                {
 118414                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 118415                }
 018416                catch (JsonException ex)
 18417                {
 018418                    _httpRequest.Dispose();
 018419                    if (_httpResponse != null)
 18420                    {
 018421                        _httpResponse.Dispose();
 18422                    }
 018423                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 18424                }
 18425            }
 118426            if (_shouldTrace)
 18427            {
 018428                ServiceClientTracing.Exit(_invocationId, _result);
 18429            }
 118430            return _result;
 118431        }
 18432
 18433        /// <summary>
 18434        /// Delete a role for a given prebuilt entity in a version of the application.
 18435        /// </summary>
 18436        /// <param name='appId'>
 18437        /// The application ID.
 18438        /// </param>
 18439        /// <param name='versionId'>
 18440        /// The version ID.
 18441        /// </param>
 18442        /// <param name='entityId'>
 18443        /// The entity ID.
 18444        /// </param>
 18445        /// <param name='roleId'>
 18446        /// The entity role Id.
 18447        /// </param>
 18448        /// <param name='customHeaders'>
 18449        /// Headers that will be added to request.
 18450        /// </param>
 18451        /// <param name='cancellationToken'>
 18452        /// The cancellation token.
 18453        /// </param>
 18454        /// <exception cref="ErrorResponseException">
 18455        /// Thrown when the operation returned an invalid status code
 18456        /// </exception>
 18457        /// <exception cref="SerializationException">
 18458        /// Thrown when unable to deserialize the response
 18459        /// </exception>
 18460        /// <exception cref="ValidationException">
 18461        /// Thrown when a required parameter is null
 18462        /// </exception>
 18463        /// <exception cref="System.ArgumentNullException">
 18464        /// Thrown when a required parameter is null
 18465        /// </exception>
 18466        /// <return>
 18467        /// A response object containing the response body and response headers.
 18468        /// </return>
 18469        public async Task<HttpOperationResponse<OperationStatus>> DeleteCustomEntityRoleWithHttpMessagesAsync(System.Gui
 18470        {
 118471            if (Client.Endpoint == null)
 18472            {
 018473                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 18474            }
 118475            if (versionId == null)
 18476            {
 018477                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 18478            }
 18479            // Tracing
 118480            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 118481            string _invocationId = null;
 118482            if (_shouldTrace)
 18483            {
 018484                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 018485                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 018486                tracingParameters.Add("appId", appId);
 018487                tracingParameters.Add("versionId", versionId);
 018488                tracingParameters.Add("entityId", entityId);
 018489                tracingParameters.Add("roleId", roleId);
 018490                tracingParameters.Add("cancellationToken", cancellationToken);
 018491                ServiceClientTracing.Enter(_invocationId, this, "DeleteCustomEntityRole", tracingParameters);
 18492            }
 18493            // Construct URL
 118494            var _baseUrl = Client.BaseUri;
 118495            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil
 118496            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 118497            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 118498            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 118499            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 118500            _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 18501            // Create HTTP transport objects
 118502            var _httpRequest = new HttpRequestMessage();
 118503            HttpResponseMessage _httpResponse = null;
 118504            _httpRequest.Method = new HttpMethod("DELETE");
 118505            _httpRequest.RequestUri = new System.Uri(_url);
 18506            // Set Headers
 18507
 18508
 118509            if (customHeaders != null)
 18510            {
 018511                foreach(var _header in customHeaders)
 18512                {
 018513                    if (_httpRequest.Headers.Contains(_header.Key))
 18514                    {
 018515                        _httpRequest.Headers.Remove(_header.Key);
 18516                    }
 018517                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 18518                }
 18519            }
 18520
 18521            // Serialize Request
 118522            string _requestContent = null;
 18523            // Set Credentials
 118524            if (Client.Credentials != null)
 18525            {
 118526                cancellationToken.ThrowIfCancellationRequested();
 118527                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 18528            }
 18529            // Send Request
 118530            if (_shouldTrace)
 18531            {
 018532                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 18533            }
 118534            cancellationToken.ThrowIfCancellationRequested();
 118535            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 118536            if (_shouldTrace)
 18537            {
 018538                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 18539            }
 118540            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 118541            cancellationToken.ThrowIfCancellationRequested();
 118542            string _responseContent = null;
 118543            if ((int)_statusCode != 200)
 18544            {
 018545                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 18546                try
 18547                {
 018548                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 018549                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 018550                    if (_errorBody != null)
 18551                    {
 018552                        ex.Body = _errorBody;
 18553                    }
 018554                }
 018555                catch (JsonException)
 18556                {
 18557                    // Ignore the exception
 018558                }
 018559                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 018560                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 018561                if (_shouldTrace)
 18562                {
 018563                    ServiceClientTracing.Error(_invocationId, ex);
 18564                }
 018565                _httpRequest.Dispose();
 018566                if (_httpResponse != null)
 18567                {
 018568                    _httpResponse.Dispose();
 18569                }
 018570                throw ex;
 18571            }
 18572            // Create Result
 118573            var _result = new HttpOperationResponse<OperationStatus>();
 118574            _result.Request = _httpRequest;
 118575            _result.Response = _httpResponse;
 18576            // Deserialize Response
 118577            if ((int)_statusCode == 200)
 18578            {
 118579                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 18580                try
 18581                {
 118582                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 118583                }
 018584                catch (JsonException ex)
 18585                {
 018586                    _httpRequest.Dispose();
 018587                    if (_httpResponse != null)
 18588                    {
 018589                        _httpResponse.Dispose();
 18590                    }
 018591                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 18592                }
 18593            }
 118594            if (_shouldTrace)
 18595            {
 018596                ServiceClientTracing.Exit(_invocationId, _result);
 18597            }
 118598            return _result;
 118599        }
 18600
 18601        /// <summary>
 18602        /// Get the explicit (exception) list of the pattern.any entity in a version of
 18603        /// the application.
 18604        /// </summary>
 18605        /// <param name='appId'>
 18606        /// The application ID.
 18607        /// </param>
 18608        /// <param name='versionId'>
 18609        /// The version ID.
 18610        /// </param>
 18611        /// <param name='entityId'>
 18612        /// The Pattern.Any entity Id.
 18613        /// </param>
 18614        /// <param name='itemId'>
 18615        /// The explicit list item Id.
 18616        /// </param>
 18617        /// <param name='customHeaders'>
 18618        /// Headers that will be added to request.
 18619        /// </param>
 18620        /// <param name='cancellationToken'>
 18621        /// The cancellation token.
 18622        /// </param>
 18623        /// <exception cref="ErrorResponseException">
 18624        /// Thrown when the operation returned an invalid status code
 18625        /// </exception>
 18626        /// <exception cref="SerializationException">
 18627        /// Thrown when unable to deserialize the response
 18628        /// </exception>
 18629        /// <exception cref="ValidationException">
 18630        /// Thrown when a required parameter is null
 18631        /// </exception>
 18632        /// <exception cref="System.ArgumentNullException">
 18633        /// Thrown when a required parameter is null
 18634        /// </exception>
 18635        /// <return>
 18636        /// A response object containing the response body and response headers.
 18637        /// </return>
 18638        public async Task<HttpOperationResponse<ExplicitListItem>> GetExplicitListItemWithHttpMessagesAsync(System.Guid 
 18639        {
 318640            if (Client.Endpoint == null)
 18641            {
 018642                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 18643            }
 318644            if (versionId == null)
 18645            {
 018646                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 18647            }
 18648            // Tracing
 318649            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 318650            string _invocationId = null;
 318651            if (_shouldTrace)
 18652            {
 018653                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 018654                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 018655                tracingParameters.Add("appId", appId);
 018656                tracingParameters.Add("versionId", versionId);
 018657                tracingParameters.Add("entityId", entityId);
 018658                tracingParameters.Add("itemId", itemId);
 018659                tracingParameters.Add("cancellationToken", cancellationToken);
 018660                ServiceClientTracing.Enter(_invocationId, this, "GetExplicitListItem", tracingParameters);
 18661            }
 18662            // Construct URL
 318663            var _baseUrl = Client.BaseUri;
 318664            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 318665            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 318666            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 318667            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 318668            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 318669            _url = _url.Replace("{itemId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 18670            // Create HTTP transport objects
 318671            var _httpRequest = new HttpRequestMessage();
 318672            HttpResponseMessage _httpResponse = null;
 318673            _httpRequest.Method = new HttpMethod("GET");
 318674            _httpRequest.RequestUri = new System.Uri(_url);
 18675            // Set Headers
 18676
 18677
 318678            if (customHeaders != null)
 18679            {
 018680                foreach(var _header in customHeaders)
 18681                {
 018682                    if (_httpRequest.Headers.Contains(_header.Key))
 18683                    {
 018684                        _httpRequest.Headers.Remove(_header.Key);
 18685                    }
 018686                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 18687                }
 18688            }
 18689
 18690            // Serialize Request
 318691            string _requestContent = null;
 18692            // Set Credentials
 318693            if (Client.Credentials != null)
 18694            {
 318695                cancellationToken.ThrowIfCancellationRequested();
 318696                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 18697            }
 18698            // Send Request
 318699            if (_shouldTrace)
 18700            {
 018701                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 18702            }
 318703            cancellationToken.ThrowIfCancellationRequested();
 318704            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 318705            if (_shouldTrace)
 18706            {
 018707                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 18708            }
 318709            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 318710            cancellationToken.ThrowIfCancellationRequested();
 318711            string _responseContent = null;
 318712            if ((int)_statusCode != 200)
 18713            {
 018714                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 18715                try
 18716                {
 018717                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 018718                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 018719                    if (_errorBody != null)
 18720                    {
 018721                        ex.Body = _errorBody;
 18722                    }
 018723                }
 018724                catch (JsonException)
 18725                {
 18726                    // Ignore the exception
 018727                }
 018728                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 018729                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 018730                if (_shouldTrace)
 18731                {
 018732                    ServiceClientTracing.Error(_invocationId, ex);
 18733                }
 018734                _httpRequest.Dispose();
 018735                if (_httpResponse != null)
 18736                {
 018737                    _httpResponse.Dispose();
 18738                }
 018739                throw ex;
 18740            }
 18741            // Create Result
 318742            var _result = new HttpOperationResponse<ExplicitListItem>();
 318743            _result.Request = _httpRequest;
 318744            _result.Response = _httpResponse;
 18745            // Deserialize Response
 318746            if ((int)_statusCode == 200)
 18747            {
 318748                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 18749                try
 18750                {
 318751                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ExplicitListItem>(_responseConte
 318752                }
 018753                catch (JsonException ex)
 18754                {
 018755                    _httpRequest.Dispose();
 018756                    if (_httpResponse != null)
 18757                    {
 018758                        _httpResponse.Dispose();
 18759                    }
 018760                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 18761                }
 18762            }
 318763            if (_shouldTrace)
 18764            {
 018765                ServiceClientTracing.Exit(_invocationId, _result);
 18766            }
 318767            return _result;
 318768        }
 18769
 18770        /// <summary>
 18771        /// Updates an explicit (exception) list item for a Pattern.Any entity in a
 18772        /// version of the application.
 18773        /// </summary>
 18774        /// <param name='appId'>
 18775        /// The application ID.
 18776        /// </param>
 18777        /// <param name='versionId'>
 18778        /// The version ID.
 18779        /// </param>
 18780        /// <param name='entityId'>
 18781        /// The Pattern.Any entity extractor ID.
 18782        /// </param>
 18783        /// <param name='itemId'>
 18784        /// The explicit list item ID.
 18785        /// </param>
 18786        /// <param name='item'>
 18787        /// The new explicit list item.
 18788        /// </param>
 18789        /// <param name='customHeaders'>
 18790        /// Headers that will be added to request.
 18791        /// </param>
 18792        /// <param name='cancellationToken'>
 18793        /// The cancellation token.
 18794        /// </param>
 18795        /// <exception cref="ErrorResponseException">
 18796        /// Thrown when the operation returned an invalid status code
 18797        /// </exception>
 18798        /// <exception cref="SerializationException">
 18799        /// Thrown when unable to deserialize the response
 18800        /// </exception>
 18801        /// <exception cref="ValidationException">
 18802        /// Thrown when a required parameter is null
 18803        /// </exception>
 18804        /// <exception cref="System.ArgumentNullException">
 18805        /// Thrown when a required parameter is null
 18806        /// </exception>
 18807        /// <return>
 18808        /// A response object containing the response body and response headers.
 18809        /// </return>
 18810        public async Task<HttpOperationResponse<OperationStatus>> UpdateExplicitListItemWithHttpMessagesAsync(System.Gui
 18811        {
 118812            if (Client.Endpoint == null)
 18813            {
 018814                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 18815            }
 118816            if (versionId == null)
 18817            {
 018818                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 18819            }
 118820            if (item == null)
 18821            {
 018822                throw new ValidationException(ValidationRules.CannotBeNull, "item");
 18823            }
 18824            // Tracing
 118825            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 118826            string _invocationId = null;
 118827            if (_shouldTrace)
 18828            {
 018829                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 018830                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 018831                tracingParameters.Add("appId", appId);
 018832                tracingParameters.Add("versionId", versionId);
 018833                tracingParameters.Add("entityId", entityId);
 018834                tracingParameters.Add("itemId", itemId);
 018835                tracingParameters.Add("item", item);
 018836                tracingParameters.Add("cancellationToken", cancellationToken);
 018837                ServiceClientTracing.Enter(_invocationId, this, "UpdateExplicitListItem", tracingParameters);
 18838            }
 18839            // Construct URL
 118840            var _baseUrl = Client.BaseUri;
 118841            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 118842            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 118843            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 118844            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 118845            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 118846            _url = _url.Replace("{itemId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 18847            // Create HTTP transport objects
 118848            var _httpRequest = new HttpRequestMessage();
 118849            HttpResponseMessage _httpResponse = null;
 118850            _httpRequest.Method = new HttpMethod("PUT");
 118851            _httpRequest.RequestUri = new System.Uri(_url);
 18852            // Set Headers
 18853
 18854
 118855            if (customHeaders != null)
 18856            {
 018857                foreach(var _header in customHeaders)
 18858                {
 018859                    if (_httpRequest.Headers.Contains(_header.Key))
 18860                    {
 018861                        _httpRequest.Headers.Remove(_header.Key);
 18862                    }
 018863                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 18864                }
 18865            }
 18866
 18867            // Serialize Request
 118868            string _requestContent = null;
 118869            if(item != null)
 18870            {
 118871                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(item, Client.SerializationSettings)
 118872                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 118873                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 18874            }
 18875            // Set Credentials
 118876            if (Client.Credentials != null)
 18877            {
 118878                cancellationToken.ThrowIfCancellationRequested();
 118879                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 18880            }
 18881            // Send Request
 118882            if (_shouldTrace)
 18883            {
 018884                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 18885            }
 118886            cancellationToken.ThrowIfCancellationRequested();
 118887            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 118888            if (_shouldTrace)
 18889            {
 018890                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 18891            }
 118892            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 118893            cancellationToken.ThrowIfCancellationRequested();
 118894            string _responseContent = null;
 118895            if ((int)_statusCode != 200)
 18896            {
 018897                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 18898                try
 18899                {
 018900                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 018901                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 018902                    if (_errorBody != null)
 18903                    {
 018904                        ex.Body = _errorBody;
 18905                    }
 018906                }
 018907                catch (JsonException)
 18908                {
 18909                    // Ignore the exception
 018910                }
 018911                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 018912                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 018913                if (_shouldTrace)
 18914                {
 018915                    ServiceClientTracing.Error(_invocationId, ex);
 18916                }
 018917                _httpRequest.Dispose();
 018918                if (_httpResponse != null)
 18919                {
 018920                    _httpResponse.Dispose();
 18921                }
 018922                throw ex;
 18923            }
 18924            // Create Result
 118925            var _result = new HttpOperationResponse<OperationStatus>();
 118926            _result.Request = _httpRequest;
 118927            _result.Response = _httpResponse;
 18928            // Deserialize Response
 118929            if ((int)_statusCode == 200)
 18930            {
 118931                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 18932                try
 18933                {
 118934                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 118935                }
 018936                catch (JsonException ex)
 18937                {
 018938                    _httpRequest.Dispose();
 018939                    if (_httpResponse != null)
 18940                    {
 018941                        _httpResponse.Dispose();
 18942                    }
 018943                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 18944                }
 18945            }
 118946            if (_shouldTrace)
 18947            {
 018948                ServiceClientTracing.Exit(_invocationId, _result);
 18949            }
 118950            return _result;
 118951        }
 18952
 18953        /// <summary>
 18954        /// Delete an item from the explicit (exception) list for a Pattern.any entity
 18955        /// in a version of the application.
 18956        /// </summary>
 18957        /// <param name='appId'>
 18958        /// The application ID.
 18959        /// </param>
 18960        /// <param name='versionId'>
 18961        /// The version ID.
 18962        /// </param>
 18963        /// <param name='entityId'>
 18964        /// The pattern.any entity id.
 18965        /// </param>
 18966        /// <param name='itemId'>
 18967        /// The explicit list item which will be deleted.
 18968        /// </param>
 18969        /// <param name='customHeaders'>
 18970        /// Headers that will be added to request.
 18971        /// </param>
 18972        /// <param name='cancellationToken'>
 18973        /// The cancellation token.
 18974        /// </param>
 18975        /// <exception cref="ErrorResponseException">
 18976        /// Thrown when the operation returned an invalid status code
 18977        /// </exception>
 18978        /// <exception cref="SerializationException">
 18979        /// Thrown when unable to deserialize the response
 18980        /// </exception>
 18981        /// <exception cref="ValidationException">
 18982        /// Thrown when a required parameter is null
 18983        /// </exception>
 18984        /// <exception cref="System.ArgumentNullException">
 18985        /// Thrown when a required parameter is null
 18986        /// </exception>
 18987        /// <return>
 18988        /// A response object containing the response body and response headers.
 18989        /// </return>
 18990        public async Task<HttpOperationResponse<OperationStatus>> DeleteExplicitListItemWithHttpMessagesAsync(System.Gui
 18991        {
 118992            if (Client.Endpoint == null)
 18993            {
 018994                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 18995            }
 118996            if (versionId == null)
 18997            {
 018998                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 18999            }
 19000            // Tracing
 119001            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 119002            string _invocationId = null;
 119003            if (_shouldTrace)
 19004            {
 019005                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 019006                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 019007                tracingParameters.Add("appId", appId);
 019008                tracingParameters.Add("versionId", versionId);
 019009                tracingParameters.Add("entityId", entityId);
 019010                tracingParameters.Add("itemId", itemId);
 019011                tracingParameters.Add("cancellationToken", cancellationToken);
 019012                ServiceClientTracing.Enter(_invocationId, this, "DeleteExplicitListItem", tracingParameters);
 19013            }
 19014            // Construct URL
 119015            var _baseUrl = Client.BaseUri;
 119016            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent
 119017            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 119018            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 119019            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 119020            _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb
 119021            _url = _url.Replace("{itemId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje
 19022            // Create HTTP transport objects
 119023            var _httpRequest = new HttpRequestMessage();
 119024            HttpResponseMessage _httpResponse = null;
 119025            _httpRequest.Method = new HttpMethod("DELETE");
 119026            _httpRequest.RequestUri = new System.Uri(_url);
 19027            // Set Headers
 19028
 19029
 119030            if (customHeaders != null)
 19031            {
 019032                foreach(var _header in customHeaders)
 19033                {
 019034                    if (_httpRequest.Headers.Contains(_header.Key))
 19035                    {
 019036                        _httpRequest.Headers.Remove(_header.Key);
 19037                    }
 019038                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 19039                }
 19040            }
 19041
 19042            // Serialize Request
 119043            string _requestContent = null;
 19044            // Set Credentials
 119045            if (Client.Credentials != null)
 19046            {
 119047                cancellationToken.ThrowIfCancellationRequested();
 119048                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 19049            }
 19050            // Send Request
 119051            if (_shouldTrace)
 19052            {
 019053                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 19054            }
 119055            cancellationToken.ThrowIfCancellationRequested();
 119056            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 119057            if (_shouldTrace)
 19058            {
 019059                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 19060            }
 119061            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 119062            cancellationToken.ThrowIfCancellationRequested();
 119063            string _responseContent = null;
 119064            if ((int)_statusCode != 200)
 19065            {
 019066                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 19067                try
 19068                {
 019069                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 019070                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 019071                    if (_errorBody != null)
 19072                    {
 019073                        ex.Body = _errorBody;
 19074                    }
 019075                }
 019076                catch (JsonException)
 19077                {
 19078                    // Ignore the exception
 019079                }
 019080                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 019081                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 019082                if (_shouldTrace)
 19083                {
 019084                    ServiceClientTracing.Error(_invocationId, ex);
 19085                }
 019086                _httpRequest.Dispose();
 019087                if (_httpResponse != null)
 19088                {
 019089                    _httpResponse.Dispose();
 19090                }
 019091                throw ex;
 19092            }
 19093            // Create Result
 119094            var _result = new HttpOperationResponse<OperationStatus>();
 119095            _result.Request = _httpRequest;
 119096            _result.Response = _httpResponse;
 19097            // Deserialize Response
 119098            if ((int)_statusCode == 200)
 19099            {
 119100                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 19101                try
 19102                {
 119103                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 119104                }
 019105                catch (JsonException ex)
 19106                {
 019107                    _httpRequest.Dispose();
 019108                    if (_httpResponse != null)
 19109                    {
 019110                        _httpResponse.Dispose();
 19111                    }
 019112                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 19113                }
 19114            }
 119115            if (_shouldTrace)
 19116            {
 019117                ServiceClientTracing.Exit(_invocationId, _result);
 19118            }
 119119            return _result;
 119120        }
 19121
 19122    }
 19123}

Methods/Properties

.ctor(...)
get_Client()
AddIntentWithHttpMessagesAsync()
ListIntentsWithHttpMessagesAsync()
AddEntityWithHttpMessagesAsync()
ListEntitiesWithHttpMessagesAsync()
ListHierarchicalEntitiesWithHttpMessagesAsync()
ListCompositeEntitiesWithHttpMessagesAsync()
ListClosedListsWithHttpMessagesAsync()
AddClosedListWithHttpMessagesAsync()
AddPrebuiltWithHttpMessagesAsync()
ListPrebuiltsWithHttpMessagesAsync()
ListPrebuiltEntitiesWithHttpMessagesAsync()
ListModelsWithHttpMessagesAsync()
ExamplesMethodWithHttpMessagesAsync()
GetIntentWithHttpMessagesAsync()
UpdateIntentWithHttpMessagesAsync()
DeleteIntentWithHttpMessagesAsync()
GetEntityWithHttpMessagesAsync()
DeleteEntityWithHttpMessagesAsync()
UpdateEntityChildWithHttpMessagesAsync()
GetIntentFeaturesWithHttpMessagesAsync()
ReplaceIntentFeaturesWithHttpMessagesAsync()
DeleteIntentFeatureWithHttpMessagesAsync()
GetEntityFeaturesWithHttpMessagesAsync()
ReplaceEntityFeaturesWithHttpMessagesAsync()
DeleteEntityFeatureWithHttpMessagesAsync()
GetHierarchicalEntityWithHttpMessagesAsync()
UpdateHierarchicalEntityWithHttpMessagesAsync()
DeleteHierarchicalEntityWithHttpMessagesAsync()
GetCompositeEntityWithHttpMessagesAsync()
UpdateCompositeEntityWithHttpMessagesAsync()
DeleteCompositeEntityWithHttpMessagesAsync()
GetClosedListWithHttpMessagesAsync()
UpdateClosedListWithHttpMessagesAsync()
PatchClosedListWithHttpMessagesAsync()
DeleteClosedListWithHttpMessagesAsync()
GetPrebuiltWithHttpMessagesAsync()
DeletePrebuiltWithHttpMessagesAsync()
DeleteSubListWithHttpMessagesAsync()
UpdateSubListWithHttpMessagesAsync()
ListIntentSuggestionsWithHttpMessagesAsync()
ListEntitySuggestionsWithHttpMessagesAsync()
AddSubListWithHttpMessagesAsync()
AddCustomPrebuiltDomainWithHttpMessagesAsync()
AddCustomPrebuiltIntentWithHttpMessagesAsync()
ListCustomPrebuiltIntentsWithHttpMessagesAsync()
AddCustomPrebuiltEntityWithHttpMessagesAsync()
ListCustomPrebuiltEntitiesWithHttpMessagesAsync()
ListCustomPrebuiltModelsWithHttpMessagesAsync()
DeleteCustomPrebuiltDomainWithHttpMessagesAsync()
AddEntityChildWithHttpMessagesAsync()
GetHierarchicalEntityChildWithHttpMessagesAsync()
UpdateHierarchicalEntityChildWithHttpMessagesAsync()
DeleteHierarchicalEntityChildWithHttpMessagesAsync()
AddCompositeEntityChildWithHttpMessagesAsync()
DeleteCompositeEntityChildWithHttpMessagesAsync()
ListRegexEntityInfosWithHttpMessagesAsync()
CreateRegexEntityModelWithHttpMessagesAsync()
ListPatternAnyEntityInfosWithHttpMessagesAsync()
CreatePatternAnyEntityModelWithHttpMessagesAsync()
ListEntityRolesWithHttpMessagesAsync()
CreateEntityRoleWithHttpMessagesAsync()
ListPrebuiltEntityRolesWithHttpMessagesAsync()
CreatePrebuiltEntityRoleWithHttpMessagesAsync()
ListClosedListEntityRolesWithHttpMessagesAsync()
CreateClosedListEntityRoleWithHttpMessagesAsync()
ListRegexEntityRolesWithHttpMessagesAsync()
CreateRegexEntityRoleWithHttpMessagesAsync()
ListCompositeEntityRolesWithHttpMessagesAsync()
CreateCompositeEntityRoleWithHttpMessagesAsync()
ListPatternAnyEntityRolesWithHttpMessagesAsync()
CreatePatternAnyEntityRoleWithHttpMessagesAsync()
ListHierarchicalEntityRolesWithHttpMessagesAsync()
CreateHierarchicalEntityRoleWithHttpMessagesAsync()
ListCustomPrebuiltEntityRolesWithHttpMessagesAsync()
CreateCustomPrebuiltEntityRoleWithHttpMessagesAsync()
GetExplicitListWithHttpMessagesAsync()
AddExplicitListItemWithHttpMessagesAsync()
GetRegexEntityEntityInfoWithHttpMessagesAsync()
UpdateRegexEntityModelWithHttpMessagesAsync()
DeleteRegexEntityModelWithHttpMessagesAsync()
GetPatternAnyEntityInfoWithHttpMessagesAsync()
UpdatePatternAnyEntityModelWithHttpMessagesAsync()
DeletePatternAnyEntityModelWithHttpMessagesAsync()
GetEntityRoleWithHttpMessagesAsync()
UpdateEntityRoleWithHttpMessagesAsync()
DeleteEntityRoleWithHttpMessagesAsync()
GetPrebuiltEntityRoleWithHttpMessagesAsync()
UpdatePrebuiltEntityRoleWithHttpMessagesAsync()
DeletePrebuiltEntityRoleWithHttpMessagesAsync()
GetClosedListEntityRoleWithHttpMessagesAsync()
UpdateClosedListEntityRoleWithHttpMessagesAsync()
DeleteClosedListEntityRoleWithHttpMessagesAsync()
GetRegexEntityRoleWithHttpMessagesAsync()
UpdateRegexEntityRoleWithHttpMessagesAsync()
DeleteRegexEntityRoleWithHttpMessagesAsync()
GetCompositeEntityRoleWithHttpMessagesAsync()
UpdateCompositeEntityRoleWithHttpMessagesAsync()
DeleteCompositeEntityRoleWithHttpMessagesAsync()
GetPatternAnyEntityRoleWithHttpMessagesAsync()
UpdatePatternAnyEntityRoleWithHttpMessagesAsync()
DeletePatternAnyEntityRoleWithHttpMessagesAsync()
GetHierarchicalEntityRoleWithHttpMessagesAsync()
UpdateHierarchicalEntityRoleWithHttpMessagesAsync()
DeleteHierarchicalEntityRoleWithHttpMessagesAsync()
GetCustomEntityRoleWithHttpMessagesAsync()
UpdateCustomPrebuiltEntityRoleWithHttpMessagesAsync()
DeleteCustomEntityRoleWithHttpMessagesAsync()
GetExplicitListItemWithHttpMessagesAsync()
UpdateExplicitListItemWithHttpMessagesAsync()
DeleteExplicitListItemWithHttpMessagesAsync()