< Summary

Class:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Examples
Assembly:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Examples.cs
Covered lines:190
Uncovered lines:163
Coverable lines:353
Total lines:806
Line coverage:53.8% (190 of 353)
Covered branches:82
Total branches:174
Branch coverage:47.1% (82 of 174)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
AddWithHttpMessagesAsync()-54.65%47.62%
BatchWithHttpMessagesAsync()-53.68%50%
ListWithHttpMessagesAsync()-53.85%50%
DeleteWithHttpMessagesAsync()-50.67%38.24%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Examples.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    /// Examples operations.
 27    /// </summary>
 28    public partial class Examples : IServiceOperations<LUISAuthoringClient>, IExamples
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the Examples 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 Examples(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>
 25951        public LUISAuthoringClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Adds a labeled example utterance in a version of the application.
 55        /// </summary>
 56        /// <param name='appId'>
 57        /// The application ID.
 58        /// </param>
 59        /// <param name='versionId'>
 60        /// The version ID.
 61        /// </param>
 62        /// <param name='exampleLabelObject'>
 63        /// A labeled example utterance with the expected intent and entities.
 64        /// </param>
 65        /// <param name='enableNestedChildren'>
 66        /// Toggles nested/flat format
 67        /// </param>
 68        /// <param name='customHeaders'>
 69        /// Headers that will be added to request.
 70        /// </param>
 71        /// <param name='cancellationToken'>
 72        /// The cancellation token.
 73        /// </param>
 74        /// <exception cref="ErrorResponseException">
 75        /// Thrown when the operation returned an invalid status code
 76        /// </exception>
 77        /// <exception cref="SerializationException">
 78        /// Thrown when unable to deserialize the response
 79        /// </exception>
 80        /// <exception cref="ValidationException">
 81        /// Thrown when a required parameter is null
 82        /// </exception>
 83        /// <exception cref="System.ArgumentNullException">
 84        /// Thrown when a required parameter is null
 85        /// </exception>
 86        /// <return>
 87        /// A response object containing the response body and response headers.
 88        /// </return>
 89        public async Task<HttpOperationResponse<LabelExampleResponse>> AddWithHttpMessagesAsync(System.Guid appId, strin
 90        {
 391            if (Client.Endpoint == null)
 92            {
 093                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 94            }
 395            if (versionId == null)
 96            {
 097                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 98            }
 399            if (exampleLabelObject == null)
 100            {
 0101                throw new ValidationException(ValidationRules.CannotBeNull, "exampleLabelObject");
 102            }
 103            // Tracing
 3104            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 3105            string _invocationId = null;
 3106            if (_shouldTrace)
 107            {
 0108                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0109                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0110                tracingParameters.Add("appId", appId);
 0111                tracingParameters.Add("versionId", versionId);
 0112                tracingParameters.Add("enableNestedChildren", enableNestedChildren);
 0113                tracingParameters.Add("exampleLabelObject", exampleLabelObject);
 0114                tracingParameters.Add("cancellationToken", cancellationToken);
 0115                ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters);
 116            }
 117            // Construct URL
 3118            var _baseUrl = Client.BaseUri;
 3119            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/example";
 3120            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 3121            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 3122            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 3123            List<string> _queryParameters = new List<string>();
 3124            if (enableNestedChildren != null)
 125            {
 3126                _queryParameters.Add(string.Format("enableNestedChildren={0}", System.Uri.EscapeDataString(Rest.Serializ
 127            }
 3128            if (_queryParameters.Count > 0)
 129            {
 3130                _url += "?" + string.Join("&", _queryParameters);
 131            }
 132            // Create HTTP transport objects
 3133            var _httpRequest = new HttpRequestMessage();
 3134            HttpResponseMessage _httpResponse = null;
 3135            _httpRequest.Method = new HttpMethod("POST");
 3136            _httpRequest.RequestUri = new System.Uri(_url);
 137            // Set Headers
 138
 139
 3140            if (customHeaders != null)
 141            {
 0142                foreach(var _header in customHeaders)
 143                {
 0144                    if (_httpRequest.Headers.Contains(_header.Key))
 145                    {
 0146                        _httpRequest.Headers.Remove(_header.Key);
 147                    }
 0148                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 149                }
 150            }
 151
 152            // Serialize Request
 3153            string _requestContent = null;
 3154            if(exampleLabelObject != null)
 155            {
 3156                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(exampleLabelObject, Client.Serializ
 3157                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 3158                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 159            }
 160            // Set Credentials
 3161            if (Client.Credentials != null)
 162            {
 3163                cancellationToken.ThrowIfCancellationRequested();
 3164                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 165            }
 166            // Send Request
 3167            if (_shouldTrace)
 168            {
 0169                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 170            }
 3171            cancellationToken.ThrowIfCancellationRequested();
 3172            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3173            if (_shouldTrace)
 174            {
 0175                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 176            }
 3177            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 3178            cancellationToken.ThrowIfCancellationRequested();
 3179            string _responseContent = null;
 3180            if ((int)_statusCode != 201)
 181            {
 0182                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 183                try
 184                {
 0185                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0186                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0187                    if (_errorBody != null)
 188                    {
 0189                        ex.Body = _errorBody;
 190                    }
 0191                }
 0192                catch (JsonException)
 193                {
 194                    // Ignore the exception
 0195                }
 0196                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0197                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0198                if (_shouldTrace)
 199                {
 0200                    ServiceClientTracing.Error(_invocationId, ex);
 201                }
 0202                _httpRequest.Dispose();
 0203                if (_httpResponse != null)
 204                {
 0205                    _httpResponse.Dispose();
 206                }
 0207                throw ex;
 208            }
 209            // Create Result
 3210            var _result = new HttpOperationResponse<LabelExampleResponse>();
 3211            _result.Request = _httpRequest;
 3212            _result.Response = _httpResponse;
 213            // Deserialize Response
 3214            if ((int)_statusCode == 201)
 215            {
 3216                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 217                try
 218                {
 3219                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<LabelExampleResponse>(_responseC
 3220                }
 0221                catch (JsonException ex)
 222                {
 0223                    _httpRequest.Dispose();
 0224                    if (_httpResponse != null)
 225                    {
 0226                        _httpResponse.Dispose();
 227                    }
 0228                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 229                }
 230            }
 3231            if (_shouldTrace)
 232            {
 0233                ServiceClientTracing.Exit(_invocationId, _result);
 234            }
 3235            return _result;
 3236        }
 237
 238        /// <summary>
 239        /// Adds a batch of labeled example utterances to a version of the application.
 240        /// </summary>
 241        /// <param name='appId'>
 242        /// The application ID.
 243        /// </param>
 244        /// <param name='versionId'>
 245        /// The version ID.
 246        /// </param>
 247        /// <param name='exampleLabelObjectArray'>
 248        /// Array of example utterances.
 249        /// </param>
 250        /// <param name='enableNestedChildren'>
 251        /// Toggles nested/flat format
 252        /// </param>
 253        /// <param name='customHeaders'>
 254        /// Headers that will be added to request.
 255        /// </param>
 256        /// <param name='cancellationToken'>
 257        /// The cancellation token.
 258        /// </param>
 259        /// <exception cref="ErrorResponseException">
 260        /// Thrown when the operation returned an invalid status code
 261        /// </exception>
 262        /// <exception cref="SerializationException">
 263        /// Thrown when unable to deserialize the response
 264        /// </exception>
 265        /// <exception cref="ValidationException">
 266        /// Thrown when a required parameter is null
 267        /// </exception>
 268        /// <exception cref="System.ArgumentNullException">
 269        /// Thrown when a required parameter is null
 270        /// </exception>
 271        /// <return>
 272        /// A response object containing the response body and response headers.
 273        /// </return>
 274        public async Task<HttpOperationResponse<IList<BatchLabelExample>>> BatchWithHttpMessagesAsync(System.Guid appId,
 275        {
 2276            if (Client.Endpoint == null)
 277            {
 0278                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 279            }
 2280            if (versionId == null)
 281            {
 0282                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 283            }
 2284            if (exampleLabelObjectArray == null)
 285            {
 0286                throw new ValidationException(ValidationRules.CannotBeNull, "exampleLabelObjectArray");
 287            }
 288            // Tracing
 2289            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2290            string _invocationId = null;
 2291            if (_shouldTrace)
 292            {
 0293                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0294                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0295                tracingParameters.Add("appId", appId);
 0296                tracingParameters.Add("versionId", versionId);
 0297                tracingParameters.Add("enableNestedChildren", enableNestedChildren);
 0298                tracingParameters.Add("exampleLabelObjectArray", exampleLabelObjectArray);
 0299                tracingParameters.Add("cancellationToken", cancellationToken);
 0300                ServiceClientTracing.Enter(_invocationId, this, "Batch", tracingParameters);
 301            }
 302            // Construct URL
 2303            var _baseUrl = Client.BaseUri;
 2304            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/examples";
 2305            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 2306            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 2307            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 2308            List<string> _queryParameters = new List<string>();
 2309            if (enableNestedChildren != null)
 310            {
 2311                _queryParameters.Add(string.Format("enableNestedChildren={0}", System.Uri.EscapeDataString(Rest.Serializ
 312            }
 2313            if (_queryParameters.Count > 0)
 314            {
 2315                _url += "?" + string.Join("&", _queryParameters);
 316            }
 317            // Create HTTP transport objects
 2318            var _httpRequest = new HttpRequestMessage();
 2319            HttpResponseMessage _httpResponse = null;
 2320            _httpRequest.Method = new HttpMethod("POST");
 2321            _httpRequest.RequestUri = new System.Uri(_url);
 322            // Set Headers
 323
 324
 2325            if (customHeaders != null)
 326            {
 0327                foreach(var _header in customHeaders)
 328                {
 0329                    if (_httpRequest.Headers.Contains(_header.Key))
 330                    {
 0331                        _httpRequest.Headers.Remove(_header.Key);
 332                    }
 0333                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 334                }
 335            }
 336
 337            // Serialize Request
 2338            string _requestContent = null;
 2339            if(exampleLabelObjectArray != null)
 340            {
 2341                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(exampleLabelObjectArray, Client.Ser
 2342                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 2343                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 344            }
 345            // Set Credentials
 2346            if (Client.Credentials != null)
 347            {
 2348                cancellationToken.ThrowIfCancellationRequested();
 2349                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 350            }
 351            // Send Request
 2352            if (_shouldTrace)
 353            {
 0354                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 355            }
 2356            cancellationToken.ThrowIfCancellationRequested();
 2357            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2358            if (_shouldTrace)
 359            {
 0360                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 361            }
 2362            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2363            cancellationToken.ThrowIfCancellationRequested();
 2364            string _responseContent = null;
 2365            if ((int)_statusCode != 201 && (int)_statusCode != 207)
 366            {
 0367                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 368                try
 369                {
 0370                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0371                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0372                    if (_errorBody != null)
 373                    {
 0374                        ex.Body = _errorBody;
 375                    }
 0376                }
 0377                catch (JsonException)
 378                {
 379                    // Ignore the exception
 0380                }
 0381                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0382                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0383                if (_shouldTrace)
 384                {
 0385                    ServiceClientTracing.Error(_invocationId, ex);
 386                }
 0387                _httpRequest.Dispose();
 0388                if (_httpResponse != null)
 389                {
 0390                    _httpResponse.Dispose();
 391                }
 0392                throw ex;
 393            }
 394            // Create Result
 2395            var _result = new HttpOperationResponse<IList<BatchLabelExample>>();
 2396            _result.Request = _httpRequest;
 2397            _result.Response = _httpResponse;
 398            // Deserialize Response
 2399            if ((int)_statusCode == 201)
 400            {
 1401                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 402                try
 403                {
 1404                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<BatchLabelExample>>(_respo
 1405                }
 0406                catch (JsonException ex)
 407                {
 0408                    _httpRequest.Dispose();
 0409                    if (_httpResponse != null)
 410                    {
 0411                        _httpResponse.Dispose();
 412                    }
 0413                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 414                }
 415            }
 416            // Deserialize Response
 2417            if ((int)_statusCode == 207)
 418            {
 1419                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 420                try
 421                {
 1422                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<BatchLabelExample>>(_respo
 1423                }
 0424                catch (JsonException ex)
 425                {
 0426                    _httpRequest.Dispose();
 0427                    if (_httpResponse != null)
 428                    {
 0429                        _httpResponse.Dispose();
 430                    }
 0431                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 432                }
 433            }
 2434            if (_shouldTrace)
 435            {
 0436                ServiceClientTracing.Exit(_invocationId, _result);
 437            }
 2438            return _result;
 2439        }
 440
 441        /// <summary>
 442        /// Returns example utterances to be reviewed from a version of the
 443        /// application.
 444        /// </summary>
 445        /// <param name='appId'>
 446        /// The application ID.
 447        /// </param>
 448        /// <param name='versionId'>
 449        /// The version ID.
 450        /// </param>
 451        /// <param name='skip'>
 452        /// The number of entries to skip. Default value is 0.
 453        /// </param>
 454        /// <param name='take'>
 455        /// The number of entries to return. Maximum page size is 500. Default is 100.
 456        /// </param>
 457        /// <param name='enableNestedChildren'>
 458        /// Toggles nested/flat format
 459        /// </param>
 460        /// <param name='customHeaders'>
 461        /// Headers that will be added to request.
 462        /// </param>
 463        /// <param name='cancellationToken'>
 464        /// The cancellation token.
 465        /// </param>
 466        /// <exception cref="ErrorResponseException">
 467        /// Thrown when the operation returned an invalid status code
 468        /// </exception>
 469        /// <exception cref="SerializationException">
 470        /// Thrown when unable to deserialize the response
 471        /// </exception>
 472        /// <exception cref="ValidationException">
 473        /// Thrown when a required parameter is null
 474        /// </exception>
 475        /// <exception cref="System.ArgumentNullException">
 476        /// Thrown when a required parameter is null
 477        /// </exception>
 478        /// <return>
 479        /// A response object containing the response body and response headers.
 480        /// </return>
 481        public async Task<HttpOperationResponse<IList<LabeledUtterance>>> ListWithHttpMessagesAsync(System.Guid appId, s
 482        {
 4483            if (Client.Endpoint == null)
 484            {
 0485                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 486            }
 4487            if (versionId == null)
 488            {
 0489                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 490            }
 4491            if (skip < 0)
 492            {
 0493                throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0);
 494            }
 4495            if (take > 500)
 496            {
 0497                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500);
 498            }
 4499            if (take < 0)
 500            {
 0501                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 502            }
 503            // Tracing
 4504            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 4505            string _invocationId = null;
 4506            if (_shouldTrace)
 507            {
 0508                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0509                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0510                tracingParameters.Add("appId", appId);
 0511                tracingParameters.Add("versionId", versionId);
 0512                tracingParameters.Add("skip", skip);
 0513                tracingParameters.Add("take", take);
 0514                tracingParameters.Add("enableNestedChildren", enableNestedChildren);
 0515                tracingParameters.Add("cancellationToken", cancellationToken);
 0516                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 517            }
 518            // Construct URL
 4519            var _baseUrl = Client.BaseUri;
 4520            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/examples";
 4521            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 4522            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 4523            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 4524            List<string> _queryParameters = new List<string>();
 4525            if (skip != null)
 526            {
 4527                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 528            }
 4529            if (take != null)
 530            {
 4531                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo
 532            }
 4533            if (enableNestedChildren != null)
 534            {
 4535                _queryParameters.Add(string.Format("enableNestedChildren={0}", System.Uri.EscapeDataString(Rest.Serializ
 536            }
 4537            if (_queryParameters.Count > 0)
 538            {
 4539                _url += "?" + string.Join("&", _queryParameters);
 540            }
 541            // Create HTTP transport objects
 4542            var _httpRequest = new HttpRequestMessage();
 4543            HttpResponseMessage _httpResponse = null;
 4544            _httpRequest.Method = new HttpMethod("GET");
 4545            _httpRequest.RequestUri = new System.Uri(_url);
 546            // Set Headers
 547
 548
 4549            if (customHeaders != null)
 550            {
 0551                foreach(var _header in customHeaders)
 552                {
 0553                    if (_httpRequest.Headers.Contains(_header.Key))
 554                    {
 0555                        _httpRequest.Headers.Remove(_header.Key);
 556                    }
 0557                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 558                }
 559            }
 560
 561            // Serialize Request
 4562            string _requestContent = null;
 563            // Set Credentials
 4564            if (Client.Credentials != null)
 565            {
 4566                cancellationToken.ThrowIfCancellationRequested();
 4567                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 568            }
 569            // Send Request
 4570            if (_shouldTrace)
 571            {
 0572                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 573            }
 4574            cancellationToken.ThrowIfCancellationRequested();
 4575            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4576            if (_shouldTrace)
 577            {
 0578                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 579            }
 4580            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 4581            cancellationToken.ThrowIfCancellationRequested();
 4582            string _responseContent = null;
 4583            if ((int)_statusCode != 200)
 584            {
 0585                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 586                try
 587                {
 0588                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0589                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0590                    if (_errorBody != null)
 591                    {
 0592                        ex.Body = _errorBody;
 593                    }
 0594                }
 0595                catch (JsonException)
 596                {
 597                    // Ignore the exception
 0598                }
 0599                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0600                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0601                if (_shouldTrace)
 602                {
 0603                    ServiceClientTracing.Error(_invocationId, ex);
 604                }
 0605                _httpRequest.Dispose();
 0606                if (_httpResponse != null)
 607                {
 0608                    _httpResponse.Dispose();
 609                }
 0610                throw ex;
 611            }
 612            // Create Result
 4613            var _result = new HttpOperationResponse<IList<LabeledUtterance>>();
 4614            _result.Request = _httpRequest;
 4615            _result.Response = _httpResponse;
 616            // Deserialize Response
 4617            if ((int)_statusCode == 200)
 618            {
 4619                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 620                try
 621                {
 4622                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<LabeledUtterance>>(_respon
 4623                }
 0624                catch (JsonException ex)
 625                {
 0626                    _httpRequest.Dispose();
 0627                    if (_httpResponse != null)
 628                    {
 0629                        _httpResponse.Dispose();
 630                    }
 0631                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 632                }
 633            }
 4634            if (_shouldTrace)
 635            {
 0636                ServiceClientTracing.Exit(_invocationId, _result);
 637            }
 4638            return _result;
 4639        }
 640
 641        /// <summary>
 642        /// Deletes the labeled example utterances with the specified ID from a version
 643        /// of the application.
 644        /// </summary>
 645        /// <param name='appId'>
 646        /// The application ID.
 647        /// </param>
 648        /// <param name='versionId'>
 649        /// The version ID.
 650        /// </param>
 651        /// <param name='exampleId'>
 652        /// The example ID.
 653        /// </param>
 654        /// <param name='customHeaders'>
 655        /// Headers that will be added to request.
 656        /// </param>
 657        /// <param name='cancellationToken'>
 658        /// The cancellation token.
 659        /// </param>
 660        /// <exception cref="ErrorResponseException">
 661        /// Thrown when the operation returned an invalid status code
 662        /// </exception>
 663        /// <exception cref="SerializationException">
 664        /// Thrown when unable to deserialize the response
 665        /// </exception>
 666        /// <exception cref="ValidationException">
 667        /// Thrown when a required parameter is null
 668        /// </exception>
 669        /// <exception cref="System.ArgumentNullException">
 670        /// Thrown when a required parameter is null
 671        /// </exception>
 672        /// <return>
 673        /// A response object containing the response body and response headers.
 674        /// </return>
 675        public async Task<HttpOperationResponse<OperationStatus>> DeleteWithHttpMessagesAsync(System.Guid appId, string 
 676        {
 1677            if (Client.Endpoint == null)
 678            {
 0679                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 680            }
 1681            if (versionId == null)
 682            {
 0683                throw new ValidationException(ValidationRules.CannotBeNull, "versionId");
 684            }
 685            // Tracing
 1686            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 1687            string _invocationId = null;
 1688            if (_shouldTrace)
 689            {
 0690                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0691                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0692                tracingParameters.Add("appId", appId);
 0693                tracingParameters.Add("versionId", versionId);
 0694                tracingParameters.Add("exampleId", exampleId);
 0695                tracingParameters.Add("cancellationToken", cancellationToken);
 0696                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 697            }
 698            // Construct URL
 1699            var _baseUrl = Client.BaseUri;
 1700            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/examples/{exa
 1701            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 1702            _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec
 1703            _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId));
 1704            _url = _url.Replace("{exampleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO
 705            // Create HTTP transport objects
 1706            var _httpRequest = new HttpRequestMessage();
 1707            HttpResponseMessage _httpResponse = null;
 1708            _httpRequest.Method = new HttpMethod("DELETE");
 1709            _httpRequest.RequestUri = new System.Uri(_url);
 710            // Set Headers
 711
 712
 1713            if (customHeaders != null)
 714            {
 0715                foreach(var _header in customHeaders)
 716                {
 0717                    if (_httpRequest.Headers.Contains(_header.Key))
 718                    {
 0719                        _httpRequest.Headers.Remove(_header.Key);
 720                    }
 0721                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 722                }
 723            }
 724
 725            // Serialize Request
 1726            string _requestContent = null;
 727            // Set Credentials
 1728            if (Client.Credentials != null)
 729            {
 1730                cancellationToken.ThrowIfCancellationRequested();
 1731                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 732            }
 733            // Send Request
 1734            if (_shouldTrace)
 735            {
 0736                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 737            }
 1738            cancellationToken.ThrowIfCancellationRequested();
 1739            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1740            if (_shouldTrace)
 741            {
 0742                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 743            }
 1744            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 1745            cancellationToken.ThrowIfCancellationRequested();
 1746            string _responseContent = null;
 1747            if ((int)_statusCode != 200)
 748            {
 0749                var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st
 750                try
 751                {
 0752                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0753                    ErrorResponse _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res
 0754                    if (_errorBody != null)
 755                    {
 0756                        ex.Body = _errorBody;
 757                    }
 0758                }
 0759                catch (JsonException)
 760                {
 761                    // Ignore the exception
 0762                }
 0763                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0764                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0765                if (_shouldTrace)
 766                {
 0767                    ServiceClientTracing.Error(_invocationId, ex);
 768                }
 0769                _httpRequest.Dispose();
 0770                if (_httpResponse != null)
 771                {
 0772                    _httpResponse.Dispose();
 773                }
 0774                throw ex;
 775            }
 776            // Create Result
 1777            var _result = new HttpOperationResponse<OperationStatus>();
 1778            _result.Request = _httpRequest;
 1779            _result.Response = _httpResponse;
 780            // Deserialize Response
 1781            if ((int)_statusCode == 200)
 782            {
 1783                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 784                try
 785                {
 1786                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten
 1787                }
 0788                catch (JsonException ex)
 789                {
 0790                    _httpRequest.Dispose();
 0791                    if (_httpResponse != null)
 792                    {
 0793                        _httpResponse.Dispose();
 794                    }
 0795                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 796                }
 797            }
 1798            if (_shouldTrace)
 799            {
 0800                ServiceClientTracing.Exit(_invocationId, _result);
 801            }
 1802            return _result;
 1803        }
 804
 805    }
 806}