< Summary

Class:Microsoft.Azure.CognitiveServices.ContentModerator.ListManagementTerm
Assembly:Microsoft.Azure.CognitiveServices.Vision.ContentModerator
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.ContentModerator\src\Generated\ListManagementTerm.cs
Covered lines:4
Uncovered lines:332
Coverable lines:336
Total lines:764
Line coverage:1.1% (4 of 336)
Covered branches:1
Total branches:170
Branch coverage:0.5% (1 of 170)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-0%100%
AddTermWithHttpMessagesAsync()-0%0%
DeleteTermWithHttpMessagesAsync()-0%0%
GetAllTermsWithHttpMessagesAsync()-0%0%
DeleteAllTermsWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.ContentModerator\src\Generated\ListManagementTerm.cs

#LineLine coverage
 1// <auto-generated>
 2// Code generated by Microsoft (R) AutoRest Code Generator.
 3// Changes may cause incorrect behavior and will be lost if the code is
 4// regenerated.
 5// </auto-generated>
 6
 7namespace Microsoft.Azure.CognitiveServices.ContentModerator
 8{
 9    using Microsoft.Rest;
 10    using Models;
 11    using Newtonsoft.Json;
 12    using System.Collections;
 13    using System.Collections.Generic;
 14    using System.IO;
 15    using System.Linq;
 16    using System.Net;
 17    using System.Net.Http;
 18    using System.Threading;
 19    using System.Threading.Tasks;
 20
 21    /// <summary>
 22    /// ListManagementTerm operations.
 23    /// </summary>
 24    public partial class ListManagementTerm : IServiceOperations<ContentModeratorClient>, IListManagementTerm
 25    {
 26        /// <summary>
 27        /// Initializes a new instance of the ListManagementTerm class.
 28        /// </summary>
 29        /// <param name='client'>
 30        /// Reference to the service client.
 31        /// </param>
 32        /// <exception cref="System.ArgumentNullException">
 33        /// Thrown when a required parameter is null
 34        /// </exception>
 535        public ListManagementTerm(ContentModeratorClient client)
 36        {
 537            if (client == null)
 38            {
 039                throw new System.ArgumentNullException("client");
 40            }
 541            Client = client;
 542        }
 43
 44        /// <summary>
 45        /// Gets a reference to the ContentModeratorClient
 46        /// </summary>
 047        public ContentModeratorClient Client { get; private set; }
 48
 49        /// <summary>
 50        /// Add a term to the term list with list Id equal to list Id passed.
 51        /// </summary>
 52        /// <param name='listId'>
 53        /// List Id of the image list.
 54        /// </param>
 55        /// <param name='term'>
 56        /// Term to be deleted
 57        /// </param>
 58        /// <param name='language'>
 59        /// Language of the terms.
 60        /// </param>
 61        /// <param name='customHeaders'>
 62        /// Headers that will be added to request.
 63        /// </param>
 64        /// <param name='cancellationToken'>
 65        /// The cancellation token.
 66        /// </param>
 67        /// <exception cref="APIErrorException">
 68        /// Thrown when the operation returned an invalid status code
 69        /// </exception>
 70        /// <exception cref="SerializationException">
 71        /// Thrown when unable to deserialize the response
 72        /// </exception>
 73        /// <exception cref="ValidationException">
 74        /// Thrown when a required parameter is null
 75        /// </exception>
 76        /// <exception cref="System.ArgumentNullException">
 77        /// Thrown when a required parameter is null
 78        /// </exception>
 79        /// <return>
 80        /// A response object containing the response body and response headers.
 81        /// </return>
 82        public async Task<HttpOperationResponse<object>> AddTermWithHttpMessagesAsync(string listId, string term, string
 83        {
 084            if (Client.Endpoint == null)
 85            {
 086                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 87            }
 088            if (listId == null)
 89            {
 090                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 91            }
 092            if (term == null)
 93            {
 094                throw new ValidationException(ValidationRules.CannotBeNull, "term");
 95            }
 096            if (language == null)
 97            {
 098                throw new ValidationException(ValidationRules.CannotBeNull, "language");
 99            }
 100            // Tracing
 0101            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0102            string _invocationId = null;
 0103            if (_shouldTrace)
 104            {
 0105                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0106                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0107                tracingParameters.Add("listId", listId);
 0108                tracingParameters.Add("term", term);
 0109                tracingParameters.Add("language", language);
 0110                tracingParameters.Add("cancellationToken", cancellationToken);
 0111                ServiceClientTracing.Enter(_invocationId, this, "AddTerm", tracingParameters);
 112            }
 113            // Construct URL
 0114            var _baseUrl = Client.BaseUri;
 0115            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists/{listId}/
 0116            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0117            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 0118            _url = _url.Replace("{term}", System.Uri.EscapeDataString(term));
 0119            List<string> _queryParameters = new List<string>();
 0120            if (language != null)
 121            {
 0122                _queryParameters.Add(string.Format("language={0}", System.Uri.EscapeDataString(language)));
 123            }
 0124            if (_queryParameters.Count > 0)
 125            {
 0126                _url += "?" + string.Join("&", _queryParameters);
 127            }
 128            // Create HTTP transport objects
 0129            var _httpRequest = new HttpRequestMessage();
 0130            HttpResponseMessage _httpResponse = null;
 0131            _httpRequest.Method = new HttpMethod("POST");
 0132            _httpRequest.RequestUri = new System.Uri(_url);
 133            // Set Headers
 134
 135
 0136            if (customHeaders != null)
 137            {
 0138                foreach(var _header in customHeaders)
 139                {
 0140                    if (_httpRequest.Headers.Contains(_header.Key))
 141                    {
 0142                        _httpRequest.Headers.Remove(_header.Key);
 143                    }
 0144                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 145                }
 146            }
 147
 148            // Serialize Request
 0149            string _requestContent = null;
 150            // Set Credentials
 0151            if (Client.Credentials != null)
 152            {
 0153                cancellationToken.ThrowIfCancellationRequested();
 0154                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 155            }
 156            // Send Request
 0157            if (_shouldTrace)
 158            {
 0159                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 160            }
 0161            cancellationToken.ThrowIfCancellationRequested();
 0162            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0163            if (_shouldTrace)
 164            {
 0165                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 166            }
 0167            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0168            cancellationToken.ThrowIfCancellationRequested();
 0169            string _responseContent = null;
 0170            if ((int)_statusCode != 201)
 171            {
 0172                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 173                try
 174                {
 0175                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0176                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0177                    if (_errorBody != null)
 178                    {
 0179                        ex.Body = _errorBody;
 180                    }
 0181                }
 0182                catch (JsonException)
 183                {
 184                    // Ignore the exception
 0185                }
 0186                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0187                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0188                if (_shouldTrace)
 189                {
 0190                    ServiceClientTracing.Error(_invocationId, ex);
 191                }
 0192                _httpRequest.Dispose();
 0193                if (_httpResponse != null)
 194                {
 0195                    _httpResponse.Dispose();
 196                }
 0197                throw ex;
 198            }
 199            // Create Result
 0200            var _result = new HttpOperationResponse<object>();
 0201            _result.Request = _httpRequest;
 0202            _result.Response = _httpResponse;
 203            // Deserialize Response
 0204            if ((int)_statusCode == 201)
 205            {
 0206                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 207                try
 208                {
 0209                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<object>(_responseContent, Client
 0210                }
 0211                catch (JsonException ex)
 212                {
 0213                    _httpRequest.Dispose();
 0214                    if (_httpResponse != null)
 215                    {
 0216                        _httpResponse.Dispose();
 217                    }
 0218                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 219                }
 220            }
 0221            if (_shouldTrace)
 222            {
 0223                ServiceClientTracing.Exit(_invocationId, _result);
 224            }
 0225            return _result;
 0226        }
 227
 228        /// <summary>
 229        /// Deletes a term from the list with list Id equal to the list Id passed.
 230        /// </summary>
 231        /// <param name='listId'>
 232        /// List Id of the image list.
 233        /// </param>
 234        /// <param name='term'>
 235        /// Term to be deleted
 236        /// </param>
 237        /// <param name='language'>
 238        /// Language of the terms.
 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="APIErrorException">
 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<string>> DeleteTermWithHttpMessagesAsync(string listId, string term, str
 262        {
 0263            if (Client.Endpoint == null)
 264            {
 0265                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 266            }
 0267            if (listId == null)
 268            {
 0269                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 270            }
 0271            if (term == null)
 272            {
 0273                throw new ValidationException(ValidationRules.CannotBeNull, "term");
 274            }
 0275            if (language == null)
 276            {
 0277                throw new ValidationException(ValidationRules.CannotBeNull, "language");
 278            }
 279            // Tracing
 0280            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0281            string _invocationId = null;
 0282            if (_shouldTrace)
 283            {
 0284                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0285                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0286                tracingParameters.Add("listId", listId);
 0287                tracingParameters.Add("term", term);
 0288                tracingParameters.Add("language", language);
 0289                tracingParameters.Add("cancellationToken", cancellationToken);
 0290                ServiceClientTracing.Enter(_invocationId, this, "DeleteTerm", tracingParameters);
 291            }
 292            // Construct URL
 0293            var _baseUrl = Client.BaseUri;
 0294            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists/{listId}/
 0295            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0296            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 0297            _url = _url.Replace("{term}", System.Uri.EscapeDataString(term));
 0298            List<string> _queryParameters = new List<string>();
 0299            if (language != null)
 300            {
 0301                _queryParameters.Add(string.Format("language={0}", System.Uri.EscapeDataString(language)));
 302            }
 0303            if (_queryParameters.Count > 0)
 304            {
 0305                _url += "?" + string.Join("&", _queryParameters);
 306            }
 307            // Create HTTP transport objects
 0308            var _httpRequest = new HttpRequestMessage();
 0309            HttpResponseMessage _httpResponse = null;
 0310            _httpRequest.Method = new HttpMethod("DELETE");
 0311            _httpRequest.RequestUri = new System.Uri(_url);
 312            // Set Headers
 313
 314
 0315            if (customHeaders != null)
 316            {
 0317                foreach(var _header in customHeaders)
 318                {
 0319                    if (_httpRequest.Headers.Contains(_header.Key))
 320                    {
 0321                        _httpRequest.Headers.Remove(_header.Key);
 322                    }
 0323                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 324                }
 325            }
 326
 327            // Serialize Request
 0328            string _requestContent = null;
 329            // Set Credentials
 0330            if (Client.Credentials != null)
 331            {
 0332                cancellationToken.ThrowIfCancellationRequested();
 0333                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 334            }
 335            // Send Request
 0336            if (_shouldTrace)
 337            {
 0338                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 339            }
 0340            cancellationToken.ThrowIfCancellationRequested();
 0341            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0342            if (_shouldTrace)
 343            {
 0344                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 345            }
 0346            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0347            cancellationToken.ThrowIfCancellationRequested();
 0348            string _responseContent = null;
 0349            if ((int)_statusCode != 204)
 350            {
 0351                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 352                try
 353                {
 0354                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0355                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0356                    if (_errorBody != null)
 357                    {
 0358                        ex.Body = _errorBody;
 359                    }
 0360                }
 0361                catch (JsonException)
 362                {
 363                    // Ignore the exception
 0364                }
 0365                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0366                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0367                if (_shouldTrace)
 368                {
 0369                    ServiceClientTracing.Error(_invocationId, ex);
 370                }
 0371                _httpRequest.Dispose();
 0372                if (_httpResponse != null)
 373                {
 0374                    _httpResponse.Dispose();
 375                }
 0376                throw ex;
 377            }
 378            // Create Result
 0379            var _result = new HttpOperationResponse<string>();
 0380            _result.Request = _httpRequest;
 0381            _result.Response = _httpResponse;
 382            // Deserialize Response
 0383            if ((int)_statusCode == 204)
 384            {
 0385                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 386                try
 387                {
 0388                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 0389                }
 0390                catch (JsonException ex)
 391                {
 0392                    _httpRequest.Dispose();
 0393                    if (_httpResponse != null)
 394                    {
 0395                        _httpResponse.Dispose();
 396                    }
 0397                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 398                }
 399            }
 0400            if (_shouldTrace)
 401            {
 0402                ServiceClientTracing.Exit(_invocationId, _result);
 403            }
 0404            return _result;
 0405        }
 406
 407        /// <summary>
 408        /// Gets all terms from the list with list Id equal to the list Id passed.
 409        /// </summary>
 410        /// <param name='listId'>
 411        /// List Id of the image list.
 412        /// </param>
 413        /// <param name='language'>
 414        /// Language of the terms.
 415        /// </param>
 416        /// <param name='offset'>
 417        /// The pagination start index.
 418        /// </param>
 419        /// <param name='limit'>
 420        /// The max limit.
 421        /// </param>
 422        /// <param name='customHeaders'>
 423        /// Headers that will be added to request.
 424        /// </param>
 425        /// <param name='cancellationToken'>
 426        /// The cancellation token.
 427        /// </param>
 428        /// <exception cref="APIErrorException">
 429        /// Thrown when the operation returned an invalid status code
 430        /// </exception>
 431        /// <exception cref="SerializationException">
 432        /// Thrown when unable to deserialize the response
 433        /// </exception>
 434        /// <exception cref="ValidationException">
 435        /// Thrown when a required parameter is null
 436        /// </exception>
 437        /// <exception cref="System.ArgumentNullException">
 438        /// Thrown when a required parameter is null
 439        /// </exception>
 440        /// <return>
 441        /// A response object containing the response body and response headers.
 442        /// </return>
 443        public async Task<HttpOperationResponse<Terms>> GetAllTermsWithHttpMessagesAsync(string listId, string language,
 444        {
 0445            if (Client.Endpoint == null)
 446            {
 0447                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 448            }
 0449            if (listId == null)
 450            {
 0451                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 452            }
 0453            if (language == null)
 454            {
 0455                throw new ValidationException(ValidationRules.CannotBeNull, "language");
 456            }
 457            // Tracing
 0458            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0459            string _invocationId = null;
 0460            if (_shouldTrace)
 461            {
 0462                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0463                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0464                tracingParameters.Add("listId", listId);
 0465                tracingParameters.Add("language", language);
 0466                tracingParameters.Add("offset", offset);
 0467                tracingParameters.Add("limit", limit);
 0468                tracingParameters.Add("cancellationToken", cancellationToken);
 0469                ServiceClientTracing.Enter(_invocationId, this, "GetAllTerms", tracingParameters);
 470            }
 471            // Construct URL
 0472            var _baseUrl = Client.BaseUri;
 0473            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists/{listId}/
 0474            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0475            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 0476            List<string> _queryParameters = new List<string>();
 0477            if (language != null)
 478            {
 0479                _queryParameters.Add(string.Format("language={0}", System.Uri.EscapeDataString(language)));
 480            }
 0481            if (offset != null)
 482            {
 0483                _queryParameters.Add(string.Format("offset={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJson
 484            }
 0485            if (limit != null)
 486            {
 0487                _queryParameters.Add(string.Format("limit={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonC
 488            }
 0489            if (_queryParameters.Count > 0)
 490            {
 0491                _url += "?" + string.Join("&", _queryParameters);
 492            }
 493            // Create HTTP transport objects
 0494            var _httpRequest = new HttpRequestMessage();
 0495            HttpResponseMessage _httpResponse = null;
 0496            _httpRequest.Method = new HttpMethod("GET");
 0497            _httpRequest.RequestUri = new System.Uri(_url);
 498            // Set Headers
 499
 500
 0501            if (customHeaders != null)
 502            {
 0503                foreach(var _header in customHeaders)
 504                {
 0505                    if (_httpRequest.Headers.Contains(_header.Key))
 506                    {
 0507                        _httpRequest.Headers.Remove(_header.Key);
 508                    }
 0509                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 510                }
 511            }
 512
 513            // Serialize Request
 0514            string _requestContent = null;
 515            // Set Credentials
 0516            if (Client.Credentials != null)
 517            {
 0518                cancellationToken.ThrowIfCancellationRequested();
 0519                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 520            }
 521            // Send Request
 0522            if (_shouldTrace)
 523            {
 0524                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 525            }
 0526            cancellationToken.ThrowIfCancellationRequested();
 0527            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0528            if (_shouldTrace)
 529            {
 0530                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 531            }
 0532            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0533            cancellationToken.ThrowIfCancellationRequested();
 0534            string _responseContent = null;
 0535            if ((int)_statusCode != 200)
 536            {
 0537                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 538                try
 539                {
 0540                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0541                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0542                    if (_errorBody != null)
 543                    {
 0544                        ex.Body = _errorBody;
 545                    }
 0546                }
 0547                catch (JsonException)
 548                {
 549                    // Ignore the exception
 0550                }
 0551                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0552                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0553                if (_shouldTrace)
 554                {
 0555                    ServiceClientTracing.Error(_invocationId, ex);
 556                }
 0557                _httpRequest.Dispose();
 0558                if (_httpResponse != null)
 559                {
 0560                    _httpResponse.Dispose();
 561                }
 0562                throw ex;
 563            }
 564            // Create Result
 0565            var _result = new HttpOperationResponse<Terms>();
 0566            _result.Request = _httpRequest;
 0567            _result.Response = _httpResponse;
 568            // Deserialize Response
 0569            if ((int)_statusCode == 200)
 570            {
 0571                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 572                try
 573                {
 0574                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Terms>(_responseContent, Client.
 0575                }
 0576                catch (JsonException ex)
 577                {
 0578                    _httpRequest.Dispose();
 0579                    if (_httpResponse != null)
 580                    {
 0581                        _httpResponse.Dispose();
 582                    }
 0583                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 584                }
 585            }
 0586            if (_shouldTrace)
 587            {
 0588                ServiceClientTracing.Exit(_invocationId, _result);
 589            }
 0590            return _result;
 0591        }
 592
 593        /// <summary>
 594        /// Deletes all terms from the list with list Id equal to the list Id passed.
 595        /// </summary>
 596        /// <param name='listId'>
 597        /// List Id of the image list.
 598        /// </param>
 599        /// <param name='language'>
 600        /// Language of the terms.
 601        /// </param>
 602        /// <param name='customHeaders'>
 603        /// Headers that will be added to request.
 604        /// </param>
 605        /// <param name='cancellationToken'>
 606        /// The cancellation token.
 607        /// </param>
 608        /// <exception cref="APIErrorException">
 609        /// Thrown when the operation returned an invalid status code
 610        /// </exception>
 611        /// <exception cref="SerializationException">
 612        /// Thrown when unable to deserialize the response
 613        /// </exception>
 614        /// <exception cref="ValidationException">
 615        /// Thrown when a required parameter is null
 616        /// </exception>
 617        /// <exception cref="System.ArgumentNullException">
 618        /// Thrown when a required parameter is null
 619        /// </exception>
 620        /// <return>
 621        /// A response object containing the response body and response headers.
 622        /// </return>
 623        public async Task<HttpOperationResponse<string>> DeleteAllTermsWithHttpMessagesAsync(string listId, string langu
 624        {
 0625            if (Client.Endpoint == null)
 626            {
 0627                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 628            }
 0629            if (listId == null)
 630            {
 0631                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 632            }
 0633            if (language == null)
 634            {
 0635                throw new ValidationException(ValidationRules.CannotBeNull, "language");
 636            }
 637            // Tracing
 0638            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0639            string _invocationId = null;
 0640            if (_shouldTrace)
 641            {
 0642                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0643                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0644                tracingParameters.Add("listId", listId);
 0645                tracingParameters.Add("language", language);
 0646                tracingParameters.Add("cancellationToken", cancellationToken);
 0647                ServiceClientTracing.Enter(_invocationId, this, "DeleteAllTerms", tracingParameters);
 648            }
 649            // Construct URL
 0650            var _baseUrl = Client.BaseUri;
 0651            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists/{listId}/
 0652            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0653            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 0654            List<string> _queryParameters = new List<string>();
 0655            if (language != null)
 656            {
 0657                _queryParameters.Add(string.Format("language={0}", System.Uri.EscapeDataString(language)));
 658            }
 0659            if (_queryParameters.Count > 0)
 660            {
 0661                _url += "?" + string.Join("&", _queryParameters);
 662            }
 663            // Create HTTP transport objects
 0664            var _httpRequest = new HttpRequestMessage();
 0665            HttpResponseMessage _httpResponse = null;
 0666            _httpRequest.Method = new HttpMethod("DELETE");
 0667            _httpRequest.RequestUri = new System.Uri(_url);
 668            // Set Headers
 669
 670
 0671            if (customHeaders != null)
 672            {
 0673                foreach(var _header in customHeaders)
 674                {
 0675                    if (_httpRequest.Headers.Contains(_header.Key))
 676                    {
 0677                        _httpRequest.Headers.Remove(_header.Key);
 678                    }
 0679                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 680                }
 681            }
 682
 683            // Serialize Request
 0684            string _requestContent = null;
 685            // Set Credentials
 0686            if (Client.Credentials != null)
 687            {
 0688                cancellationToken.ThrowIfCancellationRequested();
 0689                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 690            }
 691            // Send Request
 0692            if (_shouldTrace)
 693            {
 0694                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 695            }
 0696            cancellationToken.ThrowIfCancellationRequested();
 0697            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0698            if (_shouldTrace)
 699            {
 0700                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 701            }
 0702            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0703            cancellationToken.ThrowIfCancellationRequested();
 0704            string _responseContent = null;
 0705            if ((int)_statusCode != 204)
 706            {
 0707                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 708                try
 709                {
 0710                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0711                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0712                    if (_errorBody != null)
 713                    {
 0714                        ex.Body = _errorBody;
 715                    }
 0716                }
 0717                catch (JsonException)
 718                {
 719                    // Ignore the exception
 0720                }
 0721                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0722                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0723                if (_shouldTrace)
 724                {
 0725                    ServiceClientTracing.Error(_invocationId, ex);
 726                }
 0727                _httpRequest.Dispose();
 0728                if (_httpResponse != null)
 729                {
 0730                    _httpResponse.Dispose();
 731                }
 0732                throw ex;
 733            }
 734            // Create Result
 0735            var _result = new HttpOperationResponse<string>();
 0736            _result.Request = _httpRequest;
 0737            _result.Response = _httpResponse;
 738            // Deserialize Response
 0739            if ((int)_statusCode == 204)
 740            {
 0741                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 742                try
 743                {
 0744                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 0745                }
 0746                catch (JsonException ex)
 747                {
 0748                    _httpRequest.Dispose();
 0749                    if (_httpResponse != null)
 750                    {
 0751                        _httpResponse.Dispose();
 752                    }
 0753                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 754                }
 755            }
 0756            if (_shouldTrace)
 757            {
 0758                ServiceClientTracing.Exit(_invocationId, _result);
 759            }
 0760            return _result;
 0761        }
 762
 763    }
 764}