< Summary

Class:Microsoft.Azure.CognitiveServices.ContentModerator.ListManagementImageLists
Assembly:Microsoft.Azure.CognitiveServices.Vision.ContentModerator
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.ContentModerator\src\Generated\ListManagementImageLists.cs
Covered lines:4
Uncovered lines:440
Coverable lines:444
Total lines:994
Line coverage:0.9% (4 of 444)
Covered branches:1
Total branches:214
Branch coverage:0.4% (1 of 214)

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%
GetAllImageListsWithHttpMessagesAsync()-0%0%
RefreshIndexMethodWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.ContentModerator\src\Generated\ListManagementImageLists.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    /// ListManagementImageLists operations.
 23    /// </summary>
 24    public partial class ListManagementImageLists : IServiceOperations<ContentModeratorClient>, IListManagementImageList
 25    {
 26        /// <summary>
 27        /// Initializes a new instance of the ListManagementImageLists 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 ListManagementImageLists(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 the details of the image 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='customHeaders'>
 56        /// Headers that will be added to request.
 57        /// </param>
 58        /// <param name='cancellationToken'>
 59        /// The cancellation token.
 60        /// </param>
 61        /// <exception cref="APIErrorException">
 62        /// Thrown when the operation returned an invalid status code
 63        /// </exception>
 64        /// <exception cref="SerializationException">
 65        /// Thrown when unable to deserialize the response
 66        /// </exception>
 67        /// <exception cref="ValidationException">
 68        /// Thrown when a required parameter is null
 69        /// </exception>
 70        /// <exception cref="System.ArgumentNullException">
 71        /// Thrown when a required parameter is null
 72        /// </exception>
 73        /// <return>
 74        /// A response object containing the response body and response headers.
 75        /// </return>
 76        public async Task<HttpOperationResponse<ImageList>> GetDetailsWithHttpMessagesAsync(string listId, Dictionary<st
 77        {
 078            if (Client.Endpoint == null)
 79            {
 080                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 81            }
 082            if (listId == null)
 83            {
 084                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 85            }
 86            // Tracing
 087            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 088            string _invocationId = null;
 089            if (_shouldTrace)
 90            {
 091                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 092                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 093                tracingParameters.Add("listId", listId);
 094                tracingParameters.Add("cancellationToken", cancellationToken);
 095                ServiceClientTracing.Enter(_invocationId, this, "GetDetails", tracingParameters);
 96            }
 97            // Construct URL
 098            var _baseUrl = Client.BaseUri;
 099            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0100            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0101            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 102            // Create HTTP transport objects
 0103            var _httpRequest = new HttpRequestMessage();
 0104            HttpResponseMessage _httpResponse = null;
 0105            _httpRequest.Method = new HttpMethod("GET");
 0106            _httpRequest.RequestUri = new System.Uri(_url);
 107            // Set Headers
 108
 109
 0110            if (customHeaders != null)
 111            {
 0112                foreach(var _header in customHeaders)
 113                {
 0114                    if (_httpRequest.Headers.Contains(_header.Key))
 115                    {
 0116                        _httpRequest.Headers.Remove(_header.Key);
 117                    }
 0118                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 119                }
 120            }
 121
 122            // Serialize Request
 0123            string _requestContent = null;
 124            // Set Credentials
 0125            if (Client.Credentials != null)
 126            {
 0127                cancellationToken.ThrowIfCancellationRequested();
 0128                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 129            }
 130            // Send Request
 0131            if (_shouldTrace)
 132            {
 0133                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 134            }
 0135            cancellationToken.ThrowIfCancellationRequested();
 0136            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0137            if (_shouldTrace)
 138            {
 0139                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 140            }
 0141            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0142            cancellationToken.ThrowIfCancellationRequested();
 0143            string _responseContent = null;
 0144            if ((int)_statusCode != 200)
 145            {
 0146                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 147                try
 148                {
 0149                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0150                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0151                    if (_errorBody != null)
 152                    {
 0153                        ex.Body = _errorBody;
 154                    }
 0155                }
 0156                catch (JsonException)
 157                {
 158                    // Ignore the exception
 0159                }
 0160                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0161                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0162                if (_shouldTrace)
 163                {
 0164                    ServiceClientTracing.Error(_invocationId, ex);
 165                }
 0166                _httpRequest.Dispose();
 0167                if (_httpResponse != null)
 168                {
 0169                    _httpResponse.Dispose();
 170                }
 0171                throw ex;
 172            }
 173            // Create Result
 0174            var _result = new HttpOperationResponse<ImageList>();
 0175            _result.Request = _httpRequest;
 0176            _result.Response = _httpResponse;
 177            // Deserialize Response
 0178            if ((int)_statusCode == 200)
 179            {
 0180                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 181                try
 182                {
 0183                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ImageList>(_responseContent, Cli
 0184                }
 0185                catch (JsonException ex)
 186                {
 0187                    _httpRequest.Dispose();
 0188                    if (_httpResponse != null)
 189                    {
 0190                        _httpResponse.Dispose();
 191                    }
 0192                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 193                }
 194            }
 0195            if (_shouldTrace)
 196            {
 0197                ServiceClientTracing.Exit(_invocationId, _result);
 198            }
 0199            return _result;
 0200        }
 201
 202        /// <summary>
 203        /// Deletes image list with the list Id equal to list Id passed.
 204        /// </summary>
 205        /// <param name='listId'>
 206        /// List Id of the image list.
 207        /// </param>
 208        /// <param name='customHeaders'>
 209        /// Headers that will be added to request.
 210        /// </param>
 211        /// <param name='cancellationToken'>
 212        /// The cancellation token.
 213        /// </param>
 214        /// <exception cref="APIErrorException">
 215        /// Thrown when the operation returned an invalid status code
 216        /// </exception>
 217        /// <exception cref="SerializationException">
 218        /// Thrown when unable to deserialize the response
 219        /// </exception>
 220        /// <exception cref="ValidationException">
 221        /// Thrown when a required parameter is null
 222        /// </exception>
 223        /// <exception cref="System.ArgumentNullException">
 224        /// Thrown when a required parameter is null
 225        /// </exception>
 226        /// <return>
 227        /// A response object containing the response body and response headers.
 228        /// </return>
 229        public async Task<HttpOperationResponse<string>> DeleteWithHttpMessagesAsync(string listId, Dictionary<string, L
 230        {
 0231            if (Client.Endpoint == null)
 232            {
 0233                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 234            }
 0235            if (listId == null)
 236            {
 0237                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 238            }
 239            // Tracing
 0240            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0241            string _invocationId = null;
 0242            if (_shouldTrace)
 243            {
 0244                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0245                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0246                tracingParameters.Add("listId", listId);
 0247                tracingParameters.Add("cancellationToken", cancellationToken);
 0248                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 249            }
 250            // Construct URL
 0251            var _baseUrl = Client.BaseUri;
 0252            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0253            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0254            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 255            // Create HTTP transport objects
 0256            var _httpRequest = new HttpRequestMessage();
 0257            HttpResponseMessage _httpResponse = null;
 0258            _httpRequest.Method = new HttpMethod("DELETE");
 0259            _httpRequest.RequestUri = new System.Uri(_url);
 260            // Set Headers
 261
 262
 0263            if (customHeaders != null)
 264            {
 0265                foreach(var _header in customHeaders)
 266                {
 0267                    if (_httpRequest.Headers.Contains(_header.Key))
 268                    {
 0269                        _httpRequest.Headers.Remove(_header.Key);
 270                    }
 0271                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 272                }
 273            }
 274
 275            // Serialize Request
 0276            string _requestContent = null;
 277            // Set Credentials
 0278            if (Client.Credentials != null)
 279            {
 0280                cancellationToken.ThrowIfCancellationRequested();
 0281                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 282            }
 283            // Send Request
 0284            if (_shouldTrace)
 285            {
 0286                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 287            }
 0288            cancellationToken.ThrowIfCancellationRequested();
 0289            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0290            if (_shouldTrace)
 291            {
 0292                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 293            }
 0294            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0295            cancellationToken.ThrowIfCancellationRequested();
 0296            string _responseContent = null;
 0297            if ((int)_statusCode != 200)
 298            {
 0299                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 300                try
 301                {
 0302                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0303                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0304                    if (_errorBody != null)
 305                    {
 0306                        ex.Body = _errorBody;
 307                    }
 0308                }
 0309                catch (JsonException)
 310                {
 311                    // Ignore the exception
 0312                }
 0313                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0314                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0315                if (_shouldTrace)
 316                {
 0317                    ServiceClientTracing.Error(_invocationId, ex);
 318                }
 0319                _httpRequest.Dispose();
 0320                if (_httpResponse != null)
 321                {
 0322                    _httpResponse.Dispose();
 323                }
 0324                throw ex;
 325            }
 326            // Create Result
 0327            var _result = new HttpOperationResponse<string>();
 0328            _result.Request = _httpRequest;
 0329            _result.Response = _httpResponse;
 330            // Deserialize Response
 0331            if ((int)_statusCode == 200)
 332            {
 0333                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 334                try
 335                {
 0336                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 0337                }
 0338                catch (JsonException ex)
 339                {
 0340                    _httpRequest.Dispose();
 0341                    if (_httpResponse != null)
 342                    {
 0343                        _httpResponse.Dispose();
 344                    }
 0345                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 346                }
 347            }
 0348            if (_shouldTrace)
 349            {
 0350                ServiceClientTracing.Exit(_invocationId, _result);
 351            }
 0352            return _result;
 0353        }
 354
 355        /// <summary>
 356        /// Updates an image list with list Id equal to list Id passed.
 357        /// </summary>
 358        /// <param name='listId'>
 359        /// List Id of the image list.
 360        /// </param>
 361        /// <param name='contentType'>
 362        /// The content type.
 363        /// </param>
 364        /// <param name='body'>
 365        /// Schema of the body.
 366        /// </param>
 367        /// <param name='customHeaders'>
 368        /// Headers that will be added to request.
 369        /// </param>
 370        /// <param name='cancellationToken'>
 371        /// The cancellation token.
 372        /// </param>
 373        /// <exception cref="APIErrorException">
 374        /// Thrown when the operation returned an invalid status code
 375        /// </exception>
 376        /// <exception cref="SerializationException">
 377        /// Thrown when unable to deserialize the response
 378        /// </exception>
 379        /// <exception cref="ValidationException">
 380        /// Thrown when a required parameter is null
 381        /// </exception>
 382        /// <exception cref="System.ArgumentNullException">
 383        /// Thrown when a required parameter is null
 384        /// </exception>
 385        /// <return>
 386        /// A response object containing the response body and response headers.
 387        /// </return>
 388        public async Task<HttpOperationResponse<ImageList>> UpdateWithHttpMessagesAsync(string listId, string contentTyp
 389        {
 0390            if (Client.Endpoint == null)
 391            {
 0392                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 393            }
 0394            if (listId == null)
 395            {
 0396                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 397            }
 0398            if (contentType == null)
 399            {
 0400                throw new ValidationException(ValidationRules.CannotBeNull, "contentType");
 401            }
 0402            if (body == null)
 403            {
 0404                throw new ValidationException(ValidationRules.CannotBeNull, "body");
 405            }
 406            // Tracing
 0407            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0408            string _invocationId = null;
 0409            if (_shouldTrace)
 410            {
 0411                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0412                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0413                tracingParameters.Add("listId", listId);
 0414                tracingParameters.Add("contentType", contentType);
 0415                tracingParameters.Add("body", body);
 0416                tracingParameters.Add("cancellationToken", cancellationToken);
 0417                ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
 418            }
 419            // Construct URL
 0420            var _baseUrl = Client.BaseUri;
 0421            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0422            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0423            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 424            // Create HTTP transport objects
 0425            var _httpRequest = new HttpRequestMessage();
 0426            HttpResponseMessage _httpResponse = null;
 0427            _httpRequest.Method = new HttpMethod("PUT");
 0428            _httpRequest.RequestUri = new System.Uri(_url);
 429            // Set Headers
 430
 431
 0432            if (customHeaders != null)
 433            {
 0434                foreach(var _header in customHeaders)
 435                {
 0436                    if (_httpRequest.Headers.Contains(_header.Key))
 437                    {
 0438                        _httpRequest.Headers.Remove(_header.Key);
 439                    }
 0440                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 441                }
 442            }
 443
 444            // Serialize Request
 0445            string _requestContent = null;
 0446            if(body != null)
 447            {
 0448                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings)
 0449                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0450                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 451            }
 452            // Set Credentials
 0453            if (Client.Credentials != null)
 454            {
 0455                cancellationToken.ThrowIfCancellationRequested();
 0456                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 457            }
 458            // Send Request
 0459            if (_shouldTrace)
 460            {
 0461                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 462            }
 0463            cancellationToken.ThrowIfCancellationRequested();
 0464            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0465            if (_shouldTrace)
 466            {
 0467                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 468            }
 0469            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0470            cancellationToken.ThrowIfCancellationRequested();
 0471            string _responseContent = null;
 0472            if ((int)_statusCode != 200)
 473            {
 0474                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 475                try
 476                {
 0477                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0478                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0479                    if (_errorBody != null)
 480                    {
 0481                        ex.Body = _errorBody;
 482                    }
 0483                }
 0484                catch (JsonException)
 485                {
 486                    // Ignore the exception
 0487                }
 0488                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0489                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0490                if (_shouldTrace)
 491                {
 0492                    ServiceClientTracing.Error(_invocationId, ex);
 493                }
 0494                _httpRequest.Dispose();
 0495                if (_httpResponse != null)
 496                {
 0497                    _httpResponse.Dispose();
 498                }
 0499                throw ex;
 500            }
 501            // Create Result
 0502            var _result = new HttpOperationResponse<ImageList>();
 0503            _result.Request = _httpRequest;
 0504            _result.Response = _httpResponse;
 505            // Deserialize Response
 0506            if ((int)_statusCode == 200)
 507            {
 0508                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 509                try
 510                {
 0511                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ImageList>(_responseContent, Cli
 0512                }
 0513                catch (JsonException ex)
 514                {
 0515                    _httpRequest.Dispose();
 0516                    if (_httpResponse != null)
 517                    {
 0518                        _httpResponse.Dispose();
 519                    }
 0520                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 521                }
 522            }
 0523            if (_shouldTrace)
 524            {
 0525                ServiceClientTracing.Exit(_invocationId, _result);
 526            }
 0527            return _result;
 0528        }
 529
 530        /// <summary>
 531        /// Creates an image list.
 532        /// </summary>
 533        /// <param name='contentType'>
 534        /// The content type.
 535        /// </param>
 536        /// <param name='body'>
 537        /// Schema of the body.
 538        /// </param>
 539        /// <param name='customHeaders'>
 540        /// Headers that will be added to request.
 541        /// </param>
 542        /// <param name='cancellationToken'>
 543        /// The cancellation token.
 544        /// </param>
 545        /// <exception cref="APIErrorException">
 546        /// Thrown when the operation returned an invalid status code
 547        /// </exception>
 548        /// <exception cref="SerializationException">
 549        /// Thrown when unable to deserialize the response
 550        /// </exception>
 551        /// <exception cref="ValidationException">
 552        /// Thrown when a required parameter is null
 553        /// </exception>
 554        /// <exception cref="System.ArgumentNullException">
 555        /// Thrown when a required parameter is null
 556        /// </exception>
 557        /// <return>
 558        /// A response object containing the response body and response headers.
 559        /// </return>
 560        public async Task<HttpOperationResponse<ImageList>> CreateWithHttpMessagesAsync(string contentType, Body body, D
 561        {
 0562            if (Client.Endpoint == null)
 563            {
 0564                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 565            }
 0566            if (contentType == null)
 567            {
 0568                throw new ValidationException(ValidationRules.CannotBeNull, "contentType");
 569            }
 0570            if (body == null)
 571            {
 0572                throw new ValidationException(ValidationRules.CannotBeNull, "body");
 573            }
 574            // Tracing
 0575            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0576            string _invocationId = null;
 0577            if (_shouldTrace)
 578            {
 0579                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0580                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0581                tracingParameters.Add("contentType", contentType);
 0582                tracingParameters.Add("body", body);
 0583                tracingParameters.Add("cancellationToken", cancellationToken);
 0584                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
 585            }
 586            // Construct URL
 0587            var _baseUrl = Client.BaseUri;
 0588            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists";
 0589            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 590            // Create HTTP transport objects
 0591            var _httpRequest = new HttpRequestMessage();
 0592            HttpResponseMessage _httpResponse = null;
 0593            _httpRequest.Method = new HttpMethod("POST");
 0594            _httpRequest.RequestUri = new System.Uri(_url);
 595            // Set Headers
 596
 597
 0598            if (customHeaders != null)
 599            {
 0600                foreach(var _header in customHeaders)
 601                {
 0602                    if (_httpRequest.Headers.Contains(_header.Key))
 603                    {
 0604                        _httpRequest.Headers.Remove(_header.Key);
 605                    }
 0606                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 607                }
 608            }
 609
 610            // Serialize Request
 0611            string _requestContent = null;
 0612            if(body != null)
 613            {
 0614                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings)
 0615                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0616                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 617            }
 618            // Set Credentials
 0619            if (Client.Credentials != null)
 620            {
 0621                cancellationToken.ThrowIfCancellationRequested();
 0622                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 623            }
 624            // Send Request
 0625            if (_shouldTrace)
 626            {
 0627                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 628            }
 0629            cancellationToken.ThrowIfCancellationRequested();
 0630            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0631            if (_shouldTrace)
 632            {
 0633                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 634            }
 0635            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0636            cancellationToken.ThrowIfCancellationRequested();
 0637            string _responseContent = null;
 0638            if ((int)_statusCode != 200)
 639            {
 0640                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 641                try
 642                {
 0643                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0644                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0645                    if (_errorBody != null)
 646                    {
 0647                        ex.Body = _errorBody;
 648                    }
 0649                }
 0650                catch (JsonException)
 651                {
 652                    // Ignore the exception
 0653                }
 0654                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0655                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0656                if (_shouldTrace)
 657                {
 0658                    ServiceClientTracing.Error(_invocationId, ex);
 659                }
 0660                _httpRequest.Dispose();
 0661                if (_httpResponse != null)
 662                {
 0663                    _httpResponse.Dispose();
 664                }
 0665                throw ex;
 666            }
 667            // Create Result
 0668            var _result = new HttpOperationResponse<ImageList>();
 0669            _result.Request = _httpRequest;
 0670            _result.Response = _httpResponse;
 671            // Deserialize Response
 0672            if ((int)_statusCode == 200)
 673            {
 0674                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 675                try
 676                {
 0677                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ImageList>(_responseContent, Cli
 0678                }
 0679                catch (JsonException ex)
 680                {
 0681                    _httpRequest.Dispose();
 0682                    if (_httpResponse != null)
 683                    {
 0684                        _httpResponse.Dispose();
 685                    }
 0686                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 687                }
 688            }
 0689            if (_shouldTrace)
 690            {
 0691                ServiceClientTracing.Exit(_invocationId, _result);
 692            }
 0693            return _result;
 0694        }
 695
 696        /// <summary>
 697        /// Gets all the Image Lists.
 698        /// </summary>
 699        /// <param name='customHeaders'>
 700        /// Headers that will be added to request.
 701        /// </param>
 702        /// <param name='cancellationToken'>
 703        /// The cancellation token.
 704        /// </param>
 705        /// <exception cref="APIErrorException">
 706        /// Thrown when the operation returned an invalid status code
 707        /// </exception>
 708        /// <exception cref="SerializationException">
 709        /// Thrown when unable to deserialize the response
 710        /// </exception>
 711        /// <exception cref="ValidationException">
 712        /// Thrown when a required parameter is null
 713        /// </exception>
 714        /// <exception cref="System.ArgumentNullException">
 715        /// Thrown when a required parameter is null
 716        /// </exception>
 717        /// <return>
 718        /// A response object containing the response body and response headers.
 719        /// </return>
 720        public async Task<HttpOperationResponse<IList<ImageList>>> GetAllImageListsWithHttpMessagesAsync(Dictionary<stri
 721        {
 0722            if (Client.Endpoint == null)
 723            {
 0724                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 725            }
 726            // Tracing
 0727            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0728            string _invocationId = null;
 0729            if (_shouldTrace)
 730            {
 0731                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0732                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0733                tracingParameters.Add("cancellationToken", cancellationToken);
 0734                ServiceClientTracing.Enter(_invocationId, this, "GetAllImageLists", tracingParameters);
 735            }
 736            // Construct URL
 0737            var _baseUrl = Client.BaseUri;
 0738            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists";
 0739            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 740            // Create HTTP transport objects
 0741            var _httpRequest = new HttpRequestMessage();
 0742            HttpResponseMessage _httpResponse = null;
 0743            _httpRequest.Method = new HttpMethod("GET");
 0744            _httpRequest.RequestUri = new System.Uri(_url);
 745            // Set Headers
 746
 747
 0748            if (customHeaders != null)
 749            {
 0750                foreach(var _header in customHeaders)
 751                {
 0752                    if (_httpRequest.Headers.Contains(_header.Key))
 753                    {
 0754                        _httpRequest.Headers.Remove(_header.Key);
 755                    }
 0756                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 757                }
 758            }
 759
 760            // Serialize Request
 0761            string _requestContent = null;
 762            // Set Credentials
 0763            if (Client.Credentials != null)
 764            {
 0765                cancellationToken.ThrowIfCancellationRequested();
 0766                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 767            }
 768            // Send Request
 0769            if (_shouldTrace)
 770            {
 0771                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 772            }
 0773            cancellationToken.ThrowIfCancellationRequested();
 0774            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0775            if (_shouldTrace)
 776            {
 0777                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 778            }
 0779            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0780            cancellationToken.ThrowIfCancellationRequested();
 0781            string _responseContent = null;
 0782            if ((int)_statusCode != 200)
 783            {
 0784                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 785                try
 786                {
 0787                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0788                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0789                    if (_errorBody != null)
 790                    {
 0791                        ex.Body = _errorBody;
 792                    }
 0793                }
 0794                catch (JsonException)
 795                {
 796                    // Ignore the exception
 0797                }
 0798                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0799                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0800                if (_shouldTrace)
 801                {
 0802                    ServiceClientTracing.Error(_invocationId, ex);
 803                }
 0804                _httpRequest.Dispose();
 0805                if (_httpResponse != null)
 806                {
 0807                    _httpResponse.Dispose();
 808                }
 0809                throw ex;
 810            }
 811            // Create Result
 0812            var _result = new HttpOperationResponse<IList<ImageList>>();
 0813            _result.Request = _httpRequest;
 0814            _result.Response = _httpResponse;
 815            // Deserialize Response
 0816            if ((int)_statusCode == 200)
 817            {
 0818                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 819                try
 820                {
 0821                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ImageList>>(_responseConte
 0822                }
 0823                catch (JsonException ex)
 824                {
 0825                    _httpRequest.Dispose();
 0826                    if (_httpResponse != null)
 827                    {
 0828                        _httpResponse.Dispose();
 829                    }
 0830                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 831                }
 832            }
 0833            if (_shouldTrace)
 834            {
 0835                ServiceClientTracing.Exit(_invocationId, _result);
 836            }
 0837            return _result;
 0838        }
 839
 840        /// <summary>
 841        /// Refreshes the index of the list with list Id equal to list Id passed.
 842        /// </summary>
 843        /// <param name='listId'>
 844        /// List Id of the image list.
 845        /// </param>
 846        /// <param name='customHeaders'>
 847        /// Headers that will be added to request.
 848        /// </param>
 849        /// <param name='cancellationToken'>
 850        /// The cancellation token.
 851        /// </param>
 852        /// <exception cref="APIErrorException">
 853        /// Thrown when the operation returned an invalid status code
 854        /// </exception>
 855        /// <exception cref="SerializationException">
 856        /// Thrown when unable to deserialize the response
 857        /// </exception>
 858        /// <exception cref="ValidationException">
 859        /// Thrown when a required parameter is null
 860        /// </exception>
 861        /// <exception cref="System.ArgumentNullException">
 862        /// Thrown when a required parameter is null
 863        /// </exception>
 864        /// <return>
 865        /// A response object containing the response body and response headers.
 866        /// </return>
 867        public async Task<HttpOperationResponse<RefreshIndex>> RefreshIndexMethodWithHttpMessagesAsync(string listId, Di
 868        {
 0869            if (Client.Endpoint == null)
 870            {
 0871                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 872            }
 0873            if (listId == null)
 874            {
 0875                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 876            }
 877            // Tracing
 0878            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0879            string _invocationId = null;
 0880            if (_shouldTrace)
 881            {
 0882                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0883                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0884                tracingParameters.Add("listId", listId);
 0885                tracingParameters.Add("cancellationToken", cancellationToken);
 0886                ServiceClientTracing.Enter(_invocationId, this, "RefreshIndexMethod", tracingParameters);
 887            }
 888            // Construct URL
 0889            var _baseUrl = Client.BaseUri;
 0890            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0891            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0892            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 893            // Create HTTP transport objects
 0894            var _httpRequest = new HttpRequestMessage();
 0895            HttpResponseMessage _httpResponse = null;
 0896            _httpRequest.Method = new HttpMethod("POST");
 0897            _httpRequest.RequestUri = new System.Uri(_url);
 898            // Set Headers
 899
 900
 0901            if (customHeaders != null)
 902            {
 0903                foreach(var _header in customHeaders)
 904                {
 0905                    if (_httpRequest.Headers.Contains(_header.Key))
 906                    {
 0907                        _httpRequest.Headers.Remove(_header.Key);
 908                    }
 0909                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 910                }
 911            }
 912
 913            // Serialize Request
 0914            string _requestContent = null;
 915            // Set Credentials
 0916            if (Client.Credentials != null)
 917            {
 0918                cancellationToken.ThrowIfCancellationRequested();
 0919                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 920            }
 921            // Send Request
 0922            if (_shouldTrace)
 923            {
 0924                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 925            }
 0926            cancellationToken.ThrowIfCancellationRequested();
 0927            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0928            if (_shouldTrace)
 929            {
 0930                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 931            }
 0932            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0933            cancellationToken.ThrowIfCancellationRequested();
 0934            string _responseContent = null;
 0935            if ((int)_statusCode != 200)
 936            {
 0937                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 938                try
 939                {
 0940                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0941                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0942                    if (_errorBody != null)
 943                    {
 0944                        ex.Body = _errorBody;
 945                    }
 0946                }
 0947                catch (JsonException)
 948                {
 949                    // Ignore the exception
 0950                }
 0951                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0952                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0953                if (_shouldTrace)
 954                {
 0955                    ServiceClientTracing.Error(_invocationId, ex);
 956                }
 0957                _httpRequest.Dispose();
 0958                if (_httpResponse != null)
 959                {
 0960                    _httpResponse.Dispose();
 961                }
 0962                throw ex;
 963            }
 964            // Create Result
 0965            var _result = new HttpOperationResponse<RefreshIndex>();
 0966            _result.Request = _httpRequest;
 0967            _result.Response = _httpResponse;
 968            // Deserialize Response
 0969            if ((int)_statusCode == 200)
 970            {
 0971                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 972                try
 973                {
 0974                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<RefreshIndex>(_responseContent, 
 0975                }
 0976                catch (JsonException ex)
 977                {
 0978                    _httpRequest.Dispose();
 0979                    if (_httpResponse != null)
 980                    {
 0981                        _httpResponse.Dispose();
 982                    }
 0983                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 984                }
 985            }
 0986            if (_shouldTrace)
 987            {
 0988                ServiceClientTracing.Exit(_invocationId, _result);
 989            }
 0990            return _result;
 0991        }
 992
 993    }
 994}