< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-0%100%
AddImageWithHttpMessagesAsync()-0%0%
DeleteAllImagesWithHttpMessagesAsync()-0%0%
GetAllImageIdsWithHttpMessagesAsync()-0%0%
DeleteImageWithHttpMessagesAsync()-0%0%
AddImageUrlInputWithHttpMessagesAsync()-0%0%
AddImageFileInputWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.ContentModerator\src\Generated\ListManagementImage.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    /// ListManagementImage operations.
 23    /// </summary>
 24    public partial class ListManagementImage : IServiceOperations<ContentModeratorClient>, IListManagementImage
 25    {
 26        /// <summary>
 27        /// Initializes a new instance of the ListManagementImage 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 ListManagementImage(ContentModeratorClient client)
 36        {
 537            if (client == null)
 38            {
 039                throw new System.ArgumentNullException("client");
 40            }
 541            Client = client;
 542        }
 43
 44        /// <summary>
 45        /// Gets a reference to the ContentModeratorClient
 46        /// </summary>
 047        public ContentModeratorClient Client { get; private set; }
 48
 49        /// <summary>
 50        /// Add an image to the 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='tag'>
 56        /// Tag for the image.
 57        /// </param>
 58        /// <param name='label'>
 59        /// The image label.
 60        /// </param>
 61        /// <param name='customHeaders'>
 62        /// Headers that will be added to request.
 63        /// </param>
 64        /// <param name='cancellationToken'>
 65        /// The cancellation token.
 66        /// </param>
 67        /// <exception cref="APIErrorException">
 68        /// Thrown when the operation returned an invalid status code
 69        /// </exception>
 70        /// <exception cref="SerializationException">
 71        /// Thrown when unable to deserialize the response
 72        /// </exception>
 73        /// <exception cref="ValidationException">
 74        /// Thrown when a required parameter is null
 75        /// </exception>
 76        /// <exception cref="System.ArgumentNullException">
 77        /// Thrown when a required parameter is null
 78        /// </exception>
 79        /// <return>
 80        /// A response object containing the response body and response headers.
 81        /// </return>
 82        public async Task<HttpOperationResponse<Image>> AddImageWithHttpMessagesAsync(string listId, int? tag = default(
 83        {
 084            if (Client.Endpoint == null)
 85            {
 086                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 87            }
 088            if (listId == null)
 89            {
 090                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 91            }
 92            // Tracing
 093            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 094            string _invocationId = null;
 095            if (_shouldTrace)
 96            {
 097                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 098                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 099                tracingParameters.Add("listId", listId);
 0100                tracingParameters.Add("tag", tag);
 0101                tracingParameters.Add("label", label);
 0102                tracingParameters.Add("cancellationToken", cancellationToken);
 0103                ServiceClientTracing.Enter(_invocationId, this, "AddImage", tracingParameters);
 104            }
 105            // Construct URL
 0106            var _baseUrl = Client.BaseUri;
 0107            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0108            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0109            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 0110            List<string> _queryParameters = new List<string>();
 0111            if (tag != null)
 112            {
 0113                _queryParameters.Add(string.Format("tag={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCon
 114            }
 0115            if (label != null)
 116            {
 0117                _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
 118            }
 0119            if (_queryParameters.Count > 0)
 120            {
 0121                _url += "?" + string.Join("&", _queryParameters);
 122            }
 123            // Create HTTP transport objects
 0124            var _httpRequest = new HttpRequestMessage();
 0125            HttpResponseMessage _httpResponse = null;
 0126            _httpRequest.Method = new HttpMethod("POST");
 0127            _httpRequest.RequestUri = new System.Uri(_url);
 128            // Set Headers
 129
 130
 0131            if (customHeaders != null)
 132            {
 0133                foreach(var _header in customHeaders)
 134                {
 0135                    if (_httpRequest.Headers.Contains(_header.Key))
 136                    {
 0137                        _httpRequest.Headers.Remove(_header.Key);
 138                    }
 0139                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 140                }
 141            }
 142
 143            // Serialize Request
 0144            string _requestContent = null;
 145            // Set Credentials
 0146            if (Client.Credentials != null)
 147            {
 0148                cancellationToken.ThrowIfCancellationRequested();
 0149                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 150            }
 151            // Send Request
 0152            if (_shouldTrace)
 153            {
 0154                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 155            }
 0156            cancellationToken.ThrowIfCancellationRequested();
 0157            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0158            if (_shouldTrace)
 159            {
 0160                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 161            }
 0162            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0163            cancellationToken.ThrowIfCancellationRequested();
 0164            string _responseContent = null;
 0165            if ((int)_statusCode != 200)
 166            {
 0167                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 168                try
 169                {
 0170                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0171                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0172                    if (_errorBody != null)
 173                    {
 0174                        ex.Body = _errorBody;
 175                    }
 0176                }
 0177                catch (JsonException)
 178                {
 179                    // Ignore the exception
 0180                }
 0181                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0182                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0183                if (_shouldTrace)
 184                {
 0185                    ServiceClientTracing.Error(_invocationId, ex);
 186                }
 0187                _httpRequest.Dispose();
 0188                if (_httpResponse != null)
 189                {
 0190                    _httpResponse.Dispose();
 191                }
 0192                throw ex;
 193            }
 194            // Create Result
 0195            var _result = new HttpOperationResponse<Image>();
 0196            _result.Request = _httpRequest;
 0197            _result.Response = _httpResponse;
 198            // Deserialize Response
 0199            if ((int)_statusCode == 200)
 200            {
 0201                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 202                try
 203                {
 0204                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Image>(_responseContent, Client.
 0205                }
 0206                catch (JsonException ex)
 207                {
 0208                    _httpRequest.Dispose();
 0209                    if (_httpResponse != null)
 210                    {
 0211                        _httpResponse.Dispose();
 212                    }
 0213                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 214                }
 215            }
 0216            if (_shouldTrace)
 217            {
 0218                ServiceClientTracing.Exit(_invocationId, _result);
 219            }
 0220            return _result;
 0221        }
 222
 223        /// <summary>
 224        /// Deletes all images from the list with list Id equal to list Id passed.
 225        /// </summary>
 226        /// <param name='listId'>
 227        /// List Id of the image list.
 228        /// </param>
 229        /// <param name='customHeaders'>
 230        /// Headers that will be added to request.
 231        /// </param>
 232        /// <param name='cancellationToken'>
 233        /// The cancellation token.
 234        /// </param>
 235        /// <exception cref="APIErrorException">
 236        /// Thrown when the operation returned an invalid status code
 237        /// </exception>
 238        /// <exception cref="SerializationException">
 239        /// Thrown when unable to deserialize the response
 240        /// </exception>
 241        /// <exception cref="ValidationException">
 242        /// Thrown when a required parameter is null
 243        /// </exception>
 244        /// <exception cref="System.ArgumentNullException">
 245        /// Thrown when a required parameter is null
 246        /// </exception>
 247        /// <return>
 248        /// A response object containing the response body and response headers.
 249        /// </return>
 250        public async Task<HttpOperationResponse<string>> DeleteAllImagesWithHttpMessagesAsync(string listId, Dictionary<
 251        {
 0252            if (Client.Endpoint == null)
 253            {
 0254                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 255            }
 0256            if (listId == null)
 257            {
 0258                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 259            }
 260            // Tracing
 0261            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0262            string _invocationId = null;
 0263            if (_shouldTrace)
 264            {
 0265                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0266                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0267                tracingParameters.Add("listId", listId);
 0268                tracingParameters.Add("cancellationToken", cancellationToken);
 0269                ServiceClientTracing.Enter(_invocationId, this, "DeleteAllImages", tracingParameters);
 270            }
 271            // Construct URL
 0272            var _baseUrl = Client.BaseUri;
 0273            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0274            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0275            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 276            // Create HTTP transport objects
 0277            var _httpRequest = new HttpRequestMessage();
 0278            HttpResponseMessage _httpResponse = null;
 0279            _httpRequest.Method = new HttpMethod("DELETE");
 0280            _httpRequest.RequestUri = new System.Uri(_url);
 281            // Set Headers
 282
 283
 0284            if (customHeaders != null)
 285            {
 0286                foreach(var _header in customHeaders)
 287                {
 0288                    if (_httpRequest.Headers.Contains(_header.Key))
 289                    {
 0290                        _httpRequest.Headers.Remove(_header.Key);
 291                    }
 0292                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 293                }
 294            }
 295
 296            // Serialize Request
 0297            string _requestContent = null;
 298            // Set Credentials
 0299            if (Client.Credentials != null)
 300            {
 0301                cancellationToken.ThrowIfCancellationRequested();
 0302                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 303            }
 304            // Send Request
 0305            if (_shouldTrace)
 306            {
 0307                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 308            }
 0309            cancellationToken.ThrowIfCancellationRequested();
 0310            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0311            if (_shouldTrace)
 312            {
 0313                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 314            }
 0315            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0316            cancellationToken.ThrowIfCancellationRequested();
 0317            string _responseContent = null;
 0318            if ((int)_statusCode != 200)
 319            {
 0320                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 321                try
 322                {
 0323                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0324                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0325                    if (_errorBody != null)
 326                    {
 0327                        ex.Body = _errorBody;
 328                    }
 0329                }
 0330                catch (JsonException)
 331                {
 332                    // Ignore the exception
 0333                }
 0334                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0335                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0336                if (_shouldTrace)
 337                {
 0338                    ServiceClientTracing.Error(_invocationId, ex);
 339                }
 0340                _httpRequest.Dispose();
 0341                if (_httpResponse != null)
 342                {
 0343                    _httpResponse.Dispose();
 344                }
 0345                throw ex;
 346            }
 347            // Create Result
 0348            var _result = new HttpOperationResponse<string>();
 0349            _result.Request = _httpRequest;
 0350            _result.Response = _httpResponse;
 351            // Deserialize Response
 0352            if ((int)_statusCode == 200)
 353            {
 0354                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 355                try
 356                {
 0357                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 0358                }
 0359                catch (JsonException ex)
 360                {
 0361                    _httpRequest.Dispose();
 0362                    if (_httpResponse != null)
 363                    {
 0364                        _httpResponse.Dispose();
 365                    }
 0366                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 367                }
 368            }
 0369            if (_shouldTrace)
 370            {
 0371                ServiceClientTracing.Exit(_invocationId, _result);
 372            }
 0373            return _result;
 0374        }
 375
 376        /// <summary>
 377        /// Gets all image Ids from the list with list Id equal to list Id passed.
 378        /// </summary>
 379        /// <param name='listId'>
 380        /// List Id of the image list.
 381        /// </param>
 382        /// <param name='customHeaders'>
 383        /// Headers that will be added to request.
 384        /// </param>
 385        /// <param name='cancellationToken'>
 386        /// The cancellation token.
 387        /// </param>
 388        /// <exception cref="APIErrorException">
 389        /// Thrown when the operation returned an invalid status code
 390        /// </exception>
 391        /// <exception cref="SerializationException">
 392        /// Thrown when unable to deserialize the response
 393        /// </exception>
 394        /// <exception cref="ValidationException">
 395        /// Thrown when a required parameter is null
 396        /// </exception>
 397        /// <exception cref="System.ArgumentNullException">
 398        /// Thrown when a required parameter is null
 399        /// </exception>
 400        /// <return>
 401        /// A response object containing the response body and response headers.
 402        /// </return>
 403        public async Task<HttpOperationResponse<ImageIds>> GetAllImageIdsWithHttpMessagesAsync(string listId, Dictionary
 404        {
 0405            if (Client.Endpoint == null)
 406            {
 0407                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 408            }
 0409            if (listId == null)
 410            {
 0411                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 412            }
 413            // Tracing
 0414            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0415            string _invocationId = null;
 0416            if (_shouldTrace)
 417            {
 0418                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0419                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0420                tracingParameters.Add("listId", listId);
 0421                tracingParameters.Add("cancellationToken", cancellationToken);
 0422                ServiceClientTracing.Enter(_invocationId, this, "GetAllImageIds", tracingParameters);
 423            }
 424            // Construct URL
 0425            var _baseUrl = Client.BaseUri;
 0426            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0427            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0428            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 429            // Create HTTP transport objects
 0430            var _httpRequest = new HttpRequestMessage();
 0431            HttpResponseMessage _httpResponse = null;
 0432            _httpRequest.Method = new HttpMethod("GET");
 0433            _httpRequest.RequestUri = new System.Uri(_url);
 434            // Set Headers
 435
 436
 0437            if (customHeaders != null)
 438            {
 0439                foreach(var _header in customHeaders)
 440                {
 0441                    if (_httpRequest.Headers.Contains(_header.Key))
 442                    {
 0443                        _httpRequest.Headers.Remove(_header.Key);
 444                    }
 0445                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 446                }
 447            }
 448
 449            // Serialize Request
 0450            string _requestContent = null;
 451            // Set Credentials
 0452            if (Client.Credentials != null)
 453            {
 0454                cancellationToken.ThrowIfCancellationRequested();
 0455                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 456            }
 457            // Send Request
 0458            if (_shouldTrace)
 459            {
 0460                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 461            }
 0462            cancellationToken.ThrowIfCancellationRequested();
 0463            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0464            if (_shouldTrace)
 465            {
 0466                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 467            }
 0468            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0469            cancellationToken.ThrowIfCancellationRequested();
 0470            string _responseContent = null;
 0471            if ((int)_statusCode != 200)
 472            {
 0473                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 474                try
 475                {
 0476                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0477                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0478                    if (_errorBody != null)
 479                    {
 0480                        ex.Body = _errorBody;
 481                    }
 0482                }
 0483                catch (JsonException)
 484                {
 485                    // Ignore the exception
 0486                }
 0487                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0488                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0489                if (_shouldTrace)
 490                {
 0491                    ServiceClientTracing.Error(_invocationId, ex);
 492                }
 0493                _httpRequest.Dispose();
 0494                if (_httpResponse != null)
 495                {
 0496                    _httpResponse.Dispose();
 497                }
 0498                throw ex;
 499            }
 500            // Create Result
 0501            var _result = new HttpOperationResponse<ImageIds>();
 0502            _result.Request = _httpRequest;
 0503            _result.Response = _httpResponse;
 504            // Deserialize Response
 0505            if ((int)_statusCode == 200)
 506            {
 0507                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 508                try
 509                {
 0510                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ImageIds>(_responseContent, Clie
 0511                }
 0512                catch (JsonException ex)
 513                {
 0514                    _httpRequest.Dispose();
 0515                    if (_httpResponse != null)
 516                    {
 0517                        _httpResponse.Dispose();
 518                    }
 0519                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 520                }
 521            }
 0522            if (_shouldTrace)
 523            {
 0524                ServiceClientTracing.Exit(_invocationId, _result);
 525            }
 0526            return _result;
 0527        }
 528
 529        /// <summary>
 530        /// Deletes an image from the list with list Id and image Id passed.
 531        /// </summary>
 532        /// <param name='listId'>
 533        /// List Id of the image list.
 534        /// </param>
 535        /// <param name='imageId'>
 536        /// Id of the image.
 537        /// </param>
 538        /// <param name='customHeaders'>
 539        /// Headers that will be added to request.
 540        /// </param>
 541        /// <param name='cancellationToken'>
 542        /// The cancellation token.
 543        /// </param>
 544        /// <exception cref="APIErrorException">
 545        /// Thrown when the operation returned an invalid status code
 546        /// </exception>
 547        /// <exception cref="SerializationException">
 548        /// Thrown when unable to deserialize the response
 549        /// </exception>
 550        /// <exception cref="ValidationException">
 551        /// Thrown when a required parameter is null
 552        /// </exception>
 553        /// <exception cref="System.ArgumentNullException">
 554        /// Thrown when a required parameter is null
 555        /// </exception>
 556        /// <return>
 557        /// A response object containing the response body and response headers.
 558        /// </return>
 559        public async Task<HttpOperationResponse<string>> DeleteImageWithHttpMessagesAsync(string listId, string imageId,
 560        {
 0561            if (Client.Endpoint == null)
 562            {
 0563                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 564            }
 0565            if (listId == null)
 566            {
 0567                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 568            }
 0569            if (imageId == null)
 570            {
 0571                throw new ValidationException(ValidationRules.CannotBeNull, "imageId");
 572            }
 573            // Tracing
 0574            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0575            string _invocationId = null;
 0576            if (_shouldTrace)
 577            {
 0578                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0579                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0580                tracingParameters.Add("listId", listId);
 0581                tracingParameters.Add("imageId", imageId);
 0582                tracingParameters.Add("cancellationToken", cancellationToken);
 0583                ServiceClientTracing.Enter(_invocationId, this, "DeleteImage", tracingParameters);
 584            }
 585            // Construct URL
 0586            var _baseUrl = Client.BaseUri;
 0587            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0588            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0589            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 0590            _url = _url.Replace("{ImageId}", System.Uri.EscapeDataString(imageId));
 591            // Create HTTP transport objects
 0592            var _httpRequest = new HttpRequestMessage();
 0593            HttpResponseMessage _httpResponse = null;
 0594            _httpRequest.Method = new HttpMethod("DELETE");
 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;
 613            // Set Credentials
 0614            if (Client.Credentials != null)
 615            {
 0616                cancellationToken.ThrowIfCancellationRequested();
 0617                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 618            }
 619            // Send Request
 0620            if (_shouldTrace)
 621            {
 0622                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 623            }
 0624            cancellationToken.ThrowIfCancellationRequested();
 0625            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0626            if (_shouldTrace)
 627            {
 0628                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 629            }
 0630            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0631            cancellationToken.ThrowIfCancellationRequested();
 0632            string _responseContent = null;
 0633            if ((int)_statusCode != 200)
 634            {
 0635                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 636                try
 637                {
 0638                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0639                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0640                    if (_errorBody != null)
 641                    {
 0642                        ex.Body = _errorBody;
 643                    }
 0644                }
 0645                catch (JsonException)
 646                {
 647                    // Ignore the exception
 0648                }
 0649                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0650                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0651                if (_shouldTrace)
 652                {
 0653                    ServiceClientTracing.Error(_invocationId, ex);
 654                }
 0655                _httpRequest.Dispose();
 0656                if (_httpResponse != null)
 657                {
 0658                    _httpResponse.Dispose();
 659                }
 0660                throw ex;
 661            }
 662            // Create Result
 0663            var _result = new HttpOperationResponse<string>();
 0664            _result.Request = _httpRequest;
 0665            _result.Response = _httpResponse;
 666            // Deserialize Response
 0667            if ((int)_statusCode == 200)
 668            {
 0669                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 670                try
 671                {
 0672                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 0673                }
 0674                catch (JsonException ex)
 675                {
 0676                    _httpRequest.Dispose();
 0677                    if (_httpResponse != null)
 678                    {
 0679                        _httpResponse.Dispose();
 680                    }
 0681                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 682                }
 683            }
 0684            if (_shouldTrace)
 685            {
 0686                ServiceClientTracing.Exit(_invocationId, _result);
 687            }
 0688            return _result;
 0689        }
 690
 691        /// <summary>
 692        /// Add an image to the list with list Id equal to list Id passed.
 693        /// </summary>
 694        /// <param name='listId'>
 695        /// List Id of the image list.
 696        /// </param>
 697        /// <param name='contentType'>
 698        /// The content type.
 699        /// </param>
 700        /// <param name='imageUrl'>
 701        /// The image url.
 702        /// </param>
 703        /// <param name='tag'>
 704        /// Tag for the image.
 705        /// </param>
 706        /// <param name='label'>
 707        /// The image label.
 708        /// </param>
 709        /// <param name='customHeaders'>
 710        /// Headers that will be added to request.
 711        /// </param>
 712        /// <param name='cancellationToken'>
 713        /// The cancellation token.
 714        /// </param>
 715        /// <exception cref="APIErrorException">
 716        /// Thrown when the operation returned an invalid status code
 717        /// </exception>
 718        /// <exception cref="SerializationException">
 719        /// Thrown when unable to deserialize the response
 720        /// </exception>
 721        /// <exception cref="ValidationException">
 722        /// Thrown when a required parameter is null
 723        /// </exception>
 724        /// <exception cref="System.ArgumentNullException">
 725        /// Thrown when a required parameter is null
 726        /// </exception>
 727        /// <return>
 728        /// A response object containing the response body and response headers.
 729        /// </return>
 730        public async Task<HttpOperationResponse<Image>> AddImageUrlInputWithHttpMessagesAsync(string listId, string cont
 731        {
 0732            if (Client.Endpoint == null)
 733            {
 0734                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 735            }
 0736            if (listId == null)
 737            {
 0738                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 739            }
 0740            if (contentType == null)
 741            {
 0742                throw new ValidationException(ValidationRules.CannotBeNull, "contentType");
 743            }
 0744            if (imageUrl == null)
 745            {
 0746                throw new ValidationException(ValidationRules.CannotBeNull, "imageUrl");
 747            }
 748            // Tracing
 0749            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0750            string _invocationId = null;
 0751            if (_shouldTrace)
 752            {
 0753                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0754                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0755                tracingParameters.Add("listId", listId);
 0756                tracingParameters.Add("tag", tag);
 0757                tracingParameters.Add("label", label);
 0758                tracingParameters.Add("contentType", contentType);
 0759                tracingParameters.Add("imageUrl", imageUrl);
 0760                tracingParameters.Add("cancellationToken", cancellationToken);
 0761                ServiceClientTracing.Enter(_invocationId, this, "AddImageUrlInput", tracingParameters);
 762            }
 763            // Construct URL
 0764            var _baseUrl = Client.BaseUri;
 0765            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0766            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0767            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 0768            List<string> _queryParameters = new List<string>();
 0769            if (tag != null)
 770            {
 0771                _queryParameters.Add(string.Format("tag={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCon
 772            }
 0773            if (label != null)
 774            {
 0775                _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
 776            }
 0777            if (_queryParameters.Count > 0)
 778            {
 0779                _url += "?" + string.Join("&", _queryParameters);
 780            }
 781            // Create HTTP transport objects
 0782            var _httpRequest = new HttpRequestMessage();
 0783            HttpResponseMessage _httpResponse = null;
 0784            _httpRequest.Method = new HttpMethod("POST");
 0785            _httpRequest.RequestUri = new System.Uri(_url);
 786            // Set Headers
 787
 788
 0789            if (customHeaders != null)
 790            {
 0791                foreach(var _header in customHeaders)
 792                {
 0793                    if (_httpRequest.Headers.Contains(_header.Key))
 794                    {
 0795                        _httpRequest.Headers.Remove(_header.Key);
 796                    }
 0797                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 798                }
 799            }
 800
 801            // Serialize Request
 0802            string _requestContent = null;
 0803            if(imageUrl != null)
 804            {
 0805                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(imageUrl, Client.SerializationSetti
 0806                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0807                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 808            }
 809            // Set Credentials
 0810            if (Client.Credentials != null)
 811            {
 0812                cancellationToken.ThrowIfCancellationRequested();
 0813                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 814            }
 815            // Send Request
 0816            if (_shouldTrace)
 817            {
 0818                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 819            }
 0820            cancellationToken.ThrowIfCancellationRequested();
 0821            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0822            if (_shouldTrace)
 823            {
 0824                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 825            }
 0826            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0827            cancellationToken.ThrowIfCancellationRequested();
 0828            string _responseContent = null;
 0829            if ((int)_statusCode != 200)
 830            {
 0831                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 832                try
 833                {
 0834                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0835                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 0836                    if (_errorBody != null)
 837                    {
 0838                        ex.Body = _errorBody;
 839                    }
 0840                }
 0841                catch (JsonException)
 842                {
 843                    // Ignore the exception
 0844                }
 0845                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0846                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0847                if (_shouldTrace)
 848                {
 0849                    ServiceClientTracing.Error(_invocationId, ex);
 850                }
 0851                _httpRequest.Dispose();
 0852                if (_httpResponse != null)
 853                {
 0854                    _httpResponse.Dispose();
 855                }
 0856                throw ex;
 857            }
 858            // Create Result
 0859            var _result = new HttpOperationResponse<Image>();
 0860            _result.Request = _httpRequest;
 0861            _result.Response = _httpResponse;
 862            // Deserialize Response
 0863            if ((int)_statusCode == 200)
 864            {
 0865                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 866                try
 867                {
 0868                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Image>(_responseContent, Client.
 0869                }
 0870                catch (JsonException ex)
 871                {
 0872                    _httpRequest.Dispose();
 0873                    if (_httpResponse != null)
 874                    {
 0875                        _httpResponse.Dispose();
 876                    }
 0877                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 878                }
 879            }
 0880            if (_shouldTrace)
 881            {
 0882                ServiceClientTracing.Exit(_invocationId, _result);
 883            }
 0884            return _result;
 0885        }
 886
 887        /// <summary>
 888        /// Add an image to the list with list Id equal to list Id passed.
 889        /// </summary>
 890        /// <param name='listId'>
 891        /// List Id of the image list.
 892        /// </param>
 893        /// <param name='imageStream'>
 894        /// The image file.
 895        /// </param>
 896        /// <param name='tag'>
 897        /// Tag for the image.
 898        /// </param>
 899        /// <param name='label'>
 900        /// The image label.
 901        /// </param>
 902        /// <param name='customHeaders'>
 903        /// Headers that will be added to request.
 904        /// </param>
 905        /// <param name='cancellationToken'>
 906        /// The cancellation token.
 907        /// </param>
 908        /// <exception cref="APIErrorException">
 909        /// Thrown when the operation returned an invalid status code
 910        /// </exception>
 911        /// <exception cref="SerializationException">
 912        /// Thrown when unable to deserialize the response
 913        /// </exception>
 914        /// <exception cref="ValidationException">
 915        /// Thrown when a required parameter is null
 916        /// </exception>
 917        /// <exception cref="System.ArgumentNullException">
 918        /// Thrown when a required parameter is null
 919        /// </exception>
 920        /// <return>
 921        /// A response object containing the response body and response headers.
 922        /// </return>
 923        public async Task<HttpOperationResponse<Image>> AddImageFileInputWithHttpMessagesAsync(string listId, Stream ima
 924        {
 0925            if (Client.Endpoint == null)
 926            {
 0927                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
 928            }
 0929            if (listId == null)
 930            {
 0931                throw new ValidationException(ValidationRules.CannotBeNull, "listId");
 932            }
 0933            if (imageStream == null)
 934            {
 0935                throw new ValidationException(ValidationRules.CannotBeNull, "imageStream");
 936            }
 937            // Tracing
 0938            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0939            string _invocationId = null;
 0940            if (_shouldTrace)
 941            {
 0942                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0943                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0944                tracingParameters.Add("listId", listId);
 0945                tracingParameters.Add("tag", tag);
 0946                tracingParameters.Add("label", label);
 0947                tracingParameters.Add("imageStream", imageStream);
 0948                tracingParameters.Add("cancellationToken", cancellationToken);
 0949                ServiceClientTracing.Enter(_invocationId, this, "AddImageFileInput", tracingParameters);
 950            }
 951            // Construct URL
 0952            var _baseUrl = Client.BaseUri;
 0953            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "contentmoderator/lists/v1.0/imagelists/{listId}
 0954            _url = _url.Replace("{Endpoint}", Client.Endpoint);
 0955            _url = _url.Replace("{listId}", System.Uri.EscapeDataString(listId));
 0956            List<string> _queryParameters = new List<string>();
 0957            if (tag != null)
 958            {
 0959                _queryParameters.Add(string.Format("tag={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCon
 960            }
 0961            if (label != null)
 962            {
 0963                _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
 964            }
 0965            if (_queryParameters.Count > 0)
 966            {
 0967                _url += "?" + string.Join("&", _queryParameters);
 968            }
 969            // Create HTTP transport objects
 0970            var _httpRequest = new HttpRequestMessage();
 0971            HttpResponseMessage _httpResponse = null;
 0972            _httpRequest.Method = new HttpMethod("POST");
 0973            _httpRequest.RequestUri = new System.Uri(_url);
 974            // Set Headers
 975
 976
 0977            if (customHeaders != null)
 978            {
 0979                foreach(var _header in customHeaders)
 980                {
 0981                    if (_httpRequest.Headers.Contains(_header.Key))
 982                    {
 0983                        _httpRequest.Headers.Remove(_header.Key);
 984                    }
 0985                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 986                }
 987            }
 988
 989            // Serialize Request
 0990            string _requestContent = null;
 0991            if(imageStream == null)
 992            {
 0993              throw new System.ArgumentNullException("imageStream");
 994            }
 0995            if (imageStream != null && imageStream != Stream.Null)
 996            {
 0997                _httpRequest.Content = new StreamContent(imageStream);
 0998                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("image/gif"
 999            }
 1000            // Set Credentials
 01001            if (Client.Credentials != null)
 1002            {
 01003                cancellationToken.ThrowIfCancellationRequested();
 01004                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1005            }
 1006            // Send Request
 01007            if (_shouldTrace)
 1008            {
 01009                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1010            }
 01011            cancellationToken.ThrowIfCancellationRequested();
 01012            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01013            if (_shouldTrace)
 1014            {
 01015                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1016            }
 01017            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01018            cancellationToken.ThrowIfCancellationRequested();
 01019            string _responseContent = null;
 01020            if ((int)_statusCode != 200)
 1021            {
 01022                var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusC
 1023                try
 1024                {
 01025                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01026                    APIError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<APIError>(_responseConte
 01027                    if (_errorBody != null)
 1028                    {
 01029                        ex.Body = _errorBody;
 1030                    }
 01031                }
 01032                catch (JsonException)
 1033                {
 1034                    // Ignore the exception
 01035                }
 01036                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01037                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01038                if (_shouldTrace)
 1039                {
 01040                    ServiceClientTracing.Error(_invocationId, ex);
 1041                }
 01042                _httpRequest.Dispose();
 01043                if (_httpResponse != null)
 1044                {
 01045                    _httpResponse.Dispose();
 1046                }
 01047                throw ex;
 1048            }
 1049            // Create Result
 01050            var _result = new HttpOperationResponse<Image>();
 01051            _result.Request = _httpRequest;
 01052            _result.Response = _httpResponse;
 1053            // Deserialize Response
 01054            if ((int)_statusCode == 200)
 1055            {
 01056                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1057                try
 1058                {
 01059                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Image>(_responseContent, Client.
 01060                }
 01061                catch (JsonException ex)
 1062                {
 01063                    _httpRequest.Dispose();
 01064                    if (_httpResponse != null)
 1065                    {
 01066                        _httpResponse.Dispose();
 1067                    }
 01068                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1069                }
 1070            }
 01071            if (_shouldTrace)
 1072            {
 01073                ServiceClientTracing.Exit(_invocationId, _result);
 1074            }
 01075            return _result;
 01076        }
 1077
 1078    }
 1079}