< Summary

Class:Microsoft.Azure.CognitiveServices.ContentModerator.ListManagementTermLists
Assembly:Microsoft.Azure.CognitiveServices.Vision.ContentModerator
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.ContentModerator\src\Generated\ListManagementTermLists.cs
Covered lines:4
Uncovered lines:448
Coverable lines:452
Total lines:1012
Line coverage:0.8% (4 of 452)
Covered branches:1
Total branches:220
Branch coverage:0.4% (1 of 220)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-0%100%
GetDetailsWithHttpMessagesAsync()-0%0%
DeleteWithHttpMessagesAsync()-0%0%
UpdateWithHttpMessagesAsync()-0%0%
CreateWithHttpMessagesAsync()-0%0%
GetAllTermListsWithHttpMessagesAsync()-0%0%
RefreshIndexMethodWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.ContentModerator\src\Generated\ListManagementTermLists.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    /// ListManagementTermLists operations.
 23    /// </summary>
 24    public partial class ListManagementTermLists : IServiceOperations<ContentModeratorClient>, IListManagementTermLists
 25    {
 26        /// <summary>
 27        /// Initializes a new instance of the ListManagementTermLists 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 ListManagementTermLists(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        /// Returns list Id details of the term list with list Id equal to list Id
 51        /// passed.
 52        /// </summary>
 53        /// <param name='listId'>
 54        /// List Id of the image list.
 55        /// </param>
 56        /// <param name='customHeaders'>
 57        /// Headers that will be added to request.
 58        /// </param>
 59        /// <param name='cancellationToken'>
 60        /// The cancellation token.
 61        /// </param>
 62        /// <exception cref="APIErrorException">
 63        /// Thrown when the operation returned an invalid status code
 64        /// </exception>
 65        /// <exception cref="SerializationException">
 66        /// Thrown when unable to deserialize the response
 67        /// </exception>
 68        /// <exception cref="ValidationException">
 69        /// Thrown when a required parameter is null
 70        /// </exception>
 71        /// <exception cref="System.ArgumentNullException">
 72        /// Thrown when a required parameter is null
 73        /// </exception>
 74        /// <return>
 75        /// A response object containing the response body and response headers.
 76        /// </return>
 77        public async Task<HttpOperationResponse<TermList>> GetDetailsWithHttpMessagesAsync(string listId, Dictionary<str
 78        {
 079            if (Client.Endpoint == null)
 80            {
 081                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 82            }
 083            if (listId == null)
 84            {
 085                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 86            }
 87            // Tracing
 088            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 089            string _invocationId = null;
 090            if (_shouldTrace)
 91            {
 092                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 093                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 094                tracingParameters.Add("listId", listId);
 095                tracingParameters.Add("cancellationToken", cancellationToken);
 096                ServiceClientTracing.Enter(_invocationId, this, "GetDetails", tracingParameters);
 97            }
 98            // Construct URL
 099            var _baseUrl = Client.BaseUri;
 0100            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists/{listId}"
 0101            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0102            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 103            // Create HTTP transport objects
 0104            var _httpRequest = new HttpRequestMessage();
 0105            HttpResponseMessage _httpResponse = null;
 0106            _httpRequest.Method = new HttpMethod("GET");
 0107            _httpRequest.RequestUri = new System.Uri(_url);
 108            // Set Headers
 109
 110
 0111            if (customHeaders != null)
 112            {
 0113                foreach(var _header in customHeaders)
 114                {
 0115                    if (_httpRequest.Headers.Contains(_header.Key))
 116                    {
 0117                        _httpRequest.Headers.Remove(_header.Key);
 118                    }
 0119                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 120                }
 121            }
 122
 123            // Serialize Request
 0124            string _requestContent = null;
 125            // Set Credentials
 0126            if (Client.Credentials != null)
 127            {
 0128                cancellationToken.ThrowIfCancellationRequested();
 0129                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 130            }
 131            // Send Request
 0132            if (_shouldTrace)
 133            {
 0134                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 135            }
 0136            cancellationToken.ThrowIfCancellationRequested();
 0137            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0138            if (_shouldTrace)
 139            {
 0140                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 141            }
 0142            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0143            cancellationToken.ThrowIfCancellationRequested();
 0144            string _responseContent = null;
 0145            if ((int)_statusCode != 200)
 146            {
 0147                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 148                try
 149                {
 0150                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0151                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0152                    if (_errorBody != null)
 153                    {
 0154                        ex.Body = _errorBody;
 155                    }
 0156                }
 0157                catch (JsonException)
 158                {
 159                    // Ignore the exception
 0160                }
 0161                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0162                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0163                if (_shouldTrace)
 164                {
 0165                    ServiceClientTracing.Error(_invocationId, ex);
 166                }
 0167                _httpRequest.Dispose();
 0168                if (_httpResponse != null)
 169                {
 0170                    _httpResponse.Dispose();
 171                }
 0172                throw ex;
 173            }
 174            // Create Result
 0175            var _result = new HttpOperationResponse<TermList>();
 0176            _result.Request = _httpRequest;
 0177            _result.Response = _httpResponse;
 178            // Deserialize Response
 0179            if ((int)_statusCode == 200)
 180            {
 0181                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 182                try
 183                {
 0184                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<TermList>(_responseContent, Clie
 0185                }
 0186                catch (JsonException ex)
 187                {
 0188                    _httpRequest.Dispose();
 0189                    if (_httpResponse != null)
 190                    {
 0191                        _httpResponse.Dispose();
 192                    }
 0193                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 194                }
 195            }
 0196            if (_shouldTrace)
 197            {
 0198                ServiceClientTracing.Exit(_invocationId, _result);
 199            }
 0200            return _result;
 0201        }
 202
 203        /// <summary>
 204        /// Deletes term list with the list Id equal to list Id passed.
 205        /// </summary>
 206        /// <param name='listId'>
 207        /// List Id of the image list.
 208        /// </param>
 209        /// <param name='customHeaders'>
 210        /// Headers that will be added to request.
 211        /// </param>
 212        /// <param name='cancellationToken'>
 213        /// The cancellation token.
 214        /// </param>
 215        /// <exception cref="APIErrorException">
 216        /// Thrown when the operation returned an invalid status code
 217        /// </exception>
 218        /// <exception cref="SerializationException">
 219        /// Thrown when unable to deserialize the response
 220        /// </exception>
 221        /// <exception cref="ValidationException">
 222        /// Thrown when a required parameter is null
 223        /// </exception>
 224        /// <exception cref="System.ArgumentNullException">
 225        /// Thrown when a required parameter is null
 226        /// </exception>
 227        /// <return>
 228        /// A response object containing the response body and response headers.
 229        /// </return>
 230        public async Task<HttpOperationResponse<string>> DeleteWithHttpMessagesAsync(string listId, Dictionary<string, L
 231        {
 0232            if (Client.Endpoint == null)
 233            {
 0234                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 235            }
 0236            if (listId == null)
 237            {
 0238                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 239            }
 240            // Tracing
 0241            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0242            string _invocationId = null;
 0243            if (_shouldTrace)
 244            {
 0245                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0246                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0247                tracingParameters.Add("listId", listId);
 0248                tracingParameters.Add("cancellationToken", cancellationToken);
 0249                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 250            }
 251            // Construct URL
 0252            var _baseUrl = Client.BaseUri;
 0253            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists/{listId}"
 0254            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0255            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 256            // Create HTTP transport objects
 0257            var _httpRequest = new HttpRequestMessage();
 0258            HttpResponseMessage _httpResponse = null;
 0259            _httpRequest.Method = new HttpMethod("DELETE");
 0260            _httpRequest.RequestUri = new System.Uri(_url);
 261            // Set Headers
 262
 263
 0264            if (customHeaders != null)
 265            {
 0266                foreach(var _header in customHeaders)
 267                {
 0268                    if (_httpRequest.Headers.Contains(_header.Key))
 269                    {
 0270                        _httpRequest.Headers.Remove(_header.Key);
 271                    }
 0272                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 273                }
 274            }
 275
 276            // Serialize Request
 0277            string _requestContent = null;
 278            // Set Credentials
 0279            if (Client.Credentials != null)
 280            {
 0281                cancellationToken.ThrowIfCancellationRequested();
 0282                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 283            }
 284            // Send Request
 0285            if (_shouldTrace)
 286            {
 0287                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 288            }
 0289            cancellationToken.ThrowIfCancellationRequested();
 0290            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0291            if (_shouldTrace)
 292            {
 0293                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 294            }
 0295            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0296            cancellationToken.ThrowIfCancellationRequested();
 0297            string _responseContent = null;
 0298            if ((int)_statusCode != 200)
 299            {
 0300                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 301                try
 302                {
 0303                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0304                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0305                    if (_errorBody != null)
 306                    {
 0307                        ex.Body = _errorBody;
 308                    }
 0309                }
 0310                catch (JsonException)
 311                {
 312                    // Ignore the exception
 0313                }
 0314                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0315                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0316                if (_shouldTrace)
 317                {
 0318                    ServiceClientTracing.Error(_invocationId, ex);
 319                }
 0320                _httpRequest.Dispose();
 0321                if (_httpResponse != null)
 322                {
 0323                    _httpResponse.Dispose();
 324                }
 0325                throw ex;
 326            }
 327            // Create Result
 0328            var _result = new HttpOperationResponse<string>();
 0329            _result.Request = _httpRequest;
 0330            _result.Response = _httpResponse;
 331            // Deserialize Response
 0332            if ((int)_statusCode == 200)
 333            {
 0334                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 335                try
 336                {
 0337                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 0338                }
 0339                catch (JsonException ex)
 340                {
 0341                    _httpRequest.Dispose();
 0342                    if (_httpResponse != null)
 343                    {
 0344                        _httpResponse.Dispose();
 345                    }
 0346                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 347                }
 348            }
 0349            if (_shouldTrace)
 350            {
 0351                ServiceClientTracing.Exit(_invocationId, _result);
 352            }
 0353            return _result;
 0354        }
 355
 356        /// <summary>
 357        /// Updates an Term List.
 358        /// </summary>
 359        /// <param name='listId'>
 360        /// List Id of the image list.
 361        /// </param>
 362        /// <param name='contentType'>
 363        /// The content type.
 364        /// </param>
 365        /// <param name='body'>
 366        /// Schema of the body.
 367        /// </param>
 368        /// <param name='customHeaders'>
 369        /// Headers that will be added to request.
 370        /// </param>
 371        /// <param name='cancellationToken'>
 372        /// The cancellation token.
 373        /// </param>
 374        /// <exception cref="APIErrorException">
 375        /// Thrown when the operation returned an invalid status code
 376        /// </exception>
 377        /// <exception cref="SerializationException">
 378        /// Thrown when unable to deserialize the response
 379        /// </exception>
 380        /// <exception cref="ValidationException">
 381        /// Thrown when a required parameter is null
 382        /// </exception>
 383        /// <exception cref="System.ArgumentNullException">
 384        /// Thrown when a required parameter is null
 385        /// </exception>
 386        /// <return>
 387        /// A response object containing the response body and response headers.
 388        /// </return>
 389        public async Task<HttpOperationResponse<TermList>> UpdateWithHttpMessagesAsync(string listId, string contentType
 390        {
 0391            if (Client.Endpoint == null)
 392            {
 0393                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 394            }
 0395            if (listId == null)
 396            {
 0397                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 398            }
 0399            if (contentType == null)
 400            {
 0401                throw new ValidationException(ValidationRules.CannotBeNull, "contentType");
 402            }
 0403            if (body == null)
 404            {
 0405                throw new ValidationException(ValidationRules.CannotBeNull, "body");
 406            }
 407            // Tracing
 0408            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0409            string _invocationId = null;
 0410            if (_shouldTrace)
 411            {
 0412                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0413                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0414                tracingParameters.Add("listId", listId);
 0415                tracingParameters.Add("contentType", contentType);
 0416                tracingParameters.Add("body", body);
 0417                tracingParameters.Add("cancellationToken", cancellationToken);
 0418                ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
 419            }
 420            // Construct URL
 0421            var _baseUrl = Client.BaseUri;
 0422            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists/{listId}"
 0423            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0424            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 425            // Create HTTP transport objects
 0426            var _httpRequest = new HttpRequestMessage();
 0427            HttpResponseMessage _httpResponse = null;
 0428            _httpRequest.Method = new HttpMethod("PUT");
 0429            _httpRequest.RequestUri = new System.Uri(_url);
 430            // Set Headers
 431
 432
 0433            if (customHeaders != null)
 434            {
 0435                foreach(var _header in customHeaders)
 436                {
 0437                    if (_httpRequest.Headers.Contains(_header.Key))
 438                    {
 0439                        _httpRequest.Headers.Remove(_header.Key);
 440                    }
 0441                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 442                }
 443            }
 444
 445            // Serialize Request
 0446            string _requestContent = null;
 0447            if(body != null)
 448            {
 0449                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings)
 0450                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0451                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 452            }
 453            // Set Credentials
 0454            if (Client.Credentials != null)
 455            {
 0456                cancellationToken.ThrowIfCancellationRequested();
 0457                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 458            }
 459            // Send Request
 0460            if (_shouldTrace)
 461            {
 0462                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 463            }
 0464            cancellationToken.ThrowIfCancellationRequested();
 0465            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0466            if (_shouldTrace)
 467            {
 0468                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 469            }
 0470            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0471            cancellationToken.ThrowIfCancellationRequested();
 0472            string _responseContent = null;
 0473            if ((int)_statusCode != 200)
 474            {
 0475                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 476                try
 477                {
 0478                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0479                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0480                    if (_errorBody != null)
 481                    {
 0482                        ex.Body = _errorBody;
 483                    }
 0484                }
 0485                catch (JsonException)
 486                {
 487                    // Ignore the exception
 0488                }
 0489                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0490                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0491                if (_shouldTrace)
 492                {
 0493                    ServiceClientTracing.Error(_invocationId, ex);
 494                }
 0495                _httpRequest.Dispose();
 0496                if (_httpResponse != null)
 497                {
 0498                    _httpResponse.Dispose();
 499                }
 0500                throw ex;
 501            }
 502            // Create Result
 0503            var _result = new HttpOperationResponse<TermList>();
 0504            _result.Request = _httpRequest;
 0505            _result.Response = _httpResponse;
 506            // Deserialize Response
 0507            if ((int)_statusCode == 200)
 508            {
 0509                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 510                try
 511                {
 0512                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<TermList>(_responseContent, Clie
 0513                }
 0514                catch (JsonException ex)
 515                {
 0516                    _httpRequest.Dispose();
 0517                    if (_httpResponse != null)
 518                    {
 0519                        _httpResponse.Dispose();
 520                    }
 0521                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 522                }
 523            }
 0524            if (_shouldTrace)
 525            {
 0526                ServiceClientTracing.Exit(_invocationId, _result);
 527            }
 0528            return _result;
 0529        }
 530
 531        /// <summary>
 532        /// Creates a Term List
 533        /// </summary>
 534        /// <param name='contentType'>
 535        /// The content type.
 536        /// </param>
 537        /// <param name='body'>
 538        /// Schema of the body.
 539        /// </param>
 540        /// <param name='customHeaders'>
 541        /// Headers that will be added to request.
 542        /// </param>
 543        /// <param name='cancellationToken'>
 544        /// The cancellation token.
 545        /// </param>
 546        /// <exception cref="APIErrorException">
 547        /// Thrown when the operation returned an invalid status code
 548        /// </exception>
 549        /// <exception cref="SerializationException">
 550        /// Thrown when unable to deserialize the response
 551        /// </exception>
 552        /// <exception cref="ValidationException">
 553        /// Thrown when a required parameter is null
 554        /// </exception>
 555        /// <exception cref="System.ArgumentNullException">
 556        /// Thrown when a required parameter is null
 557        /// </exception>
 558        /// <return>
 559        /// A response object containing the response body and response headers.
 560        /// </return>
 561        public async Task<HttpOperationResponse<TermList>> CreateWithHttpMessagesAsync(string contentType, Body body, Di
 562        {
 0563            if (Client.Endpoint == null)
 564            {
 0565                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 566            }
 0567            if (contentType == null)
 568            {
 0569                throw new ValidationException(ValidationRules.CannotBeNull, "contentType");
 570            }
 0571            if (body == null)
 572            {
 0573                throw new ValidationException(ValidationRules.CannotBeNull, "body");
 574            }
 575            // Tracing
 0576            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0577            string _invocationId = null;
 0578            if (_shouldTrace)
 579            {
 0580                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0581                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0582                tracingParameters.Add("contentType", contentType);
 0583                tracingParameters.Add("body", body);
 0584                tracingParameters.Add("cancellationToken", cancellationToken);
 0585                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
 586            }
 587            // Construct URL
 0588            var _baseUrl = Client.BaseUri;
 0589            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists";
 0590            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 591            // Create HTTP transport objects
 0592            var _httpRequest = new HttpRequestMessage();
 0593            HttpResponseMessage _httpResponse = null;
 0594            _httpRequest.Method = new HttpMethod("POST");
 0595            _httpRequest.RequestUri = new System.Uri(_url);
 596            // Set Headers
 597
 598
 0599            if (customHeaders != null)
 600            {
 0601                foreach(var _header in customHeaders)
 602                {
 0603                    if (_httpRequest.Headers.Contains(_header.Key))
 604                    {
 0605                        _httpRequest.Headers.Remove(_header.Key);
 606                    }
 0607                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 608                }
 609            }
 610
 611            // Serialize Request
 0612            string _requestContent = null;
 0613            if(body != null)
 614            {
 0615                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings)
 0616                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0617                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 618            }
 619            // Set Credentials
 0620            if (Client.Credentials != null)
 621            {
 0622                cancellationToken.ThrowIfCancellationRequested();
 0623                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 624            }
 625            // Send Request
 0626            if (_shouldTrace)
 627            {
 0628                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 629            }
 0630            cancellationToken.ThrowIfCancellationRequested();
 0631            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0632            if (_shouldTrace)
 633            {
 0634                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 635            }
 0636            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0637            cancellationToken.ThrowIfCancellationRequested();
 0638            string _responseContent = null;
 0639            if ((int)_statusCode != 200)
 640            {
 0641                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 642                try
 643                {
 0644                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0645                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0646                    if (_errorBody != null)
 647                    {
 0648                        ex.Body = _errorBody;
 649                    }
 0650                }
 0651                catch (JsonException)
 652                {
 653                    // Ignore the exception
 0654                }
 0655                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0656                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0657                if (_shouldTrace)
 658                {
 0659                    ServiceClientTracing.Error(_invocationId, ex);
 660                }
 0661                _httpRequest.Dispose();
 0662                if (_httpResponse != null)
 663                {
 0664                    _httpResponse.Dispose();
 665                }
 0666                throw ex;
 667            }
 668            // Create Result
 0669            var _result = new HttpOperationResponse<TermList>();
 0670            _result.Request = _httpRequest;
 0671            _result.Response = _httpResponse;
 672            // Deserialize Response
 0673            if ((int)_statusCode == 200)
 674            {
 0675                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 676                try
 677                {
 0678                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<TermList>(_responseContent, Clie
 0679                }
 0680                catch (JsonException ex)
 681                {
 0682                    _httpRequest.Dispose();
 0683                    if (_httpResponse != null)
 684                    {
 0685                        _httpResponse.Dispose();
 686                    }
 0687                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 688                }
 689            }
 0690            if (_shouldTrace)
 691            {
 0692                ServiceClientTracing.Exit(_invocationId, _result);
 693            }
 0694            return _result;
 0695        }
 696
 697        /// <summary>
 698        /// gets all the Term Lists
 699        /// </summary>
 700        /// <param name='customHeaders'>
 701        /// Headers that will be added to request.
 702        /// </param>
 703        /// <param name='cancellationToken'>
 704        /// The cancellation token.
 705        /// </param>
 706        /// <exception cref="APIErrorException">
 707        /// Thrown when the operation returned an invalid status code
 708        /// </exception>
 709        /// <exception cref="SerializationException">
 710        /// Thrown when unable to deserialize the response
 711        /// </exception>
 712        /// <exception cref="ValidationException">
 713        /// Thrown when a required parameter is null
 714        /// </exception>
 715        /// <exception cref="System.ArgumentNullException">
 716        /// Thrown when a required parameter is null
 717        /// </exception>
 718        /// <return>
 719        /// A response object containing the response body and response headers.
 720        /// </return>
 721        public async Task<HttpOperationResponse<IList<TermList>>> GetAllTermListsWithHttpMessagesAsync(Dictionary<string
 722        {
 0723            if (Client.Endpoint == null)
 724            {
 0725                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 726            }
 727            // Tracing
 0728            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0729            string _invocationId = null;
 0730            if (_shouldTrace)
 731            {
 0732                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0733                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0734                tracingParameters.Add("cancellationToken", cancellationToken);
 0735                ServiceClientTracing.Enter(_invocationId, this, "GetAllTermLists", tracingParameters);
 736            }
 737            // Construct URL
 0738            var _baseUrl = Client.BaseUri;
 0739            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists";
 0740            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 741            // Create HTTP transport objects
 0742            var _httpRequest = new HttpRequestMessage();
 0743            HttpResponseMessage _httpResponse = null;
 0744            _httpRequest.Method = new HttpMethod("GET");
 0745            _httpRequest.RequestUri = new System.Uri(_url);
 746            // Set Headers
 747
 748
 0749            if (customHeaders != null)
 750            {
 0751                foreach(var _header in customHeaders)
 752                {
 0753                    if (_httpRequest.Headers.Contains(_header.Key))
 754                    {
 0755                        _httpRequest.Headers.Remove(_header.Key);
 756                    }
 0757                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 758                }
 759            }
 760
 761            // Serialize Request
 0762            string _requestContent = null;
 763            // Set Credentials
 0764            if (Client.Credentials != null)
 765            {
 0766                cancellationToken.ThrowIfCancellationRequested();
 0767                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 768            }
 769            // Send Request
 0770            if (_shouldTrace)
 771            {
 0772                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 773            }
 0774            cancellationToken.ThrowIfCancellationRequested();
 0775            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0776            if (_shouldTrace)
 777            {
 0778                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 779            }
 0780            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0781            cancellationToken.ThrowIfCancellationRequested();
 0782            string _responseContent = null;
 0783            if ((int)_statusCode != 200)
 784            {
 0785                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 786                try
 787                {
 0788                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0789                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0790                    if (_errorBody != null)
 791                    {
 0792                        ex.Body = _errorBody;
 793                    }
 0794                }
 0795                catch (JsonException)
 796                {
 797                    // Ignore the exception
 0798                }
 0799                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0800                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0801                if (_shouldTrace)
 802                {
 0803                    ServiceClientTracing.Error(_invocationId, ex);
 804                }
 0805                _httpRequest.Dispose();
 0806                if (_httpResponse != null)
 807                {
 0808                    _httpResponse.Dispose();
 809                }
 0810                throw ex;
 811            }
 812            // Create Result
 0813            var _result = new HttpOperationResponse<IList<TermList>>();
 0814            _result.Request = _httpRequest;
 0815            _result.Response = _httpResponse;
 816            // Deserialize Response
 0817            if ((int)_statusCode == 200)
 818            {
 0819                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 820                try
 821                {
 0822                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<TermList>>(_responseConten
 0823                }
 0824                catch (JsonException ex)
 825                {
 0826                    _httpRequest.Dispose();
 0827                    if (_httpResponse != null)
 828                    {
 0829                        _httpResponse.Dispose();
 830                    }
 0831                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 832                }
 833            }
 0834            if (_shouldTrace)
 835            {
 0836                ServiceClientTracing.Exit(_invocationId, _result);
 837            }
 0838            return _result;
 0839        }
 840
 841        /// <summary>
 842        /// Refreshes the index of the list with list Id equal to list ID passed.
 843        /// </summary>
 844        /// <param name='listId'>
 845        /// List Id of the image list.
 846        /// </param>
 847        /// <param name='language'>
 848        /// Language of the terms.
 849        /// </param>
 850        /// <param name='customHeaders'>
 851        /// Headers that will be added to request.
 852        /// </param>
 853        /// <param name='cancellationToken'>
 854        /// The cancellation token.
 855        /// </param>
 856        /// <exception cref="APIErrorException">
 857        /// Thrown when the operation returned an invalid status code
 858        /// </exception>
 859        /// <exception cref="SerializationException">
 860        /// Thrown when unable to deserialize the response
 861        /// </exception>
 862        /// <exception cref="ValidationException">
 863        /// Thrown when a required parameter is null
 864        /// </exception>
 865        /// <exception cref="System.ArgumentNullException">
 866        /// Thrown when a required parameter is null
 867        /// </exception>
 868        /// <return>
 869        /// A response object containing the response body and response headers.
 870        /// </return>
 871        public async Task<HttpOperationResponse<RefreshIndex>> RefreshIndexMethodWithHttpMessagesAsync(string listId, st
 872        {
 0873            if (Client.Endpoint == null)
 874            {
 0875                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 876            }
 0877            if (listId == null)
 878            {
 0879                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 880            }
 0881            if (language == null)
 882            {
 0883                throw new ValidationException(ValidationRules.CannotBeNull, "language");
 884            }
 885            // Tracing
 0886            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0887            string _invocationId = null;
 0888            if (_shouldTrace)
 889            {
 0890                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0891                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0892                tracingParameters.Add("listId", listId);
 0893                tracingParameters.Add("language", language);
 0894                tracingParameters.Add("cancellationToken", cancellationToken);
 0895                ServiceClientTracing.Enter(_invocationId, this, "RefreshIndexMethod", tracingParameters);
 896            }
 897            // Construct URL
 0898            var _baseUrl = Client.BaseUri;
 0899            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/termlists/{listId}/
 0900            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0901            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 0902            List<string> _queryParameters = new List<string>();
 0903            if (language != null)
 904            {
 0905                _queryParameters.Add(string.Format("language={0}", System.Uri.EscapeDataString(language)));
 906            }
 0907            if (_queryParameters.Count > 0)
 908            {
 0909                _url += "?" + string.Join("&", _queryParameters);
 910            }
 911            // Create HTTP transport objects
 0912            var _httpRequest = new HttpRequestMessage();
 0913            HttpResponseMessage _httpResponse = null;
 0914            _httpRequest.Method = new HttpMethod("POST");
 0915            _httpRequest.RequestUri = new System.Uri(_url);
 916            // Set Headers
 917
 918
 0919            if (customHeaders != null)
 920            {
 0921                foreach(var _header in customHeaders)
 922                {
 0923                    if (_httpRequest.Headers.Contains(_header.Key))
 924                    {
 0925                        _httpRequest.Headers.Remove(_header.Key);
 926                    }
 0927                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 928                }
 929            }
 930
 931            // Serialize Request
 0932            string _requestContent = null;
 933            // Set Credentials
 0934            if (Client.Credentials != null)
 935            {
 0936                cancellationToken.ThrowIfCancellationRequested();
 0937                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 938            }
 939            // Send Request
 0940            if (_shouldTrace)
 941            {
 0942                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 943            }
 0944            cancellationToken.ThrowIfCancellationRequested();
 0945            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0946            if (_shouldTrace)
 947            {
 0948                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 949            }
 0950            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0951            cancellationToken.ThrowIfCancellationRequested();
 0952            string _responseContent = null;
 0953            if ((int)_statusCode != 200)
 954            {
 0955                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 956                try
 957                {
 0958                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0959                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0960                    if (_errorBody != null)
 961                    {
 0962                        ex.Body = _errorBody;
 963                    }
 0964                }
 0965                catch (JsonException)
 966                {
 967                    // Ignore the exception
 0968                }
 0969                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0970                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0971                if (_shouldTrace)
 972                {
 0973                    ServiceClientTracing.Error(_invocationId, ex);
 974                }
 0975                _httpRequest.Dispose();
 0976                if (_httpResponse != null)
 977                {
 0978                    _httpResponse.Dispose();
 979                }
 0980                throw ex;
 981            }
 982            // Create Result
 0983            var _result = new HttpOperationResponse<RefreshIndex>();
 0984            _result.Request = _httpRequest;
 0985            _result.Response = _httpResponse;
 986            // Deserialize Response
 0987            if ((int)_statusCode == 200)
 988            {
 0989                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 990                try
 991                {
 0992                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<RefreshIndex>(_responseContent, 
 0993                }
 0994                catch (JsonException ex)
 995                {
 0996                    _httpRequest.Dispose();
 0997                    if (_httpResponse != null)
 998                    {
 0999                        _httpResponse.Dispose();
 1000                    }
 01001                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1002                }
 1003            }
 01004            if (_shouldTrace)
 1005            {
 01006                ServiceClientTracing.Exit(_invocationId, _result);
 1007            }
 01008            return _result;
 01009        }
 1010
 1011    }
 1012}