< Summary

Class:Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training.CustomVisionTrainingClient
Assembly:Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.CustomVision.Training\src\Generated\CustomVisionTrainingClient.cs
Covered lines:2029
Uncovered lines:1947
Coverable lines:3976
Total lines:9284
Line coverage:51% (2029 of 3976)
Covered branches:834
Total branches:1964
Branch coverage:42.4% (834 of 1964)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_BaseUri()-100%100%
get_SerializationSettings()-100%100%
get_DeserializationSettings()-100%100%
get_Endpoint()-100%100%
get_Credentials()-100%100%
.ctor(...)-0%100%
.ctor(...)-100%100%
.ctor(...)-0%100%
.ctor(...)-85.71%75%
.ctor(...)-0%0%
.ctor(...)-0%0%
Initialize()-100%100%
GetDomainsWithHttpMessagesAsync()-50.75%37.5%
GetDomainWithHttpMessagesAsync()-50.72%37.5%
GetProjectsWithHttpMessagesAsync()-50.75%37.5%
CreateProjectWithHttpMessagesAsync()-52.87%50%
GetProjectWithHttpMessagesAsync()-50.72%37.5%
DeleteProjectWithHttpMessagesAsync()-51.67%35.71%
UpdateProjectWithHttpMessagesAsync()-52.63%41.67%
GetArtifactWithHttpMessagesAsync()-59.09%47.22%
ExportProjectWithHttpMessagesAsync()-50.72%37.5%
GetImagesWithHttpMessagesAsync()-50%48.28%
DeleteImagesWithHttpMessagesAsync()-53.25%50%
GetImageRegionProposalsWithHttpMessagesAsync()-50.7%37.5%
GetImageCountWithHttpMessagesAsync()-51.19%45.24%
CreateImagesFromFilesWithHttpMessagesAsync()-48.24%40.48%
GetImagesByIdsWithHttpMessagesAsync()-53.01%47.73%
UpdateImageMetadataWithHttpMessagesAsync()-51.02%48.15%
CreateImagesFromPredictionsWithHttpMessagesAsync()-48.24%40.48%
CreateImageRegionsWithHttpMessagesAsync()-48.24%40.48%
DeleteImageRegionsWithHttpMessagesAsync()-54.79%47.5%
QuerySuggestedImagesWithHttpMessagesAsync()-54.32%44.74%
QuerySuggestedImageCountWithHttpMessagesAsync()-54.32%44.74%
GetTaggedImagesWithHttpMessagesAsync()-53.13%51.85%
GetTaggedImageCountWithHttpMessagesAsync()-50%39.47%
CreateImageTagsWithHttpMessagesAsync()-52.63%41.67%
DeleteImageTagsWithHttpMessagesAsync()-55.42%52%
GetUntaggedImagesWithHttpMessagesAsync()-52.27%47.83%
GetUntaggedImageCountWithHttpMessagesAsync()-50.67%38.89%
CreateImagesFromUrlsWithHttpMessagesAsync()-48.24%40.48%
GetIterationsWithHttpMessagesAsync()-50.72%37.5%
GetIterationWithHttpMessagesAsync()-50.7%37.5%
DeleteIterationWithHttpMessagesAsync()-51.61%35.71%
UpdateIterationWithHttpMessagesAsync()-52.56%41.67%
GetExportsWithHttpMessagesAsync()-50.7%37.5%
ExportIterationWithHttpMessagesAsync()-52.44%45%
GetIterationPerformanceWithHttpMessagesAsync()-52.5%44.74%
GetImagePerformancesWithHttpMessagesAsync()-0%0%
GetImagePerformanceCountWithHttpMessagesAsync()-50.65%38.89%
PublishIterationWithHttpMessagesAsync()-52.87%47.73%
UnpublishIterationWithHttpMessagesAsync()-51.61%35.71%
DeletePredictionWithHttpMessagesAsync()-54.79%47.5%
QueryPredictionsWithHttpMessagesAsync()-52.63%41.67%
QuickTestImageUrlWithHttpMessagesAsync()-56.32%52.27%
GetTagsWithHttpMessagesAsync()-53.33%44.44%
CreateTagWithHttpMessagesAsync()-53.01%47.62%
GetTagWithHttpMessagesAsync()-53.25%44.44%
DeleteTagWithHttpMessagesAsync()-51.61%35.71%
UpdateTagWithHttpMessagesAsync()-52.56%41.67%
SuggestTagsAndRegionsWithHttpMessagesAsync()-53.57%47.73%
TrainProjectWithHttpMessagesAsync()-50.56%47.73%
ImportProjectWithHttpMessagesAsync()-52.56%45%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.CustomVision.Training\src\Generated\CustomVisionTrainingClient.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training
 12{
 13    using Microsoft.Rest;
 14    using Microsoft.Rest.Serialization;
 15    using Models;
 16    using Newtonsoft.Json;
 17    using System.Collections;
 18    using System.Collections.Generic;
 19    using System.IO;
 20    using System.Net;
 21    using System.Net.Http;
 22    using System.Net.Http.Headers;
 23    using System.Threading;
 24    using System.Threading.Tasks;
 25
 26    public partial class CustomVisionTrainingClient : ServiceClient<CustomVisionTrainingClient>, ICustomVisionTrainingCl
 27    {
 28        /// <summary>
 29        /// The base URI of the service.
 30        /// </summary>
 33031        internal string BaseUri {get; set;}
 32
 33        /// <summary>
 34        /// Gets or sets json serialization settings.
 35        /// </summary>
 53036        public JsonSerializerSettings SerializationSettings { get; private set; }
 37
 38        /// <summary>
 39        /// Gets or sets json deserialization settings.
 40        /// </summary>
 29441        public JsonSerializerSettings DeserializationSettings { get; private set; }
 42
 43        /// <summary>
 44        /// Supported Cognitive Services endpoints.
 45        /// </summary>
 59446        public string Endpoint { get; set; }
 47
 48        /// <summary>
 49        /// Subscription credentials which uniquely identify client subscription.
 50        /// </summary>
 72651        public ServiceClientCredentials Credentials { get; private set; }
 52
 53        /// <summary>
 54        /// Initializes a new instance of the CustomVisionTrainingClient class.
 55        /// </summary>
 56        /// <param name='httpClient'>
 57        /// HttpClient to be used
 58        /// </param>
 59        /// <param name='disposeHttpClient'>
 60        /// True: will dispose the provided httpClient on calling CustomVisionTrainingClient.Dispose(). False: will not 
 061        protected CustomVisionTrainingClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHt
 62        {
 063            Initialize();
 064        }
 65
 66        /// <summary>
 67        /// Initializes a new instance of the CustomVisionTrainingClient class.
 68        /// </summary>
 69        /// <param name='handlers'>
 70        /// Optional. The delegating handlers to add to the http client pipeline.
 71        /// </param>
 6672        protected CustomVisionTrainingClient(params DelegatingHandler[] handlers) : base(handlers)
 73        {
 6674            Initialize();
 6675        }
 76
 77        /// <summary>
 78        /// Initializes a new instance of the CustomVisionTrainingClient class.
 79        /// </summary>
 80        /// <param name='rootHandler'>
 81        /// Optional. The http client handler used to handle http transport.
 82        /// </param>
 83        /// <param name='handlers'>
 84        /// Optional. The delegating handlers to add to the http client pipeline.
 85        /// </param>
 086        protected CustomVisionTrainingClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(
 87        {
 088            Initialize();
 089        }
 90
 91        /// <summary>
 92        /// Initializes a new instance of the CustomVisionTrainingClient class.
 93        /// </summary>
 94        /// <param name='credentials'>
 95        /// Required. Subscription credentials which uniquely identify client subscription.
 96        /// </param>
 97        /// <param name='handlers'>
 98        /// Optional. The delegating handlers to add to the http client pipeline.
 99        /// </param>
 100        /// <exception cref="System.ArgumentNullException">
 101        /// Thrown when a required parameter is null
 102        /// </exception>
 66103        public CustomVisionTrainingClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : t
 104        {
 66105            if (credentials == null)
 106            {
 0107                throw new System.ArgumentNullException("credentials");
 108            }
 66109            Credentials = credentials;
 66110            if (Credentials != null)
 111            {
 66112                Credentials.InitializeServiceClient(this);
 113            }
 66114        }
 115
 116        /// <summary>
 117        /// Initializes a new instance of the CustomVisionTrainingClient class.
 118        /// </summary>
 119        /// <param name='credentials'>
 120        /// Required. Subscription credentials which uniquely identify client subscription.
 121        /// </param>
 122        /// <param name='httpClient'>
 123        /// HttpClient to be used
 124        /// </param>
 125        /// <param name='disposeHttpClient'>
 126        /// True: will dispose the provided httpClient on calling CustomVisionTrainingClient.Dispose(). False: will not 
 127        /// <exception cref="System.ArgumentNullException">
 128        /// Thrown when a required parameter is null
 129        /// </exception>
 0130        public CustomVisionTrainingClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpC
 131        {
 0132            if (credentials == null)
 133            {
 0134                throw new System.ArgumentNullException("credentials");
 135            }
 0136            Credentials = credentials;
 0137            if (Credentials != null)
 138            {
 0139                Credentials.InitializeServiceClient(this);
 140            }
 0141        }
 142
 143        /// <summary>
 144        /// Initializes a new instance of the CustomVisionTrainingClient class.
 145        /// </summary>
 146        /// <param name='credentials'>
 147        /// Required. Subscription credentials which uniquely identify client subscription.
 148        /// </param>
 149        /// <param name='rootHandler'>
 150        /// Optional. The http client handler used to handle http transport.
 151        /// </param>
 152        /// <param name='handlers'>
 153        /// Optional. The delegating handlers to add to the http client pipeline.
 154        /// </param>
 155        /// <exception cref="System.ArgumentNullException">
 156        /// Thrown when a required parameter is null
 157        /// </exception>
 0158        public CustomVisionTrainingClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params De
 159        {
 0160            if (credentials == null)
 161            {
 0162                throw new System.ArgumentNullException("credentials");
 163            }
 0164            Credentials = credentials;
 0165            if (Credentials != null)
 166            {
 0167                Credentials.InitializeServiceClient(this);
 168            }
 0169        }
 170
 171        /// <summary>
 172        /// An optional partial-method to perform custom initialization.
 173        ///</summary>
 174        partial void CustomInitialize();
 175        /// <summary>
 176        /// Initializes client properties.
 177        /// </summary>
 178        private void Initialize()
 179        {
 66180            BaseUri = "{Endpoint}/customvision/v3.3/training";
 66181            SerializationSettings = new JsonSerializerSettings
 66182            {
 66183                Formatting = Newtonsoft.Json.Formatting.Indented,
 66184                DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
 66185                DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
 66186                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
 66187                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
 66188                ContractResolver = new ReadOnlyJsonContractResolver(),
 66189                Converters = new  List<JsonConverter>
 66190                    {
 66191                        new Iso8601TimeSpanConverter()
 66192                    }
 66193            };
 66194            DeserializationSettings = new JsonSerializerSettings
 66195            {
 66196                DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
 66197                DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
 66198                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
 66199                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
 66200                ContractResolver = new ReadOnlyJsonContractResolver(),
 66201                Converters = new List<JsonConverter>
 66202                    {
 66203                        new Iso8601TimeSpanConverter()
 66204                    }
 66205            };
 206            CustomInitialize();
 66207        }
 208        /// <summary>
 209        /// Get a list of the available domains.
 210        /// </summary>
 211        /// <param name='customHeaders'>
 212        /// Headers that will be added to request.
 213        /// </param>
 214        /// <param name='cancellationToken'>
 215        /// The cancellation token.
 216        /// </param>
 217        /// <exception cref="CustomVisionErrorException">
 218        /// Thrown when the operation returned an invalid status code
 219        /// </exception>
 220        /// <exception cref="SerializationException">
 221        /// Thrown when unable to deserialize the response
 222        /// </exception>
 223        /// <exception cref="ValidationException">
 224        /// Thrown when a required parameter is null
 225        /// </exception>
 226        /// <exception cref="System.ArgumentNullException">
 227        /// Thrown when a required parameter is null
 228        /// </exception>
 229        /// <return>
 230        /// A response object containing the response body and response headers.
 231        /// </return>
 232        public async Task<HttpOperationResponse<IList<Domain>>> GetDomainsWithHttpMessagesAsync(Dictionary<string, List<
 233        {
 2234            if (Endpoint == null)
 235            {
 0236                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 237            }
 238            // Tracing
 2239            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2240            string _invocationId = null;
 2241            if (_shouldTrace)
 242            {
 0243                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0244                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0245                tracingParameters.Add("cancellationToken", cancellationToken);
 0246                ServiceClientTracing.Enter(_invocationId, this, "GetDomains", tracingParameters);
 247            }
 248            // Construct URL
 2249            var _baseUrl = BaseUri;
 2250            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "domains";
 2251            _url = _url.Replace("{Endpoint}", Endpoint);
 252            // Create HTTP transport objects
 2253            var _httpRequest = new HttpRequestMessage();
 2254            HttpResponseMessage _httpResponse = null;
 2255            _httpRequest.Method = new HttpMethod("GET");
 2256            _httpRequest.RequestUri = new System.Uri(_url);
 257            // Set Headers
 258
 259
 2260            if (customHeaders != null)
 261            {
 0262                foreach(var _header in customHeaders)
 263                {
 0264                    if (_httpRequest.Headers.Contains(_header.Key))
 265                    {
 0266                        _httpRequest.Headers.Remove(_header.Key);
 267                    }
 0268                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 269                }
 270            }
 271
 272            // Serialize Request
 2273            string _requestContent = null;
 274            // Set Credentials
 2275            if (Credentials != null)
 276            {
 2277                cancellationToken.ThrowIfCancellationRequested();
 2278                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 279            }
 280            // Send Request
 2281            if (_shouldTrace)
 282            {
 0283                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 284            }
 2285            cancellationToken.ThrowIfCancellationRequested();
 2286            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2287            if (_shouldTrace)
 288            {
 0289                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 290            }
 2291            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2292            cancellationToken.ThrowIfCancellationRequested();
 2293            string _responseContent = null;
 2294            if ((int)_statusCode != 200)
 295            {
 0296                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 297                try
 298                {
 0299                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0300                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 0301                    if (_errorBody != null)
 302                    {
 0303                        ex.Body = _errorBody;
 304                    }
 0305                }
 0306                catch (JsonException)
 307                {
 308                    // Ignore the exception
 0309                }
 0310                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0311                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0312                if (_shouldTrace)
 313                {
 0314                    ServiceClientTracing.Error(_invocationId, ex);
 315                }
 0316                _httpRequest.Dispose();
 0317                if (_httpResponse != null)
 318                {
 0319                    _httpResponse.Dispose();
 320                }
 0321                throw ex;
 322            }
 323            // Create Result
 2324            var _result = new HttpOperationResponse<IList<Domain>>();
 2325            _result.Request = _httpRequest;
 2326            _result.Response = _httpResponse;
 327            // Deserialize Response
 2328            if ((int)_statusCode == 200)
 329            {
 2330                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 331                try
 332                {
 2333                    _result.Body = SafeJsonConvert.DeserializeObject<IList<Domain>>(_responseContent, DeserializationSet
 2334                }
 0335                catch (JsonException ex)
 336                {
 0337                    _httpRequest.Dispose();
 0338                    if (_httpResponse != null)
 339                    {
 0340                        _httpResponse.Dispose();
 341                    }
 0342                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 343                }
 344            }
 2345            if (_shouldTrace)
 346            {
 0347                ServiceClientTracing.Exit(_invocationId, _result);
 348            }
 2349            return _result;
 2350        }
 351
 352        /// <summary>
 353        /// Get information about a specific domain.
 354        /// </summary>
 355        /// <param name='domainId'>
 356        /// The id of the domain to get information about.
 357        /// </param>
 358        /// <param name='customHeaders'>
 359        /// Headers that will be added to request.
 360        /// </param>
 361        /// <param name='cancellationToken'>
 362        /// The cancellation token.
 363        /// </param>
 364        /// <exception cref="CustomVisionErrorException">
 365        /// Thrown when the operation returned an invalid status code
 366        /// </exception>
 367        /// <exception cref="SerializationException">
 368        /// Thrown when unable to deserialize the response
 369        /// </exception>
 370        /// <exception cref="ValidationException">
 371        /// Thrown when a required parameter is null
 372        /// </exception>
 373        /// <exception cref="System.ArgumentNullException">
 374        /// Thrown when a required parameter is null
 375        /// </exception>
 376        /// <return>
 377        /// A response object containing the response body and response headers.
 378        /// </return>
 379        public async Task<HttpOperationResponse<Domain>> GetDomainWithHttpMessagesAsync(System.Guid domainId, Dictionary
 380        {
 2381            if (Endpoint == null)
 382            {
 0383                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 384            }
 385            // Tracing
 2386            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2387            string _invocationId = null;
 2388            if (_shouldTrace)
 389            {
 0390                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0391                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0392                tracingParameters.Add("domainId", domainId);
 0393                tracingParameters.Add("cancellationToken", cancellationToken);
 0394                ServiceClientTracing.Enter(_invocationId, this, "GetDomain", tracingParameters);
 395            }
 396            // Construct URL
 2397            var _baseUrl = BaseUri;
 2398            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "domains/{domainId}";
 2399            _url = _url.Replace("{Endpoint}", Endpoint);
 2400            _url = _url.Replace("{domainId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(domainId, Seri
 401            // Create HTTP transport objects
 2402            var _httpRequest = new HttpRequestMessage();
 2403            HttpResponseMessage _httpResponse = null;
 2404            _httpRequest.Method = new HttpMethod("GET");
 2405            _httpRequest.RequestUri = new System.Uri(_url);
 406            // Set Headers
 407
 408
 2409            if (customHeaders != null)
 410            {
 0411                foreach(var _header in customHeaders)
 412                {
 0413                    if (_httpRequest.Headers.Contains(_header.Key))
 414                    {
 0415                        _httpRequest.Headers.Remove(_header.Key);
 416                    }
 0417                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 418                }
 419            }
 420
 421            // Serialize Request
 2422            string _requestContent = null;
 423            // Set Credentials
 2424            if (Credentials != null)
 425            {
 2426                cancellationToken.ThrowIfCancellationRequested();
 2427                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 428            }
 429            // Send Request
 2430            if (_shouldTrace)
 431            {
 0432                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 433            }
 2434            cancellationToken.ThrowIfCancellationRequested();
 2435            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2436            if (_shouldTrace)
 437            {
 0438                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 439            }
 2440            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2441            cancellationToken.ThrowIfCancellationRequested();
 2442            string _responseContent = null;
 2443            if ((int)_statusCode != 200)
 444            {
 0445                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 446                try
 447                {
 0448                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0449                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 0450                    if (_errorBody != null)
 451                    {
 0452                        ex.Body = _errorBody;
 453                    }
 0454                }
 0455                catch (JsonException)
 456                {
 457                    // Ignore the exception
 0458                }
 0459                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0460                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0461                if (_shouldTrace)
 462                {
 0463                    ServiceClientTracing.Error(_invocationId, ex);
 464                }
 0465                _httpRequest.Dispose();
 0466                if (_httpResponse != null)
 467                {
 0468                    _httpResponse.Dispose();
 469                }
 0470                throw ex;
 471            }
 472            // Create Result
 2473            var _result = new HttpOperationResponse<Domain>();
 2474            _result.Request = _httpRequest;
 2475            _result.Response = _httpResponse;
 476            // Deserialize Response
 2477            if ((int)_statusCode == 200)
 478            {
 2479                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 480                try
 481                {
 2482                    _result.Body = SafeJsonConvert.DeserializeObject<Domain>(_responseContent, DeserializationSettings);
 2483                }
 0484                catch (JsonException ex)
 485                {
 0486                    _httpRequest.Dispose();
 0487                    if (_httpResponse != null)
 488                    {
 0489                        _httpResponse.Dispose();
 490                    }
 0491                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 492                }
 493            }
 2494            if (_shouldTrace)
 495            {
 0496                ServiceClientTracing.Exit(_invocationId, _result);
 497            }
 2498            return _result;
 2499        }
 500
 501        /// <summary>
 502        /// Get your projects.
 503        /// </summary>
 504        /// <param name='customHeaders'>
 505        /// Headers that will be added to request.
 506        /// </param>
 507        /// <param name='cancellationToken'>
 508        /// The cancellation token.
 509        /// </param>
 510        /// <exception cref="CustomVisionErrorException">
 511        /// Thrown when the operation returned an invalid status code
 512        /// </exception>
 513        /// <exception cref="SerializationException">
 514        /// Thrown when unable to deserialize the response
 515        /// </exception>
 516        /// <exception cref="ValidationException">
 517        /// Thrown when a required parameter is null
 518        /// </exception>
 519        /// <exception cref="System.ArgumentNullException">
 520        /// Thrown when a required parameter is null
 521        /// </exception>
 522        /// <return>
 523        /// A response object containing the response body and response headers.
 524        /// </return>
 525        public async Task<HttpOperationResponse<IList<Project>>> GetProjectsWithHttpMessagesAsync(Dictionary<string, Lis
 526        {
 2527            if (Endpoint == null)
 528            {
 0529                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 530            }
 531            // Tracing
 2532            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2533            string _invocationId = null;
 2534            if (_shouldTrace)
 535            {
 0536                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0537                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0538                tracingParameters.Add("cancellationToken", cancellationToken);
 0539                ServiceClientTracing.Enter(_invocationId, this, "GetProjects", tracingParameters);
 540            }
 541            // Construct URL
 2542            var _baseUrl = BaseUri;
 2543            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects";
 2544            _url = _url.Replace("{Endpoint}", Endpoint);
 545            // Create HTTP transport objects
 2546            var _httpRequest = new HttpRequestMessage();
 2547            HttpResponseMessage _httpResponse = null;
 2548            _httpRequest.Method = new HttpMethod("GET");
 2549            _httpRequest.RequestUri = new System.Uri(_url);
 550            // Set Headers
 551
 552
 2553            if (customHeaders != null)
 554            {
 0555                foreach(var _header in customHeaders)
 556                {
 0557                    if (_httpRequest.Headers.Contains(_header.Key))
 558                    {
 0559                        _httpRequest.Headers.Remove(_header.Key);
 560                    }
 0561                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 562                }
 563            }
 564
 565            // Serialize Request
 2566            string _requestContent = null;
 567            // Set Credentials
 2568            if (Credentials != null)
 569            {
 2570                cancellationToken.ThrowIfCancellationRequested();
 2571                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 572            }
 573            // Send Request
 2574            if (_shouldTrace)
 575            {
 0576                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 577            }
 2578            cancellationToken.ThrowIfCancellationRequested();
 2579            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2580            if (_shouldTrace)
 581            {
 0582                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 583            }
 2584            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2585            cancellationToken.ThrowIfCancellationRequested();
 2586            string _responseContent = null;
 2587            if ((int)_statusCode != 200)
 588            {
 0589                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 590                try
 591                {
 0592                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0593                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 0594                    if (_errorBody != null)
 595                    {
 0596                        ex.Body = _errorBody;
 597                    }
 0598                }
 0599                catch (JsonException)
 600                {
 601                    // Ignore the exception
 0602                }
 0603                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0604                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0605                if (_shouldTrace)
 606                {
 0607                    ServiceClientTracing.Error(_invocationId, ex);
 608                }
 0609                _httpRequest.Dispose();
 0610                if (_httpResponse != null)
 611                {
 0612                    _httpResponse.Dispose();
 613                }
 0614                throw ex;
 615            }
 616            // Create Result
 2617            var _result = new HttpOperationResponse<IList<Project>>();
 2618            _result.Request = _httpRequest;
 2619            _result.Response = _httpResponse;
 620            // Deserialize Response
 2621            if ((int)_statusCode == 200)
 622            {
 2623                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 624                try
 625                {
 2626                    _result.Body = SafeJsonConvert.DeserializeObject<IList<Project>>(_responseContent, DeserializationSe
 2627                }
 0628                catch (JsonException ex)
 629                {
 0630                    _httpRequest.Dispose();
 0631                    if (_httpResponse != null)
 632                    {
 0633                        _httpResponse.Dispose();
 634                    }
 0635                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 636                }
 637            }
 2638            if (_shouldTrace)
 639            {
 0640                ServiceClientTracing.Exit(_invocationId, _result);
 641            }
 2642            return _result;
 2643        }
 644
 645        /// <summary>
 646        /// Create a project.
 647        /// </summary>
 648        /// <param name='name'>
 649        /// Name of the project.
 650        /// </param>
 651        /// <param name='description'>
 652        /// The description of the project.
 653        /// </param>
 654        /// <param name='domainId'>
 655        /// The id of the domain to use for this project. Defaults to General.
 656        /// </param>
 657        /// <param name='classificationType'>
 658        /// The type of classifier to create for this project. Possible values include:
 659        /// 'Multiclass', 'Multilabel'
 660        /// </param>
 661        /// <param name='targetExportPlatforms'>
 662        /// List of platforms the trained model is intending exporting to.
 663        /// </param>
 664        /// <param name='customHeaders'>
 665        /// Headers that will be added to request.
 666        /// </param>
 667        /// <param name='cancellationToken'>
 668        /// The cancellation token.
 669        /// </param>
 670        /// <exception cref="CustomVisionErrorException">
 671        /// Thrown when the operation returned an invalid status code
 672        /// </exception>
 673        /// <exception cref="SerializationException">
 674        /// Thrown when unable to deserialize the response
 675        /// </exception>
 676        /// <exception cref="ValidationException">
 677        /// Thrown when a required parameter is null
 678        /// </exception>
 679        /// <exception cref="System.ArgumentNullException">
 680        /// Thrown when a required parameter is null
 681        /// </exception>
 682        /// <return>
 683        /// A response object containing the response body and response headers.
 684        /// </return>
 685        public async Task<HttpOperationResponse<Project>> CreateProjectWithHttpMessagesAsync(string name, string descrip
 686        {
 18687            if (Endpoint == null)
 688            {
 0689                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 690            }
 18691            if (name == null)
 692            {
 0693                throw new ValidationException(ValidationRules.CannotBeNull, "name");
 694            }
 695            // Tracing
 18696            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 18697            string _invocationId = null;
 18698            if (_shouldTrace)
 699            {
 0700                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0701                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0702                tracingParameters.Add("name", name);
 0703                tracingParameters.Add("description", description);
 0704                tracingParameters.Add("domainId", domainId);
 0705                tracingParameters.Add("classificationType", classificationType);
 0706                tracingParameters.Add("targetExportPlatforms", targetExportPlatforms);
 0707                tracingParameters.Add("cancellationToken", cancellationToken);
 0708                ServiceClientTracing.Enter(_invocationId, this, "CreateProject", tracingParameters);
 709            }
 710            // Construct URL
 18711            var _baseUrl = BaseUri;
 18712            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects";
 18713            _url = _url.Replace("{Endpoint}", Endpoint);
 18714            List<string> _queryParameters = new List<string>();
 18715            if (name != null)
 716            {
 18717                _queryParameters.Add(string.Format("name={0}", System.Uri.EscapeDataString(name)));
 718            }
 18719            if (description != null)
 720            {
 14721                _queryParameters.Add(string.Format("description={0}", System.Uri.EscapeDataString(description)));
 722            }
 18723            if (domainId != null)
 724            {
 12725                _queryParameters.Add(string.Format("domainId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serialize
 726            }
 18727            if (classificationType != null)
 728            {
 0729                _queryParameters.Add(string.Format("classificationType={0}", System.Uri.EscapeDataString(SafeJsonConvert
 730            }
 18731            if (targetExportPlatforms != null)
 732            {
 0733                _queryParameters.Add(string.Format("targetExportPlatforms={0}", System.Uri.EscapeDataString(string.Join(
 734            }
 18735            if (_queryParameters.Count > 0)
 736            {
 18737                _url += "?" + string.Join("&", _queryParameters);
 738            }
 739            // Create HTTP transport objects
 18740            var _httpRequest = new HttpRequestMessage();
 18741            HttpResponseMessage _httpResponse = null;
 18742            _httpRequest.Method = new HttpMethod("POST");
 18743            _httpRequest.RequestUri = new System.Uri(_url);
 744            // Set Headers
 745
 746
 18747            if (customHeaders != null)
 748            {
 0749                foreach(var _header in customHeaders)
 750                {
 0751                    if (_httpRequest.Headers.Contains(_header.Key))
 752                    {
 0753                        _httpRequest.Headers.Remove(_header.Key);
 754                    }
 0755                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 756                }
 757            }
 758
 759            // Serialize Request
 18760            string _requestContent = null;
 761            // Set Credentials
 18762            if (Credentials != null)
 763            {
 18764                cancellationToken.ThrowIfCancellationRequested();
 18765                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 766            }
 767            // Send Request
 18768            if (_shouldTrace)
 769            {
 0770                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 771            }
 18772            cancellationToken.ThrowIfCancellationRequested();
 18773            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 18774            if (_shouldTrace)
 775            {
 0776                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 777            }
 18778            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 18779            cancellationToken.ThrowIfCancellationRequested();
 18780            string _responseContent = null;
 18781            if ((int)_statusCode != 200)
 782            {
 0783                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 784                try
 785                {
 0786                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0787                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 0788                    if (_errorBody != null)
 789                    {
 0790                        ex.Body = _errorBody;
 791                    }
 0792                }
 0793                catch (JsonException)
 794                {
 795                    // Ignore the exception
 0796                }
 0797                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0798                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0799                if (_shouldTrace)
 800                {
 0801                    ServiceClientTracing.Error(_invocationId, ex);
 802                }
 0803                _httpRequest.Dispose();
 0804                if (_httpResponse != null)
 805                {
 0806                    _httpResponse.Dispose();
 807                }
 0808                throw ex;
 809            }
 810            // Create Result
 18811            var _result = new HttpOperationResponse<Project>();
 18812            _result.Request = _httpRequest;
 18813            _result.Response = _httpResponse;
 814            // Deserialize Response
 18815            if ((int)_statusCode == 200)
 816            {
 18817                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 818                try
 819                {
 18820                    _result.Body = SafeJsonConvert.DeserializeObject<Project>(_responseContent, DeserializationSettings)
 18821                }
 0822                catch (JsonException ex)
 823                {
 0824                    _httpRequest.Dispose();
 0825                    if (_httpResponse != null)
 826                    {
 0827                        _httpResponse.Dispose();
 828                    }
 0829                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 830                }
 831            }
 18832            if (_shouldTrace)
 833            {
 0834                ServiceClientTracing.Exit(_invocationId, _result);
 835            }
 18836            return _result;
 18837        }
 838
 839        /// <summary>
 840        /// Get a specific project.
 841        /// </summary>
 842        /// <param name='projectId'>
 843        /// The id of the project to get.
 844        /// </param>
 845        /// <param name='customHeaders'>
 846        /// Headers that will be added to request.
 847        /// </param>
 848        /// <param name='cancellationToken'>
 849        /// The cancellation token.
 850        /// </param>
 851        /// <exception cref="CustomVisionErrorException">
 852        /// Thrown when the operation returned an invalid status code
 853        /// </exception>
 854        /// <exception cref="SerializationException">
 855        /// Thrown when unable to deserialize the response
 856        /// </exception>
 857        /// <exception cref="ValidationException">
 858        /// Thrown when a required parameter is null
 859        /// </exception>
 860        /// <exception cref="System.ArgumentNullException">
 861        /// Thrown when a required parameter is null
 862        /// </exception>
 863        /// <return>
 864        /// A response object containing the response body and response headers.
 865        /// </return>
 866        public async Task<HttpOperationResponse<Project>> GetProjectWithHttpMessagesAsync(System.Guid projectId, Diction
 867        {
 4868            if (Endpoint == null)
 869            {
 0870                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 871            }
 872            // Tracing
 4873            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 4874            string _invocationId = null;
 4875            if (_shouldTrace)
 876            {
 0877                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0878                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0879                tracingParameters.Add("projectId", projectId);
 0880                tracingParameters.Add("cancellationToken", cancellationToken);
 0881                ServiceClientTracing.Enter(_invocationId, this, "GetProject", tracingParameters);
 882            }
 883            // Construct URL
 4884            var _baseUrl = BaseUri;
 4885            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}";
 4886            _url = _url.Replace("{Endpoint}", Endpoint);
 4887            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 888            // Create HTTP transport objects
 4889            var _httpRequest = new HttpRequestMessage();
 4890            HttpResponseMessage _httpResponse = null;
 4891            _httpRequest.Method = new HttpMethod("GET");
 4892            _httpRequest.RequestUri = new System.Uri(_url);
 893            // Set Headers
 894
 895
 4896            if (customHeaders != null)
 897            {
 0898                foreach(var _header in customHeaders)
 899                {
 0900                    if (_httpRequest.Headers.Contains(_header.Key))
 901                    {
 0902                        _httpRequest.Headers.Remove(_header.Key);
 903                    }
 0904                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 905                }
 906            }
 907
 908            // Serialize Request
 4909            string _requestContent = null;
 910            // Set Credentials
 4911            if (Credentials != null)
 912            {
 4913                cancellationToken.ThrowIfCancellationRequested();
 4914                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 915            }
 916            // Send Request
 4917            if (_shouldTrace)
 918            {
 0919                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 920            }
 4921            cancellationToken.ThrowIfCancellationRequested();
 4922            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4923            if (_shouldTrace)
 924            {
 0925                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 926            }
 4927            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 4928            cancellationToken.ThrowIfCancellationRequested();
 4929            string _responseContent = null;
 4930            if ((int)_statusCode != 200)
 931            {
 0932                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 933                try
 934                {
 0935                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0936                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 0937                    if (_errorBody != null)
 938                    {
 0939                        ex.Body = _errorBody;
 940                    }
 0941                }
 0942                catch (JsonException)
 943                {
 944                    // Ignore the exception
 0945                }
 0946                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0947                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0948                if (_shouldTrace)
 949                {
 0950                    ServiceClientTracing.Error(_invocationId, ex);
 951                }
 0952                _httpRequest.Dispose();
 0953                if (_httpResponse != null)
 954                {
 0955                    _httpResponse.Dispose();
 956                }
 0957                throw ex;
 958            }
 959            // Create Result
 4960            var _result = new HttpOperationResponse<Project>();
 4961            _result.Request = _httpRequest;
 4962            _result.Response = _httpResponse;
 963            // Deserialize Response
 4964            if ((int)_statusCode == 200)
 965            {
 4966                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 967                try
 968                {
 4969                    _result.Body = SafeJsonConvert.DeserializeObject<Project>(_responseContent, DeserializationSettings)
 4970                }
 0971                catch (JsonException ex)
 972                {
 0973                    _httpRequest.Dispose();
 0974                    if (_httpResponse != null)
 975                    {
 0976                        _httpResponse.Dispose();
 977                    }
 0978                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 979                }
 980            }
 4981            if (_shouldTrace)
 982            {
 0983                ServiceClientTracing.Exit(_invocationId, _result);
 984            }
 4985            return _result;
 4986        }
 987
 988        /// <summary>
 989        /// Delete a specific project.
 990        /// </summary>
 991        /// <param name='projectId'>
 992        /// The project id.
 993        /// </param>
 994        /// <param name='customHeaders'>
 995        /// Headers that will be added to request.
 996        /// </param>
 997        /// <param name='cancellationToken'>
 998        /// The cancellation token.
 999        /// </param>
 1000        /// <exception cref="CustomVisionErrorException">
 1001        /// Thrown when the operation returned an invalid status code
 1002        /// </exception>
 1003        /// <exception cref="ValidationException">
 1004        /// Thrown when a required parameter is null
 1005        /// </exception>
 1006        /// <exception cref="System.ArgumentNullException">
 1007        /// Thrown when a required parameter is null
 1008        /// </exception>
 1009        /// <return>
 1010        /// A response object containing the response body and response headers.
 1011        /// </return>
 1012        public async Task<HttpOperationResponse> DeleteProjectWithHttpMessagesAsync(System.Guid projectId, Dictionary<st
 1013        {
 181014            if (Endpoint == null)
 1015            {
 01016                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 1017            }
 1018            // Tracing
 181019            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 181020            string _invocationId = null;
 181021            if (_shouldTrace)
 1022            {
 01023                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01024                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01025                tracingParameters.Add("projectId", projectId);
 01026                tracingParameters.Add("cancellationToken", cancellationToken);
 01027                ServiceClientTracing.Enter(_invocationId, this, "DeleteProject", tracingParameters);
 1028            }
 1029            // Construct URL
 181030            var _baseUrl = BaseUri;
 181031            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}";
 181032            _url = _url.Replace("{Endpoint}", Endpoint);
 181033            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 1034            // Create HTTP transport objects
 181035            var _httpRequest = new HttpRequestMessage();
 181036            HttpResponseMessage _httpResponse = null;
 181037            _httpRequest.Method = new HttpMethod("DELETE");
 181038            _httpRequest.RequestUri = new System.Uri(_url);
 1039            // Set Headers
 1040
 1041
 181042            if (customHeaders != null)
 1043            {
 01044                foreach(var _header in customHeaders)
 1045                {
 01046                    if (_httpRequest.Headers.Contains(_header.Key))
 1047                    {
 01048                        _httpRequest.Headers.Remove(_header.Key);
 1049                    }
 01050                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1051                }
 1052            }
 1053
 1054            // Serialize Request
 181055            string _requestContent = null;
 1056            // Set Credentials
 181057            if (Credentials != null)
 1058            {
 181059                cancellationToken.ThrowIfCancellationRequested();
 181060                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1061            }
 1062            // Send Request
 181063            if (_shouldTrace)
 1064            {
 01065                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1066            }
 181067            cancellationToken.ThrowIfCancellationRequested();
 181068            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 181069            if (_shouldTrace)
 1070            {
 01071                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1072            }
 181073            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 181074            cancellationToken.ThrowIfCancellationRequested();
 181075            string _responseContent = null;
 181076            if ((int)_statusCode != 204)
 1077            {
 01078                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 1079                try
 1080                {
 01081                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01082                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 01083                    if (_errorBody != null)
 1084                    {
 01085                        ex.Body = _errorBody;
 1086                    }
 01087                }
 01088                catch (JsonException)
 1089                {
 1090                    // Ignore the exception
 01091                }
 01092                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01093                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01094                if (_shouldTrace)
 1095                {
 01096                    ServiceClientTracing.Error(_invocationId, ex);
 1097                }
 01098                _httpRequest.Dispose();
 01099                if (_httpResponse != null)
 1100                {
 01101                    _httpResponse.Dispose();
 1102                }
 01103                throw ex;
 1104            }
 1105            // Create Result
 181106            var _result = new HttpOperationResponse();
 181107            _result.Request = _httpRequest;
 181108            _result.Response = _httpResponse;
 181109            if (_shouldTrace)
 1110            {
 01111                ServiceClientTracing.Exit(_invocationId, _result);
 1112            }
 181113            return _result;
 181114        }
 1115
 1116        /// <summary>
 1117        /// Update a specific project.
 1118        /// </summary>
 1119        /// <param name='projectId'>
 1120        /// The id of the project to update.
 1121        /// </param>
 1122        /// <param name='updatedProject'>
 1123        /// The updated project model.
 1124        /// </param>
 1125        /// <param name='customHeaders'>
 1126        /// Headers that will be added to request.
 1127        /// </param>
 1128        /// <param name='cancellationToken'>
 1129        /// The cancellation token.
 1130        /// </param>
 1131        /// <exception cref="CustomVisionErrorException">
 1132        /// Thrown when the operation returned an invalid status code
 1133        /// </exception>
 1134        /// <exception cref="SerializationException">
 1135        /// Thrown when unable to deserialize the response
 1136        /// </exception>
 1137        /// <exception cref="ValidationException">
 1138        /// Thrown when a required parameter is null
 1139        /// </exception>
 1140        /// <exception cref="System.ArgumentNullException">
 1141        /// Thrown when a required parameter is null
 1142        /// </exception>
 1143        /// <return>
 1144        /// A response object containing the response body and response headers.
 1145        /// </return>
 1146        public async Task<HttpOperationResponse<Project>> UpdateProjectWithHttpMessagesAsync(System.Guid projectId, Proj
 1147        {
 21148            if (Endpoint == null)
 1149            {
 01150                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 1151            }
 21152            if (updatedProject == null)
 1153            {
 01154                throw new ValidationException(ValidationRules.CannotBeNull, "updatedProject");
 1155            }
 1156            // Tracing
 21157            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 21158            string _invocationId = null;
 21159            if (_shouldTrace)
 1160            {
 01161                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01162                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01163                tracingParameters.Add("projectId", projectId);
 01164                tracingParameters.Add("updatedProject", updatedProject);
 01165                tracingParameters.Add("cancellationToken", cancellationToken);
 01166                ServiceClientTracing.Enter(_invocationId, this, "UpdateProject", tracingParameters);
 1167            }
 1168            // Construct URL
 21169            var _baseUrl = BaseUri;
 21170            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}";
 21171            _url = _url.Replace("{Endpoint}", Endpoint);
 21172            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 1173            // Create HTTP transport objects
 21174            var _httpRequest = new HttpRequestMessage();
 21175            HttpResponseMessage _httpResponse = null;
 21176            _httpRequest.Method = new HttpMethod("PATCH");
 21177            _httpRequest.RequestUri = new System.Uri(_url);
 1178            // Set Headers
 1179
 1180
 21181            if (customHeaders != null)
 1182            {
 01183                foreach(var _header in customHeaders)
 1184                {
 01185                    if (_httpRequest.Headers.Contains(_header.Key))
 1186                    {
 01187                        _httpRequest.Headers.Remove(_header.Key);
 1188                    }
 01189                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1190                }
 1191            }
 1192
 1193            // Serialize Request
 21194            string _requestContent = null;
 21195            if(updatedProject != null)
 1196            {
 21197                _requestContent = SafeJsonConvert.SerializeObject(updatedProject, SerializationSettings);
 21198                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 21199                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 1200            }
 1201            // Set Credentials
 21202            if (Credentials != null)
 1203            {
 21204                cancellationToken.ThrowIfCancellationRequested();
 21205                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1206            }
 1207            // Send Request
 21208            if (_shouldTrace)
 1209            {
 01210                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1211            }
 21212            cancellationToken.ThrowIfCancellationRequested();
 21213            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 21214            if (_shouldTrace)
 1215            {
 01216                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1217            }
 21218            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 21219            cancellationToken.ThrowIfCancellationRequested();
 21220            string _responseContent = null;
 21221            if ((int)_statusCode != 200)
 1222            {
 01223                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 1224                try
 1225                {
 01226                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01227                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 01228                    if (_errorBody != null)
 1229                    {
 01230                        ex.Body = _errorBody;
 1231                    }
 01232                }
 01233                catch (JsonException)
 1234                {
 1235                    // Ignore the exception
 01236                }
 01237                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01238                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01239                if (_shouldTrace)
 1240                {
 01241                    ServiceClientTracing.Error(_invocationId, ex);
 1242                }
 01243                _httpRequest.Dispose();
 01244                if (_httpResponse != null)
 1245                {
 01246                    _httpResponse.Dispose();
 1247                }
 01248                throw ex;
 1249            }
 1250            // Create Result
 21251            var _result = new HttpOperationResponse<Project>();
 21252            _result.Request = _httpRequest;
 21253            _result.Response = _httpResponse;
 1254            // Deserialize Response
 21255            if ((int)_statusCode == 200)
 1256            {
 21257                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1258                try
 1259                {
 21260                    _result.Body = SafeJsonConvert.DeserializeObject<Project>(_responseContent, DeserializationSettings)
 21261                }
 01262                catch (JsonException ex)
 1263                {
 01264                    _httpRequest.Dispose();
 01265                    if (_httpResponse != null)
 1266                    {
 01267                        _httpResponse.Dispose();
 1268                    }
 01269                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1270                }
 1271            }
 21272            if (_shouldTrace)
 1273            {
 01274                ServiceClientTracing.Exit(_invocationId, _result);
 1275            }
 21276            return _result;
 21277        }
 1278
 1279        /// <summary>
 1280        /// Get artifact content from blob storage, based on artifact relative path in
 1281        /// the blob.
 1282        /// </summary>
 1283        /// <param name='projectId'>
 1284        /// The project id.
 1285        /// </param>
 1286        /// <param name='path'>
 1287        /// The relative path for artifact.
 1288        /// </param>
 1289        /// <param name='customHeaders'>
 1290        /// Headers that will be added to request.
 1291        /// </param>
 1292        /// <param name='cancellationToken'>
 1293        /// The cancellation token.
 1294        /// </param>
 1295        /// <exception cref="HttpOperationException">
 1296        /// Thrown when the operation returned an invalid status code
 1297        /// </exception>
 1298        /// <exception cref="SerializationException">
 1299        /// Thrown when unable to deserialize the response
 1300        /// </exception>
 1301        /// <exception cref="ValidationException">
 1302        /// Thrown when a required parameter is null
 1303        /// </exception>
 1304        /// <exception cref="System.ArgumentNullException">
 1305        /// Thrown when a required parameter is null
 1306        /// </exception>
 1307        /// <return>
 1308        /// A response object containing the response body and response headers.
 1309        /// </return>
 1310        public async Task<HttpOperationResponse<Stream>> GetArtifactWithHttpMessagesAsync(System.Guid projectId, string 
 1311        {
 21312            if (Endpoint == null)
 1313            {
 01314                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 1315            }
 21316            if (path == null)
 1317            {
 01318                throw new ValidationException(ValidationRules.CannotBeNull, "path");
 1319            }
 1320            // Tracing
 21321            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 21322            string _invocationId = null;
 21323            if (_shouldTrace)
 1324            {
 01325                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01326                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01327                tracingParameters.Add("projectId", projectId);
 01328                tracingParameters.Add("path", path);
 01329                tracingParameters.Add("cancellationToken", cancellationToken);
 01330                ServiceClientTracing.Enter(_invocationId, this, "GetArtifact", tracingParameters);
 1331            }
 1332            // Construct URL
 21333            var _baseUrl = BaseUri;
 21334            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/artifacts";
 21335            _url = _url.Replace("{Endpoint}", Endpoint);
 21336            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 21337            List<string> _queryParameters = new List<string>();
 21338            if (path != null)
 1339            {
 21340                _queryParameters.Add(string.Format("path={0}", System.Uri.EscapeDataString(path)));
 1341            }
 21342            if (_queryParameters.Count > 0)
 1343            {
 21344                _url += "?" + string.Join("&", _queryParameters);
 1345            }
 1346            // Create HTTP transport objects
 21347            var _httpRequest = new HttpRequestMessage();
 21348            HttpResponseMessage _httpResponse = null;
 21349            _httpRequest.Method = new HttpMethod("GET");
 21350            _httpRequest.RequestUri = new System.Uri(_url);
 1351            // Set Headers
 1352
 1353
 21354            if (customHeaders != null)
 1355            {
 01356                foreach(var _header in customHeaders)
 1357                {
 01358                    if (_httpRequest.Headers.Contains(_header.Key))
 1359                    {
 01360                        _httpRequest.Headers.Remove(_header.Key);
 1361                    }
 01362                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1363                }
 1364            }
 1365
 1366            // Serialize Request
 21367            string _requestContent = null;
 1368            // Set Credentials
 21369            if (Credentials != null)
 1370            {
 21371                cancellationToken.ThrowIfCancellationRequested();
 21372                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1373            }
 1374            // Send Request
 21375            if (_shouldTrace)
 1376            {
 01377                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1378            }
 21379            cancellationToken.ThrowIfCancellationRequested();
 21380            _httpResponse = await HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeader
 21381            if (_shouldTrace)
 1382            {
 01383                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1384            }
 21385            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 21386            cancellationToken.ThrowIfCancellationRequested();
 21387            string _responseContent = null;
 21388            if ((int)_statusCode != 200)
 1389            {
 01390                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _st
 01391                if (_httpResponse.Content != null) {
 01392                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1393                }
 1394                else {
 01395                    _responseContent = string.Empty;
 1396                }
 01397                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01398                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01399                if (_shouldTrace)
 1400                {
 01401                    ServiceClientTracing.Error(_invocationId, ex);
 1402                }
 01403                _httpRequest.Dispose();
 01404                if (_httpResponse != null)
 1405                {
 01406                    _httpResponse.Dispose();
 1407                }
 01408                throw ex;
 1409            }
 1410            // Create Result
 21411            var _result = new HttpOperationResponse<Stream>();
 21412            _result.Request = _httpRequest;
 21413            _result.Response = _httpResponse;
 1414            // Deserialize Response
 21415            if ((int)_statusCode == 200)
 1416            {
 21417                _result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
 1418            }
 21419            if (_shouldTrace)
 1420            {
 01421                ServiceClientTracing.Exit(_invocationId, _result);
 1422            }
 21423            return _result;
 21424        }
 1425
 1426        /// <summary>
 1427        /// Exports a project.
 1428        /// </summary>
 1429        /// <param name='projectId'>
 1430        /// The project id of the project to export.
 1431        /// </param>
 1432        /// <param name='customHeaders'>
 1433        /// Headers that will be added to request.
 1434        /// </param>
 1435        /// <param name='cancellationToken'>
 1436        /// The cancellation token.
 1437        /// </param>
 1438        /// <exception cref="CustomVisionErrorException">
 1439        /// Thrown when the operation returned an invalid status code
 1440        /// </exception>
 1441        /// <exception cref="SerializationException">
 1442        /// Thrown when unable to deserialize the response
 1443        /// </exception>
 1444        /// <exception cref="ValidationException">
 1445        /// Thrown when a required parameter is null
 1446        /// </exception>
 1447        /// <exception cref="System.ArgumentNullException">
 1448        /// Thrown when a required parameter is null
 1449        /// </exception>
 1450        /// <return>
 1451        /// A response object containing the response body and response headers.
 1452        /// </return>
 1453        public async Task<HttpOperationResponse<ProjectExport>> ExportProjectWithHttpMessagesAsync(System.Guid projectId
 1454        {
 21455            if (Endpoint == null)
 1456            {
 01457                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 1458            }
 1459            // Tracing
 21460            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 21461            string _invocationId = null;
 21462            if (_shouldTrace)
 1463            {
 01464                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01465                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01466                tracingParameters.Add("projectId", projectId);
 01467                tracingParameters.Add("cancellationToken", cancellationToken);
 01468                ServiceClientTracing.Enter(_invocationId, this, "ExportProject", tracingParameters);
 1469            }
 1470            // Construct URL
 21471            var _baseUrl = BaseUri;
 21472            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/export";
 21473            _url = _url.Replace("{Endpoint}", Endpoint);
 21474            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 1475            // Create HTTP transport objects
 21476            var _httpRequest = new HttpRequestMessage();
 21477            HttpResponseMessage _httpResponse = null;
 21478            _httpRequest.Method = new HttpMethod("GET");
 21479            _httpRequest.RequestUri = new System.Uri(_url);
 1480            // Set Headers
 1481
 1482
 21483            if (customHeaders != null)
 1484            {
 01485                foreach(var _header in customHeaders)
 1486                {
 01487                    if (_httpRequest.Headers.Contains(_header.Key))
 1488                    {
 01489                        _httpRequest.Headers.Remove(_header.Key);
 1490                    }
 01491                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1492                }
 1493            }
 1494
 1495            // Serialize Request
 21496            string _requestContent = null;
 1497            // Set Credentials
 21498            if (Credentials != null)
 1499            {
 21500                cancellationToken.ThrowIfCancellationRequested();
 21501                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1502            }
 1503            // Send Request
 21504            if (_shouldTrace)
 1505            {
 01506                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1507            }
 21508            cancellationToken.ThrowIfCancellationRequested();
 21509            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 21510            if (_shouldTrace)
 1511            {
 01512                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1513            }
 21514            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 21515            cancellationToken.ThrowIfCancellationRequested();
 21516            string _responseContent = null;
 21517            if ((int)_statusCode != 200)
 1518            {
 01519                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 1520                try
 1521                {
 01522                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01523                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 01524                    if (_errorBody != null)
 1525                    {
 01526                        ex.Body = _errorBody;
 1527                    }
 01528                }
 01529                catch (JsonException)
 1530                {
 1531                    // Ignore the exception
 01532                }
 01533                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01534                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01535                if (_shouldTrace)
 1536                {
 01537                    ServiceClientTracing.Error(_invocationId, ex);
 1538                }
 01539                _httpRequest.Dispose();
 01540                if (_httpResponse != null)
 1541                {
 01542                    _httpResponse.Dispose();
 1543                }
 01544                throw ex;
 1545            }
 1546            // Create Result
 21547            var _result = new HttpOperationResponse<ProjectExport>();
 21548            _result.Request = _httpRequest;
 21549            _result.Response = _httpResponse;
 1550            // Deserialize Response
 21551            if ((int)_statusCode == 200)
 1552            {
 21553                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1554                try
 1555                {
 21556                    _result.Body = SafeJsonConvert.DeserializeObject<ProjectExport>(_responseContent, DeserializationSet
 21557                }
 01558                catch (JsonException ex)
 1559                {
 01560                    _httpRequest.Dispose();
 01561                    if (_httpResponse != null)
 1562                    {
 01563                        _httpResponse.Dispose();
 1564                    }
 01565                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1566                }
 1567            }
 21568            if (_shouldTrace)
 1569            {
 01570                ServiceClientTracing.Exit(_invocationId, _result);
 1571            }
 21572            return _result;
 21573        }
 1574
 1575        /// <summary>
 1576        /// Get images for a given project iteration or workspace.
 1577        /// </summary>
 1578        /// <remarks>
 1579        /// This API supports batching and range selection. By default it will only
 1580        /// return first 50 images matching images.
 1581        /// Use the {take} and {skip} parameters to control how many images to return
 1582        /// in a given batch.
 1583        /// The filtering is on an and/or relationship. For example, if the provided
 1584        /// tag ids are for the "Dog" and
 1585        /// "Cat" tags, then only images tagged with Dog and/or Cat will be returned
 1586        /// </remarks>
 1587        /// <param name='projectId'>
 1588        /// The project id.
 1589        /// </param>
 1590        /// <param name='iterationId'>
 1591        /// The iteration id. Defaults to workspace.
 1592        /// </param>
 1593        /// <param name='tagIds'>
 1594        /// A list of tags ids to filter the images. Defaults to all tagged images when
 1595        /// null. Limited to 20.
 1596        /// </param>
 1597        /// <param name='taggingStatus'>
 1598        /// The tagging status filter. It can be 'All', 'Tagged', or 'Untagged'.
 1599        /// Defaults to 'All'. Possible values include: 'All', 'Tagged', 'Untagged'
 1600        /// </param>
 1601        /// <param name='filter'>
 1602        /// An expression to filter the images against image metadata. Only images
 1603        /// where the expression evaluates to true are included in the response.
 1604        /// The expression supports eq (Equal), ne (Not equal), and (Logical and), or
 1605        /// (Logical or) operators.
 1606        /// Here is an example, metadata=key1 eq 'value1' and key2 ne 'value2'.
 1607        /// </param>
 1608        /// <param name='orderBy'>
 1609        /// The ordering. Defaults to newest. Possible values include: 'Newest',
 1610        /// 'Oldest'
 1611        /// </param>
 1612        /// <param name='take'>
 1613        /// Maximum number of images to return. Defaults to 50, limited to 256.
 1614        /// </param>
 1615        /// <param name='skip'>
 1616        /// Number of images to skip before beginning the image batch. Defaults to 0.
 1617        /// </param>
 1618        /// <param name='customHeaders'>
 1619        /// Headers that will be added to request.
 1620        /// </param>
 1621        /// <param name='cancellationToken'>
 1622        /// The cancellation token.
 1623        /// </param>
 1624        /// <exception cref="CustomVisionErrorException">
 1625        /// Thrown when the operation returned an invalid status code
 1626        /// </exception>
 1627        /// <exception cref="SerializationException">
 1628        /// Thrown when unable to deserialize the response
 1629        /// </exception>
 1630        /// <exception cref="ValidationException">
 1631        /// Thrown when a required parameter is null
 1632        /// </exception>
 1633        /// <exception cref="System.ArgumentNullException">
 1634        /// Thrown when a required parameter is null
 1635        /// </exception>
 1636        /// <return>
 1637        /// A response object containing the response body and response headers.
 1638        /// </return>
 1639        public async Task<HttpOperationResponse<IList<Image>>> GetImagesWithHttpMessagesAsync(System.Guid projectId, Sys
 1640        {
 61641            if (Endpoint == null)
 1642            {
 01643                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 1644            }
 61645            if (tagIds != null)
 1646            {
 01647                if (tagIds.Count > 20)
 1648                {
 01649                    throw new ValidationException(ValidationRules.MaxItems, "tagIds", 20);
 1650                }
 01651                if (tagIds.Count < 0)
 1652                {
 01653                    throw new ValidationException(ValidationRules.MinItems, "tagIds", 0);
 1654                }
 1655            }
 61656            if (take > 256)
 1657            {
 01658                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 256);
 1659            }
 61660            if (take < 0)
 1661            {
 01662                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 1663            }
 1664            // Tracing
 61665            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 61666            string _invocationId = null;
 61667            if (_shouldTrace)
 1668            {
 01669                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01670                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01671                tracingParameters.Add("projectId", projectId);
 01672                tracingParameters.Add("iterationId", iterationId);
 01673                tracingParameters.Add("tagIds", tagIds);
 01674                tracingParameters.Add("taggingStatus", taggingStatus);
 01675                tracingParameters.Add("filter", filter);
 01676                tracingParameters.Add("orderBy", orderBy);
 01677                tracingParameters.Add("take", take);
 01678                tracingParameters.Add("skip", skip);
 01679                tracingParameters.Add("cancellationToken", cancellationToken);
 01680                ServiceClientTracing.Enter(_invocationId, this, "GetImages", tracingParameters);
 1681            }
 1682            // Construct URL
 61683            var _baseUrl = BaseUri;
 61684            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images";
 61685            _url = _url.Replace("{Endpoint}", Endpoint);
 61686            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 61687            List<string> _queryParameters = new List<string>();
 61688            if (iterationId != null)
 1689            {
 01690                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 1691            }
 61692            if (tagIds != null)
 1693            {
 01694                _queryParameters.Add(string.Format("tagIds={0}", System.Uri.EscapeDataString(string.Join(",", tagIds))))
 1695            }
 61696            if (taggingStatus != null)
 1697            {
 41698                _queryParameters.Add(string.Format("taggingStatus={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seri
 1699            }
 61700            if (filter != null)
 1701            {
 01702                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 1703            }
 61704            if (orderBy != null)
 1705            {
 01706                _queryParameters.Add(string.Format("orderBy={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 1707            }
 61708            if (take != null)
 1709            {
 61710                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObje
 1711            }
 61712            if (skip != null)
 1713            {
 61714                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObje
 1715            }
 61716            if (_queryParameters.Count > 0)
 1717            {
 61718                _url += "?" + string.Join("&", _queryParameters);
 1719            }
 1720            // Create HTTP transport objects
 61721            var _httpRequest = new HttpRequestMessage();
 61722            HttpResponseMessage _httpResponse = null;
 61723            _httpRequest.Method = new HttpMethod("GET");
 61724            _httpRequest.RequestUri = new System.Uri(_url);
 1725            // Set Headers
 1726
 1727
 61728            if (customHeaders != null)
 1729            {
 01730                foreach(var _header in customHeaders)
 1731                {
 01732                    if (_httpRequest.Headers.Contains(_header.Key))
 1733                    {
 01734                        _httpRequest.Headers.Remove(_header.Key);
 1735                    }
 01736                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1737                }
 1738            }
 1739
 1740            // Serialize Request
 61741            string _requestContent = null;
 1742            // Set Credentials
 61743            if (Credentials != null)
 1744            {
 61745                cancellationToken.ThrowIfCancellationRequested();
 61746                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1747            }
 1748            // Send Request
 61749            if (_shouldTrace)
 1750            {
 01751                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1752            }
 61753            cancellationToken.ThrowIfCancellationRequested();
 61754            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 61755            if (_shouldTrace)
 1756            {
 01757                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1758            }
 61759            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 61760            cancellationToken.ThrowIfCancellationRequested();
 61761            string _responseContent = null;
 61762            if ((int)_statusCode != 200)
 1763            {
 01764                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 1765                try
 1766                {
 01767                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01768                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 01769                    if (_errorBody != null)
 1770                    {
 01771                        ex.Body = _errorBody;
 1772                    }
 01773                }
 01774                catch (JsonException)
 1775                {
 1776                    // Ignore the exception
 01777                }
 01778                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01779                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01780                if (_shouldTrace)
 1781                {
 01782                    ServiceClientTracing.Error(_invocationId, ex);
 1783                }
 01784                _httpRequest.Dispose();
 01785                if (_httpResponse != null)
 1786                {
 01787                    _httpResponse.Dispose();
 1788                }
 01789                throw ex;
 1790            }
 1791            // Create Result
 61792            var _result = new HttpOperationResponse<IList<Image>>();
 61793            _result.Request = _httpRequest;
 61794            _result.Response = _httpResponse;
 1795            // Deserialize Response
 61796            if ((int)_statusCode == 200)
 1797            {
 61798                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1799                try
 1800                {
 61801                    _result.Body = SafeJsonConvert.DeserializeObject<IList<Image>>(_responseContent, DeserializationSett
 61802                }
 01803                catch (JsonException ex)
 1804                {
 01805                    _httpRequest.Dispose();
 01806                    if (_httpResponse != null)
 1807                    {
 01808                        _httpResponse.Dispose();
 1809                    }
 01810                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1811                }
 1812            }
 61813            if (_shouldTrace)
 1814            {
 01815                ServiceClientTracing.Exit(_invocationId, _result);
 1816            }
 61817            return _result;
 61818        }
 1819
 1820        /// <summary>
 1821        /// Add the provided images to the set of training images.
 1822        /// </summary>
 1823        /// <remarks>
 1824        /// This API accepts body content as multipart/form-data and
 1825        /// application/octet-stream. When using multipart
 1826        /// multiple image files can be sent at once, with a maximum of 64 files.
 1827        /// If all images are successful created, 200(OK) status code will be returned.
 1828        /// Otherwise, 207 (Multi-Status) status code will be returned and detail
 1829        /// status for each image will be listed in the response payload.
 1830        /// </remarks>
 1831        /// <param name='projectId'>
 1832        /// The project id.
 1833        /// </param>
 1834        /// <param name='imageData'>
 1835        /// Binary image data. Supported formats are JPEG, GIF, PNG, and BMP. Supports
 1836        /// images up to 6MB.
 1837        /// </param>
 1838        /// <param name='tagIds'>
 1839        /// The tags ids with which to tag each image. Limited to 20.
 1840        /// </param>
 1841        /// <param name='customHeaders'>
 1842        /// Headers that will be added to request.
 1843        /// </param>
 1844        /// <param name='cancellationToken'>
 1845        /// The cancellation token.
 1846        /// </param>
 1847        /// <exception cref="CustomVisionErrorException">
 1848        /// Thrown when the operation returned an invalid status code
 1849        /// </exception>
 1850        /// <exception cref="SerializationException">
 1851        /// Thrown when unable to deserialize the response
 1852        /// </exception>
 1853        /// <exception cref="ValidationException">
 1854        /// Thrown when a required parameter is null
 1855        /// </exception>
 1856        /// <exception cref="System.ArgumentNullException">
 1857        /// Thrown when a required parameter is null
 1858        /// </exception>
 1859        /// <return>
 1860        /// A response object containing the response body and response headers.
 1861        /// </return>
 1862        public async Task<HttpOperationResponse<ImageCreateSummary>> CreateImagesFromDataWithHttpMessagesAsync(System.Gu
 1863        {
 1864            if (Endpoint == null)
 1865            {
 1866                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 1867            }
 1868            if (tagIds != null)
 1869            {
 1870                if (tagIds.Count > 20)
 1871                {
 1872                    throw new ValidationException(ValidationRules.MaxItems, "tagIds", 20);
 1873                }
 1874                if (tagIds.Count < 0)
 1875                {
 1876                    throw new ValidationException(ValidationRules.MinItems, "tagIds", 0);
 1877                }
 1878            }
 1879            if (imageData == null)
 1880            {
 1881                throw new ValidationException(ValidationRules.CannotBeNull, "imageData");
 1882            }
 1883            // Tracing
 1884            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 1885            string _invocationId = null;
 1886            if (_shouldTrace)
 1887            {
 1888                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 1889                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 1890                tracingParameters.Add("projectId", projectId);
 1891                tracingParameters.Add("tagIds", tagIds);
 1892                tracingParameters.Add("imageData", imageData);
 1893                tracingParameters.Add("cancellationToken", cancellationToken);
 1894                ServiceClientTracing.Enter(_invocationId, this, "CreateImagesFromData", tracingParameters);
 1895            }
 1896            // Construct URL
 1897            var _baseUrl = BaseUri;
 1898            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images";
 1899            _url = _url.Replace("{Endpoint}", Endpoint);
 1900            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 1901            List<string> _queryParameters = new List<string>();
 1902            if (tagIds != null)
 1903            {
 1904                _queryParameters.Add(string.Format("tagIds={0}", System.Uri.EscapeDataString(string.Join(",", tagIds))))
 1905            }
 1906            if (_queryParameters.Count > 0)
 1907            {
 1908                _url += "?" + string.Join("&", _queryParameters);
 1909            }
 1910            // Create HTTP transport objects
 1911            var _httpRequest = new HttpRequestMessage();
 1912            HttpResponseMessage _httpResponse = null;
 1913            _httpRequest.Method = new HttpMethod("POST");
 1914            _httpRequest.RequestUri = new System.Uri(_url);
 1915            // Set Headers
 1916
 1917
 1918            if (customHeaders != null)
 1919            {
 1920                foreach(var _header in customHeaders)
 1921                {
 1922                    if (_httpRequest.Headers.Contains(_header.Key))
 1923                    {
 1924                        _httpRequest.Headers.Remove(_header.Key);
 1925                    }
 1926                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1927                }
 1928            }
 1929
 1930            // Serialize Request
 1931            string _requestContent = null;
 1932            MultipartFormDataContent _multiPartContent = new MultipartFormDataContent();
 1933            if (imageData != null)
 1934            {
 1935                StreamContent _imageData = new StreamContent(imageData);
 1936                _imageData.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
 1937                ContentDispositionHeaderValue _contentDispositionHeaderValue = new ContentDispositionHeaderValue("form-d
 1938                _contentDispositionHeaderValue.Name = "imageData";
 1939                // get filename from stream if it's a file otherwise, just use  'unknown'
 1940                var _fileStream = imageData as FileStream;
 1941                var _fileName = (_fileStream != null ? _fileStream.Name : null) ?? "unknown";
 3201942                if(System.Linq.Enumerable.Any(_fileName, c => c > 127) )
 1943                {
 1944                    // non ASCII chars detected, need UTF encoding:
 1945                    _contentDispositionHeaderValue.FileNameStar = _fileName;
 1946                }
 1947                else
 1948                {
 1949                    // ASCII only
 1950                    _contentDispositionHeaderValue.FileName = _fileName;
 1951                }
 1952                _imageData.Headers.ContentDisposition = _contentDispositionHeaderValue;
 1953                _multiPartContent.Add(_imageData, "imageData");
 1954            }
 1955            _httpRequest.Content = _multiPartContent;
 1956            // Set Credentials
 1957            if (Credentials != null)
 1958            {
 1959                cancellationToken.ThrowIfCancellationRequested();
 1960                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1961            }
 1962            // Send Request
 1963            if (_shouldTrace)
 1964            {
 1965                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1966            }
 1967            cancellationToken.ThrowIfCancellationRequested();
 1968            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1969            if (_shouldTrace)
 1970            {
 1971                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1972            }
 1973            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 1974            cancellationToken.ThrowIfCancellationRequested();
 1975            string _responseContent = null;
 1976            if ((int)_statusCode != 200 && (int)_statusCode != 207)
 1977            {
 1978                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 1979                try
 1980                {
 1981                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1982                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 1983                    if (_errorBody != null)
 1984                    {
 1985                        ex.Body = _errorBody;
 1986                    }
 1987                }
 1988                catch (JsonException)
 1989                {
 1990                    // Ignore the exception
 1991                }
 1992                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 1993                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 1994                if (_shouldTrace)
 1995                {
 1996                    ServiceClientTracing.Error(_invocationId, ex);
 1997                }
 1998                _httpRequest.Dispose();
 1999                if (_httpResponse != null)
 2000                {
 2001                    _httpResponse.Dispose();
 2002                }
 2003                throw ex;
 2004            }
 2005            // Create Result
 2006            var _result = new HttpOperationResponse<ImageCreateSummary>();
 2007            _result.Request = _httpRequest;
 2008            _result.Response = _httpResponse;
 2009            // Deserialize Response
 2010            if ((int)_statusCode == 200)
 2011            {
 2012                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2013                try
 2014                {
 2015                    _result.Body = SafeJsonConvert.DeserializeObject<ImageCreateSummary>(_responseContent, Deserializati
 2016                }
 2017                catch (JsonException ex)
 2018                {
 2019                    _httpRequest.Dispose();
 2020                    if (_httpResponse != null)
 2021                    {
 2022                        _httpResponse.Dispose();
 2023                    }
 2024                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2025                }
 2026            }
 2027            // Deserialize Response
 2028            if ((int)_statusCode == 207)
 2029            {
 2030                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2031                try
 2032                {
 2033                    _result.Body = SafeJsonConvert.DeserializeObject<ImageCreateSummary>(_responseContent, Deserializati
 2034                }
 2035                catch (JsonException ex)
 2036                {
 2037                    _httpRequest.Dispose();
 2038                    if (_httpResponse != null)
 2039                    {
 2040                        _httpResponse.Dispose();
 2041                    }
 2042                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2043                }
 2044            }
 2045            if (_shouldTrace)
 2046            {
 2047                ServiceClientTracing.Exit(_invocationId, _result);
 2048            }
 2049            return _result;
 2050        }
 2051
 2052        /// <summary>
 2053        /// Delete images from the set of training images.
 2054        /// </summary>
 2055        /// <param name='projectId'>
 2056        /// The project id.
 2057        /// </param>
 2058        /// <param name='imageIds'>
 2059        /// Ids of the images to be deleted. Limited to 256 images per batch.
 2060        /// </param>
 2061        /// <param name='allImages'>
 2062        /// Flag to specify delete all images, specify this flag or a list of images.
 2063        /// Using this flag will return a 202 response to indicate the images are being
 2064        /// deleted.
 2065        /// </param>
 2066        /// <param name='allIterations'>
 2067        /// Removes these images from all iterations, not just the current workspace.
 2068        /// Using this flag will return a 202 response to indicate the images are being
 2069        /// deleted.
 2070        /// </param>
 2071        /// <param name='customHeaders'>
 2072        /// Headers that will be added to request.
 2073        /// </param>
 2074        /// <param name='cancellationToken'>
 2075        /// The cancellation token.
 2076        /// </param>
 2077        /// <exception cref="CustomVisionErrorException">
 2078        /// Thrown when the operation returned an invalid status code
 2079        /// </exception>
 2080        /// <exception cref="ValidationException">
 2081        /// Thrown when a required parameter is null
 2082        /// </exception>
 2083        /// <exception cref="System.ArgumentNullException">
 2084        /// Thrown when a required parameter is null
 2085        /// </exception>
 2086        /// <return>
 2087        /// A response object containing the response body and response headers.
 2088        /// </return>
 2089        public async Task<HttpOperationResponse> DeleteImagesWithHttpMessagesAsync(System.Guid projectId, IList<System.G
 2090        {
 22091            if (Endpoint == null)
 2092            {
 02093                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 2094            }
 22095            if (imageIds != null)
 2096            {
 22097                if (imageIds.Count > 256)
 2098                {
 02099                    throw new ValidationException(ValidationRules.MaxItems, "imageIds", 256);
 2100                }
 22101                if (imageIds.Count < 0)
 2102                {
 02103                    throw new ValidationException(ValidationRules.MinItems, "imageIds", 0);
 2104                }
 2105            }
 2106            // Tracing
 22107            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 22108            string _invocationId = null;
 22109            if (_shouldTrace)
 2110            {
 02111                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02112                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02113                tracingParameters.Add("projectId", projectId);
 02114                tracingParameters.Add("imageIds", imageIds);
 02115                tracingParameters.Add("allImages", allImages);
 02116                tracingParameters.Add("allIterations", allIterations);
 02117                tracingParameters.Add("cancellationToken", cancellationToken);
 02118                ServiceClientTracing.Enter(_invocationId, this, "DeleteImages", tracingParameters);
 2119            }
 2120            // Construct URL
 22121            var _baseUrl = BaseUri;
 22122            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images";
 22123            _url = _url.Replace("{Endpoint}", Endpoint);
 22124            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 22125            List<string> _queryParameters = new List<string>();
 22126            if (imageIds != null)
 2127            {
 22128                _queryParameters.Add(string.Format("imageIds={0}", System.Uri.EscapeDataString(string.Join(",", imageIds
 2129            }
 22130            if (allImages != null)
 2131            {
 02132                _queryParameters.Add(string.Format("allImages={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serializ
 2133            }
 22134            if (allIterations != null)
 2135            {
 02136                _queryParameters.Add(string.Format("allIterations={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seri
 2137            }
 22138            if (_queryParameters.Count > 0)
 2139            {
 22140                _url += "?" + string.Join("&", _queryParameters);
 2141            }
 2142            // Create HTTP transport objects
 22143            var _httpRequest = new HttpRequestMessage();
 22144            HttpResponseMessage _httpResponse = null;
 22145            _httpRequest.Method = new HttpMethod("DELETE");
 22146            _httpRequest.RequestUri = new System.Uri(_url);
 2147            // Set Headers
 2148
 2149
 22150            if (customHeaders != null)
 2151            {
 02152                foreach(var _header in customHeaders)
 2153                {
 02154                    if (_httpRequest.Headers.Contains(_header.Key))
 2155                    {
 02156                        _httpRequest.Headers.Remove(_header.Key);
 2157                    }
 02158                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2159                }
 2160            }
 2161
 2162            // Serialize Request
 22163            string _requestContent = null;
 2164            // Set Credentials
 22165            if (Credentials != null)
 2166            {
 22167                cancellationToken.ThrowIfCancellationRequested();
 22168                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2169            }
 2170            // Send Request
 22171            if (_shouldTrace)
 2172            {
 02173                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2174            }
 22175            cancellationToken.ThrowIfCancellationRequested();
 22176            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 22177            if (_shouldTrace)
 2178            {
 02179                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2180            }
 22181            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 22182            cancellationToken.ThrowIfCancellationRequested();
 22183            string _responseContent = null;
 22184            if ((int)_statusCode != 202 && (int)_statusCode != 204)
 2185            {
 02186                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 2187                try
 2188                {
 02189                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02190                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 02191                    if (_errorBody != null)
 2192                    {
 02193                        ex.Body = _errorBody;
 2194                    }
 02195                }
 02196                catch (JsonException)
 2197                {
 2198                    // Ignore the exception
 02199                }
 02200                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02201                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02202                if (_shouldTrace)
 2203                {
 02204                    ServiceClientTracing.Error(_invocationId, ex);
 2205                }
 02206                _httpRequest.Dispose();
 02207                if (_httpResponse != null)
 2208                {
 02209                    _httpResponse.Dispose();
 2210                }
 02211                throw ex;
 2212            }
 2213            // Create Result
 22214            var _result = new HttpOperationResponse();
 22215            _result.Request = _httpRequest;
 22216            _result.Response = _httpResponse;
 22217            if (_shouldTrace)
 2218            {
 02219                ServiceClientTracing.Exit(_invocationId, _result);
 2220            }
 22221            return _result;
 22222        }
 2223
 2224        /// <summary>
 2225        /// Get region proposals for an image. Returns empty array if no proposals are
 2226        /// found.
 2227        /// </summary>
 2228        /// <remarks>
 2229        /// This API will get region proposals for an image along with confidences for
 2230        /// the region. It returns an empty array if no proposals are found.
 2231        /// </remarks>
 2232        /// <param name='projectId'>
 2233        /// The project id.
 2234        /// </param>
 2235        /// <param name='imageId'>
 2236        /// The image id.
 2237        /// </param>
 2238        /// <param name='customHeaders'>
 2239        /// Headers that will be added to request.
 2240        /// </param>
 2241        /// <param name='cancellationToken'>
 2242        /// The cancellation token.
 2243        /// </param>
 2244        /// <exception cref="CustomVisionErrorException">
 2245        /// Thrown when the operation returned an invalid status code
 2246        /// </exception>
 2247        /// <exception cref="SerializationException">
 2248        /// Thrown when unable to deserialize the response
 2249        /// </exception>
 2250        /// <exception cref="ValidationException">
 2251        /// Thrown when a required parameter is null
 2252        /// </exception>
 2253        /// <exception cref="System.ArgumentNullException">
 2254        /// Thrown when a required parameter is null
 2255        /// </exception>
 2256        /// <return>
 2257        /// A response object containing the response body and response headers.
 2258        /// </return>
 2259        public async Task<HttpOperationResponse<ImageRegionProposal>> GetImageRegionProposalsWithHttpMessagesAsync(Syste
 2260        {
 22261            if (Endpoint == null)
 2262            {
 02263                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 2264            }
 2265            // Tracing
 22266            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 22267            string _invocationId = null;
 22268            if (_shouldTrace)
 2269            {
 02270                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02271                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02272                tracingParameters.Add("projectId", projectId);
 02273                tracingParameters.Add("imageId", imageId);
 02274                tracingParameters.Add("cancellationToken", cancellationToken);
 02275                ServiceClientTracing.Enter(_invocationId, this, "GetImageRegionProposals", tracingParameters);
 2276            }
 2277            // Construct URL
 22278            var _baseUrl = BaseUri;
 22279            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/{imageId}/regionpro
 22280            _url = _url.Replace("{Endpoint}", Endpoint);
 22281            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 22282            _url = _url.Replace("{imageId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(imageId, Serial
 2283            // Create HTTP transport objects
 22284            var _httpRequest = new HttpRequestMessage();
 22285            HttpResponseMessage _httpResponse = null;
 22286            _httpRequest.Method = new HttpMethod("POST");
 22287            _httpRequest.RequestUri = new System.Uri(_url);
 2288            // Set Headers
 2289
 2290
 22291            if (customHeaders != null)
 2292            {
 02293                foreach(var _header in customHeaders)
 2294                {
 02295                    if (_httpRequest.Headers.Contains(_header.Key))
 2296                    {
 02297                        _httpRequest.Headers.Remove(_header.Key);
 2298                    }
 02299                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2300                }
 2301            }
 2302
 2303            // Serialize Request
 22304            string _requestContent = null;
 2305            // Set Credentials
 22306            if (Credentials != null)
 2307            {
 22308                cancellationToken.ThrowIfCancellationRequested();
 22309                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2310            }
 2311            // Send Request
 22312            if (_shouldTrace)
 2313            {
 02314                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2315            }
 22316            cancellationToken.ThrowIfCancellationRequested();
 22317            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 22318            if (_shouldTrace)
 2319            {
 02320                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2321            }
 22322            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 22323            cancellationToken.ThrowIfCancellationRequested();
 22324            string _responseContent = null;
 22325            if ((int)_statusCode != 200)
 2326            {
 02327                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 2328                try
 2329                {
 02330                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02331                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 02332                    if (_errorBody != null)
 2333                    {
 02334                        ex.Body = _errorBody;
 2335                    }
 02336                }
 02337                catch (JsonException)
 2338                {
 2339                    // Ignore the exception
 02340                }
 02341                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02342                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02343                if (_shouldTrace)
 2344                {
 02345                    ServiceClientTracing.Error(_invocationId, ex);
 2346                }
 02347                _httpRequest.Dispose();
 02348                if (_httpResponse != null)
 2349                {
 02350                    _httpResponse.Dispose();
 2351                }
 02352                throw ex;
 2353            }
 2354            // Create Result
 22355            var _result = new HttpOperationResponse<ImageRegionProposal>();
 22356            _result.Request = _httpRequest;
 22357            _result.Response = _httpResponse;
 2358            // Deserialize Response
 22359            if ((int)_statusCode == 200)
 2360            {
 22361                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2362                try
 2363                {
 22364                    _result.Body = SafeJsonConvert.DeserializeObject<ImageRegionProposal>(_responseContent, Deserializat
 22365                }
 02366                catch (JsonException ex)
 2367                {
 02368                    _httpRequest.Dispose();
 02369                    if (_httpResponse != null)
 2370                    {
 02371                        _httpResponse.Dispose();
 2372                    }
 02373                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2374                }
 2375            }
 22376            if (_shouldTrace)
 2377            {
 02378                ServiceClientTracing.Exit(_invocationId, _result);
 2379            }
 22380            return _result;
 22381        }
 2382
 2383        /// <summary>
 2384        /// Get the number of images.
 2385        /// </summary>
 2386        /// <remarks>
 2387        /// The filtering is on an and/or relationship. For example, if the provided
 2388        /// tag ids are for the "Dog" and
 2389        /// "Cat" tags, then only images tagged with Dog and/or Cat will be returned
 2390        /// </remarks>
 2391        /// <param name='projectId'>
 2392        /// The project id.
 2393        /// </param>
 2394        /// <param name='iterationId'>
 2395        /// The iteration id. Defaults to workspace.
 2396        /// </param>
 2397        /// <param name='taggingStatus'>
 2398        /// The tagging status filter. It can be 'All', 'Tagged', or 'Untagged'.
 2399        /// Defaults to 'All'. Possible values include: 'All', 'Tagged', 'Untagged'
 2400        /// </param>
 2401        /// <param name='filter'>
 2402        /// An expression to filter the images against image metadata. Only images
 2403        /// where the expression evaluates to true are included in the response.
 2404        /// The expression supports eq (Equal), ne (Not equal), and (Logical and), or
 2405        /// (Logical or) operators.
 2406        /// Here is an example, metadata=key1 eq 'value1' and key2 ne 'value2'.
 2407        /// </param>
 2408        /// <param name='tagIds'>
 2409        /// A list of tags ids to filter the images to count. Defaults to all tags when
 2410        /// null.
 2411        /// </param>
 2412        /// <param name='customHeaders'>
 2413        /// Headers that will be added to request.
 2414        /// </param>
 2415        /// <param name='cancellationToken'>
 2416        /// The cancellation token.
 2417        /// </param>
 2418        /// <exception cref="CustomVisionErrorException">
 2419        /// Thrown when the operation returned an invalid status code
 2420        /// </exception>
 2421        /// <exception cref="SerializationException">
 2422        /// Thrown when unable to deserialize the response
 2423        /// </exception>
 2424        /// <exception cref="ValidationException">
 2425        /// Thrown when a required parameter is null
 2426        /// </exception>
 2427        /// <exception cref="System.ArgumentNullException">
 2428        /// Thrown when a required parameter is null
 2429        /// </exception>
 2430        /// <return>
 2431        /// A response object containing the response body and response headers.
 2432        /// </return>
 2433        public async Task<HttpOperationResponse<int?>> GetImageCountWithHttpMessagesAsync(System.Guid projectId, System.
 2434        {
 22435            if (Endpoint == null)
 2436            {
 02437                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 2438            }
 2439            // Tracing
 22440            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 22441            string _invocationId = null;
 22442            if (_shouldTrace)
 2443            {
 02444                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02445                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02446                tracingParameters.Add("projectId", projectId);
 02447                tracingParameters.Add("iterationId", iterationId);
 02448                tracingParameters.Add("taggingStatus", taggingStatus);
 02449                tracingParameters.Add("filter", filter);
 02450                tracingParameters.Add("tagIds", tagIds);
 02451                tracingParameters.Add("cancellationToken", cancellationToken);
 02452                ServiceClientTracing.Enter(_invocationId, this, "GetImageCount", tracingParameters);
 2453            }
 2454            // Construct URL
 22455            var _baseUrl = BaseUri;
 22456            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/count";
 22457            _url = _url.Replace("{Endpoint}", Endpoint);
 22458            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 22459            List<string> _queryParameters = new List<string>();
 22460            if (iterationId != null)
 2461            {
 02462                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 2463            }
 22464            if (taggingStatus != null)
 2465            {
 22466                _queryParameters.Add(string.Format("taggingStatus={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seri
 2467            }
 22468            if (filter != null)
 2469            {
 02470                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
 2471            }
 22472            if (tagIds != null)
 2473            {
 02474                _queryParameters.Add(string.Format("tagIds={0}", System.Uri.EscapeDataString(string.Join(",", tagIds))))
 2475            }
 22476            if (_queryParameters.Count > 0)
 2477            {
 22478                _url += "?" + string.Join("&", _queryParameters);
 2479            }
 2480            // Create HTTP transport objects
 22481            var _httpRequest = new HttpRequestMessage();
 22482            HttpResponseMessage _httpResponse = null;
 22483            _httpRequest.Method = new HttpMethod("GET");
 22484            _httpRequest.RequestUri = new System.Uri(_url);
 2485            // Set Headers
 2486
 2487
 22488            if (customHeaders != null)
 2489            {
 02490                foreach(var _header in customHeaders)
 2491                {
 02492                    if (_httpRequest.Headers.Contains(_header.Key))
 2493                    {
 02494                        _httpRequest.Headers.Remove(_header.Key);
 2495                    }
 02496                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2497                }
 2498            }
 2499
 2500            // Serialize Request
 22501            string _requestContent = null;
 2502            // Set Credentials
 22503            if (Credentials != null)
 2504            {
 22505                cancellationToken.ThrowIfCancellationRequested();
 22506                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2507            }
 2508            // Send Request
 22509            if (_shouldTrace)
 2510            {
 02511                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2512            }
 22513            cancellationToken.ThrowIfCancellationRequested();
 22514            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 22515            if (_shouldTrace)
 2516            {
 02517                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2518            }
 22519            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 22520            cancellationToken.ThrowIfCancellationRequested();
 22521            string _responseContent = null;
 22522            if ((int)_statusCode != 200)
 2523            {
 02524                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 2525                try
 2526                {
 02527                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02528                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 02529                    if (_errorBody != null)
 2530                    {
 02531                        ex.Body = _errorBody;
 2532                    }
 02533                }
 02534                catch (JsonException)
 2535                {
 2536                    // Ignore the exception
 02537                }
 02538                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02539                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02540                if (_shouldTrace)
 2541                {
 02542                    ServiceClientTracing.Error(_invocationId, ex);
 2543                }
 02544                _httpRequest.Dispose();
 02545                if (_httpResponse != null)
 2546                {
 02547                    _httpResponse.Dispose();
 2548                }
 02549                throw ex;
 2550            }
 2551            // Create Result
 22552            var _result = new HttpOperationResponse<int?>();
 22553            _result.Request = _httpRequest;
 22554            _result.Response = _httpResponse;
 2555            // Deserialize Response
 22556            if ((int)_statusCode == 200)
 2557            {
 22558                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2559                try
 2560                {
 22561                    _result.Body = SafeJsonConvert.DeserializeObject<int?>(_responseContent, DeserializationSettings);
 22562                }
 02563                catch (JsonException ex)
 2564                {
 02565                    _httpRequest.Dispose();
 02566                    if (_httpResponse != null)
 2567                    {
 02568                        _httpResponse.Dispose();
 2569                    }
 02570                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2571                }
 2572            }
 22573            if (_shouldTrace)
 2574            {
 02575                ServiceClientTracing.Exit(_invocationId, _result);
 2576            }
 22577            return _result;
 22578        }
 2579
 2580        /// <summary>
 2581        /// Add the provided batch of images to the set of training images.
 2582        /// </summary>
 2583        /// <remarks>
 2584        /// This API accepts a batch of files, and optionally tags, to create images.
 2585        /// There is a limit of 64 images and 20 tags.
 2586        /// If all images are successful created, 200(OK) status code will be returned.
 2587        /// Otherwise, 207 (Multi-Status) status code will be returned and detail
 2588        /// status for each image will be listed in the response payload.
 2589        /// </remarks>
 2590        /// <param name='projectId'>
 2591        /// The project id.
 2592        /// </param>
 2593        /// <param name='batch'>
 2594        /// The batch of image files to add. Limited to 64 images and 20 tags per
 2595        /// batch.
 2596        /// </param>
 2597        /// <param name='customHeaders'>
 2598        /// Headers that will be added to request.
 2599        /// </param>
 2600        /// <param name='cancellationToken'>
 2601        /// The cancellation token.
 2602        /// </param>
 2603        /// <exception cref="CustomVisionErrorException">
 2604        /// Thrown when the operation returned an invalid status code
 2605        /// </exception>
 2606        /// <exception cref="SerializationException">
 2607        /// Thrown when unable to deserialize the response
 2608        /// </exception>
 2609        /// <exception cref="ValidationException">
 2610        /// Thrown when a required parameter is null
 2611        /// </exception>
 2612        /// <exception cref="System.ArgumentNullException">
 2613        /// Thrown when a required parameter is null
 2614        /// </exception>
 2615        /// <return>
 2616        /// A response object containing the response body and response headers.
 2617        /// </return>
 2618        public async Task<HttpOperationResponse<ImageCreateSummary>> CreateImagesFromFilesWithHttpMessagesAsync(System.G
 2619        {
 82620            if (Endpoint == null)
 2621            {
 02622                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 2623            }
 82624            if (batch == null)
 2625            {
 02626                throw new ValidationException(ValidationRules.CannotBeNull, "batch");
 2627            }
 2628            // Tracing
 82629            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 82630            string _invocationId = null;
 82631            if (_shouldTrace)
 2632            {
 02633                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02634                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02635                tracingParameters.Add("projectId", projectId);
 02636                tracingParameters.Add("batch", batch);
 02637                tracingParameters.Add("cancellationToken", cancellationToken);
 02638                ServiceClientTracing.Enter(_invocationId, this, "CreateImagesFromFiles", tracingParameters);
 2639            }
 2640            // Construct URL
 82641            var _baseUrl = BaseUri;
 82642            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/files";
 82643            _url = _url.Replace("{Endpoint}", Endpoint);
 82644            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 2645            // Create HTTP transport objects
 82646            var _httpRequest = new HttpRequestMessage();
 82647            HttpResponseMessage _httpResponse = null;
 82648            _httpRequest.Method = new HttpMethod("POST");
 82649            _httpRequest.RequestUri = new System.Uri(_url);
 2650            // Set Headers
 2651
 2652
 82653            if (customHeaders != null)
 2654            {
 02655                foreach(var _header in customHeaders)
 2656                {
 02657                    if (_httpRequest.Headers.Contains(_header.Key))
 2658                    {
 02659                        _httpRequest.Headers.Remove(_header.Key);
 2660                    }
 02661                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2662                }
 2663            }
 2664
 2665            // Serialize Request
 82666            string _requestContent = null;
 82667            if(batch != null)
 2668            {
 82669                _requestContent = SafeJsonConvert.SerializeObject(batch, SerializationSettings);
 82670                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 82671                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 2672            }
 2673            // Set Credentials
 82674            if (Credentials != null)
 2675            {
 82676                cancellationToken.ThrowIfCancellationRequested();
 82677                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2678            }
 2679            // Send Request
 82680            if (_shouldTrace)
 2681            {
 02682                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2683            }
 82684            cancellationToken.ThrowIfCancellationRequested();
 82685            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 82686            if (_shouldTrace)
 2687            {
 02688                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2689            }
 82690            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 82691            cancellationToken.ThrowIfCancellationRequested();
 82692            string _responseContent = null;
 82693            if ((int)_statusCode != 200 && (int)_statusCode != 207)
 2694            {
 02695                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 2696                try
 2697                {
 02698                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02699                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 02700                    if (_errorBody != null)
 2701                    {
 02702                        ex.Body = _errorBody;
 2703                    }
 02704                }
 02705                catch (JsonException)
 2706                {
 2707                    // Ignore the exception
 02708                }
 02709                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02710                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02711                if (_shouldTrace)
 2712                {
 02713                    ServiceClientTracing.Error(_invocationId, ex);
 2714                }
 02715                _httpRequest.Dispose();
 02716                if (_httpResponse != null)
 2717                {
 02718                    _httpResponse.Dispose();
 2719                }
 02720                throw ex;
 2721            }
 2722            // Create Result
 82723            var _result = new HttpOperationResponse<ImageCreateSummary>();
 82724            _result.Request = _httpRequest;
 82725            _result.Response = _httpResponse;
 2726            // Deserialize Response
 82727            if ((int)_statusCode == 200)
 2728            {
 82729                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2730                try
 2731                {
 82732                    _result.Body = SafeJsonConvert.DeserializeObject<ImageCreateSummary>(_responseContent, Deserializati
 82733                }
 02734                catch (JsonException ex)
 2735                {
 02736                    _httpRequest.Dispose();
 02737                    if (_httpResponse != null)
 2738                    {
 02739                        _httpResponse.Dispose();
 2740                    }
 02741                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2742                }
 2743            }
 2744            // Deserialize Response
 82745            if ((int)_statusCode == 207)
 2746            {
 02747                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2748                try
 2749                {
 02750                    _result.Body = SafeJsonConvert.DeserializeObject<ImageCreateSummary>(_responseContent, Deserializati
 02751                }
 02752                catch (JsonException ex)
 2753                {
 02754                    _httpRequest.Dispose();
 02755                    if (_httpResponse != null)
 2756                    {
 02757                        _httpResponse.Dispose();
 2758                    }
 02759                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2760                }
 2761            }
 82762            if (_shouldTrace)
 2763            {
 02764                ServiceClientTracing.Exit(_invocationId, _result);
 2765            }
 82766            return _result;
 82767        }
 2768
 2769        /// <summary>
 2770        /// Get images by id for a given project iteration.
 2771        /// </summary>
 2772        /// <remarks>
 2773        /// This API will return a set of Images for the specified tags and optionally
 2774        /// iteration. If no iteration is specified the
 2775        /// current workspace is used.
 2776        /// </remarks>
 2777        /// <param name='projectId'>
 2778        /// The project id.
 2779        /// </param>
 2780        /// <param name='imageIds'>
 2781        /// The list of image ids to retrieve. Limited to 256.
 2782        /// </param>
 2783        /// <param name='iterationId'>
 2784        /// The iteration id. Defaults to workspace.
 2785        /// </param>
 2786        /// <param name='customHeaders'>
 2787        /// Headers that will be added to request.
 2788        /// </param>
 2789        /// <param name='cancellationToken'>
 2790        /// The cancellation token.
 2791        /// </param>
 2792        /// <exception cref="CustomVisionErrorException">
 2793        /// Thrown when the operation returned an invalid status code
 2794        /// </exception>
 2795        /// <exception cref="SerializationException">
 2796        /// Thrown when unable to deserialize the response
 2797        /// </exception>
 2798        /// <exception cref="ValidationException">
 2799        /// Thrown when a required parameter is null
 2800        /// </exception>
 2801        /// <exception cref="System.ArgumentNullException">
 2802        /// Thrown when a required parameter is null
 2803        /// </exception>
 2804        /// <return>
 2805        /// A response object containing the response body and response headers.
 2806        /// </return>
 2807        public async Task<HttpOperationResponse<IList<Image>>> GetImagesByIdsWithHttpMessagesAsync(System.Guid projectId
 2808        {
 62809            if (Endpoint == null)
 2810            {
 02811                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 2812            }
 62813            if (imageIds != null)
 2814            {
 62815                if (imageIds.Count > 256)
 2816                {
 02817                    throw new ValidationException(ValidationRules.MaxItems, "imageIds", 256);
 2818                }
 62819                if (imageIds.Count < 0)
 2820                {
 02821                    throw new ValidationException(ValidationRules.MinItems, "imageIds", 0);
 2822                }
 2823            }
 2824            // Tracing
 62825            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 62826            string _invocationId = null;
 62827            if (_shouldTrace)
 2828            {
 02829                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 02830                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 02831                tracingParameters.Add("projectId", projectId);
 02832                tracingParameters.Add("imageIds", imageIds);
 02833                tracingParameters.Add("iterationId", iterationId);
 02834                tracingParameters.Add("cancellationToken", cancellationToken);
 02835                ServiceClientTracing.Enter(_invocationId, this, "GetImagesByIds", tracingParameters);
 2836            }
 2837            // Construct URL
 62838            var _baseUrl = BaseUri;
 62839            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/id";
 62840            _url = _url.Replace("{Endpoint}", Endpoint);
 62841            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 62842            List<string> _queryParameters = new List<string>();
 62843            if (imageIds != null)
 2844            {
 62845                _queryParameters.Add(string.Format("imageIds={0}", System.Uri.EscapeDataString(string.Join(",", imageIds
 2846            }
 62847            if (iterationId != null)
 2848            {
 02849                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 2850            }
 62851            if (_queryParameters.Count > 0)
 2852            {
 62853                _url += "?" + string.Join("&", _queryParameters);
 2854            }
 2855            // Create HTTP transport objects
 62856            var _httpRequest = new HttpRequestMessage();
 62857            HttpResponseMessage _httpResponse = null;
 62858            _httpRequest.Method = new HttpMethod("GET");
 62859            _httpRequest.RequestUri = new System.Uri(_url);
 2860            // Set Headers
 2861
 2862
 62863            if (customHeaders != null)
 2864            {
 02865                foreach(var _header in customHeaders)
 2866                {
 02867                    if (_httpRequest.Headers.Contains(_header.Key))
 2868                    {
 02869                        _httpRequest.Headers.Remove(_header.Key);
 2870                    }
 02871                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 2872                }
 2873            }
 2874
 2875            // Serialize Request
 62876            string _requestContent = null;
 2877            // Set Credentials
 62878            if (Credentials != null)
 2879            {
 62880                cancellationToken.ThrowIfCancellationRequested();
 62881                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2882            }
 2883            // Send Request
 62884            if (_shouldTrace)
 2885            {
 02886                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 2887            }
 62888            cancellationToken.ThrowIfCancellationRequested();
 62889            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 62890            if (_shouldTrace)
 2891            {
 02892                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 2893            }
 62894            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 62895            cancellationToken.ThrowIfCancellationRequested();
 62896            string _responseContent = null;
 62897            if ((int)_statusCode != 200)
 2898            {
 02899                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 2900                try
 2901                {
 02902                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 02903                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 02904                    if (_errorBody != null)
 2905                    {
 02906                        ex.Body = _errorBody;
 2907                    }
 02908                }
 02909                catch (JsonException)
 2910                {
 2911                    // Ignore the exception
 02912                }
 02913                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 02914                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 02915                if (_shouldTrace)
 2916                {
 02917                    ServiceClientTracing.Error(_invocationId, ex);
 2918                }
 02919                _httpRequest.Dispose();
 02920                if (_httpResponse != null)
 2921                {
 02922                    _httpResponse.Dispose();
 2923                }
 02924                throw ex;
 2925            }
 2926            // Create Result
 62927            var _result = new HttpOperationResponse<IList<Image>>();
 62928            _result.Request = _httpRequest;
 62929            _result.Response = _httpResponse;
 2930            // Deserialize Response
 62931            if ((int)_statusCode == 200)
 2932            {
 62933                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 2934                try
 2935                {
 62936                    _result.Body = SafeJsonConvert.DeserializeObject<IList<Image>>(_responseContent, DeserializationSett
 62937                }
 02938                catch (JsonException ex)
 2939                {
 02940                    _httpRequest.Dispose();
 02941                    if (_httpResponse != null)
 2942                    {
 02943                        _httpResponse.Dispose();
 2944                    }
 02945                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 2946                }
 2947            }
 62948            if (_shouldTrace)
 2949            {
 02950                ServiceClientTracing.Exit(_invocationId, _result);
 2951            }
 62952            return _result;
 62953        }
 2954
 2955        /// <summary>
 2956        /// Update metadata of images.
 2957        /// </summary>
 2958        /// <remarks>
 2959        /// This API accepts a batch of image Ids, and metadata, to update images.
 2960        /// There is a limit of 64 images.
 2961        /// </remarks>
 2962        /// <param name='projectId'>
 2963        /// The project id.
 2964        /// </param>
 2965        /// <param name='imageIds'>
 2966        /// The list of image ids to update. Limited to 64.
 2967        /// </param>
 2968        /// <param name='metadata'>
 2969        /// The metadata to be updated to the specified images. Limited to 50 key-value
 2970        /// pairs per image. The length of key is limited to 256. The length of value
 2971        /// is limited to 512.
 2972        /// </param>
 2973        /// <param name='customHeaders'>
 2974        /// Headers that will be added to request.
 2975        /// </param>
 2976        /// <param name='cancellationToken'>
 2977        /// The cancellation token.
 2978        /// </param>
 2979        /// <exception cref="CustomVisionErrorException">
 2980        /// Thrown when the operation returned an invalid status code
 2981        /// </exception>
 2982        /// <exception cref="SerializationException">
 2983        /// Thrown when unable to deserialize the response
 2984        /// </exception>
 2985        /// <exception cref="ValidationException">
 2986        /// Thrown when a required parameter is null
 2987        /// </exception>
 2988        /// <exception cref="System.ArgumentNullException">
 2989        /// Thrown when a required parameter is null
 2990        /// </exception>
 2991        /// <return>
 2992        /// A response object containing the response body and response headers.
 2993        /// </return>
 2994        public async Task<HttpOperationResponse<ImageMetadataUpdateSummary>> UpdateImageMetadataWithHttpMessagesAsync(Sy
 2995        {
 22996            if (Endpoint == null)
 2997            {
 02998                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 2999            }
 23000            if (imageIds == null)
 3001            {
 03002                throw new ValidationException(ValidationRules.CannotBeNull, "imageIds");
 3003            }
 23004            if (imageIds != null)
 3005            {
 23006                if (imageIds.Count > 256)
 3007                {
 03008                    throw new ValidationException(ValidationRules.MaxItems, "imageIds", 256);
 3009                }
 23010                if (imageIds.Count < 0)
 3011                {
 03012                    throw new ValidationException(ValidationRules.MinItems, "imageIds", 0);
 3013                }
 3014            }
 23015            if (metadata == null)
 3016            {
 03017                throw new ValidationException(ValidationRules.CannotBeNull, "metadata");
 3018            }
 3019            // Tracing
 23020            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 23021            string _invocationId = null;
 23022            if (_shouldTrace)
 3023            {
 03024                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03025                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03026                tracingParameters.Add("projectId", projectId);
 03027                tracingParameters.Add("imageIds", imageIds);
 03028                tracingParameters.Add("metadata", metadata);
 03029                tracingParameters.Add("cancellationToken", cancellationToken);
 03030                ServiceClientTracing.Enter(_invocationId, this, "UpdateImageMetadata", tracingParameters);
 3031            }
 3032            // Construct URL
 23033            var _baseUrl = BaseUri;
 23034            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/metadata";
 23035            _url = _url.Replace("{Endpoint}", Endpoint);
 23036            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 23037            List<string> _queryParameters = new List<string>();
 23038            if (imageIds != null)
 3039            {
 23040                _queryParameters.Add(string.Format("imageIds={0}", System.Uri.EscapeDataString(string.Join(",", imageIds
 3041            }
 23042            if (_queryParameters.Count > 0)
 3043            {
 23044                _url += "?" + string.Join("&", _queryParameters);
 3045            }
 3046            // Create HTTP transport objects
 23047            var _httpRequest = new HttpRequestMessage();
 23048            HttpResponseMessage _httpResponse = null;
 23049            _httpRequest.Method = new HttpMethod("POST");
 23050            _httpRequest.RequestUri = new System.Uri(_url);
 3051            // Set Headers
 3052
 3053
 23054            if (customHeaders != null)
 3055            {
 03056                foreach(var _header in customHeaders)
 3057                {
 03058                    if (_httpRequest.Headers.Contains(_header.Key))
 3059                    {
 03060                        _httpRequest.Headers.Remove(_header.Key);
 3061                    }
 03062                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3063                }
 3064            }
 3065
 3066            // Serialize Request
 23067            string _requestContent = null;
 23068            if(metadata != null)
 3069            {
 23070                _requestContent = SafeJsonConvert.SerializeObject(metadata, SerializationSettings);
 23071                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 23072                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 3073            }
 3074            // Set Credentials
 23075            if (Credentials != null)
 3076            {
 23077                cancellationToken.ThrowIfCancellationRequested();
 23078                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3079            }
 3080            // Send Request
 23081            if (_shouldTrace)
 3082            {
 03083                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3084            }
 23085            cancellationToken.ThrowIfCancellationRequested();
 23086            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 23087            if (_shouldTrace)
 3088            {
 03089                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3090            }
 23091            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 23092            cancellationToken.ThrowIfCancellationRequested();
 23093            string _responseContent = null;
 23094            if ((int)_statusCode != 200 && (int)_statusCode != 207)
 3095            {
 03096                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 3097                try
 3098                {
 03099                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03100                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 03101                    if (_errorBody != null)
 3102                    {
 03103                        ex.Body = _errorBody;
 3104                    }
 03105                }
 03106                catch (JsonException)
 3107                {
 3108                    // Ignore the exception
 03109                }
 03110                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03111                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03112                if (_shouldTrace)
 3113                {
 03114                    ServiceClientTracing.Error(_invocationId, ex);
 3115                }
 03116                _httpRequest.Dispose();
 03117                if (_httpResponse != null)
 3118                {
 03119                    _httpResponse.Dispose();
 3120                }
 03121                throw ex;
 3122            }
 3123            // Create Result
 23124            var _result = new HttpOperationResponse<ImageMetadataUpdateSummary>();
 23125            _result.Request = _httpRequest;
 23126            _result.Response = _httpResponse;
 3127            // Deserialize Response
 23128            if ((int)_statusCode == 200)
 3129            {
 23130                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3131                try
 3132                {
 23133                    _result.Body = SafeJsonConvert.DeserializeObject<ImageMetadataUpdateSummary>(_responseContent, Deser
 23134                }
 03135                catch (JsonException ex)
 3136                {
 03137                    _httpRequest.Dispose();
 03138                    if (_httpResponse != null)
 3139                    {
 03140                        _httpResponse.Dispose();
 3141                    }
 03142                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3143                }
 3144            }
 3145            // Deserialize Response
 23146            if ((int)_statusCode == 207)
 3147            {
 03148                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3149                try
 3150                {
 03151                    _result.Body = SafeJsonConvert.DeserializeObject<ImageMetadataUpdateSummary>(_responseContent, Deser
 03152                }
 03153                catch (JsonException ex)
 3154                {
 03155                    _httpRequest.Dispose();
 03156                    if (_httpResponse != null)
 3157                    {
 03158                        _httpResponse.Dispose();
 3159                    }
 03160                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3161                }
 3162            }
 23163            if (_shouldTrace)
 3164            {
 03165                ServiceClientTracing.Exit(_invocationId, _result);
 3166            }
 23167            return _result;
 23168        }
 3169
 3170        /// <summary>
 3171        /// Add the specified predicted images to the set of training images.
 3172        /// </summary>
 3173        /// <remarks>
 3174        /// This API creates a batch of images from predicted images specified. There
 3175        /// is a limit of 64 images and 20 tags.
 3176        /// If all images are successful created, 200(OK) status code will be returned.
 3177        /// Otherwise, 207 (Multi-Status) status code will be returned and detail
 3178        /// status for each image will be listed in the response payload.
 3179        /// </remarks>
 3180        /// <param name='projectId'>
 3181        /// The project id.
 3182        /// </param>
 3183        /// <param name='batch'>
 3184        /// Image, tag ids, and metadata. Limited to 64 images and 20 tags per batch.
 3185        /// </param>
 3186        /// <param name='customHeaders'>
 3187        /// Headers that will be added to request.
 3188        /// </param>
 3189        /// <param name='cancellationToken'>
 3190        /// The cancellation token.
 3191        /// </param>
 3192        /// <exception cref="CustomVisionErrorException">
 3193        /// Thrown when the operation returned an invalid status code
 3194        /// </exception>
 3195        /// <exception cref="SerializationException">
 3196        /// Thrown when unable to deserialize the response
 3197        /// </exception>
 3198        /// <exception cref="ValidationException">
 3199        /// Thrown when a required parameter is null
 3200        /// </exception>
 3201        /// <exception cref="System.ArgumentNullException">
 3202        /// Thrown when a required parameter is null
 3203        /// </exception>
 3204        /// <return>
 3205        /// A response object containing the response body and response headers.
 3206        /// </return>
 3207        public async Task<HttpOperationResponse<ImageCreateSummary>> CreateImagesFromPredictionsWithHttpMessagesAsync(Sy
 3208        {
 23209            if (Endpoint == null)
 3210            {
 03211                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 3212            }
 23213            if (batch == null)
 3214            {
 03215                throw new ValidationException(ValidationRules.CannotBeNull, "batch");
 3216            }
 3217            // Tracing
 23218            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 23219            string _invocationId = null;
 23220            if (_shouldTrace)
 3221            {
 03222                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03223                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03224                tracingParameters.Add("projectId", projectId);
 03225                tracingParameters.Add("batch", batch);
 03226                tracingParameters.Add("cancellationToken", cancellationToken);
 03227                ServiceClientTracing.Enter(_invocationId, this, "CreateImagesFromPredictions", tracingParameters);
 3228            }
 3229            // Construct URL
 23230            var _baseUrl = BaseUri;
 23231            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/predictions";
 23232            _url = _url.Replace("{Endpoint}", Endpoint);
 23233            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 3234            // Create HTTP transport objects
 23235            var _httpRequest = new HttpRequestMessage();
 23236            HttpResponseMessage _httpResponse = null;
 23237            _httpRequest.Method = new HttpMethod("POST");
 23238            _httpRequest.RequestUri = new System.Uri(_url);
 3239            // Set Headers
 3240
 3241
 23242            if (customHeaders != null)
 3243            {
 03244                foreach(var _header in customHeaders)
 3245                {
 03246                    if (_httpRequest.Headers.Contains(_header.Key))
 3247                    {
 03248                        _httpRequest.Headers.Remove(_header.Key);
 3249                    }
 03250                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3251                }
 3252            }
 3253
 3254            // Serialize Request
 23255            string _requestContent = null;
 23256            if(batch != null)
 3257            {
 23258                _requestContent = SafeJsonConvert.SerializeObject(batch, SerializationSettings);
 23259                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 23260                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 3261            }
 3262            // Set Credentials
 23263            if (Credentials != null)
 3264            {
 23265                cancellationToken.ThrowIfCancellationRequested();
 23266                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3267            }
 3268            // Send Request
 23269            if (_shouldTrace)
 3270            {
 03271                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3272            }
 23273            cancellationToken.ThrowIfCancellationRequested();
 23274            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 23275            if (_shouldTrace)
 3276            {
 03277                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3278            }
 23279            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 23280            cancellationToken.ThrowIfCancellationRequested();
 23281            string _responseContent = null;
 23282            if ((int)_statusCode != 200 && (int)_statusCode != 207)
 3283            {
 03284                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 3285                try
 3286                {
 03287                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03288                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 03289                    if (_errorBody != null)
 3290                    {
 03291                        ex.Body = _errorBody;
 3292                    }
 03293                }
 03294                catch (JsonException)
 3295                {
 3296                    // Ignore the exception
 03297                }
 03298                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03299                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03300                if (_shouldTrace)
 3301                {
 03302                    ServiceClientTracing.Error(_invocationId, ex);
 3303                }
 03304                _httpRequest.Dispose();
 03305                if (_httpResponse != null)
 3306                {
 03307                    _httpResponse.Dispose();
 3308                }
 03309                throw ex;
 3310            }
 3311            // Create Result
 23312            var _result = new HttpOperationResponse<ImageCreateSummary>();
 23313            _result.Request = _httpRequest;
 23314            _result.Response = _httpResponse;
 3315            // Deserialize Response
 23316            if ((int)_statusCode == 200)
 3317            {
 23318                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3319                try
 3320                {
 23321                    _result.Body = SafeJsonConvert.DeserializeObject<ImageCreateSummary>(_responseContent, Deserializati
 23322                }
 03323                catch (JsonException ex)
 3324                {
 03325                    _httpRequest.Dispose();
 03326                    if (_httpResponse != null)
 3327                    {
 03328                        _httpResponse.Dispose();
 3329                    }
 03330                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3331                }
 3332            }
 3333            // Deserialize Response
 23334            if ((int)_statusCode == 207)
 3335            {
 03336                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3337                try
 3338                {
 03339                    _result.Body = SafeJsonConvert.DeserializeObject<ImageCreateSummary>(_responseContent, Deserializati
 03340                }
 03341                catch (JsonException ex)
 3342                {
 03343                    _httpRequest.Dispose();
 03344                    if (_httpResponse != null)
 3345                    {
 03346                        _httpResponse.Dispose();
 3347                    }
 03348                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3349                }
 3350            }
 23351            if (_shouldTrace)
 3352            {
 03353                ServiceClientTracing.Exit(_invocationId, _result);
 3354            }
 23355            return _result;
 23356        }
 3357
 3358        /// <summary>
 3359        /// Create a set of image regions.
 3360        /// </summary>
 3361        /// <remarks>
 3362        /// This API accepts a batch of image regions, and optionally tags, to update
 3363        /// existing images with region information.
 3364        /// There is a limit of 64 entries in the batch.
 3365        /// If all regions are successful created, 200(OK) status code will be
 3366        /// returned.
 3367        /// Otherwise, 207 (Multi-Status) status code will be returned and detail
 3368        /// status for each region will be listed in the response payload.
 3369        /// </remarks>
 3370        /// <param name='projectId'>
 3371        /// The project id.
 3372        /// </param>
 3373        /// <param name='batch'>
 3374        /// Batch of image regions which include a tag and bounding box. Limited to 64.
 3375        /// </param>
 3376        /// <param name='customHeaders'>
 3377        /// Headers that will be added to request.
 3378        /// </param>
 3379        /// <param name='cancellationToken'>
 3380        /// The cancellation token.
 3381        /// </param>
 3382        /// <exception cref="CustomVisionErrorException">
 3383        /// Thrown when the operation returned an invalid status code
 3384        /// </exception>
 3385        /// <exception cref="SerializationException">
 3386        /// Thrown when unable to deserialize the response
 3387        /// </exception>
 3388        /// <exception cref="ValidationException">
 3389        /// Thrown when a required parameter is null
 3390        /// </exception>
 3391        /// <exception cref="System.ArgumentNullException">
 3392        /// Thrown when a required parameter is null
 3393        /// </exception>
 3394        /// <return>
 3395        /// A response object containing the response body and response headers.
 3396        /// </return>
 3397        public async Task<HttpOperationResponse<ImageRegionCreateSummary>> CreateImageRegionsWithHttpMessagesAsync(Syste
 3398        {
 23399            if (Endpoint == null)
 3400            {
 03401                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 3402            }
 23403            if (batch == null)
 3404            {
 03405                throw new ValidationException(ValidationRules.CannotBeNull, "batch");
 3406            }
 3407            // Tracing
 23408            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 23409            string _invocationId = null;
 23410            if (_shouldTrace)
 3411            {
 03412                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03413                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03414                tracingParameters.Add("projectId", projectId);
 03415                tracingParameters.Add("batch", batch);
 03416                tracingParameters.Add("cancellationToken", cancellationToken);
 03417                ServiceClientTracing.Enter(_invocationId, this, "CreateImageRegions", tracingParameters);
 3418            }
 3419            // Construct URL
 23420            var _baseUrl = BaseUri;
 23421            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/regions";
 23422            _url = _url.Replace("{Endpoint}", Endpoint);
 23423            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 3424            // Create HTTP transport objects
 23425            var _httpRequest = new HttpRequestMessage();
 23426            HttpResponseMessage _httpResponse = null;
 23427            _httpRequest.Method = new HttpMethod("POST");
 23428            _httpRequest.RequestUri = new System.Uri(_url);
 3429            // Set Headers
 3430
 3431
 23432            if (customHeaders != null)
 3433            {
 03434                foreach(var _header in customHeaders)
 3435                {
 03436                    if (_httpRequest.Headers.Contains(_header.Key))
 3437                    {
 03438                        _httpRequest.Headers.Remove(_header.Key);
 3439                    }
 03440                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3441                }
 3442            }
 3443
 3444            // Serialize Request
 23445            string _requestContent = null;
 23446            if(batch != null)
 3447            {
 23448                _requestContent = SafeJsonConvert.SerializeObject(batch, SerializationSettings);
 23449                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 23450                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 3451            }
 3452            // Set Credentials
 23453            if (Credentials != null)
 3454            {
 23455                cancellationToken.ThrowIfCancellationRequested();
 23456                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3457            }
 3458            // Send Request
 23459            if (_shouldTrace)
 3460            {
 03461                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3462            }
 23463            cancellationToken.ThrowIfCancellationRequested();
 23464            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 23465            if (_shouldTrace)
 3466            {
 03467                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3468            }
 23469            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 23470            cancellationToken.ThrowIfCancellationRequested();
 23471            string _responseContent = null;
 23472            if ((int)_statusCode != 200 && (int)_statusCode != 207)
 3473            {
 03474                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 3475                try
 3476                {
 03477                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03478                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 03479                    if (_errorBody != null)
 3480                    {
 03481                        ex.Body = _errorBody;
 3482                    }
 03483                }
 03484                catch (JsonException)
 3485                {
 3486                    // Ignore the exception
 03487                }
 03488                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03489                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03490                if (_shouldTrace)
 3491                {
 03492                    ServiceClientTracing.Error(_invocationId, ex);
 3493                }
 03494                _httpRequest.Dispose();
 03495                if (_httpResponse != null)
 3496                {
 03497                    _httpResponse.Dispose();
 3498                }
 03499                throw ex;
 3500            }
 3501            // Create Result
 23502            var _result = new HttpOperationResponse<ImageRegionCreateSummary>();
 23503            _result.Request = _httpRequest;
 23504            _result.Response = _httpResponse;
 3505            // Deserialize Response
 23506            if ((int)_statusCode == 200)
 3507            {
 23508                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3509                try
 3510                {
 23511                    _result.Body = SafeJsonConvert.DeserializeObject<ImageRegionCreateSummary>(_responseContent, Deseria
 23512                }
 03513                catch (JsonException ex)
 3514                {
 03515                    _httpRequest.Dispose();
 03516                    if (_httpResponse != null)
 3517                    {
 03518                        _httpResponse.Dispose();
 3519                    }
 03520                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3521                }
 3522            }
 3523            // Deserialize Response
 23524            if ((int)_statusCode == 207)
 3525            {
 03526                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3527                try
 3528                {
 03529                    _result.Body = SafeJsonConvert.DeserializeObject<ImageRegionCreateSummary>(_responseContent, Deseria
 03530                }
 03531                catch (JsonException ex)
 3532                {
 03533                    _httpRequest.Dispose();
 03534                    if (_httpResponse != null)
 3535                    {
 03536                        _httpResponse.Dispose();
 3537                    }
 03538                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3539                }
 3540            }
 23541            if (_shouldTrace)
 3542            {
 03543                ServiceClientTracing.Exit(_invocationId, _result);
 3544            }
 23545            return _result;
 23546        }
 3547
 3548        /// <summary>
 3549        /// Delete a set of image regions.
 3550        /// </summary>
 3551        /// <param name='projectId'>
 3552        /// The project id.
 3553        /// </param>
 3554        /// <param name='regionIds'>
 3555        /// Regions to delete. Limited to 64.
 3556        /// </param>
 3557        /// <param name='customHeaders'>
 3558        /// Headers that will be added to request.
 3559        /// </param>
 3560        /// <param name='cancellationToken'>
 3561        /// The cancellation token.
 3562        /// </param>
 3563        /// <exception cref="CustomVisionErrorException">
 3564        /// Thrown when the operation returned an invalid status code
 3565        /// </exception>
 3566        /// <exception cref="ValidationException">
 3567        /// Thrown when a required parameter is null
 3568        /// </exception>
 3569        /// <exception cref="System.ArgumentNullException">
 3570        /// Thrown when a required parameter is null
 3571        /// </exception>
 3572        /// <return>
 3573        /// A response object containing the response body and response headers.
 3574        /// </return>
 3575        public async Task<HttpOperationResponse> DeleteImageRegionsWithHttpMessagesAsync(System.Guid projectId, IList<Sy
 3576        {
 23577            if (Endpoint == null)
 3578            {
 03579                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 3580            }
 23581            if (regionIds == null)
 3582            {
 03583                throw new ValidationException(ValidationRules.CannotBeNull, "regionIds");
 3584            }
 23585            if (regionIds != null)
 3586            {
 23587                if (regionIds.Count > 64)
 3588                {
 03589                    throw new ValidationException(ValidationRules.MaxItems, "regionIds", 64);
 3590                }
 23591                if (regionIds.Count < 0)
 3592                {
 03593                    throw new ValidationException(ValidationRules.MinItems, "regionIds", 0);
 3594                }
 3595            }
 3596            // Tracing
 23597            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 23598            string _invocationId = null;
 23599            if (_shouldTrace)
 3600            {
 03601                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03602                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03603                tracingParameters.Add("projectId", projectId);
 03604                tracingParameters.Add("regionIds", regionIds);
 03605                tracingParameters.Add("cancellationToken", cancellationToken);
 03606                ServiceClientTracing.Enter(_invocationId, this, "DeleteImageRegions", tracingParameters);
 3607            }
 3608            // Construct URL
 23609            var _baseUrl = BaseUri;
 23610            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/regions";
 23611            _url = _url.Replace("{Endpoint}", Endpoint);
 23612            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 23613            List<string> _queryParameters = new List<string>();
 23614            if (regionIds != null)
 3615            {
 23616                _queryParameters.Add(string.Format("regionIds={0}", System.Uri.EscapeDataString(string.Join(",", regionI
 3617            }
 23618            if (_queryParameters.Count > 0)
 3619            {
 23620                _url += "?" + string.Join("&", _queryParameters);
 3621            }
 3622            // Create HTTP transport objects
 23623            var _httpRequest = new HttpRequestMessage();
 23624            HttpResponseMessage _httpResponse = null;
 23625            _httpRequest.Method = new HttpMethod("DELETE");
 23626            _httpRequest.RequestUri = new System.Uri(_url);
 3627            // Set Headers
 3628
 3629
 23630            if (customHeaders != null)
 3631            {
 03632                foreach(var _header in customHeaders)
 3633                {
 03634                    if (_httpRequest.Headers.Contains(_header.Key))
 3635                    {
 03636                        _httpRequest.Headers.Remove(_header.Key);
 3637                    }
 03638                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3639                }
 3640            }
 3641
 3642            // Serialize Request
 23643            string _requestContent = null;
 3644            // Set Credentials
 23645            if (Credentials != null)
 3646            {
 23647                cancellationToken.ThrowIfCancellationRequested();
 23648                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3649            }
 3650            // Send Request
 23651            if (_shouldTrace)
 3652            {
 03653                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3654            }
 23655            cancellationToken.ThrowIfCancellationRequested();
 23656            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 23657            if (_shouldTrace)
 3658            {
 03659                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3660            }
 23661            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 23662            cancellationToken.ThrowIfCancellationRequested();
 23663            string _responseContent = null;
 23664            if ((int)_statusCode != 204)
 3665            {
 03666                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 3667                try
 3668                {
 03669                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03670                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 03671                    if (_errorBody != null)
 3672                    {
 03673                        ex.Body = _errorBody;
 3674                    }
 03675                }
 03676                catch (JsonException)
 3677                {
 3678                    // Ignore the exception
 03679                }
 03680                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03681                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03682                if (_shouldTrace)
 3683                {
 03684                    ServiceClientTracing.Error(_invocationId, ex);
 3685                }
 03686                _httpRequest.Dispose();
 03687                if (_httpResponse != null)
 3688                {
 03689                    _httpResponse.Dispose();
 3690                }
 03691                throw ex;
 3692            }
 3693            // Create Result
 23694            var _result = new HttpOperationResponse();
 23695            _result.Request = _httpRequest;
 23696            _result.Response = _httpResponse;
 23697            if (_shouldTrace)
 3698            {
 03699                ServiceClientTracing.Exit(_invocationId, _result);
 3700            }
 23701            return _result;
 23702        }
 3703
 3704        /// <summary>
 3705        /// Get untagged images whose suggested tags match given tags. Returns empty
 3706        /// array if no images are found.
 3707        /// </summary>
 3708        /// <remarks>
 3709        /// This API will fetch untagged images filtered by suggested tags Ids. It
 3710        /// returns an empty array if no images are found.
 3711        /// </remarks>
 3712        /// <param name='projectId'>
 3713        /// The project id.
 3714        /// </param>
 3715        /// <param name='iterationId'>
 3716        /// IterationId to use for the suggested tags and regions.
 3717        /// </param>
 3718        /// <param name='query'>
 3719        /// Contains properties we need to query suggested images.
 3720        /// </param>
 3721        /// <param name='customHeaders'>
 3722        /// Headers that will be added to request.
 3723        /// </param>
 3724        /// <param name='cancellationToken'>
 3725        /// The cancellation token.
 3726        /// </param>
 3727        /// <exception cref="CustomVisionErrorException">
 3728        /// Thrown when the operation returned an invalid status code
 3729        /// </exception>
 3730        /// <exception cref="SerializationException">
 3731        /// Thrown when unable to deserialize the response
 3732        /// </exception>
 3733        /// <exception cref="ValidationException">
 3734        /// Thrown when a required parameter is null
 3735        /// </exception>
 3736        /// <exception cref="System.ArgumentNullException">
 3737        /// Thrown when a required parameter is null
 3738        /// </exception>
 3739        /// <return>
 3740        /// A response object containing the response body and response headers.
 3741        /// </return>
 3742        public async Task<HttpOperationResponse<SuggestedTagAndRegionQuery>> QuerySuggestedImagesWithHttpMessagesAsync(S
 3743        {
 23744            if (Endpoint == null)
 3745            {
 03746                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 3747            }
 23748            if (query == null)
 3749            {
 03750                throw new ValidationException(ValidationRules.CannotBeNull, "query");
 3751            }
 3752            // Tracing
 23753            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 23754            string _invocationId = null;
 23755            if (_shouldTrace)
 3756            {
 03757                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03758                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03759                tracingParameters.Add("projectId", projectId);
 03760                tracingParameters.Add("iterationId", iterationId);
 03761                tracingParameters.Add("query", query);
 03762                tracingParameters.Add("cancellationToken", cancellationToken);
 03763                ServiceClientTracing.Enter(_invocationId, this, "QuerySuggestedImages", tracingParameters);
 3764            }
 3765            // Construct URL
 23766            var _baseUrl = BaseUri;
 23767            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/suggested";
 23768            _url = _url.Replace("{Endpoint}", Endpoint);
 23769            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 23770            List<string> _queryParameters = new List<string>();
 23771            _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 23772            if (_queryParameters.Count > 0)
 3773            {
 23774                _url += "?" + string.Join("&", _queryParameters);
 3775            }
 3776            // Create HTTP transport objects
 23777            var _httpRequest = new HttpRequestMessage();
 23778            HttpResponseMessage _httpResponse = null;
 23779            _httpRequest.Method = new HttpMethod("POST");
 23780            _httpRequest.RequestUri = new System.Uri(_url);
 3781            // Set Headers
 3782
 3783
 23784            if (customHeaders != null)
 3785            {
 03786                foreach(var _header in customHeaders)
 3787                {
 03788                    if (_httpRequest.Headers.Contains(_header.Key))
 3789                    {
 03790                        _httpRequest.Headers.Remove(_header.Key);
 3791                    }
 03792                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3793                }
 3794            }
 3795
 3796            // Serialize Request
 23797            string _requestContent = null;
 23798            if(query != null)
 3799            {
 23800                _requestContent = SafeJsonConvert.SerializeObject(query, SerializationSettings);
 23801                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 23802                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 3803            }
 3804            // Set Credentials
 23805            if (Credentials != null)
 3806            {
 23807                cancellationToken.ThrowIfCancellationRequested();
 23808                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3809            }
 3810            // Send Request
 23811            if (_shouldTrace)
 3812            {
 03813                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3814            }
 23815            cancellationToken.ThrowIfCancellationRequested();
 23816            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 23817            if (_shouldTrace)
 3818            {
 03819                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3820            }
 23821            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 23822            cancellationToken.ThrowIfCancellationRequested();
 23823            string _responseContent = null;
 23824            if ((int)_statusCode != 200)
 3825            {
 03826                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 3827                try
 3828                {
 03829                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 03830                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 03831                    if (_errorBody != null)
 3832                    {
 03833                        ex.Body = _errorBody;
 3834                    }
 03835                }
 03836                catch (JsonException)
 3837                {
 3838                    // Ignore the exception
 03839                }
 03840                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 03841                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 03842                if (_shouldTrace)
 3843                {
 03844                    ServiceClientTracing.Error(_invocationId, ex);
 3845                }
 03846                _httpRequest.Dispose();
 03847                if (_httpResponse != null)
 3848                {
 03849                    _httpResponse.Dispose();
 3850                }
 03851                throw ex;
 3852            }
 3853            // Create Result
 23854            var _result = new HttpOperationResponse<SuggestedTagAndRegionQuery>();
 23855            _result.Request = _httpRequest;
 23856            _result.Response = _httpResponse;
 3857            // Deserialize Response
 23858            if ((int)_statusCode == 200)
 3859            {
 23860                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 3861                try
 3862                {
 23863                    _result.Body = SafeJsonConvert.DeserializeObject<SuggestedTagAndRegionQuery>(_responseContent, Deser
 23864                }
 03865                catch (JsonException ex)
 3866                {
 03867                    _httpRequest.Dispose();
 03868                    if (_httpResponse != null)
 3869                    {
 03870                        _httpResponse.Dispose();
 3871                    }
 03872                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 3873                }
 3874            }
 23875            if (_shouldTrace)
 3876            {
 03877                ServiceClientTracing.Exit(_invocationId, _result);
 3878            }
 23879            return _result;
 23880        }
 3881
 3882        /// <summary>
 3883        /// Get count of images whose suggested tags match given tags and their
 3884        /// probabilities are greater than or equal to the given threshold. Returns
 3885        /// count as 0 if none found.
 3886        /// </summary>
 3887        /// <remarks>
 3888        /// This API takes in tagIds to get count of untagged images per suggested tags
 3889        /// for a given threshold.
 3890        /// </remarks>
 3891        /// <param name='projectId'>
 3892        /// The project id.
 3893        /// </param>
 3894        /// <param name='iterationId'>
 3895        /// IterationId to use for the suggested tags and regions.
 3896        /// </param>
 3897        /// <param name='query'>
 3898        /// Model that contains tagIds, threshold and projectType to query by.
 3899        /// </param>
 3900        /// <param name='customHeaders'>
 3901        /// Headers that will be added to request.
 3902        /// </param>
 3903        /// <param name='cancellationToken'>
 3904        /// The cancellation token.
 3905        /// </param>
 3906        /// <exception cref="CustomVisionErrorException">
 3907        /// Thrown when the operation returned an invalid status code
 3908        /// </exception>
 3909        /// <exception cref="SerializationException">
 3910        /// Thrown when unable to deserialize the response
 3911        /// </exception>
 3912        /// <exception cref="ValidationException">
 3913        /// Thrown when a required parameter is null
 3914        /// </exception>
 3915        /// <exception cref="System.ArgumentNullException">
 3916        /// Thrown when a required parameter is null
 3917        /// </exception>
 3918        /// <return>
 3919        /// A response object containing the response body and response headers.
 3920        /// </return>
 3921        public async Task<HttpOperationResponse<IDictionary<string, int?>>> QuerySuggestedImageCountWithHttpMessagesAsyn
 3922        {
 63923            if (Endpoint == null)
 3924            {
 03925                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 3926            }
 63927            if (query == null)
 3928            {
 03929                throw new ValidationException(ValidationRules.CannotBeNull, "query");
 3930            }
 3931            // Tracing
 63932            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 63933            string _invocationId = null;
 63934            if (_shouldTrace)
 3935            {
 03936                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 03937                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 03938                tracingParameters.Add("projectId", projectId);
 03939                tracingParameters.Add("iterationId", iterationId);
 03940                tracingParameters.Add("query", query);
 03941                tracingParameters.Add("cancellationToken", cancellationToken);
 03942                ServiceClientTracing.Enter(_invocationId, this, "QuerySuggestedImageCount", tracingParameters);
 3943            }
 3944            // Construct URL
 63945            var _baseUrl = BaseUri;
 63946            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/suggested/count";
 63947            _url = _url.Replace("{Endpoint}", Endpoint);
 63948            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 63949            List<string> _queryParameters = new List<string>();
 63950            _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 63951            if (_queryParameters.Count > 0)
 3952            {
 63953                _url += "?" + string.Join("&", _queryParameters);
 3954            }
 3955            // Create HTTP transport objects
 63956            var _httpRequest = new HttpRequestMessage();
 63957            HttpResponseMessage _httpResponse = null;
 63958            _httpRequest.Method = new HttpMethod("POST");
 63959            _httpRequest.RequestUri = new System.Uri(_url);
 3960            // Set Headers
 3961
 3962
 63963            if (customHeaders != null)
 3964            {
 03965                foreach(var _header in customHeaders)
 3966                {
 03967                    if (_httpRequest.Headers.Contains(_header.Key))
 3968                    {
 03969                        _httpRequest.Headers.Remove(_header.Key);
 3970                    }
 03971                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 3972                }
 3973            }
 3974
 3975            // Serialize Request
 63976            string _requestContent = null;
 63977            if(query != null)
 3978            {
 63979                _requestContent = SafeJsonConvert.SerializeObject(query, SerializationSettings);
 63980                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 63981                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 3982            }
 3983            // Set Credentials
 63984            if (Credentials != null)
 3985            {
 63986                cancellationToken.ThrowIfCancellationRequested();
 63987                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 3988            }
 3989            // Send Request
 63990            if (_shouldTrace)
 3991            {
 03992                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 3993            }
 63994            cancellationToken.ThrowIfCancellationRequested();
 63995            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 63996            if (_shouldTrace)
 3997            {
 03998                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 3999            }
 64000            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 64001            cancellationToken.ThrowIfCancellationRequested();
 64002            string _responseContent = null;
 64003            if ((int)_statusCode != 200)
 4004            {
 04005                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 4006                try
 4007                {
 04008                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04009                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 04010                    if (_errorBody != null)
 4011                    {
 04012                        ex.Body = _errorBody;
 4013                    }
 04014                }
 04015                catch (JsonException)
 4016                {
 4017                    // Ignore the exception
 04018                }
 04019                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04020                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04021                if (_shouldTrace)
 4022                {
 04023                    ServiceClientTracing.Error(_invocationId, ex);
 4024                }
 04025                _httpRequest.Dispose();
 04026                if (_httpResponse != null)
 4027                {
 04028                    _httpResponse.Dispose();
 4029                }
 04030                throw ex;
 4031            }
 4032            // Create Result
 64033            var _result = new HttpOperationResponse<IDictionary<string, int?>>();
 64034            _result.Request = _httpRequest;
 64035            _result.Response = _httpResponse;
 4036            // Deserialize Response
 64037            if ((int)_statusCode == 200)
 4038            {
 64039                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4040                try
 4041                {
 64042                    _result.Body = SafeJsonConvert.DeserializeObject<IDictionary<string, int?>>(_responseContent, Deseri
 64043                }
 04044                catch (JsonException ex)
 4045                {
 04046                    _httpRequest.Dispose();
 04047                    if (_httpResponse != null)
 4048                    {
 04049                        _httpResponse.Dispose();
 4050                    }
 04051                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4052                }
 4053            }
 64054            if (_shouldTrace)
 4055            {
 04056                ServiceClientTracing.Exit(_invocationId, _result);
 4057            }
 64058            return _result;
 64059        }
 4060
 4061        /// <summary>
 4062        /// Get tagged images for a given project iteration.
 4063        /// </summary>
 4064        /// <remarks>
 4065        /// This API supports batching and range selection. By default it will only
 4066        /// return first 50 images matching images.
 4067        /// Use the {take} and {skip} parameters to control how many images to return
 4068        /// in a given batch.
 4069        /// The filtering is on an and/or relationship. For example, if the provided
 4070        /// tag ids are for the "Dog" and
 4071        /// "Cat" tags, then only images tagged with Dog and/or Cat will be returned
 4072        /// </remarks>
 4073        /// <param name='projectId'>
 4074        /// The project id.
 4075        /// </param>
 4076        /// <param name='iterationId'>
 4077        /// The iteration id. Defaults to workspace.
 4078        /// </param>
 4079        /// <param name='tagIds'>
 4080        /// A list of tags ids to filter the images. Defaults to all tagged images when
 4081        /// null. Limited to 20.
 4082        /// </param>
 4083        /// <param name='orderBy'>
 4084        /// The ordering. Defaults to newest. Possible values include: 'Newest',
 4085        /// 'Oldest'
 4086        /// </param>
 4087        /// <param name='take'>
 4088        /// Maximum number of images to return. Defaults to 50, limited to 256.
 4089        /// </param>
 4090        /// <param name='skip'>
 4091        /// Number of images to skip before beginning the image batch. Defaults to 0.
 4092        /// </param>
 4093        /// <param name='customHeaders'>
 4094        /// Headers that will be added to request.
 4095        /// </param>
 4096        /// <param name='cancellationToken'>
 4097        /// The cancellation token.
 4098        /// </param>
 4099        /// <exception cref="CustomVisionErrorException">
 4100        /// Thrown when the operation returned an invalid status code
 4101        /// </exception>
 4102        /// <exception cref="SerializationException">
 4103        /// Thrown when unable to deserialize the response
 4104        /// </exception>
 4105        /// <exception cref="ValidationException">
 4106        /// Thrown when a required parameter is null
 4107        /// </exception>
 4108        /// <exception cref="System.ArgumentNullException">
 4109        /// Thrown when a required parameter is null
 4110        /// </exception>
 4111        /// <return>
 4112        /// A response object containing the response body and response headers.
 4113        /// </return>
 4114        public async Task<HttpOperationResponse<IList<Image>>> GetTaggedImagesWithHttpMessagesAsync(System.Guid projectI
 4115        {
 124116            if (Endpoint == null)
 4117            {
 04118                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 4119            }
 124120            if (tagIds != null)
 4121            {
 44122                if (tagIds.Count > 20)
 4123                {
 04124                    throw new ValidationException(ValidationRules.MaxItems, "tagIds", 20);
 4125                }
 44126                if (tagIds.Count < 0)
 4127                {
 04128                    throw new ValidationException(ValidationRules.MinItems, "tagIds", 0);
 4129                }
 4130            }
 124131            if (take > 256)
 4132            {
 04133                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 256);
 4134            }
 124135            if (take < 0)
 4136            {
 04137                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 4138            }
 4139            // Tracing
 124140            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 124141            string _invocationId = null;
 124142            if (_shouldTrace)
 4143            {
 04144                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04145                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04146                tracingParameters.Add("projectId", projectId);
 04147                tracingParameters.Add("iterationId", iterationId);
 04148                tracingParameters.Add("tagIds", tagIds);
 04149                tracingParameters.Add("orderBy", orderBy);
 04150                tracingParameters.Add("take", take);
 04151                tracingParameters.Add("skip", skip);
 04152                tracingParameters.Add("cancellationToken", cancellationToken);
 04153                ServiceClientTracing.Enter(_invocationId, this, "GetTaggedImages", tracingParameters);
 4154            }
 4155            // Construct URL
 124156            var _baseUrl = BaseUri;
 124157            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/tagged";
 124158            _url = _url.Replace("{Endpoint}", Endpoint);
 124159            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 124160            List<string> _queryParameters = new List<string>();
 124161            if (iterationId != null)
 4162            {
 04163                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 4164            }
 124165            if (tagIds != null)
 4166            {
 44167                _queryParameters.Add(string.Format("tagIds={0}", System.Uri.EscapeDataString(string.Join(",", tagIds))))
 4168            }
 124169            if (orderBy != null)
 4170            {
 04171                _queryParameters.Add(string.Format("orderBy={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 4172            }
 124173            if (take != null)
 4174            {
 124175                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObje
 4176            }
 124177            if (skip != null)
 4178            {
 124179                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObje
 4180            }
 124181            if (_queryParameters.Count > 0)
 4182            {
 124183                _url += "?" + string.Join("&", _queryParameters);
 4184            }
 4185            // Create HTTP transport objects
 124186            var _httpRequest = new HttpRequestMessage();
 124187            HttpResponseMessage _httpResponse = null;
 124188            _httpRequest.Method = new HttpMethod("GET");
 124189            _httpRequest.RequestUri = new System.Uri(_url);
 4190            // Set Headers
 4191
 4192
 124193            if (customHeaders != null)
 4194            {
 04195                foreach(var _header in customHeaders)
 4196                {
 04197                    if (_httpRequest.Headers.Contains(_header.Key))
 4198                    {
 04199                        _httpRequest.Headers.Remove(_header.Key);
 4200                    }
 04201                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4202                }
 4203            }
 4204
 4205            // Serialize Request
 124206            string _requestContent = null;
 4207            // Set Credentials
 124208            if (Credentials != null)
 4209            {
 124210                cancellationToken.ThrowIfCancellationRequested();
 124211                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4212            }
 4213            // Send Request
 124214            if (_shouldTrace)
 4215            {
 04216                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4217            }
 124218            cancellationToken.ThrowIfCancellationRequested();
 124219            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 124220            if (_shouldTrace)
 4221            {
 04222                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4223            }
 124224            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 124225            cancellationToken.ThrowIfCancellationRequested();
 124226            string _responseContent = null;
 124227            if ((int)_statusCode != 200)
 4228            {
 04229                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 4230                try
 4231                {
 04232                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04233                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 04234                    if (_errorBody != null)
 4235                    {
 04236                        ex.Body = _errorBody;
 4237                    }
 04238                }
 04239                catch (JsonException)
 4240                {
 4241                    // Ignore the exception
 04242                }
 04243                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04244                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04245                if (_shouldTrace)
 4246                {
 04247                    ServiceClientTracing.Error(_invocationId, ex);
 4248                }
 04249                _httpRequest.Dispose();
 04250                if (_httpResponse != null)
 4251                {
 04252                    _httpResponse.Dispose();
 4253                }
 04254                throw ex;
 4255            }
 4256            // Create Result
 124257            var _result = new HttpOperationResponse<IList<Image>>();
 124258            _result.Request = _httpRequest;
 124259            _result.Response = _httpResponse;
 4260            // Deserialize Response
 124261            if ((int)_statusCode == 200)
 4262            {
 124263                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4264                try
 4265                {
 124266                    _result.Body = SafeJsonConvert.DeserializeObject<IList<Image>>(_responseContent, DeserializationSett
 124267                }
 04268                catch (JsonException ex)
 4269                {
 04270                    _httpRequest.Dispose();
 04271                    if (_httpResponse != null)
 4272                    {
 04273                        _httpResponse.Dispose();
 4274                    }
 04275                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4276                }
 4277            }
 124278            if (_shouldTrace)
 4279            {
 04280                ServiceClientTracing.Exit(_invocationId, _result);
 4281            }
 124282            return _result;
 124283        }
 4284
 4285        /// <summary>
 4286        /// Gets the number of images tagged with the provided {tagIds}.
 4287        /// </summary>
 4288        /// <remarks>
 4289        /// The filtering is on an and/or relationship. For example, if the provided
 4290        /// tag ids are for the "Dog" and
 4291        /// "Cat" tags, then only images tagged with Dog and/or Cat will be returned
 4292        /// </remarks>
 4293        /// <param name='projectId'>
 4294        /// The project id.
 4295        /// </param>
 4296        /// <param name='iterationId'>
 4297        /// The iteration id. Defaults to workspace.
 4298        /// </param>
 4299        /// <param name='tagIds'>
 4300        /// A list of tags ids to filter the images to count. Defaults to all tags when
 4301        /// null.
 4302        /// </param>
 4303        /// <param name='customHeaders'>
 4304        /// Headers that will be added to request.
 4305        /// </param>
 4306        /// <param name='cancellationToken'>
 4307        /// The cancellation token.
 4308        /// </param>
 4309        /// <exception cref="CustomVisionErrorException">
 4310        /// Thrown when the operation returned an invalid status code
 4311        /// </exception>
 4312        /// <exception cref="SerializationException">
 4313        /// Thrown when unable to deserialize the response
 4314        /// </exception>
 4315        /// <exception cref="ValidationException">
 4316        /// Thrown when a required parameter is null
 4317        /// </exception>
 4318        /// <exception cref="System.ArgumentNullException">
 4319        /// Thrown when a required parameter is null
 4320        /// </exception>
 4321        /// <return>
 4322        /// A response object containing the response body and response headers.
 4323        /// </return>
 4324        public async Task<HttpOperationResponse<int?>> GetTaggedImageCountWithHttpMessagesAsync(System.Guid projectId, S
 4325        {
 64326            if (Endpoint == null)
 4327            {
 04328                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 4329            }
 4330            // Tracing
 64331            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 64332            string _invocationId = null;
 64333            if (_shouldTrace)
 4334            {
 04335                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04336                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04337                tracingParameters.Add("projectId", projectId);
 04338                tracingParameters.Add("iterationId", iterationId);
 04339                tracingParameters.Add("tagIds", tagIds);
 04340                tracingParameters.Add("cancellationToken", cancellationToken);
 04341                ServiceClientTracing.Enter(_invocationId, this, "GetTaggedImageCount", tracingParameters);
 4342            }
 4343            // Construct URL
 64344            var _baseUrl = BaseUri;
 64345            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/tagged/count";
 64346            _url = _url.Replace("{Endpoint}", Endpoint);
 64347            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 64348            List<string> _queryParameters = new List<string>();
 64349            if (iterationId != null)
 4350            {
 04351                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 4352            }
 64353            if (tagIds != null)
 4354            {
 04355                _queryParameters.Add(string.Format("tagIds={0}", System.Uri.EscapeDataString(string.Join(",", tagIds))))
 4356            }
 64357            if (_queryParameters.Count > 0)
 4358            {
 04359                _url += "?" + string.Join("&", _queryParameters);
 4360            }
 4361            // Create HTTP transport objects
 64362            var _httpRequest = new HttpRequestMessage();
 64363            HttpResponseMessage _httpResponse = null;
 64364            _httpRequest.Method = new HttpMethod("GET");
 64365            _httpRequest.RequestUri = new System.Uri(_url);
 4366            // Set Headers
 4367
 4368
 64369            if (customHeaders != null)
 4370            {
 04371                foreach(var _header in customHeaders)
 4372                {
 04373                    if (_httpRequest.Headers.Contains(_header.Key))
 4374                    {
 04375                        _httpRequest.Headers.Remove(_header.Key);
 4376                    }
 04377                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4378                }
 4379            }
 4380
 4381            // Serialize Request
 64382            string _requestContent = null;
 4383            // Set Credentials
 64384            if (Credentials != null)
 4385            {
 64386                cancellationToken.ThrowIfCancellationRequested();
 64387                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4388            }
 4389            // Send Request
 64390            if (_shouldTrace)
 4391            {
 04392                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4393            }
 64394            cancellationToken.ThrowIfCancellationRequested();
 64395            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 64396            if (_shouldTrace)
 4397            {
 04398                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4399            }
 64400            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 64401            cancellationToken.ThrowIfCancellationRequested();
 64402            string _responseContent = null;
 64403            if ((int)_statusCode != 200)
 4404            {
 04405                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 4406                try
 4407                {
 04408                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04409                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 04410                    if (_errorBody != null)
 4411                    {
 04412                        ex.Body = _errorBody;
 4413                    }
 04414                }
 04415                catch (JsonException)
 4416                {
 4417                    // Ignore the exception
 04418                }
 04419                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04420                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04421                if (_shouldTrace)
 4422                {
 04423                    ServiceClientTracing.Error(_invocationId, ex);
 4424                }
 04425                _httpRequest.Dispose();
 04426                if (_httpResponse != null)
 4427                {
 04428                    _httpResponse.Dispose();
 4429                }
 04430                throw ex;
 4431            }
 4432            // Create Result
 64433            var _result = new HttpOperationResponse<int?>();
 64434            _result.Request = _httpRequest;
 64435            _result.Response = _httpResponse;
 4436            // Deserialize Response
 64437            if ((int)_statusCode == 200)
 4438            {
 64439                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4440                try
 4441                {
 64442                    _result.Body = SafeJsonConvert.DeserializeObject<int?>(_responseContent, DeserializationSettings);
 64443                }
 04444                catch (JsonException ex)
 4445                {
 04446                    _httpRequest.Dispose();
 04447                    if (_httpResponse != null)
 4448                    {
 04449                        _httpResponse.Dispose();
 4450                    }
 04451                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4452                }
 4453            }
 64454            if (_shouldTrace)
 4455            {
 04456                ServiceClientTracing.Exit(_invocationId, _result);
 4457            }
 64458            return _result;
 64459        }
 4460
 4461        /// <summary>
 4462        /// Associate a set of images with a set of tags.
 4463        /// </summary>
 4464        /// <param name='projectId'>
 4465        /// The project id.
 4466        /// </param>
 4467        /// <param name='batch'>
 4468        /// Batch of image tags. Limited to 128 tags per batch.
 4469        /// </param>
 4470        /// <param name='customHeaders'>
 4471        /// Headers that will be added to request.
 4472        /// </param>
 4473        /// <param name='cancellationToken'>
 4474        /// The cancellation token.
 4475        /// </param>
 4476        /// <exception cref="CustomVisionErrorException">
 4477        /// Thrown when the operation returned an invalid status code
 4478        /// </exception>
 4479        /// <exception cref="SerializationException">
 4480        /// Thrown when unable to deserialize the response
 4481        /// </exception>
 4482        /// <exception cref="ValidationException">
 4483        /// Thrown when a required parameter is null
 4484        /// </exception>
 4485        /// <exception cref="System.ArgumentNullException">
 4486        /// Thrown when a required parameter is null
 4487        /// </exception>
 4488        /// <return>
 4489        /// A response object containing the response body and response headers.
 4490        /// </return>
 4491        public async Task<HttpOperationResponse<ImageTagCreateSummary>> CreateImageTagsWithHttpMessagesAsync(System.Guid
 4492        {
 24493            if (Endpoint == null)
 4494            {
 04495                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 4496            }
 24497            if (batch == null)
 4498            {
 04499                throw new ValidationException(ValidationRules.CannotBeNull, "batch");
 4500            }
 4501            // Tracing
 24502            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 24503            string _invocationId = null;
 24504            if (_shouldTrace)
 4505            {
 04506                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04507                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04508                tracingParameters.Add("projectId", projectId);
 04509                tracingParameters.Add("batch", batch);
 04510                tracingParameters.Add("cancellationToken", cancellationToken);
 04511                ServiceClientTracing.Enter(_invocationId, this, "CreateImageTags", tracingParameters);
 4512            }
 4513            // Construct URL
 24514            var _baseUrl = BaseUri;
 24515            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/tags";
 24516            _url = _url.Replace("{Endpoint}", Endpoint);
 24517            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 4518            // Create HTTP transport objects
 24519            var _httpRequest = new HttpRequestMessage();
 24520            HttpResponseMessage _httpResponse = null;
 24521            _httpRequest.Method = new HttpMethod("POST");
 24522            _httpRequest.RequestUri = new System.Uri(_url);
 4523            // Set Headers
 4524
 4525
 24526            if (customHeaders != null)
 4527            {
 04528                foreach(var _header in customHeaders)
 4529                {
 04530                    if (_httpRequest.Headers.Contains(_header.Key))
 4531                    {
 04532                        _httpRequest.Headers.Remove(_header.Key);
 4533                    }
 04534                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4535                }
 4536            }
 4537
 4538            // Serialize Request
 24539            string _requestContent = null;
 24540            if(batch != null)
 4541            {
 24542                _requestContent = SafeJsonConvert.SerializeObject(batch, SerializationSettings);
 24543                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 24544                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 4545            }
 4546            // Set Credentials
 24547            if (Credentials != null)
 4548            {
 24549                cancellationToken.ThrowIfCancellationRequested();
 24550                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4551            }
 4552            // Send Request
 24553            if (_shouldTrace)
 4554            {
 04555                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4556            }
 24557            cancellationToken.ThrowIfCancellationRequested();
 24558            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 24559            if (_shouldTrace)
 4560            {
 04561                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4562            }
 24563            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 24564            cancellationToken.ThrowIfCancellationRequested();
 24565            string _responseContent = null;
 24566            if ((int)_statusCode != 200)
 4567            {
 04568                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 4569                try
 4570                {
 04571                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04572                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 04573                    if (_errorBody != null)
 4574                    {
 04575                        ex.Body = _errorBody;
 4576                    }
 04577                }
 04578                catch (JsonException)
 4579                {
 4580                    // Ignore the exception
 04581                }
 04582                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04583                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04584                if (_shouldTrace)
 4585                {
 04586                    ServiceClientTracing.Error(_invocationId, ex);
 4587                }
 04588                _httpRequest.Dispose();
 04589                if (_httpResponse != null)
 4590                {
 04591                    _httpResponse.Dispose();
 4592                }
 04593                throw ex;
 4594            }
 4595            // Create Result
 24596            var _result = new HttpOperationResponse<ImageTagCreateSummary>();
 24597            _result.Request = _httpRequest;
 24598            _result.Response = _httpResponse;
 4599            // Deserialize Response
 24600            if ((int)_statusCode == 200)
 4601            {
 24602                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4603                try
 4604                {
 24605                    _result.Body = SafeJsonConvert.DeserializeObject<ImageTagCreateSummary>(_responseContent, Deserializ
 24606                }
 04607                catch (JsonException ex)
 4608                {
 04609                    _httpRequest.Dispose();
 04610                    if (_httpResponse != null)
 4611                    {
 04612                        _httpResponse.Dispose();
 4613                    }
 04614                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4615                }
 4616            }
 24617            if (_shouldTrace)
 4618            {
 04619                ServiceClientTracing.Exit(_invocationId, _result);
 4620            }
 24621            return _result;
 24622        }
 4623
 4624        /// <summary>
 4625        /// Remove a set of tags from a set of images.
 4626        /// </summary>
 4627        /// <param name='projectId'>
 4628        /// The project id.
 4629        /// </param>
 4630        /// <param name='imageIds'>
 4631        /// Image ids. Limited to 64 images.
 4632        /// </param>
 4633        /// <param name='tagIds'>
 4634        /// Tags to be deleted from the specified images. Limited to 20 tags.
 4635        /// </param>
 4636        /// <param name='customHeaders'>
 4637        /// Headers that will be added to request.
 4638        /// </param>
 4639        /// <param name='cancellationToken'>
 4640        /// The cancellation token.
 4641        /// </param>
 4642        /// <exception cref="CustomVisionErrorException">
 4643        /// Thrown when the operation returned an invalid status code
 4644        /// </exception>
 4645        /// <exception cref="ValidationException">
 4646        /// Thrown when a required parameter is null
 4647        /// </exception>
 4648        /// <exception cref="System.ArgumentNullException">
 4649        /// Thrown when a required parameter is null
 4650        /// </exception>
 4651        /// <return>
 4652        /// A response object containing the response body and response headers.
 4653        /// </return>
 4654        public async Task<HttpOperationResponse> DeleteImageTagsWithHttpMessagesAsync(System.Guid projectId, IList<Syste
 4655        {
 24656            if (Endpoint == null)
 4657            {
 04658                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 4659            }
 24660            if (imageIds == null)
 4661            {
 04662                throw new ValidationException(ValidationRules.CannotBeNull, "imageIds");
 4663            }
 24664            if (imageIds != null)
 4665            {
 24666                if (imageIds.Count > 64)
 4667                {
 04668                    throw new ValidationException(ValidationRules.MaxItems, "imageIds", 64);
 4669                }
 24670                if (imageIds.Count < 0)
 4671                {
 04672                    throw new ValidationException(ValidationRules.MinItems, "imageIds", 0);
 4673                }
 4674            }
 24675            if (tagIds == null)
 4676            {
 04677                throw new ValidationException(ValidationRules.CannotBeNull, "tagIds");
 4678            }
 24679            if (tagIds != null)
 4680            {
 24681                if (tagIds.Count > 20)
 4682                {
 04683                    throw new ValidationException(ValidationRules.MaxItems, "tagIds", 20);
 4684                }
 24685                if (tagIds.Count < 0)
 4686                {
 04687                    throw new ValidationException(ValidationRules.MinItems, "tagIds", 0);
 4688                }
 4689            }
 4690            // Tracing
 24691            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 24692            string _invocationId = null;
 24693            if (_shouldTrace)
 4694            {
 04695                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04696                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04697                tracingParameters.Add("projectId", projectId);
 04698                tracingParameters.Add("imageIds", imageIds);
 04699                tracingParameters.Add("tagIds", tagIds);
 04700                tracingParameters.Add("cancellationToken", cancellationToken);
 04701                ServiceClientTracing.Enter(_invocationId, this, "DeleteImageTags", tracingParameters);
 4702            }
 4703            // Construct URL
 24704            var _baseUrl = BaseUri;
 24705            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/tags";
 24706            _url = _url.Replace("{Endpoint}", Endpoint);
 24707            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 24708            List<string> _queryParameters = new List<string>();
 24709            if (imageIds != null)
 4710            {
 24711                _queryParameters.Add(string.Format("imageIds={0}", System.Uri.EscapeDataString(string.Join(",", imageIds
 4712            }
 24713            if (tagIds != null)
 4714            {
 24715                _queryParameters.Add(string.Format("tagIds={0}", System.Uri.EscapeDataString(string.Join(",", tagIds))))
 4716            }
 24717            if (_queryParameters.Count > 0)
 4718            {
 24719                _url += "?" + string.Join("&", _queryParameters);
 4720            }
 4721            // Create HTTP transport objects
 24722            var _httpRequest = new HttpRequestMessage();
 24723            HttpResponseMessage _httpResponse = null;
 24724            _httpRequest.Method = new HttpMethod("DELETE");
 24725            _httpRequest.RequestUri = new System.Uri(_url);
 4726            // Set Headers
 4727
 4728
 24729            if (customHeaders != null)
 4730            {
 04731                foreach(var _header in customHeaders)
 4732                {
 04733                    if (_httpRequest.Headers.Contains(_header.Key))
 4734                    {
 04735                        _httpRequest.Headers.Remove(_header.Key);
 4736                    }
 04737                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4738                }
 4739            }
 4740
 4741            // Serialize Request
 24742            string _requestContent = null;
 4743            // Set Credentials
 24744            if (Credentials != null)
 4745            {
 24746                cancellationToken.ThrowIfCancellationRequested();
 24747                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4748            }
 4749            // Send Request
 24750            if (_shouldTrace)
 4751            {
 04752                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4753            }
 24754            cancellationToken.ThrowIfCancellationRequested();
 24755            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 24756            if (_shouldTrace)
 4757            {
 04758                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4759            }
 24760            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 24761            cancellationToken.ThrowIfCancellationRequested();
 24762            string _responseContent = null;
 24763            if ((int)_statusCode != 204)
 4764            {
 04765                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 4766                try
 4767                {
 04768                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04769                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 04770                    if (_errorBody != null)
 4771                    {
 04772                        ex.Body = _errorBody;
 4773                    }
 04774                }
 04775                catch (JsonException)
 4776                {
 4777                    // Ignore the exception
 04778                }
 04779                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04780                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04781                if (_shouldTrace)
 4782                {
 04783                    ServiceClientTracing.Error(_invocationId, ex);
 4784                }
 04785                _httpRequest.Dispose();
 04786                if (_httpResponse != null)
 4787                {
 04788                    _httpResponse.Dispose();
 4789                }
 04790                throw ex;
 4791            }
 4792            // Create Result
 24793            var _result = new HttpOperationResponse();
 24794            _result.Request = _httpRequest;
 24795            _result.Response = _httpResponse;
 24796            if (_shouldTrace)
 4797            {
 04798                ServiceClientTracing.Exit(_invocationId, _result);
 4799            }
 24800            return _result;
 24801        }
 4802
 4803        /// <summary>
 4804        /// Get untagged images for a given project iteration.
 4805        /// </summary>
 4806        /// <remarks>
 4807        /// This API supports batching and range selection. By default it will only
 4808        /// return first 50 images matching images.
 4809        /// Use the {take} and {skip} parameters to control how many images to return
 4810        /// in a given batch.
 4811        /// </remarks>
 4812        /// <param name='projectId'>
 4813        /// The project id.
 4814        /// </param>
 4815        /// <param name='iterationId'>
 4816        /// The iteration id. Defaults to workspace.
 4817        /// </param>
 4818        /// <param name='orderBy'>
 4819        /// The ordering. Defaults to newest. Possible values include: 'Newest',
 4820        /// 'Oldest'
 4821        /// </param>
 4822        /// <param name='take'>
 4823        /// Maximum number of images to return. Defaults to 50, limited to 256.
 4824        /// </param>
 4825        /// <param name='skip'>
 4826        /// Number of images to skip before beginning the image batch. Defaults to 0.
 4827        /// </param>
 4828        /// <param name='customHeaders'>
 4829        /// Headers that will be added to request.
 4830        /// </param>
 4831        /// <param name='cancellationToken'>
 4832        /// The cancellation token.
 4833        /// </param>
 4834        /// <exception cref="CustomVisionErrorException">
 4835        /// Thrown when the operation returned an invalid status code
 4836        /// </exception>
 4837        /// <exception cref="SerializationException">
 4838        /// Thrown when unable to deserialize the response
 4839        /// </exception>
 4840        /// <exception cref="ValidationException">
 4841        /// Thrown when a required parameter is null
 4842        /// </exception>
 4843        /// <exception cref="System.ArgumentNullException">
 4844        /// Thrown when a required parameter is null
 4845        /// </exception>
 4846        /// <return>
 4847        /// A response object containing the response body and response headers.
 4848        /// </return>
 4849        public async Task<HttpOperationResponse<IList<Image>>> GetUntaggedImagesWithHttpMessagesAsync(System.Guid projec
 4850        {
 64851            if (Endpoint == null)
 4852            {
 04853                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 4854            }
 64855            if (take > 256)
 4856            {
 04857                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 256);
 4858            }
 64859            if (take < 0)
 4860            {
 04861                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 4862            }
 4863            // Tracing
 64864            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 64865            string _invocationId = null;
 64866            if (_shouldTrace)
 4867            {
 04868                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 04869                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 04870                tracingParameters.Add("projectId", projectId);
 04871                tracingParameters.Add("iterationId", iterationId);
 04872                tracingParameters.Add("orderBy", orderBy);
 04873                tracingParameters.Add("take", take);
 04874                tracingParameters.Add("skip", skip);
 04875                tracingParameters.Add("cancellationToken", cancellationToken);
 04876                ServiceClientTracing.Enter(_invocationId, this, "GetUntaggedImages", tracingParameters);
 4877            }
 4878            // Construct URL
 64879            var _baseUrl = BaseUri;
 64880            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/untagged";
 64881            _url = _url.Replace("{Endpoint}", Endpoint);
 64882            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 64883            List<string> _queryParameters = new List<string>();
 64884            if (iterationId != null)
 4885            {
 04886                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 4887            }
 64888            if (orderBy != null)
 4889            {
 04890                _queryParameters.Add(string.Format("orderBy={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 4891            }
 64892            if (take != null)
 4893            {
 64894                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObje
 4895            }
 64896            if (skip != null)
 4897            {
 64898                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObje
 4899            }
 64900            if (_queryParameters.Count > 0)
 4901            {
 64902                _url += "?" + string.Join("&", _queryParameters);
 4903            }
 4904            // Create HTTP transport objects
 64905            var _httpRequest = new HttpRequestMessage();
 64906            HttpResponseMessage _httpResponse = null;
 64907            _httpRequest.Method = new HttpMethod("GET");
 64908            _httpRequest.RequestUri = new System.Uri(_url);
 4909            // Set Headers
 4910
 4911
 64912            if (customHeaders != null)
 4913            {
 04914                foreach(var _header in customHeaders)
 4915                {
 04916                    if (_httpRequest.Headers.Contains(_header.Key))
 4917                    {
 04918                        _httpRequest.Headers.Remove(_header.Key);
 4919                    }
 04920                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 4921                }
 4922            }
 4923
 4924            // Serialize Request
 64925            string _requestContent = null;
 4926            // Set Credentials
 64927            if (Credentials != null)
 4928            {
 64929                cancellationToken.ThrowIfCancellationRequested();
 64930                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4931            }
 4932            // Send Request
 64933            if (_shouldTrace)
 4934            {
 04935                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 4936            }
 64937            cancellationToken.ThrowIfCancellationRequested();
 64938            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 64939            if (_shouldTrace)
 4940            {
 04941                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 4942            }
 64943            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 64944            cancellationToken.ThrowIfCancellationRequested();
 64945            string _responseContent = null;
 64946            if ((int)_statusCode != 200)
 4947            {
 04948                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 4949                try
 4950                {
 04951                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 04952                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 04953                    if (_errorBody != null)
 4954                    {
 04955                        ex.Body = _errorBody;
 4956                    }
 04957                }
 04958                catch (JsonException)
 4959                {
 4960                    // Ignore the exception
 04961                }
 04962                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 04963                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 04964                if (_shouldTrace)
 4965                {
 04966                    ServiceClientTracing.Error(_invocationId, ex);
 4967                }
 04968                _httpRequest.Dispose();
 04969                if (_httpResponse != null)
 4970                {
 04971                    _httpResponse.Dispose();
 4972                }
 04973                throw ex;
 4974            }
 4975            // Create Result
 64976            var _result = new HttpOperationResponse<IList<Image>>();
 64977            _result.Request = _httpRequest;
 64978            _result.Response = _httpResponse;
 4979            // Deserialize Response
 64980            if ((int)_statusCode == 200)
 4981            {
 64982                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4983                try
 4984                {
 64985                    _result.Body = SafeJsonConvert.DeserializeObject<IList<Image>>(_responseContent, DeserializationSett
 64986                }
 04987                catch (JsonException ex)
 4988                {
 04989                    _httpRequest.Dispose();
 04990                    if (_httpResponse != null)
 4991                    {
 04992                        _httpResponse.Dispose();
 4993                    }
 04994                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 4995                }
 4996            }
 64997            if (_shouldTrace)
 4998            {
 04999                ServiceClientTracing.Exit(_invocationId, _result);
 5000            }
 65001            return _result;
 65002        }
 5003
 5004        /// <summary>
 5005        /// Gets the number of untagged images.
 5006        /// </summary>
 5007        /// <remarks>
 5008        /// This API returns the images which have no tags for a given project and
 5009        /// optionally an iteration. If no iteration is specified the
 5010        /// current workspace is used.
 5011        /// </remarks>
 5012        /// <param name='projectId'>
 5013        /// The project id.
 5014        /// </param>
 5015        /// <param name='iterationId'>
 5016        /// The iteration id. Defaults to workspace.
 5017        /// </param>
 5018        /// <param name='customHeaders'>
 5019        /// Headers that will be added to request.
 5020        /// </param>
 5021        /// <param name='cancellationToken'>
 5022        /// The cancellation token.
 5023        /// </param>
 5024        /// <exception cref="CustomVisionErrorException">
 5025        /// Thrown when the operation returned an invalid status code
 5026        /// </exception>
 5027        /// <exception cref="SerializationException">
 5028        /// Thrown when unable to deserialize the response
 5029        /// </exception>
 5030        /// <exception cref="ValidationException">
 5031        /// Thrown when a required parameter is null
 5032        /// </exception>
 5033        /// <exception cref="System.ArgumentNullException">
 5034        /// Thrown when a required parameter is null
 5035        /// </exception>
 5036        /// <return>
 5037        /// A response object containing the response body and response headers.
 5038        /// </return>
 5039        public async Task<HttpOperationResponse<int?>> GetUntaggedImageCountWithHttpMessagesAsync(System.Guid projectId,
 5040        {
 25041            if (Endpoint == null)
 5042            {
 05043                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 5044            }
 5045            // Tracing
 25046            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 25047            string _invocationId = null;
 25048            if (_shouldTrace)
 5049            {
 05050                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05051                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05052                tracingParameters.Add("projectId", projectId);
 05053                tracingParameters.Add("iterationId", iterationId);
 05054                tracingParameters.Add("cancellationToken", cancellationToken);
 05055                ServiceClientTracing.Enter(_invocationId, this, "GetUntaggedImageCount", tracingParameters);
 5056            }
 5057            // Construct URL
 25058            var _baseUrl = BaseUri;
 25059            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/untagged/count";
 25060            _url = _url.Replace("{Endpoint}", Endpoint);
 25061            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 25062            List<string> _queryParameters = new List<string>();
 25063            if (iterationId != null)
 5064            {
 05065                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 5066            }
 25067            if (_queryParameters.Count > 0)
 5068            {
 05069                _url += "?" + string.Join("&", _queryParameters);
 5070            }
 5071            // Create HTTP transport objects
 25072            var _httpRequest = new HttpRequestMessage();
 25073            HttpResponseMessage _httpResponse = null;
 25074            _httpRequest.Method = new HttpMethod("GET");
 25075            _httpRequest.RequestUri = new System.Uri(_url);
 5076            // Set Headers
 5077
 5078
 25079            if (customHeaders != null)
 5080            {
 05081                foreach(var _header in customHeaders)
 5082                {
 05083                    if (_httpRequest.Headers.Contains(_header.Key))
 5084                    {
 05085                        _httpRequest.Headers.Remove(_header.Key);
 5086                    }
 05087                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5088                }
 5089            }
 5090
 5091            // Serialize Request
 25092            string _requestContent = null;
 5093            // Set Credentials
 25094            if (Credentials != null)
 5095            {
 25096                cancellationToken.ThrowIfCancellationRequested();
 25097                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5098            }
 5099            // Send Request
 25100            if (_shouldTrace)
 5101            {
 05102                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5103            }
 25104            cancellationToken.ThrowIfCancellationRequested();
 25105            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 25106            if (_shouldTrace)
 5107            {
 05108                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5109            }
 25110            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 25111            cancellationToken.ThrowIfCancellationRequested();
 25112            string _responseContent = null;
 25113            if ((int)_statusCode != 200)
 5114            {
 05115                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 5116                try
 5117                {
 05118                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05119                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 05120                    if (_errorBody != null)
 5121                    {
 05122                        ex.Body = _errorBody;
 5123                    }
 05124                }
 05125                catch (JsonException)
 5126                {
 5127                    // Ignore the exception
 05128                }
 05129                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05130                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05131                if (_shouldTrace)
 5132                {
 05133                    ServiceClientTracing.Error(_invocationId, ex);
 5134                }
 05135                _httpRequest.Dispose();
 05136                if (_httpResponse != null)
 5137                {
 05138                    _httpResponse.Dispose();
 5139                }
 05140                throw ex;
 5141            }
 5142            // Create Result
 25143            var _result = new HttpOperationResponse<int?>();
 25144            _result.Request = _httpRequest;
 25145            _result.Response = _httpResponse;
 5146            // Deserialize Response
 25147            if ((int)_statusCode == 200)
 5148            {
 25149                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5150                try
 5151                {
 25152                    _result.Body = SafeJsonConvert.DeserializeObject<int?>(_responseContent, DeserializationSettings);
 25153                }
 05154                catch (JsonException ex)
 5155                {
 05156                    _httpRequest.Dispose();
 05157                    if (_httpResponse != null)
 5158                    {
 05159                        _httpResponse.Dispose();
 5160                    }
 05161                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5162                }
 5163            }
 25164            if (_shouldTrace)
 5165            {
 05166                ServiceClientTracing.Exit(_invocationId, _result);
 5167            }
 25168            return _result;
 25169        }
 5170
 5171        /// <summary>
 5172        /// Add the provided images urls to the set of training images.
 5173        /// </summary>
 5174        /// <remarks>
 5175        /// This API accepts a batch of urls, and optionally tags, to create images.
 5176        /// There is a limit of 64 images and 20 tags.
 5177        /// If all images are successful created, 200(OK) status code will be returned.
 5178        /// Otherwise, 207 (Multi-Status) status code will be returned and detail
 5179        /// status for each image will be listed in the response payload.
 5180        /// </remarks>
 5181        /// <param name='projectId'>
 5182        /// The project id.
 5183        /// </param>
 5184        /// <param name='batch'>
 5185        /// Image urls, tag ids, and metadata. Limited to 64 images and 20 tags per
 5186        /// batch.
 5187        /// </param>
 5188        /// <param name='customHeaders'>
 5189        /// Headers that will be added to request.
 5190        /// </param>
 5191        /// <param name='cancellationToken'>
 5192        /// The cancellation token.
 5193        /// </param>
 5194        /// <exception cref="CustomVisionErrorException">
 5195        /// Thrown when the operation returned an invalid status code
 5196        /// </exception>
 5197        /// <exception cref="SerializationException">
 5198        /// Thrown when unable to deserialize the response
 5199        /// </exception>
 5200        /// <exception cref="ValidationException">
 5201        /// Thrown when a required parameter is null
 5202        /// </exception>
 5203        /// <exception cref="System.ArgumentNullException">
 5204        /// Thrown when a required parameter is null
 5205        /// </exception>
 5206        /// <return>
 5207        /// A response object containing the response body and response headers.
 5208        /// </return>
 5209        public async Task<HttpOperationResponse<ImageCreateSummary>> CreateImagesFromUrlsWithHttpMessagesAsync(System.Gu
 5210        {
 45211            if (Endpoint == null)
 5212            {
 05213                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 5214            }
 45215            if (batch == null)
 5216            {
 05217                throw new ValidationException(ValidationRules.CannotBeNull, "batch");
 5218            }
 5219            // Tracing
 45220            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 45221            string _invocationId = null;
 45222            if (_shouldTrace)
 5223            {
 05224                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05225                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05226                tracingParameters.Add("projectId", projectId);
 05227                tracingParameters.Add("batch", batch);
 05228                tracingParameters.Add("cancellationToken", cancellationToken);
 05229                ServiceClientTracing.Enter(_invocationId, this, "CreateImagesFromUrls", tracingParameters);
 5230            }
 5231            // Construct URL
 45232            var _baseUrl = BaseUri;
 45233            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/images/urls";
 45234            _url = _url.Replace("{Endpoint}", Endpoint);
 45235            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 5236            // Create HTTP transport objects
 45237            var _httpRequest = new HttpRequestMessage();
 45238            HttpResponseMessage _httpResponse = null;
 45239            _httpRequest.Method = new HttpMethod("POST");
 45240            _httpRequest.RequestUri = new System.Uri(_url);
 5241            // Set Headers
 5242
 5243
 45244            if (customHeaders != null)
 5245            {
 05246                foreach(var _header in customHeaders)
 5247                {
 05248                    if (_httpRequest.Headers.Contains(_header.Key))
 5249                    {
 05250                        _httpRequest.Headers.Remove(_header.Key);
 5251                    }
 05252                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5253                }
 5254            }
 5255
 5256            // Serialize Request
 45257            string _requestContent = null;
 45258            if(batch != null)
 5259            {
 45260                _requestContent = SafeJsonConvert.SerializeObject(batch, SerializationSettings);
 45261                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 45262                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 5263            }
 5264            // Set Credentials
 45265            if (Credentials != null)
 5266            {
 45267                cancellationToken.ThrowIfCancellationRequested();
 45268                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5269            }
 5270            // Send Request
 45271            if (_shouldTrace)
 5272            {
 05273                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5274            }
 45275            cancellationToken.ThrowIfCancellationRequested();
 45276            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 45277            if (_shouldTrace)
 5278            {
 05279                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5280            }
 45281            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 45282            cancellationToken.ThrowIfCancellationRequested();
 45283            string _responseContent = null;
 45284            if ((int)_statusCode != 200 && (int)_statusCode != 207)
 5285            {
 05286                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 5287                try
 5288                {
 05289                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05290                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 05291                    if (_errorBody != null)
 5292                    {
 05293                        ex.Body = _errorBody;
 5294                    }
 05295                }
 05296                catch (JsonException)
 5297                {
 5298                    // Ignore the exception
 05299                }
 05300                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05301                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05302                if (_shouldTrace)
 5303                {
 05304                    ServiceClientTracing.Error(_invocationId, ex);
 5305                }
 05306                _httpRequest.Dispose();
 05307                if (_httpResponse != null)
 5308                {
 05309                    _httpResponse.Dispose();
 5310                }
 05311                throw ex;
 5312            }
 5313            // Create Result
 45314            var _result = new HttpOperationResponse<ImageCreateSummary>();
 45315            _result.Request = _httpRequest;
 45316            _result.Response = _httpResponse;
 5317            // Deserialize Response
 45318            if ((int)_statusCode == 200)
 5319            {
 45320                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5321                try
 5322                {
 45323                    _result.Body = SafeJsonConvert.DeserializeObject<ImageCreateSummary>(_responseContent, Deserializati
 45324                }
 05325                catch (JsonException ex)
 5326                {
 05327                    _httpRequest.Dispose();
 05328                    if (_httpResponse != null)
 5329                    {
 05330                        _httpResponse.Dispose();
 5331                    }
 05332                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5333                }
 5334            }
 5335            // Deserialize Response
 45336            if ((int)_statusCode == 207)
 5337            {
 05338                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5339                try
 5340                {
 05341                    _result.Body = SafeJsonConvert.DeserializeObject<ImageCreateSummary>(_responseContent, Deserializati
 05342                }
 05343                catch (JsonException ex)
 5344                {
 05345                    _httpRequest.Dispose();
 05346                    if (_httpResponse != null)
 5347                    {
 05348                        _httpResponse.Dispose();
 5349                    }
 05350                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5351                }
 5352            }
 45353            if (_shouldTrace)
 5354            {
 05355                ServiceClientTracing.Exit(_invocationId, _result);
 5356            }
 45357            return _result;
 45358        }
 5359
 5360        /// <summary>
 5361        /// Get iterations for the project.
 5362        /// </summary>
 5363        /// <param name='projectId'>
 5364        /// The project id.
 5365        /// </param>
 5366        /// <param name='customHeaders'>
 5367        /// Headers that will be added to request.
 5368        /// </param>
 5369        /// <param name='cancellationToken'>
 5370        /// The cancellation token.
 5371        /// </param>
 5372        /// <exception cref="CustomVisionErrorException">
 5373        /// Thrown when the operation returned an invalid status code
 5374        /// </exception>
 5375        /// <exception cref="SerializationException">
 5376        /// Thrown when unable to deserialize the response
 5377        /// </exception>
 5378        /// <exception cref="ValidationException">
 5379        /// Thrown when a required parameter is null
 5380        /// </exception>
 5381        /// <exception cref="System.ArgumentNullException">
 5382        /// Thrown when a required parameter is null
 5383        /// </exception>
 5384        /// <return>
 5385        /// A response object containing the response body and response headers.
 5386        /// </return>
 5387        public async Task<HttpOperationResponse<IList<Iteration>>> GetIterationsWithHttpMessagesAsync(System.Guid projec
 5388        {
 125389            if (Endpoint == null)
 5390            {
 05391                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 5392            }
 5393            // Tracing
 125394            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 125395            string _invocationId = null;
 125396            if (_shouldTrace)
 5397            {
 05398                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05399                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05400                tracingParameters.Add("projectId", projectId);
 05401                tracingParameters.Add("cancellationToken", cancellationToken);
 05402                ServiceClientTracing.Enter(_invocationId, this, "GetIterations", tracingParameters);
 5403            }
 5404            // Construct URL
 125405            var _baseUrl = BaseUri;
 125406            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations";
 125407            _url = _url.Replace("{Endpoint}", Endpoint);
 125408            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 5409            // Create HTTP transport objects
 125410            var _httpRequest = new HttpRequestMessage();
 125411            HttpResponseMessage _httpResponse = null;
 125412            _httpRequest.Method = new HttpMethod("GET");
 125413            _httpRequest.RequestUri = new System.Uri(_url);
 5414            // Set Headers
 5415
 5416
 125417            if (customHeaders != null)
 5418            {
 05419                foreach(var _header in customHeaders)
 5420                {
 05421                    if (_httpRequest.Headers.Contains(_header.Key))
 5422                    {
 05423                        _httpRequest.Headers.Remove(_header.Key);
 5424                    }
 05425                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5426                }
 5427            }
 5428
 5429            // Serialize Request
 125430            string _requestContent = null;
 5431            // Set Credentials
 125432            if (Credentials != null)
 5433            {
 125434                cancellationToken.ThrowIfCancellationRequested();
 125435                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5436            }
 5437            // Send Request
 125438            if (_shouldTrace)
 5439            {
 05440                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5441            }
 125442            cancellationToken.ThrowIfCancellationRequested();
 125443            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 125444            if (_shouldTrace)
 5445            {
 05446                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5447            }
 125448            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 125449            cancellationToken.ThrowIfCancellationRequested();
 125450            string _responseContent = null;
 125451            if ((int)_statusCode != 200)
 5452            {
 05453                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 5454                try
 5455                {
 05456                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05457                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 05458                    if (_errorBody != null)
 5459                    {
 05460                        ex.Body = _errorBody;
 5461                    }
 05462                }
 05463                catch (JsonException)
 5464                {
 5465                    // Ignore the exception
 05466                }
 05467                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05468                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05469                if (_shouldTrace)
 5470                {
 05471                    ServiceClientTracing.Error(_invocationId, ex);
 5472                }
 05473                _httpRequest.Dispose();
 05474                if (_httpResponse != null)
 5475                {
 05476                    _httpResponse.Dispose();
 5477                }
 05478                throw ex;
 5479            }
 5480            // Create Result
 125481            var _result = new HttpOperationResponse<IList<Iteration>>();
 125482            _result.Request = _httpRequest;
 125483            _result.Response = _httpResponse;
 5484            // Deserialize Response
 125485            if ((int)_statusCode == 200)
 5486            {
 125487                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5488                try
 5489                {
 125490                    _result.Body = SafeJsonConvert.DeserializeObject<IList<Iteration>>(_responseContent, Deserialization
 125491                }
 05492                catch (JsonException ex)
 5493                {
 05494                    _httpRequest.Dispose();
 05495                    if (_httpResponse != null)
 5496                    {
 05497                        _httpResponse.Dispose();
 5498                    }
 05499                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5500                }
 5501            }
 125502            if (_shouldTrace)
 5503            {
 05504                ServiceClientTracing.Exit(_invocationId, _result);
 5505            }
 125506            return _result;
 125507        }
 5508
 5509        /// <summary>
 5510        /// Get a specific iteration.
 5511        /// </summary>
 5512        /// <param name='projectId'>
 5513        /// The id of the project the iteration belongs to.
 5514        /// </param>
 5515        /// <param name='iterationId'>
 5516        /// The id of the iteration to get.
 5517        /// </param>
 5518        /// <param name='customHeaders'>
 5519        /// Headers that will be added to request.
 5520        /// </param>
 5521        /// <param name='cancellationToken'>
 5522        /// The cancellation token.
 5523        /// </param>
 5524        /// <exception cref="CustomVisionErrorException">
 5525        /// Thrown when the operation returned an invalid status code
 5526        /// </exception>
 5527        /// <exception cref="SerializationException">
 5528        /// Thrown when unable to deserialize the response
 5529        /// </exception>
 5530        /// <exception cref="ValidationException">
 5531        /// Thrown when a required parameter is null
 5532        /// </exception>
 5533        /// <exception cref="System.ArgumentNullException">
 5534        /// Thrown when a required parameter is null
 5535        /// </exception>
 5536        /// <return>
 5537        /// A response object containing the response body and response headers.
 5538        /// </return>
 5539        public async Task<HttpOperationResponse<Iteration>> GetIterationWithHttpMessagesAsync(System.Guid projectId, Sys
 5540        {
 325541            if (Endpoint == null)
 5542            {
 05543                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 5544            }
 5545            // Tracing
 325546            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 325547            string _invocationId = null;
 325548            if (_shouldTrace)
 5549            {
 05550                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05551                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05552                tracingParameters.Add("projectId", projectId);
 05553                tracingParameters.Add("iterationId", iterationId);
 05554                tracingParameters.Add("cancellationToken", cancellationToken);
 05555                ServiceClientTracing.Enter(_invocationId, this, "GetIteration", tracingParameters);
 5556            }
 5557            // Construct URL
 325558            var _baseUrl = BaseUri;
 325559            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}";
 325560            _url = _url.Replace("{Endpoint}", Endpoint);
 325561            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 325562            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 5563            // Create HTTP transport objects
 325564            var _httpRequest = new HttpRequestMessage();
 325565            HttpResponseMessage _httpResponse = null;
 325566            _httpRequest.Method = new HttpMethod("GET");
 325567            _httpRequest.RequestUri = new System.Uri(_url);
 5568            // Set Headers
 5569
 5570
 325571            if (customHeaders != null)
 5572            {
 05573                foreach(var _header in customHeaders)
 5574                {
 05575                    if (_httpRequest.Headers.Contains(_header.Key))
 5576                    {
 05577                        _httpRequest.Headers.Remove(_header.Key);
 5578                    }
 05579                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5580                }
 5581            }
 5582
 5583            // Serialize Request
 325584            string _requestContent = null;
 5585            // Set Credentials
 325586            if (Credentials != null)
 5587            {
 325588                cancellationToken.ThrowIfCancellationRequested();
 325589                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5590            }
 5591            // Send Request
 325592            if (_shouldTrace)
 5593            {
 05594                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5595            }
 325596            cancellationToken.ThrowIfCancellationRequested();
 325597            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 325598            if (_shouldTrace)
 5599            {
 05600                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5601            }
 325602            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 325603            cancellationToken.ThrowIfCancellationRequested();
 325604            string _responseContent = null;
 325605            if ((int)_statusCode != 200)
 5606            {
 05607                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 5608                try
 5609                {
 05610                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05611                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 05612                    if (_errorBody != null)
 5613                    {
 05614                        ex.Body = _errorBody;
 5615                    }
 05616                }
 05617                catch (JsonException)
 5618                {
 5619                    // Ignore the exception
 05620                }
 05621                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05622                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05623                if (_shouldTrace)
 5624                {
 05625                    ServiceClientTracing.Error(_invocationId, ex);
 5626                }
 05627                _httpRequest.Dispose();
 05628                if (_httpResponse != null)
 5629                {
 05630                    _httpResponse.Dispose();
 5631                }
 05632                throw ex;
 5633            }
 5634            // Create Result
 325635            var _result = new HttpOperationResponse<Iteration>();
 325636            _result.Request = _httpRequest;
 325637            _result.Response = _httpResponse;
 5638            // Deserialize Response
 325639            if ((int)_statusCode == 200)
 5640            {
 325641                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5642                try
 5643                {
 325644                    _result.Body = SafeJsonConvert.DeserializeObject<Iteration>(_responseContent, DeserializationSetting
 325645                }
 05646                catch (JsonException ex)
 5647                {
 05648                    _httpRequest.Dispose();
 05649                    if (_httpResponse != null)
 5650                    {
 05651                        _httpResponse.Dispose();
 5652                    }
 05653                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5654                }
 5655            }
 325656            if (_shouldTrace)
 5657            {
 05658                ServiceClientTracing.Exit(_invocationId, _result);
 5659            }
 325660            return _result;
 325661        }
 5662
 5663        /// <summary>
 5664        /// Delete a specific iteration of a project.
 5665        /// </summary>
 5666        /// <param name='projectId'>
 5667        /// The project id.
 5668        /// </param>
 5669        /// <param name='iterationId'>
 5670        /// The iteration id.
 5671        /// </param>
 5672        /// <param name='customHeaders'>
 5673        /// Headers that will be added to request.
 5674        /// </param>
 5675        /// <param name='cancellationToken'>
 5676        /// The cancellation token.
 5677        /// </param>
 5678        /// <exception cref="CustomVisionErrorException">
 5679        /// Thrown when the operation returned an invalid status code
 5680        /// </exception>
 5681        /// <exception cref="ValidationException">
 5682        /// Thrown when a required parameter is null
 5683        /// </exception>
 5684        /// <exception cref="System.ArgumentNullException">
 5685        /// Thrown when a required parameter is null
 5686        /// </exception>
 5687        /// <return>
 5688        /// A response object containing the response body and response headers.
 5689        /// </return>
 5690        public async Task<HttpOperationResponse> DeleteIterationWithHttpMessagesAsync(System.Guid projectId, System.Guid
 5691        {
 25692            if (Endpoint == null)
 5693            {
 05694                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 5695            }
 5696            // Tracing
 25697            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 25698            string _invocationId = null;
 25699            if (_shouldTrace)
 5700            {
 05701                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05702                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05703                tracingParameters.Add("projectId", projectId);
 05704                tracingParameters.Add("iterationId", iterationId);
 05705                tracingParameters.Add("cancellationToken", cancellationToken);
 05706                ServiceClientTracing.Enter(_invocationId, this, "DeleteIteration", tracingParameters);
 5707            }
 5708            // Construct URL
 25709            var _baseUrl = BaseUri;
 25710            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}";
 25711            _url = _url.Replace("{Endpoint}", Endpoint);
 25712            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 25713            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 5714            // Create HTTP transport objects
 25715            var _httpRequest = new HttpRequestMessage();
 25716            HttpResponseMessage _httpResponse = null;
 25717            _httpRequest.Method = new HttpMethod("DELETE");
 25718            _httpRequest.RequestUri = new System.Uri(_url);
 5719            // Set Headers
 5720
 5721
 25722            if (customHeaders != null)
 5723            {
 05724                foreach(var _header in customHeaders)
 5725                {
 05726                    if (_httpRequest.Headers.Contains(_header.Key))
 5727                    {
 05728                        _httpRequest.Headers.Remove(_header.Key);
 5729                    }
 05730                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5731                }
 5732            }
 5733
 5734            // Serialize Request
 25735            string _requestContent = null;
 5736            // Set Credentials
 25737            if (Credentials != null)
 5738            {
 25739                cancellationToken.ThrowIfCancellationRequested();
 25740                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5741            }
 5742            // Send Request
 25743            if (_shouldTrace)
 5744            {
 05745                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5746            }
 25747            cancellationToken.ThrowIfCancellationRequested();
 25748            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 25749            if (_shouldTrace)
 5750            {
 05751                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5752            }
 25753            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 25754            cancellationToken.ThrowIfCancellationRequested();
 25755            string _responseContent = null;
 25756            if ((int)_statusCode != 204)
 5757            {
 05758                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 5759                try
 5760                {
 05761                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05762                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 05763                    if (_errorBody != null)
 5764                    {
 05765                        ex.Body = _errorBody;
 5766                    }
 05767                }
 05768                catch (JsonException)
 5769                {
 5770                    // Ignore the exception
 05771                }
 05772                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05773                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05774                if (_shouldTrace)
 5775                {
 05776                    ServiceClientTracing.Error(_invocationId, ex);
 5777                }
 05778                _httpRequest.Dispose();
 05779                if (_httpResponse != null)
 5780                {
 05781                    _httpResponse.Dispose();
 5782                }
 05783                throw ex;
 5784            }
 5785            // Create Result
 25786            var _result = new HttpOperationResponse();
 25787            _result.Request = _httpRequest;
 25788            _result.Response = _httpResponse;
 25789            if (_shouldTrace)
 5790            {
 05791                ServiceClientTracing.Exit(_invocationId, _result);
 5792            }
 25793            return _result;
 25794        }
 5795
 5796        /// <summary>
 5797        /// Update a specific iteration.
 5798        /// </summary>
 5799        /// <param name='projectId'>
 5800        /// Project id.
 5801        /// </param>
 5802        /// <param name='iterationId'>
 5803        /// Iteration id.
 5804        /// </param>
 5805        /// <param name='updatedIteration'>
 5806        /// The updated iteration model.
 5807        /// </param>
 5808        /// <param name='customHeaders'>
 5809        /// Headers that will be added to request.
 5810        /// </param>
 5811        /// <param name='cancellationToken'>
 5812        /// The cancellation token.
 5813        /// </param>
 5814        /// <exception cref="CustomVisionErrorException">
 5815        /// Thrown when the operation returned an invalid status code
 5816        /// </exception>
 5817        /// <exception cref="SerializationException">
 5818        /// Thrown when unable to deserialize the response
 5819        /// </exception>
 5820        /// <exception cref="ValidationException">
 5821        /// Thrown when a required parameter is null
 5822        /// </exception>
 5823        /// <exception cref="System.ArgumentNullException">
 5824        /// Thrown when a required parameter is null
 5825        /// </exception>
 5826        /// <return>
 5827        /// A response object containing the response body and response headers.
 5828        /// </return>
 5829        public async Task<HttpOperationResponse<Iteration>> UpdateIterationWithHttpMessagesAsync(System.Guid projectId, 
 5830        {
 25831            if (Endpoint == null)
 5832            {
 05833                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 5834            }
 25835            if (updatedIteration == null)
 5836            {
 05837                throw new ValidationException(ValidationRules.CannotBeNull, "updatedIteration");
 5838            }
 5839            // Tracing
 25840            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 25841            string _invocationId = null;
 25842            if (_shouldTrace)
 5843            {
 05844                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 05845                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 05846                tracingParameters.Add("projectId", projectId);
 05847                tracingParameters.Add("iterationId", iterationId);
 05848                tracingParameters.Add("updatedIteration", updatedIteration);
 05849                tracingParameters.Add("cancellationToken", cancellationToken);
 05850                ServiceClientTracing.Enter(_invocationId, this, "UpdateIteration", tracingParameters);
 5851            }
 5852            // Construct URL
 25853            var _baseUrl = BaseUri;
 25854            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}";
 25855            _url = _url.Replace("{Endpoint}", Endpoint);
 25856            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 25857            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 5858            // Create HTTP transport objects
 25859            var _httpRequest = new HttpRequestMessage();
 25860            HttpResponseMessage _httpResponse = null;
 25861            _httpRequest.Method = new HttpMethod("PATCH");
 25862            _httpRequest.RequestUri = new System.Uri(_url);
 5863            // Set Headers
 5864
 5865
 25866            if (customHeaders != null)
 5867            {
 05868                foreach(var _header in customHeaders)
 5869                {
 05870                    if (_httpRequest.Headers.Contains(_header.Key))
 5871                    {
 05872                        _httpRequest.Headers.Remove(_header.Key);
 5873                    }
 05874                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 5875                }
 5876            }
 5877
 5878            // Serialize Request
 25879            string _requestContent = null;
 25880            if(updatedIteration != null)
 5881            {
 25882                _requestContent = SafeJsonConvert.SerializeObject(updatedIteration, SerializationSettings);
 25883                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 25884                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 5885            }
 5886            // Set Credentials
 25887            if (Credentials != null)
 5888            {
 25889                cancellationToken.ThrowIfCancellationRequested();
 25890                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 5891            }
 5892            // Send Request
 25893            if (_shouldTrace)
 5894            {
 05895                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 5896            }
 25897            cancellationToken.ThrowIfCancellationRequested();
 25898            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 25899            if (_shouldTrace)
 5900            {
 05901                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 5902            }
 25903            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 25904            cancellationToken.ThrowIfCancellationRequested();
 25905            string _responseContent = null;
 25906            if ((int)_statusCode != 200)
 5907            {
 05908                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 5909                try
 5910                {
 05911                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 05912                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 05913                    if (_errorBody != null)
 5914                    {
 05915                        ex.Body = _errorBody;
 5916                    }
 05917                }
 05918                catch (JsonException)
 5919                {
 5920                    // Ignore the exception
 05921                }
 05922                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 05923                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 05924                if (_shouldTrace)
 5925                {
 05926                    ServiceClientTracing.Error(_invocationId, ex);
 5927                }
 05928                _httpRequest.Dispose();
 05929                if (_httpResponse != null)
 5930                {
 05931                    _httpResponse.Dispose();
 5932                }
 05933                throw ex;
 5934            }
 5935            // Create Result
 25936            var _result = new HttpOperationResponse<Iteration>();
 25937            _result.Request = _httpRequest;
 25938            _result.Response = _httpResponse;
 5939            // Deserialize Response
 25940            if ((int)_statusCode == 200)
 5941            {
 25942                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 5943                try
 5944                {
 25945                    _result.Body = SafeJsonConvert.DeserializeObject<Iteration>(_responseContent, DeserializationSetting
 25946                }
 05947                catch (JsonException ex)
 5948                {
 05949                    _httpRequest.Dispose();
 05950                    if (_httpResponse != null)
 5951                    {
 05952                        _httpResponse.Dispose();
 5953                    }
 05954                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 5955                }
 5956            }
 25957            if (_shouldTrace)
 5958            {
 05959                ServiceClientTracing.Exit(_invocationId, _result);
 5960            }
 25961            return _result;
 25962        }
 5963
 5964        /// <summary>
 5965        /// Get the list of exports for a specific iteration.
 5966        /// </summary>
 5967        /// <param name='projectId'>
 5968        /// The project id.
 5969        /// </param>
 5970        /// <param name='iterationId'>
 5971        /// The iteration id.
 5972        /// </param>
 5973        /// <param name='customHeaders'>
 5974        /// Headers that will be added to request.
 5975        /// </param>
 5976        /// <param name='cancellationToken'>
 5977        /// The cancellation token.
 5978        /// </param>
 5979        /// <exception cref="CustomVisionErrorException">
 5980        /// Thrown when the operation returned an invalid status code
 5981        /// </exception>
 5982        /// <exception cref="SerializationException">
 5983        /// Thrown when unable to deserialize the response
 5984        /// </exception>
 5985        /// <exception cref="ValidationException">
 5986        /// Thrown when a required parameter is null
 5987        /// </exception>
 5988        /// <exception cref="System.ArgumentNullException">
 5989        /// Thrown when a required parameter is null
 5990        /// </exception>
 5991        /// <return>
 5992        /// A response object containing the response body and response headers.
 5993        /// </return>
 5994        public async Task<HttpOperationResponse<IList<Export>>> GetExportsWithHttpMessagesAsync(System.Guid projectId, S
 5995        {
 125996            if (Endpoint == null)
 5997            {
 05998                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 5999            }
 6000            // Tracing
 126001            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 126002            string _invocationId = null;
 126003            if (_shouldTrace)
 6004            {
 06005                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06006                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06007                tracingParameters.Add("projectId", projectId);
 06008                tracingParameters.Add("iterationId", iterationId);
 06009                tracingParameters.Add("cancellationToken", cancellationToken);
 06010                ServiceClientTracing.Enter(_invocationId, this, "GetExports", tracingParameters);
 6011            }
 6012            // Construct URL
 126013            var _baseUrl = BaseUri;
 126014            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}/e
 126015            _url = _url.Replace("{Endpoint}", Endpoint);
 126016            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 126017            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 6018            // Create HTTP transport objects
 126019            var _httpRequest = new HttpRequestMessage();
 126020            HttpResponseMessage _httpResponse = null;
 126021            _httpRequest.Method = new HttpMethod("GET");
 126022            _httpRequest.RequestUri = new System.Uri(_url);
 6023            // Set Headers
 6024
 6025
 126026            if (customHeaders != null)
 6027            {
 06028                foreach(var _header in customHeaders)
 6029                {
 06030                    if (_httpRequest.Headers.Contains(_header.Key))
 6031                    {
 06032                        _httpRequest.Headers.Remove(_header.Key);
 6033                    }
 06034                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6035                }
 6036            }
 6037
 6038            // Serialize Request
 126039            string _requestContent = null;
 6040            // Set Credentials
 126041            if (Credentials != null)
 6042            {
 126043                cancellationToken.ThrowIfCancellationRequested();
 126044                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6045            }
 6046            // Send Request
 126047            if (_shouldTrace)
 6048            {
 06049                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6050            }
 126051            cancellationToken.ThrowIfCancellationRequested();
 126052            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 126053            if (_shouldTrace)
 6054            {
 06055                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6056            }
 126057            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 126058            cancellationToken.ThrowIfCancellationRequested();
 126059            string _responseContent = null;
 126060            if ((int)_statusCode != 200)
 6061            {
 06062                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 6063                try
 6064                {
 06065                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06066                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 06067                    if (_errorBody != null)
 6068                    {
 06069                        ex.Body = _errorBody;
 6070                    }
 06071                }
 06072                catch (JsonException)
 6073                {
 6074                    // Ignore the exception
 06075                }
 06076                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06077                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06078                if (_shouldTrace)
 6079                {
 06080                    ServiceClientTracing.Error(_invocationId, ex);
 6081                }
 06082                _httpRequest.Dispose();
 06083                if (_httpResponse != null)
 6084                {
 06085                    _httpResponse.Dispose();
 6086                }
 06087                throw ex;
 6088            }
 6089            // Create Result
 126090            var _result = new HttpOperationResponse<IList<Export>>();
 126091            _result.Request = _httpRequest;
 126092            _result.Response = _httpResponse;
 6093            // Deserialize Response
 126094            if ((int)_statusCode == 200)
 6095            {
 126096                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6097                try
 6098                {
 126099                    _result.Body = SafeJsonConvert.DeserializeObject<IList<Export>>(_responseContent, DeserializationSet
 126100                }
 06101                catch (JsonException ex)
 6102                {
 06103                    _httpRequest.Dispose();
 06104                    if (_httpResponse != null)
 6105                    {
 06106                        _httpResponse.Dispose();
 6107                    }
 06108                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6109                }
 6110            }
 126111            if (_shouldTrace)
 6112            {
 06113                ServiceClientTracing.Exit(_invocationId, _result);
 6114            }
 126115            return _result;
 126116        }
 6117
 6118        /// <summary>
 6119        /// Export a trained iteration.
 6120        /// </summary>
 6121        /// <param name='projectId'>
 6122        /// The project id.
 6123        /// </param>
 6124        /// <param name='iterationId'>
 6125        /// The iteration id.
 6126        /// </param>
 6127        /// <param name='platform'>
 6128        /// The target platform. Possible values include: 'CoreML', 'TensorFlow',
 6129        /// 'DockerFile', 'ONNX', 'VAIDK'
 6130        /// </param>
 6131        /// <param name='flavor'>
 6132        /// The flavor of the target platform. Possible values include: 'Linux',
 6133        /// 'Windows', 'ONNX10', 'ONNX12', 'ARM', 'TensorFlowNormal', 'TensorFlowLite'
 6134        /// </param>
 6135        /// <param name='customHeaders'>
 6136        /// Headers that will be added to request.
 6137        /// </param>
 6138        /// <param name='cancellationToken'>
 6139        /// The cancellation token.
 6140        /// </param>
 6141        /// <exception cref="CustomVisionErrorException">
 6142        /// Thrown when the operation returned an invalid status code
 6143        /// </exception>
 6144        /// <exception cref="SerializationException">
 6145        /// Thrown when unable to deserialize the response
 6146        /// </exception>
 6147        /// <exception cref="ValidationException">
 6148        /// Thrown when a required parameter is null
 6149        /// </exception>
 6150        /// <exception cref="System.ArgumentNullException">
 6151        /// Thrown when a required parameter is null
 6152        /// </exception>
 6153        /// <return>
 6154        /// A response object containing the response body and response headers.
 6155        /// </return>
 6156        public async Task<HttpOperationResponse<Export>> ExportIterationWithHttpMessagesAsync(System.Guid projectId, Sys
 6157        {
 26158            if (Endpoint == null)
 6159            {
 06160                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 6161            }
 26162            if (platform == null)
 6163            {
 06164                throw new ValidationException(ValidationRules.CannotBeNull, "platform");
 6165            }
 6166            // Tracing
 26167            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 26168            string _invocationId = null;
 26169            if (_shouldTrace)
 6170            {
 06171                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06172                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06173                tracingParameters.Add("projectId", projectId);
 06174                tracingParameters.Add("iterationId", iterationId);
 06175                tracingParameters.Add("platform", platform);
 06176                tracingParameters.Add("flavor", flavor);
 06177                tracingParameters.Add("cancellationToken", cancellationToken);
 06178                ServiceClientTracing.Enter(_invocationId, this, "ExportIteration", tracingParameters);
 6179            }
 6180            // Construct URL
 26181            var _baseUrl = BaseUri;
 26182            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}/e
 26183            _url = _url.Replace("{Endpoint}", Endpoint);
 26184            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 26185            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 26186            List<string> _queryParameters = new List<string>();
 26187            if (platform != null)
 6188            {
 26189                _queryParameters.Add(string.Format("platform={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serialize
 6190            }
 26191            if (flavor != null)
 6192            {
 06193                _queryParameters.Add(string.Format("flavor={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeOb
 6194            }
 26195            if (_queryParameters.Count > 0)
 6196            {
 26197                _url += "?" + string.Join("&", _queryParameters);
 6198            }
 6199            // Create HTTP transport objects
 26200            var _httpRequest = new HttpRequestMessage();
 26201            HttpResponseMessage _httpResponse = null;
 26202            _httpRequest.Method = new HttpMethod("POST");
 26203            _httpRequest.RequestUri = new System.Uri(_url);
 6204            // Set Headers
 6205
 6206
 26207            if (customHeaders != null)
 6208            {
 06209                foreach(var _header in customHeaders)
 6210                {
 06211                    if (_httpRequest.Headers.Contains(_header.Key))
 6212                    {
 06213                        _httpRequest.Headers.Remove(_header.Key);
 6214                    }
 06215                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6216                }
 6217            }
 6218
 6219            // Serialize Request
 26220            string _requestContent = null;
 6221            // Set Credentials
 26222            if (Credentials != null)
 6223            {
 26224                cancellationToken.ThrowIfCancellationRequested();
 26225                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6226            }
 6227            // Send Request
 26228            if (_shouldTrace)
 6229            {
 06230                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6231            }
 26232            cancellationToken.ThrowIfCancellationRequested();
 26233            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 26234            if (_shouldTrace)
 6235            {
 06236                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6237            }
 26238            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 26239            cancellationToken.ThrowIfCancellationRequested();
 26240            string _responseContent = null;
 26241            if ((int)_statusCode != 200)
 6242            {
 06243                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 6244                try
 6245                {
 06246                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06247                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 06248                    if (_errorBody != null)
 6249                    {
 06250                        ex.Body = _errorBody;
 6251                    }
 06252                }
 06253                catch (JsonException)
 6254                {
 6255                    // Ignore the exception
 06256                }
 06257                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06258                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06259                if (_shouldTrace)
 6260                {
 06261                    ServiceClientTracing.Error(_invocationId, ex);
 6262                }
 06263                _httpRequest.Dispose();
 06264                if (_httpResponse != null)
 6265                {
 06266                    _httpResponse.Dispose();
 6267                }
 06268                throw ex;
 6269            }
 6270            // Create Result
 26271            var _result = new HttpOperationResponse<Export>();
 26272            _result.Request = _httpRequest;
 26273            _result.Response = _httpResponse;
 6274            // Deserialize Response
 26275            if ((int)_statusCode == 200)
 6276            {
 26277                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6278                try
 6279                {
 26280                    _result.Body = SafeJsonConvert.DeserializeObject<Export>(_responseContent, DeserializationSettings);
 26281                }
 06282                catch (JsonException ex)
 6283                {
 06284                    _httpRequest.Dispose();
 06285                    if (_httpResponse != null)
 6286                    {
 06287                        _httpResponse.Dispose();
 6288                    }
 06289                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6290                }
 6291            }
 26292            if (_shouldTrace)
 6293            {
 06294                ServiceClientTracing.Exit(_invocationId, _result);
 6295            }
 26296            return _result;
 26297        }
 6298
 6299        /// <summary>
 6300        /// Get detailed performance information about an iteration.
 6301        /// </summary>
 6302        /// <param name='projectId'>
 6303        /// The id of the project the iteration belongs to.
 6304        /// </param>
 6305        /// <param name='iterationId'>
 6306        /// The id of the iteration to get.
 6307        /// </param>
 6308        /// <param name='threshold'>
 6309        /// The threshold used to determine true predictions.
 6310        /// </param>
 6311        /// <param name='overlapThreshold'>
 6312        /// If applicable, the bounding box overlap threshold used to determine true
 6313        /// predictions.
 6314        /// </param>
 6315        /// <param name='customHeaders'>
 6316        /// Headers that will be added to request.
 6317        /// </param>
 6318        /// <param name='cancellationToken'>
 6319        /// The cancellation token.
 6320        /// </param>
 6321        /// <exception cref="CustomVisionErrorException">
 6322        /// Thrown when the operation returned an invalid status code
 6323        /// </exception>
 6324        /// <exception cref="SerializationException">
 6325        /// Thrown when unable to deserialize the response
 6326        /// </exception>
 6327        /// <exception cref="ValidationException">
 6328        /// Thrown when a required parameter is null
 6329        /// </exception>
 6330        /// <exception cref="System.ArgumentNullException">
 6331        /// Thrown when a required parameter is null
 6332        /// </exception>
 6333        /// <return>
 6334        /// A response object containing the response body and response headers.
 6335        /// </return>
 6336        public async Task<HttpOperationResponse<IterationPerformance>> GetIterationPerformanceWithHttpMessagesAsync(Syst
 6337        {
 26338            if (Endpoint == null)
 6339            {
 06340                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 6341            }
 6342            // Tracing
 26343            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 26344            string _invocationId = null;
 26345            if (_shouldTrace)
 6346            {
 06347                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06348                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06349                tracingParameters.Add("projectId", projectId);
 06350                tracingParameters.Add("iterationId", iterationId);
 06351                tracingParameters.Add("threshold", threshold);
 06352                tracingParameters.Add("overlapThreshold", overlapThreshold);
 06353                tracingParameters.Add("cancellationToken", cancellationToken);
 06354                ServiceClientTracing.Enter(_invocationId, this, "GetIterationPerformance", tracingParameters);
 6355            }
 6356            // Construct URL
 26357            var _baseUrl = BaseUri;
 26358            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}/p
 26359            _url = _url.Replace("{Endpoint}", Endpoint);
 26360            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 26361            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 26362            List<string> _queryParameters = new List<string>();
 26363            if (threshold != null)
 6364            {
 26365                _queryParameters.Add(string.Format("threshold={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serializ
 6366            }
 26367            if (overlapThreshold != null)
 6368            {
 06369                _queryParameters.Add(string.Format("overlapThreshold={0}", System.Uri.EscapeDataString(SafeJsonConvert.S
 6370            }
 26371            if (_queryParameters.Count > 0)
 6372            {
 26373                _url += "?" + string.Join("&", _queryParameters);
 6374            }
 6375            // Create HTTP transport objects
 26376            var _httpRequest = new HttpRequestMessage();
 26377            HttpResponseMessage _httpResponse = null;
 26378            _httpRequest.Method = new HttpMethod("GET");
 26379            _httpRequest.RequestUri = new System.Uri(_url);
 6380            // Set Headers
 6381
 6382
 26383            if (customHeaders != null)
 6384            {
 06385                foreach(var _header in customHeaders)
 6386                {
 06387                    if (_httpRequest.Headers.Contains(_header.Key))
 6388                    {
 06389                        _httpRequest.Headers.Remove(_header.Key);
 6390                    }
 06391                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6392                }
 6393            }
 6394
 6395            // Serialize Request
 26396            string _requestContent = null;
 6397            // Set Credentials
 26398            if (Credentials != null)
 6399            {
 26400                cancellationToken.ThrowIfCancellationRequested();
 26401                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6402            }
 6403            // Send Request
 26404            if (_shouldTrace)
 6405            {
 06406                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6407            }
 26408            cancellationToken.ThrowIfCancellationRequested();
 26409            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 26410            if (_shouldTrace)
 6411            {
 06412                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6413            }
 26414            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 26415            cancellationToken.ThrowIfCancellationRequested();
 26416            string _responseContent = null;
 26417            if ((int)_statusCode != 200)
 6418            {
 06419                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 6420                try
 6421                {
 06422                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06423                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 06424                    if (_errorBody != null)
 6425                    {
 06426                        ex.Body = _errorBody;
 6427                    }
 06428                }
 06429                catch (JsonException)
 6430                {
 6431                    // Ignore the exception
 06432                }
 06433                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06434                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06435                if (_shouldTrace)
 6436                {
 06437                    ServiceClientTracing.Error(_invocationId, ex);
 6438                }
 06439                _httpRequest.Dispose();
 06440                if (_httpResponse != null)
 6441                {
 06442                    _httpResponse.Dispose();
 6443                }
 06444                throw ex;
 6445            }
 6446            // Create Result
 26447            var _result = new HttpOperationResponse<IterationPerformance>();
 26448            _result.Request = _httpRequest;
 26449            _result.Response = _httpResponse;
 6450            // Deserialize Response
 26451            if ((int)_statusCode == 200)
 6452            {
 26453                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6454                try
 6455                {
 26456                    _result.Body = SafeJsonConvert.DeserializeObject<IterationPerformance>(_responseContent, Deserializa
 26457                }
 06458                catch (JsonException ex)
 6459                {
 06460                    _httpRequest.Dispose();
 06461                    if (_httpResponse != null)
 6462                    {
 06463                        _httpResponse.Dispose();
 6464                    }
 06465                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6466                }
 6467            }
 26468            if (_shouldTrace)
 6469            {
 06470                ServiceClientTracing.Exit(_invocationId, _result);
 6471            }
 26472            return _result;
 26473        }
 6474
 6475        /// <summary>
 6476        /// Get image with its prediction for a given project iteration.
 6477        /// </summary>
 6478        /// <remarks>
 6479        /// This API supports batching and range selection. By default it will only
 6480        /// return first 50 images matching images.
 6481        /// Use the {take} and {skip} parameters to control how many images to return
 6482        /// in a given batch.
 6483        /// The filtering is on an and/or relationship. For example, if the provided
 6484        /// tag ids are for the "Dog" and
 6485        /// "Cat" tags, then only images tagged with Dog and/or Cat will be returned
 6486        /// </remarks>
 6487        /// <param name='projectId'>
 6488        /// The project id.
 6489        /// </param>
 6490        /// <param name='iterationId'>
 6491        /// The iteration id. Defaults to workspace.
 6492        /// </param>
 6493        /// <param name='tagIds'>
 6494        /// A list of tags ids to filter the images. Defaults to all tagged images when
 6495        /// null. Limited to 20.
 6496        /// </param>
 6497        /// <param name='orderBy'>
 6498        /// The ordering. Defaults to newest. Possible values include: 'Newest',
 6499        /// 'Oldest'
 6500        /// </param>
 6501        /// <param name='take'>
 6502        /// Maximum number of images to return. Defaults to 50, limited to 256.
 6503        /// </param>
 6504        /// <param name='skip'>
 6505        /// Number of images to skip before beginning the image batch. Defaults to 0.
 6506        /// </param>
 6507        /// <param name='customHeaders'>
 6508        /// Headers that will be added to request.
 6509        /// </param>
 6510        /// <param name='cancellationToken'>
 6511        /// The cancellation token.
 6512        /// </param>
 6513        /// <exception cref="CustomVisionErrorException">
 6514        /// Thrown when the operation returned an invalid status code
 6515        /// </exception>
 6516        /// <exception cref="SerializationException">
 6517        /// Thrown when unable to deserialize the response
 6518        /// </exception>
 6519        /// <exception cref="ValidationException">
 6520        /// Thrown when a required parameter is null
 6521        /// </exception>
 6522        /// <exception cref="System.ArgumentNullException">
 6523        /// Thrown when a required parameter is null
 6524        /// </exception>
 6525        /// <return>
 6526        /// A response object containing the response body and response headers.
 6527        /// </return>
 6528        public async Task<HttpOperationResponse<IList<ImagePerformance>>> GetImagePerformancesWithHttpMessagesAsync(Syst
 6529        {
 06530            if (Endpoint == null)
 6531            {
 06532                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 6533            }
 06534            if (tagIds != null)
 6535            {
 06536                if (tagIds.Count > 20)
 6537                {
 06538                    throw new ValidationException(ValidationRules.MaxItems, "tagIds", 20);
 6539                }
 06540                if (tagIds.Count < 0)
 6541                {
 06542                    throw new ValidationException(ValidationRules.MinItems, "tagIds", 0);
 6543                }
 6544            }
 06545            if (take > 256)
 6546            {
 06547                throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 256);
 6548            }
 06549            if (take < 0)
 6550            {
 06551                throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0);
 6552            }
 6553            // Tracing
 06554            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 06555            string _invocationId = null;
 06556            if (_shouldTrace)
 6557            {
 06558                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06559                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06560                tracingParameters.Add("projectId", projectId);
 06561                tracingParameters.Add("iterationId", iterationId);
 06562                tracingParameters.Add("tagIds", tagIds);
 06563                tracingParameters.Add("orderBy", orderBy);
 06564                tracingParameters.Add("take", take);
 06565                tracingParameters.Add("skip", skip);
 06566                tracingParameters.Add("cancellationToken", cancellationToken);
 06567                ServiceClientTracing.Enter(_invocationId, this, "GetImagePerformances", tracingParameters);
 6568            }
 6569            // Construct URL
 06570            var _baseUrl = BaseUri;
 06571            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}/p
 06572            _url = _url.Replace("{Endpoint}", Endpoint);
 06573            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 06574            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 06575            List<string> _queryParameters = new List<string>();
 06576            if (tagIds != null)
 6577            {
 06578                _queryParameters.Add(string.Format("tagIds={0}", System.Uri.EscapeDataString(string.Join(",", tagIds))))
 6579            }
 06580            if (orderBy != null)
 6581            {
 06582                _queryParameters.Add(string.Format("orderBy={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 6583            }
 06584            if (take != null)
 6585            {
 06586                _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObje
 6587            }
 06588            if (skip != null)
 6589            {
 06590                _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObje
 6591            }
 06592            if (_queryParameters.Count > 0)
 6593            {
 06594                _url += "?" + string.Join("&", _queryParameters);
 6595            }
 6596            // Create HTTP transport objects
 06597            var _httpRequest = new HttpRequestMessage();
 06598            HttpResponseMessage _httpResponse = null;
 06599            _httpRequest.Method = new HttpMethod("GET");
 06600            _httpRequest.RequestUri = new System.Uri(_url);
 6601            // Set Headers
 6602
 6603
 06604            if (customHeaders != null)
 6605            {
 06606                foreach(var _header in customHeaders)
 6607                {
 06608                    if (_httpRequest.Headers.Contains(_header.Key))
 6609                    {
 06610                        _httpRequest.Headers.Remove(_header.Key);
 6611                    }
 06612                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6613                }
 6614            }
 6615
 6616            // Serialize Request
 06617            string _requestContent = null;
 6618            // Set Credentials
 06619            if (Credentials != null)
 6620            {
 06621                cancellationToken.ThrowIfCancellationRequested();
 06622                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6623            }
 6624            // Send Request
 06625            if (_shouldTrace)
 6626            {
 06627                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6628            }
 06629            cancellationToken.ThrowIfCancellationRequested();
 06630            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 06631            if (_shouldTrace)
 6632            {
 06633                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6634            }
 06635            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 06636            cancellationToken.ThrowIfCancellationRequested();
 06637            string _responseContent = null;
 06638            if ((int)_statusCode != 200)
 6639            {
 06640                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 6641                try
 6642                {
 06643                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06644                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 06645                    if (_errorBody != null)
 6646                    {
 06647                        ex.Body = _errorBody;
 6648                    }
 06649                }
 06650                catch (JsonException)
 6651                {
 6652                    // Ignore the exception
 06653                }
 06654                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06655                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06656                if (_shouldTrace)
 6657                {
 06658                    ServiceClientTracing.Error(_invocationId, ex);
 6659                }
 06660                _httpRequest.Dispose();
 06661                if (_httpResponse != null)
 6662                {
 06663                    _httpResponse.Dispose();
 6664                }
 06665                throw ex;
 6666            }
 6667            // Create Result
 06668            var _result = new HttpOperationResponse<IList<ImagePerformance>>();
 06669            _result.Request = _httpRequest;
 06670            _result.Response = _httpResponse;
 6671            // Deserialize Response
 06672            if ((int)_statusCode == 200)
 6673            {
 06674                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6675                try
 6676                {
 06677                    _result.Body = SafeJsonConvert.DeserializeObject<IList<ImagePerformance>>(_responseContent, Deserial
 06678                }
 06679                catch (JsonException ex)
 6680                {
 06681                    _httpRequest.Dispose();
 06682                    if (_httpResponse != null)
 6683                    {
 06684                        _httpResponse.Dispose();
 6685                    }
 06686                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6687                }
 6688            }
 06689            if (_shouldTrace)
 6690            {
 06691                ServiceClientTracing.Exit(_invocationId, _result);
 6692            }
 06693            return _result;
 06694        }
 6695
 6696        /// <summary>
 6697        /// Gets the number of images tagged with the provided {tagIds} that have
 6698        /// prediction results from
 6699        /// training for the provided iteration {iterationId}.
 6700        /// </summary>
 6701        /// <remarks>
 6702        /// The filtering is on an and/or relationship. For example, if the provided
 6703        /// tag ids are for the "Dog" and
 6704        /// "Cat" tags, then only images tagged with Dog and/or Cat will be returned
 6705        /// </remarks>
 6706        /// <param name='projectId'>
 6707        /// The project id.
 6708        /// </param>
 6709        /// <param name='iterationId'>
 6710        /// The iteration id. Defaults to workspace.
 6711        /// </param>
 6712        /// <param name='tagIds'>
 6713        /// A list of tags ids to filter the images to count. Defaults to all tags when
 6714        /// null.
 6715        /// </param>
 6716        /// <param name='customHeaders'>
 6717        /// Headers that will be added to request.
 6718        /// </param>
 6719        /// <param name='cancellationToken'>
 6720        /// The cancellation token.
 6721        /// </param>
 6722        /// <exception cref="CustomVisionErrorException">
 6723        /// Thrown when the operation returned an invalid status code
 6724        /// </exception>
 6725        /// <exception cref="SerializationException">
 6726        /// Thrown when unable to deserialize the response
 6727        /// </exception>
 6728        /// <exception cref="ValidationException">
 6729        /// Thrown when a required parameter is null
 6730        /// </exception>
 6731        /// <exception cref="System.ArgumentNullException">
 6732        /// Thrown when a required parameter is null
 6733        /// </exception>
 6734        /// <return>
 6735        /// A response object containing the response body and response headers.
 6736        /// </return>
 6737        public async Task<HttpOperationResponse<int?>> GetImagePerformanceCountWithHttpMessagesAsync(System.Guid project
 6738        {
 26739            if (Endpoint == null)
 6740            {
 06741                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 6742            }
 6743            // Tracing
 26744            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 26745            string _invocationId = null;
 26746            if (_shouldTrace)
 6747            {
 06748                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06749                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06750                tracingParameters.Add("projectId", projectId);
 06751                tracingParameters.Add("iterationId", iterationId);
 06752                tracingParameters.Add("tagIds", tagIds);
 06753                tracingParameters.Add("cancellationToken", cancellationToken);
 06754                ServiceClientTracing.Enter(_invocationId, this, "GetImagePerformanceCount", tracingParameters);
 6755            }
 6756            // Construct URL
 26757            var _baseUrl = BaseUri;
 26758            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}/p
 26759            _url = _url.Replace("{Endpoint}", Endpoint);
 26760            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 26761            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 26762            List<string> _queryParameters = new List<string>();
 26763            if (tagIds != null)
 6764            {
 06765                _queryParameters.Add(string.Format("tagIds={0}", System.Uri.EscapeDataString(string.Join(",", tagIds))))
 6766            }
 26767            if (_queryParameters.Count > 0)
 6768            {
 06769                _url += "?" + string.Join("&", _queryParameters);
 6770            }
 6771            // Create HTTP transport objects
 26772            var _httpRequest = new HttpRequestMessage();
 26773            HttpResponseMessage _httpResponse = null;
 26774            _httpRequest.Method = new HttpMethod("GET");
 26775            _httpRequest.RequestUri = new System.Uri(_url);
 6776            // Set Headers
 6777
 6778
 26779            if (customHeaders != null)
 6780            {
 06781                foreach(var _header in customHeaders)
 6782                {
 06783                    if (_httpRequest.Headers.Contains(_header.Key))
 6784                    {
 06785                        _httpRequest.Headers.Remove(_header.Key);
 6786                    }
 06787                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6788                }
 6789            }
 6790
 6791            // Serialize Request
 26792            string _requestContent = null;
 6793            // Set Credentials
 26794            if (Credentials != null)
 6795            {
 26796                cancellationToken.ThrowIfCancellationRequested();
 26797                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6798            }
 6799            // Send Request
 26800            if (_shouldTrace)
 6801            {
 06802                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6803            }
 26804            cancellationToken.ThrowIfCancellationRequested();
 26805            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 26806            if (_shouldTrace)
 6807            {
 06808                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 6809            }
 26810            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 26811            cancellationToken.ThrowIfCancellationRequested();
 26812            string _responseContent = null;
 26813            if ((int)_statusCode != 200)
 6814            {
 06815                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 6816                try
 6817                {
 06818                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 06819                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 06820                    if (_errorBody != null)
 6821                    {
 06822                        ex.Body = _errorBody;
 6823                    }
 06824                }
 06825                catch (JsonException)
 6826                {
 6827                    // Ignore the exception
 06828                }
 06829                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 06830                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 06831                if (_shouldTrace)
 6832                {
 06833                    ServiceClientTracing.Error(_invocationId, ex);
 6834                }
 06835                _httpRequest.Dispose();
 06836                if (_httpResponse != null)
 6837                {
 06838                    _httpResponse.Dispose();
 6839                }
 06840                throw ex;
 6841            }
 6842            // Create Result
 26843            var _result = new HttpOperationResponse<int?>();
 26844            _result.Request = _httpRequest;
 26845            _result.Response = _httpResponse;
 6846            // Deserialize Response
 26847            if ((int)_statusCode == 200)
 6848            {
 26849                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6850                try
 6851                {
 26852                    _result.Body = SafeJsonConvert.DeserializeObject<int?>(_responseContent, DeserializationSettings);
 26853                }
 06854                catch (JsonException ex)
 6855                {
 06856                    _httpRequest.Dispose();
 06857                    if (_httpResponse != null)
 6858                    {
 06859                        _httpResponse.Dispose();
 6860                    }
 06861                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 6862                }
 6863            }
 26864            if (_shouldTrace)
 6865            {
 06866                ServiceClientTracing.Exit(_invocationId, _result);
 6867            }
 26868            return _result;
 26869        }
 6870
 6871        /// <summary>
 6872        /// Publish a specific iteration.
 6873        /// </summary>
 6874        /// <param name='projectId'>
 6875        /// The project id.
 6876        /// </param>
 6877        /// <param name='iterationId'>
 6878        /// The iteration id.
 6879        /// </param>
 6880        /// <param name='publishName'>
 6881        /// The name to give the published iteration.
 6882        /// </param>
 6883        /// <param name='predictionId'>
 6884        /// The id of the prediction resource to publish to.
 6885        /// </param>
 6886        /// <param name='overwrite'>
 6887        /// Whether to overwrite the published model with the given name (default:
 6888        /// false).
 6889        /// </param>
 6890        /// <param name='customHeaders'>
 6891        /// Headers that will be added to request.
 6892        /// </param>
 6893        /// <param name='cancellationToken'>
 6894        /// The cancellation token.
 6895        /// </param>
 6896        /// <exception cref="CustomVisionErrorException">
 6897        /// Thrown when the operation returned an invalid status code
 6898        /// </exception>
 6899        /// <exception cref="SerializationException">
 6900        /// Thrown when unable to deserialize the response
 6901        /// </exception>
 6902        /// <exception cref="ValidationException">
 6903        /// Thrown when a required parameter is null
 6904        /// </exception>
 6905        /// <exception cref="System.ArgumentNullException">
 6906        /// Thrown when a required parameter is null
 6907        /// </exception>
 6908        /// <return>
 6909        /// A response object containing the response body and response headers.
 6910        /// </return>
 6911        public async Task<HttpOperationResponse<bool?>> PublishIterationWithHttpMessagesAsync(System.Guid projectId, Sys
 6912        {
 26913            if (Endpoint == null)
 6914            {
 06915                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 6916            }
 26917            if (publishName == null)
 6918            {
 06919                throw new ValidationException(ValidationRules.CannotBeNull, "publishName");
 6920            }
 26921            if (predictionId == null)
 6922            {
 06923                throw new ValidationException(ValidationRules.CannotBeNull, "predictionId");
 6924            }
 6925            // Tracing
 26926            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 26927            string _invocationId = null;
 26928            if (_shouldTrace)
 6929            {
 06930                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 06931                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 06932                tracingParameters.Add("projectId", projectId);
 06933                tracingParameters.Add("iterationId", iterationId);
 06934                tracingParameters.Add("publishName", publishName);
 06935                tracingParameters.Add("predictionId", predictionId);
 06936                tracingParameters.Add("overwrite", overwrite);
 06937                tracingParameters.Add("cancellationToken", cancellationToken);
 06938                ServiceClientTracing.Enter(_invocationId, this, "PublishIteration", tracingParameters);
 6939            }
 6940            // Construct URL
 26941            var _baseUrl = BaseUri;
 26942            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}/p
 26943            _url = _url.Replace("{Endpoint}", Endpoint);
 26944            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 26945            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 26946            List<string> _queryParameters = new List<string>();
 26947            if (publishName != null)
 6948            {
 26949                _queryParameters.Add(string.Format("publishName={0}", System.Uri.EscapeDataString(publishName)));
 6950            }
 26951            if (predictionId != null)
 6952            {
 26953                _queryParameters.Add(string.Format("predictionId={0}", System.Uri.EscapeDataString(predictionId)));
 6954            }
 26955            if (overwrite != null)
 6956            {
 06957                _queryParameters.Add(string.Format("overwrite={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serializ
 6958            }
 26959            if (_queryParameters.Count > 0)
 6960            {
 26961                _url += "?" + string.Join("&", _queryParameters);
 6962            }
 6963            // Create HTTP transport objects
 26964            var _httpRequest = new HttpRequestMessage();
 26965            HttpResponseMessage _httpResponse = null;
 26966            _httpRequest.Method = new HttpMethod("POST");
 26967            _httpRequest.RequestUri = new System.Uri(_url);
 6968            // Set Headers
 6969
 6970
 26971            if (customHeaders != null)
 6972            {
 06973                foreach(var _header in customHeaders)
 6974                {
 06975                    if (_httpRequest.Headers.Contains(_header.Key))
 6976                    {
 06977                        _httpRequest.Headers.Remove(_header.Key);
 6978                    }
 06979                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 6980                }
 6981            }
 6982
 6983            // Serialize Request
 26984            string _requestContent = null;
 6985            // Set Credentials
 26986            if (Credentials != null)
 6987            {
 26988                cancellationToken.ThrowIfCancellationRequested();
 26989                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6990            }
 6991            // Send Request
 26992            if (_shouldTrace)
 6993            {
 06994                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 6995            }
 26996            cancellationToken.ThrowIfCancellationRequested();
 26997            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 26998            if (_shouldTrace)
 6999            {
 07000                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7001            }
 27002            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 27003            cancellationToken.ThrowIfCancellationRequested();
 27004            string _responseContent = null;
 27005            if ((int)_statusCode != 200)
 7006            {
 07007                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 7008                try
 7009                {
 07010                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07011                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 07012                    if (_errorBody != null)
 7013                    {
 07014                        ex.Body = _errorBody;
 7015                    }
 07016                }
 07017                catch (JsonException)
 7018                {
 7019                    // Ignore the exception
 07020                }
 07021                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07022                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07023                if (_shouldTrace)
 7024                {
 07025                    ServiceClientTracing.Error(_invocationId, ex);
 7026                }
 07027                _httpRequest.Dispose();
 07028                if (_httpResponse != null)
 7029                {
 07030                    _httpResponse.Dispose();
 7031                }
 07032                throw ex;
 7033            }
 7034            // Create Result
 27035            var _result = new HttpOperationResponse<bool?>();
 27036            _result.Request = _httpRequest;
 27037            _result.Response = _httpResponse;
 7038            // Deserialize Response
 27039            if ((int)_statusCode == 200)
 7040            {
 27041                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7042                try
 7043                {
 27044                    _result.Body = SafeJsonConvert.DeserializeObject<bool?>(_responseContent, DeserializationSettings);
 27045                }
 07046                catch (JsonException ex)
 7047                {
 07048                    _httpRequest.Dispose();
 07049                    if (_httpResponse != null)
 7050                    {
 07051                        _httpResponse.Dispose();
 7052                    }
 07053                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7054                }
 7055            }
 27056            if (_shouldTrace)
 7057            {
 07058                ServiceClientTracing.Exit(_invocationId, _result);
 7059            }
 27060            return _result;
 27061        }
 7062
 7063        /// <summary>
 7064        /// Unpublish a specific iteration.
 7065        /// </summary>
 7066        /// <param name='projectId'>
 7067        /// The project id.
 7068        /// </param>
 7069        /// <param name='iterationId'>
 7070        /// The iteration id.
 7071        /// </param>
 7072        /// <param name='customHeaders'>
 7073        /// Headers that will be added to request.
 7074        /// </param>
 7075        /// <param name='cancellationToken'>
 7076        /// The cancellation token.
 7077        /// </param>
 7078        /// <exception cref="CustomVisionErrorException">
 7079        /// Thrown when the operation returned an invalid status code
 7080        /// </exception>
 7081        /// <exception cref="ValidationException">
 7082        /// Thrown when a required parameter is null
 7083        /// </exception>
 7084        /// <exception cref="System.ArgumentNullException">
 7085        /// Thrown when a required parameter is null
 7086        /// </exception>
 7087        /// <return>
 7088        /// A response object containing the response body and response headers.
 7089        /// </return>
 7090        public async Task<HttpOperationResponse> UnpublishIterationWithHttpMessagesAsync(System.Guid projectId, System.G
 7091        {
 27092            if (Endpoint == null)
 7093            {
 07094                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 7095            }
 7096            // Tracing
 27097            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 27098            string _invocationId = null;
 27099            if (_shouldTrace)
 7100            {
 07101                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07102                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07103                tracingParameters.Add("projectId", projectId);
 07104                tracingParameters.Add("iterationId", iterationId);
 07105                tracingParameters.Add("cancellationToken", cancellationToken);
 07106                ServiceClientTracing.Enter(_invocationId, this, "UnpublishIteration", tracingParameters);
 7107            }
 7108            // Construct URL
 27109            var _baseUrl = BaseUri;
 27110            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/iterations/{iterationId}/p
 27111            _url = _url.Replace("{Endpoint}", Endpoint);
 27112            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 27113            _url = _url.Replace("{iterationId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(iterationId
 7114            // Create HTTP transport objects
 27115            var _httpRequest = new HttpRequestMessage();
 27116            HttpResponseMessage _httpResponse = null;
 27117            _httpRequest.Method = new HttpMethod("DELETE");
 27118            _httpRequest.RequestUri = new System.Uri(_url);
 7119            // Set Headers
 7120
 7121
 27122            if (customHeaders != null)
 7123            {
 07124                foreach(var _header in customHeaders)
 7125                {
 07126                    if (_httpRequest.Headers.Contains(_header.Key))
 7127                    {
 07128                        _httpRequest.Headers.Remove(_header.Key);
 7129                    }
 07130                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7131                }
 7132            }
 7133
 7134            // Serialize Request
 27135            string _requestContent = null;
 7136            // Set Credentials
 27137            if (Credentials != null)
 7138            {
 27139                cancellationToken.ThrowIfCancellationRequested();
 27140                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7141            }
 7142            // Send Request
 27143            if (_shouldTrace)
 7144            {
 07145                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7146            }
 27147            cancellationToken.ThrowIfCancellationRequested();
 27148            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 27149            if (_shouldTrace)
 7150            {
 07151                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7152            }
 27153            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 27154            cancellationToken.ThrowIfCancellationRequested();
 27155            string _responseContent = null;
 27156            if ((int)_statusCode != 204)
 7157            {
 07158                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 7159                try
 7160                {
 07161                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07162                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 07163                    if (_errorBody != null)
 7164                    {
 07165                        ex.Body = _errorBody;
 7166                    }
 07167                }
 07168                catch (JsonException)
 7169                {
 7170                    // Ignore the exception
 07171                }
 07172                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07173                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07174                if (_shouldTrace)
 7175                {
 07176                    ServiceClientTracing.Error(_invocationId, ex);
 7177                }
 07178                _httpRequest.Dispose();
 07179                if (_httpResponse != null)
 7180                {
 07181                    _httpResponse.Dispose();
 7182                }
 07183                throw ex;
 7184            }
 7185            // Create Result
 27186            var _result = new HttpOperationResponse();
 27187            _result.Request = _httpRequest;
 27188            _result.Response = _httpResponse;
 27189            if (_shouldTrace)
 7190            {
 07191                ServiceClientTracing.Exit(_invocationId, _result);
 7192            }
 27193            return _result;
 27194        }
 7195
 7196        /// <summary>
 7197        /// Delete a set of predicted images and their associated prediction results.
 7198        /// </summary>
 7199        /// <param name='projectId'>
 7200        /// The project id.
 7201        /// </param>
 7202        /// <param name='ids'>
 7203        /// The prediction ids. Limited to 64.
 7204        /// </param>
 7205        /// <param name='customHeaders'>
 7206        /// Headers that will be added to request.
 7207        /// </param>
 7208        /// <param name='cancellationToken'>
 7209        /// The cancellation token.
 7210        /// </param>
 7211        /// <exception cref="CustomVisionErrorException">
 7212        /// Thrown when the operation returned an invalid status code
 7213        /// </exception>
 7214        /// <exception cref="ValidationException">
 7215        /// Thrown when a required parameter is null
 7216        /// </exception>
 7217        /// <exception cref="System.ArgumentNullException">
 7218        /// Thrown when a required parameter is null
 7219        /// </exception>
 7220        /// <return>
 7221        /// A response object containing the response body and response headers.
 7222        /// </return>
 7223        public async Task<HttpOperationResponse> DeletePredictionWithHttpMessagesAsync(System.Guid projectId, IList<Syst
 7224        {
 27225            if (Endpoint == null)
 7226            {
 07227                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 7228            }
 27229            if (ids == null)
 7230            {
 07231                throw new ValidationException(ValidationRules.CannotBeNull, "ids");
 7232            }
 27233            if (ids != null)
 7234            {
 27235                if (ids.Count > 64)
 7236                {
 07237                    throw new ValidationException(ValidationRules.MaxItems, "ids", 64);
 7238                }
 27239                if (ids.Count < 0)
 7240                {
 07241                    throw new ValidationException(ValidationRules.MinItems, "ids", 0);
 7242                }
 7243            }
 7244            // Tracing
 27245            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 27246            string _invocationId = null;
 27247            if (_shouldTrace)
 7248            {
 07249                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07250                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07251                tracingParameters.Add("projectId", projectId);
 07252                tracingParameters.Add("ids", ids);
 07253                tracingParameters.Add("cancellationToken", cancellationToken);
 07254                ServiceClientTracing.Enter(_invocationId, this, "DeletePrediction", tracingParameters);
 7255            }
 7256            // Construct URL
 27257            var _baseUrl = BaseUri;
 27258            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/predictions";
 27259            _url = _url.Replace("{Endpoint}", Endpoint);
 27260            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 27261            List<string> _queryParameters = new List<string>();
 27262            if (ids != null)
 7263            {
 27264                _queryParameters.Add(string.Format("ids={0}", System.Uri.EscapeDataString(string.Join(",", ids))));
 7265            }
 27266            if (_queryParameters.Count > 0)
 7267            {
 27268                _url += "?" + string.Join("&", _queryParameters);
 7269            }
 7270            // Create HTTP transport objects
 27271            var _httpRequest = new HttpRequestMessage();
 27272            HttpResponseMessage _httpResponse = null;
 27273            _httpRequest.Method = new HttpMethod("DELETE");
 27274            _httpRequest.RequestUri = new System.Uri(_url);
 7275            // Set Headers
 7276
 7277
 27278            if (customHeaders != null)
 7279            {
 07280                foreach(var _header in customHeaders)
 7281                {
 07282                    if (_httpRequest.Headers.Contains(_header.Key))
 7283                    {
 07284                        _httpRequest.Headers.Remove(_header.Key);
 7285                    }
 07286                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7287                }
 7288            }
 7289
 7290            // Serialize Request
 27291            string _requestContent = null;
 7292            // Set Credentials
 27293            if (Credentials != null)
 7294            {
 27295                cancellationToken.ThrowIfCancellationRequested();
 27296                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7297            }
 7298            // Send Request
 27299            if (_shouldTrace)
 7300            {
 07301                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7302            }
 27303            cancellationToken.ThrowIfCancellationRequested();
 27304            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 27305            if (_shouldTrace)
 7306            {
 07307                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7308            }
 27309            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 27310            cancellationToken.ThrowIfCancellationRequested();
 27311            string _responseContent = null;
 27312            if ((int)_statusCode != 204)
 7313            {
 07314                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 7315                try
 7316                {
 07317                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07318                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 07319                    if (_errorBody != null)
 7320                    {
 07321                        ex.Body = _errorBody;
 7322                    }
 07323                }
 07324                catch (JsonException)
 7325                {
 7326                    // Ignore the exception
 07327                }
 07328                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07329                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07330                if (_shouldTrace)
 7331                {
 07332                    ServiceClientTracing.Error(_invocationId, ex);
 7333                }
 07334                _httpRequest.Dispose();
 07335                if (_httpResponse != null)
 7336                {
 07337                    _httpResponse.Dispose();
 7338                }
 07339                throw ex;
 7340            }
 7341            // Create Result
 27342            var _result = new HttpOperationResponse();
 27343            _result.Request = _httpRequest;
 27344            _result.Response = _httpResponse;
 27345            if (_shouldTrace)
 7346            {
 07347                ServiceClientTracing.Exit(_invocationId, _result);
 7348            }
 27349            return _result;
 27350        }
 7351
 7352        /// <summary>
 7353        /// Get images that were sent to your prediction endpoint.
 7354        /// </summary>
 7355        /// <param name='projectId'>
 7356        /// The project id.
 7357        /// </param>
 7358        /// <param name='query'>
 7359        /// Parameters used to query the predictions. Limited to combining 2 tags.
 7360        /// </param>
 7361        /// <param name='customHeaders'>
 7362        /// Headers that will be added to request.
 7363        /// </param>
 7364        /// <param name='cancellationToken'>
 7365        /// The cancellation token.
 7366        /// </param>
 7367        /// <exception cref="CustomVisionErrorException">
 7368        /// Thrown when the operation returned an invalid status code
 7369        /// </exception>
 7370        /// <exception cref="SerializationException">
 7371        /// Thrown when unable to deserialize the response
 7372        /// </exception>
 7373        /// <exception cref="ValidationException">
 7374        /// Thrown when a required parameter is null
 7375        /// </exception>
 7376        /// <exception cref="System.ArgumentNullException">
 7377        /// Thrown when a required parameter is null
 7378        /// </exception>
 7379        /// <return>
 7380        /// A response object containing the response body and response headers.
 7381        /// </return>
 7382        public async Task<HttpOperationResponse<PredictionQueryResult>> QueryPredictionsWithHttpMessagesAsync(System.Gui
 7383        {
 47384            if (Endpoint == null)
 7385            {
 07386                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 7387            }
 47388            if (query == null)
 7389            {
 07390                throw new ValidationException(ValidationRules.CannotBeNull, "query");
 7391            }
 7392            // Tracing
 47393            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 47394            string _invocationId = null;
 47395            if (_shouldTrace)
 7396            {
 07397                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07398                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07399                tracingParameters.Add("projectId", projectId);
 07400                tracingParameters.Add("query", query);
 07401                tracingParameters.Add("cancellationToken", cancellationToken);
 07402                ServiceClientTracing.Enter(_invocationId, this, "QueryPredictions", tracingParameters);
 7403            }
 7404            // Construct URL
 47405            var _baseUrl = BaseUri;
 47406            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/predictions/query";
 47407            _url = _url.Replace("{Endpoint}", Endpoint);
 47408            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 7409            // Create HTTP transport objects
 47410            var _httpRequest = new HttpRequestMessage();
 47411            HttpResponseMessage _httpResponse = null;
 47412            _httpRequest.Method = new HttpMethod("POST");
 47413            _httpRequest.RequestUri = new System.Uri(_url);
 7414            // Set Headers
 7415
 7416
 47417            if (customHeaders != null)
 7418            {
 07419                foreach(var _header in customHeaders)
 7420                {
 07421                    if (_httpRequest.Headers.Contains(_header.Key))
 7422                    {
 07423                        _httpRequest.Headers.Remove(_header.Key);
 7424                    }
 07425                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7426                }
 7427            }
 7428
 7429            // Serialize Request
 47430            string _requestContent = null;
 47431            if(query != null)
 7432            {
 47433                _requestContent = SafeJsonConvert.SerializeObject(query, SerializationSettings);
 47434                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 47435                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 7436            }
 7437            // Set Credentials
 47438            if (Credentials != null)
 7439            {
 47440                cancellationToken.ThrowIfCancellationRequested();
 47441                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7442            }
 7443            // Send Request
 47444            if (_shouldTrace)
 7445            {
 07446                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7447            }
 47448            cancellationToken.ThrowIfCancellationRequested();
 47449            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 47450            if (_shouldTrace)
 7451            {
 07452                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7453            }
 47454            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 47455            cancellationToken.ThrowIfCancellationRequested();
 47456            string _responseContent = null;
 47457            if ((int)_statusCode != 200)
 7458            {
 07459                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 7460                try
 7461                {
 07462                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07463                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 07464                    if (_errorBody != null)
 7465                    {
 07466                        ex.Body = _errorBody;
 7467                    }
 07468                }
 07469                catch (JsonException)
 7470                {
 7471                    // Ignore the exception
 07472                }
 07473                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07474                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07475                if (_shouldTrace)
 7476                {
 07477                    ServiceClientTracing.Error(_invocationId, ex);
 7478                }
 07479                _httpRequest.Dispose();
 07480                if (_httpResponse != null)
 7481                {
 07482                    _httpResponse.Dispose();
 7483                }
 07484                throw ex;
 7485            }
 7486            // Create Result
 47487            var _result = new HttpOperationResponse<PredictionQueryResult>();
 47488            _result.Request = _httpRequest;
 47489            _result.Response = _httpResponse;
 7490            // Deserialize Response
 47491            if ((int)_statusCode == 200)
 7492            {
 47493                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7494                try
 7495                {
 47496                    _result.Body = SafeJsonConvert.DeserializeObject<PredictionQueryResult>(_responseContent, Deserializ
 47497                }
 07498                catch (JsonException ex)
 7499                {
 07500                    _httpRequest.Dispose();
 07501                    if (_httpResponse != null)
 7502                    {
 07503                        _httpResponse.Dispose();
 7504                    }
 07505                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7506                }
 7507            }
 47508            if (_shouldTrace)
 7509            {
 07510                ServiceClientTracing.Exit(_invocationId, _result);
 7511            }
 47512            return _result;
 47513        }
 7514
 7515        /// <summary>
 7516        /// Quick test an image.
 7517        /// </summary>
 7518        /// <param name='projectId'>
 7519        /// The project id.
 7520        /// </param>
 7521        /// <param name='imageData'>
 7522        /// Binary image data. Supported formats are JPEG, GIF, PNG, and BMP. Supports
 7523        /// images up to 6MB.
 7524        /// </param>
 7525        /// <param name='iterationId'>
 7526        /// Optional. Specifies the id of a particular iteration to evaluate against.
 7527        /// The default iteration for the project will be used when not specified.
 7528        /// </param>
 7529        /// <param name='store'>
 7530        /// Optional. Specifies whether or not to store the result of this prediction.
 7531        /// The default is true, to store.
 7532        /// </param>
 7533        /// <param name='customHeaders'>
 7534        /// Headers that will be added to request.
 7535        /// </param>
 7536        /// <param name='cancellationToken'>
 7537        /// The cancellation token.
 7538        /// </param>
 7539        /// <exception cref="CustomVisionErrorException">
 7540        /// Thrown when the operation returned an invalid status code
 7541        /// </exception>
 7542        /// <exception cref="SerializationException">
 7543        /// Thrown when unable to deserialize the response
 7544        /// </exception>
 7545        /// <exception cref="ValidationException">
 7546        /// Thrown when a required parameter is null
 7547        /// </exception>
 7548        /// <exception cref="System.ArgumentNullException">
 7549        /// Thrown when a required parameter is null
 7550        /// </exception>
 7551        /// <return>
 7552        /// A response object containing the response body and response headers.
 7553        /// </return>
 7554        public async Task<HttpOperationResponse<ImagePrediction>> QuickTestImageWithHttpMessagesAsync(System.Guid projec
 7555        {
 7556            if (Endpoint == null)
 7557            {
 7558                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 7559            }
 7560            if (imageData == null)
 7561            {
 7562                throw new ValidationException(ValidationRules.CannotBeNull, "imageData");
 7563            }
 7564            // Tracing
 7565            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 7566            string _invocationId = null;
 7567            if (_shouldTrace)
 7568            {
 7569                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 7570                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 7571                tracingParameters.Add("projectId", projectId);
 7572                tracingParameters.Add("iterationId", iterationId);
 7573                tracingParameters.Add("store", store);
 7574                tracingParameters.Add("imageData", imageData);
 7575                tracingParameters.Add("cancellationToken", cancellationToken);
 7576                ServiceClientTracing.Enter(_invocationId, this, "QuickTestImage", tracingParameters);
 7577            }
 7578            // Construct URL
 7579            var _baseUrl = BaseUri;
 7580            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/quicktest/image";
 7581            _url = _url.Replace("{Endpoint}", Endpoint);
 7582            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 7583            List<string> _queryParameters = new List<string>();
 7584            if (iterationId != null)
 7585            {
 7586                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 7587            }
 7588            if (store != null)
 7589            {
 7590                _queryParameters.Add(string.Format("store={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObj
 7591            }
 7592            if (_queryParameters.Count > 0)
 7593            {
 7594                _url += "?" + string.Join("&", _queryParameters);
 7595            }
 7596            // Create HTTP transport objects
 7597            var _httpRequest = new HttpRequestMessage();
 7598            HttpResponseMessage _httpResponse = null;
 7599            _httpRequest.Method = new HttpMethod("POST");
 7600            _httpRequest.RequestUri = new System.Uri(_url);
 7601            // Set Headers
 7602
 7603
 7604            if (customHeaders != null)
 7605            {
 7606                foreach(var _header in customHeaders)
 7607                {
 7608                    if (_httpRequest.Headers.Contains(_header.Key))
 7609                    {
 7610                        _httpRequest.Headers.Remove(_header.Key);
 7611                    }
 7612                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7613                }
 7614            }
 7615
 7616            // Serialize Request
 7617            string _requestContent = null;
 7618            MultipartFormDataContent _multiPartContent = new MultipartFormDataContent();
 7619            if (imageData != null)
 7620            {
 7621                StreamContent _imageData = new StreamContent(imageData);
 7622                _imageData.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
 7623                ContentDispositionHeaderValue _contentDispositionHeaderValue = new ContentDispositionHeaderValue("form-d
 7624                _contentDispositionHeaderValue.Name = "imageData";
 7625                // get filename from stream if it's a file otherwise, just use  'unknown'
 7626                var _fileStream = imageData as FileStream;
 7627                var _fileName = (_fileStream != null ? _fileStream.Name : null) ?? "unknown";
 6307628                if(System.Linq.Enumerable.Any(_fileName, c => c > 127) )
 7629                {
 7630                    // non ASCII chars detected, need UTF encoding:
 7631                    _contentDispositionHeaderValue.FileNameStar = _fileName;
 7632                }
 7633                else
 7634                {
 7635                    // ASCII only
 7636                    _contentDispositionHeaderValue.FileName = _fileName;
 7637                }
 7638                _imageData.Headers.ContentDisposition = _contentDispositionHeaderValue;
 7639                _multiPartContent.Add(_imageData, "imageData");
 7640            }
 7641            _httpRequest.Content = _multiPartContent;
 7642            // Set Credentials
 7643            if (Credentials != null)
 7644            {
 7645                cancellationToken.ThrowIfCancellationRequested();
 7646                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7647            }
 7648            // Send Request
 7649            if (_shouldTrace)
 7650            {
 7651                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7652            }
 7653            cancellationToken.ThrowIfCancellationRequested();
 7654            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7655            if (_shouldTrace)
 7656            {
 7657                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7658            }
 7659            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 7660            cancellationToken.ThrowIfCancellationRequested();
 7661            string _responseContent = null;
 7662            if ((int)_statusCode != 200)
 7663            {
 7664                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 7665                try
 7666                {
 7667                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7668                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 7669                    if (_errorBody != null)
 7670                    {
 7671                        ex.Body = _errorBody;
 7672                    }
 7673                }
 7674                catch (JsonException)
 7675                {
 7676                    // Ignore the exception
 7677                }
 7678                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 7679                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 7680                if (_shouldTrace)
 7681                {
 7682                    ServiceClientTracing.Error(_invocationId, ex);
 7683                }
 7684                _httpRequest.Dispose();
 7685                if (_httpResponse != null)
 7686                {
 7687                    _httpResponse.Dispose();
 7688                }
 7689                throw ex;
 7690            }
 7691            // Create Result
 7692            var _result = new HttpOperationResponse<ImagePrediction>();
 7693            _result.Request = _httpRequest;
 7694            _result.Response = _httpResponse;
 7695            // Deserialize Response
 7696            if ((int)_statusCode == 200)
 7697            {
 7698                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7699                try
 7700                {
 7701                    _result.Body = SafeJsonConvert.DeserializeObject<ImagePrediction>(_responseContent, DeserializationS
 7702                }
 7703                catch (JsonException ex)
 7704                {
 7705                    _httpRequest.Dispose();
 7706                    if (_httpResponse != null)
 7707                    {
 7708                        _httpResponse.Dispose();
 7709                    }
 7710                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7711                }
 7712            }
 7713            if (_shouldTrace)
 7714            {
 7715                ServiceClientTracing.Exit(_invocationId, _result);
 7716            }
 7717            return _result;
 7718        }
 7719
 7720        /// <summary>
 7721        /// Quick test an image url.
 7722        /// </summary>
 7723        /// <param name='projectId'>
 7724        /// The project to evaluate against.
 7725        /// </param>
 7726        /// <param name='imageUrl'>
 7727        /// An ImageUrl that contains the url of the image to be evaluated.
 7728        /// </param>
 7729        /// <param name='iterationId'>
 7730        /// Optional. Specifies the id of a particular iteration to evaluate against.
 7731        /// The default iteration for the project will be used when not specified.
 7732        /// </param>
 7733        /// <param name='store'>
 7734        /// Optional. Specifies whether or not to store the result of this prediction.
 7735        /// The default is true, to store.
 7736        /// </param>
 7737        /// <param name='customHeaders'>
 7738        /// Headers that will be added to request.
 7739        /// </param>
 7740        /// <param name='cancellationToken'>
 7741        /// The cancellation token.
 7742        /// </param>
 7743        /// <exception cref="CustomVisionErrorException">
 7744        /// Thrown when the operation returned an invalid status code
 7745        /// </exception>
 7746        /// <exception cref="SerializationException">
 7747        /// Thrown when unable to deserialize the response
 7748        /// </exception>
 7749        /// <exception cref="ValidationException">
 7750        /// Thrown when a required parameter is null
 7751        /// </exception>
 7752        /// <exception cref="System.ArgumentNullException">
 7753        /// Thrown when a required parameter is null
 7754        /// </exception>
 7755        /// <return>
 7756        /// A response object containing the response body and response headers.
 7757        /// </return>
 7758        public async Task<HttpOperationResponse<ImagePrediction>> QuickTestImageUrlWithHttpMessagesAsync(System.Guid pro
 7759        {
 47760            if (Endpoint == null)
 7761            {
 07762                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 7763            }
 47764            if (imageUrl == null)
 7765            {
 07766                throw new ValidationException(ValidationRules.CannotBeNull, "imageUrl");
 7767            }
 47768            if (imageUrl != null)
 7769            {
 47770                imageUrl.Validate();
 7771            }
 7772            // Tracing
 47773            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 47774            string _invocationId = null;
 47775            if (_shouldTrace)
 7776            {
 07777                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07778                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07779                tracingParameters.Add("projectId", projectId);
 07780                tracingParameters.Add("imageUrl", imageUrl);
 07781                tracingParameters.Add("iterationId", iterationId);
 07782                tracingParameters.Add("store", store);
 07783                tracingParameters.Add("cancellationToken", cancellationToken);
 07784                ServiceClientTracing.Enter(_invocationId, this, "QuickTestImageUrl", tracingParameters);
 7785            }
 7786            // Construct URL
 47787            var _baseUrl = BaseUri;
 47788            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/quicktest/url";
 47789            _url = _url.Replace("{Endpoint}", Endpoint);
 47790            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 47791            List<string> _queryParameters = new List<string>();
 47792            if (iterationId != null)
 7793            {
 47794                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 7795            }
 47796            if (store != null)
 7797            {
 47798                _queryParameters.Add(string.Format("store={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObj
 7799            }
 47800            if (_queryParameters.Count > 0)
 7801            {
 47802                _url += "?" + string.Join("&", _queryParameters);
 7803            }
 7804            // Create HTTP transport objects
 47805            var _httpRequest = new HttpRequestMessage();
 47806            HttpResponseMessage _httpResponse = null;
 47807            _httpRequest.Method = new HttpMethod("POST");
 47808            _httpRequest.RequestUri = new System.Uri(_url);
 7809            // Set Headers
 7810
 7811
 47812            if (customHeaders != null)
 7813            {
 07814                foreach(var _header in customHeaders)
 7815                {
 07816                    if (_httpRequest.Headers.Contains(_header.Key))
 7817                    {
 07818                        _httpRequest.Headers.Remove(_header.Key);
 7819                    }
 07820                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7821                }
 7822            }
 7823
 7824            // Serialize Request
 47825            string _requestContent = null;
 47826            if(imageUrl != null)
 7827            {
 47828                _requestContent = SafeJsonConvert.SerializeObject(imageUrl, SerializationSettings);
 47829                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 47830                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 7831            }
 7832            // Set Credentials
 47833            if (Credentials != null)
 7834            {
 47835                cancellationToken.ThrowIfCancellationRequested();
 47836                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7837            }
 7838            // Send Request
 47839            if (_shouldTrace)
 7840            {
 07841                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 7842            }
 47843            cancellationToken.ThrowIfCancellationRequested();
 47844            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 47845            if (_shouldTrace)
 7846            {
 07847                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 7848            }
 47849            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 47850            cancellationToken.ThrowIfCancellationRequested();
 47851            string _responseContent = null;
 47852            if ((int)_statusCode != 200)
 7853            {
 07854                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 7855                try
 7856                {
 07857                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 07858                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 07859                    if (_errorBody != null)
 7860                    {
 07861                        ex.Body = _errorBody;
 7862                    }
 07863                }
 07864                catch (JsonException)
 7865                {
 7866                    // Ignore the exception
 07867                }
 07868                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 07869                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 07870                if (_shouldTrace)
 7871                {
 07872                    ServiceClientTracing.Error(_invocationId, ex);
 7873                }
 07874                _httpRequest.Dispose();
 07875                if (_httpResponse != null)
 7876                {
 07877                    _httpResponse.Dispose();
 7878                }
 07879                throw ex;
 7880            }
 7881            // Create Result
 47882            var _result = new HttpOperationResponse<ImagePrediction>();
 47883            _result.Request = _httpRequest;
 47884            _result.Response = _httpResponse;
 7885            // Deserialize Response
 47886            if ((int)_statusCode == 200)
 7887            {
 47888                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 7889                try
 7890                {
 47891                    _result.Body = SafeJsonConvert.DeserializeObject<ImagePrediction>(_responseContent, DeserializationS
 47892                }
 07893                catch (JsonException ex)
 7894                {
 07895                    _httpRequest.Dispose();
 07896                    if (_httpResponse != null)
 7897                    {
 07898                        _httpResponse.Dispose();
 7899                    }
 07900                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 7901                }
 7902            }
 47903            if (_shouldTrace)
 7904            {
 07905                ServiceClientTracing.Exit(_invocationId, _result);
 7906            }
 47907            return _result;
 47908        }
 7909
 7910        /// <summary>
 7911        /// Get the tags for a given project and iteration.
 7912        /// </summary>
 7913        /// <param name='projectId'>
 7914        /// The project id.
 7915        /// </param>
 7916        /// <param name='iterationId'>
 7917        /// The iteration id. Defaults to workspace.
 7918        /// </param>
 7919        /// <param name='customHeaders'>
 7920        /// Headers that will be added to request.
 7921        /// </param>
 7922        /// <param name='cancellationToken'>
 7923        /// The cancellation token.
 7924        /// </param>
 7925        /// <exception cref="CustomVisionErrorException">
 7926        /// Thrown when the operation returned an invalid status code
 7927        /// </exception>
 7928        /// <exception cref="SerializationException">
 7929        /// Thrown when unable to deserialize the response
 7930        /// </exception>
 7931        /// <exception cref="ValidationException">
 7932        /// Thrown when a required parameter is null
 7933        /// </exception>
 7934        /// <exception cref="System.ArgumentNullException">
 7935        /// Thrown when a required parameter is null
 7936        /// </exception>
 7937        /// <return>
 7938        /// A response object containing the response body and response headers.
 7939        /// </return>
 7940        public async Task<HttpOperationResponse<IList<Tag>>> GetTagsWithHttpMessagesAsync(System.Guid projectId, System.
 7941        {
 127942            if (Endpoint == null)
 7943            {
 07944                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 7945            }
 7946            // Tracing
 127947            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 127948            string _invocationId = null;
 127949            if (_shouldTrace)
 7950            {
 07951                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 07952                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 07953                tracingParameters.Add("projectId", projectId);
 07954                tracingParameters.Add("iterationId", iterationId);
 07955                tracingParameters.Add("cancellationToken", cancellationToken);
 07956                ServiceClientTracing.Enter(_invocationId, this, "GetTags", tracingParameters);
 7957            }
 7958            // Construct URL
 127959            var _baseUrl = BaseUri;
 127960            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/tags";
 127961            _url = _url.Replace("{Endpoint}", Endpoint);
 127962            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 127963            List<string> _queryParameters = new List<string>();
 127964            if (iterationId != null)
 7965            {
 47966                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 7967            }
 127968            if (_queryParameters.Count > 0)
 7969            {
 47970                _url += "?" + string.Join("&", _queryParameters);
 7971            }
 7972            // Create HTTP transport objects
 127973            var _httpRequest = new HttpRequestMessage();
 127974            HttpResponseMessage _httpResponse = null;
 127975            _httpRequest.Method = new HttpMethod("GET");
 127976            _httpRequest.RequestUri = new System.Uri(_url);
 7977            // Set Headers
 7978
 7979
 127980            if (customHeaders != null)
 7981            {
 07982                foreach(var _header in customHeaders)
 7983                {
 07984                    if (_httpRequest.Headers.Contains(_header.Key))
 7985                    {
 07986                        _httpRequest.Headers.Remove(_header.Key);
 7987                    }
 07988                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 7989                }
 7990            }
 7991
 7992            // Serialize Request
 127993            string _requestContent = null;
 7994            // Set Credentials
 127995            if (Credentials != null)
 7996            {
 127997                cancellationToken.ThrowIfCancellationRequested();
 127998                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 7999            }
 8000            // Send Request
 128001            if (_shouldTrace)
 8002            {
 08003                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8004            }
 128005            cancellationToken.ThrowIfCancellationRequested();
 128006            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 128007            if (_shouldTrace)
 8008            {
 08009                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8010            }
 128011            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 128012            cancellationToken.ThrowIfCancellationRequested();
 128013            string _responseContent = null;
 128014            if ((int)_statusCode != 200)
 8015            {
 08016                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 8017                try
 8018                {
 08019                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08020                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 08021                    if (_errorBody != null)
 8022                    {
 08023                        ex.Body = _errorBody;
 8024                    }
 08025                }
 08026                catch (JsonException)
 8027                {
 8028                    // Ignore the exception
 08029                }
 08030                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08031                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08032                if (_shouldTrace)
 8033                {
 08034                    ServiceClientTracing.Error(_invocationId, ex);
 8035                }
 08036                _httpRequest.Dispose();
 08037                if (_httpResponse != null)
 8038                {
 08039                    _httpResponse.Dispose();
 8040                }
 08041                throw ex;
 8042            }
 8043            // Create Result
 128044            var _result = new HttpOperationResponse<IList<Tag>>();
 128045            _result.Request = _httpRequest;
 128046            _result.Response = _httpResponse;
 8047            // Deserialize Response
 128048            if ((int)_statusCode == 200)
 8049            {
 128050                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8051                try
 8052                {
 128053                    _result.Body = SafeJsonConvert.DeserializeObject<IList<Tag>>(_responseContent, DeserializationSettin
 128054                }
 08055                catch (JsonException ex)
 8056                {
 08057                    _httpRequest.Dispose();
 08058                    if (_httpResponse != null)
 8059                    {
 08060                        _httpResponse.Dispose();
 8061                    }
 08062                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8063                }
 8064            }
 128065            if (_shouldTrace)
 8066            {
 08067                ServiceClientTracing.Exit(_invocationId, _result);
 8068            }
 128069            return _result;
 128070        }
 8071
 8072        /// <summary>
 8073        /// Create a tag for the project.
 8074        /// </summary>
 8075        /// <param name='projectId'>
 8076        /// The project id.
 8077        /// </param>
 8078        /// <param name='name'>
 8079        /// The tag name.
 8080        /// </param>
 8081        /// <param name='description'>
 8082        /// Optional description for the tag.
 8083        /// </param>
 8084        /// <param name='type'>
 8085        /// Optional type for the tag. Possible values include: 'Regular', 'Negative',
 8086        /// 'GeneralProduct'
 8087        /// </param>
 8088        /// <param name='customHeaders'>
 8089        /// Headers that will be added to request.
 8090        /// </param>
 8091        /// <param name='cancellationToken'>
 8092        /// The cancellation token.
 8093        /// </param>
 8094        /// <exception cref="CustomVisionErrorException">
 8095        /// Thrown when the operation returned an invalid status code
 8096        /// </exception>
 8097        /// <exception cref="SerializationException">
 8098        /// Thrown when unable to deserialize the response
 8099        /// </exception>
 8100        /// <exception cref="ValidationException">
 8101        /// Thrown when a required parameter is null
 8102        /// </exception>
 8103        /// <exception cref="System.ArgumentNullException">
 8104        /// Thrown when a required parameter is null
 8105        /// </exception>
 8106        /// <return>
 8107        /// A response object containing the response body and response headers.
 8108        /// </return>
 8109        public async Task<HttpOperationResponse<Tag>> CreateTagWithHttpMessagesAsync(System.Guid projectId, string name,
 8110        {
 188111            if (Endpoint == null)
 8112            {
 08113                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 8114            }
 188115            if (name == null)
 8116            {
 08117                throw new ValidationException(ValidationRules.CannotBeNull, "name");
 8118            }
 8119            // Tracing
 188120            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 188121            string _invocationId = null;
 188122            if (_shouldTrace)
 8123            {
 08124                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08125                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08126                tracingParameters.Add("projectId", projectId);
 08127                tracingParameters.Add("name", name);
 08128                tracingParameters.Add("description", description);
 08129                tracingParameters.Add("type", type);
 08130                tracingParameters.Add("cancellationToken", cancellationToken);
 08131                ServiceClientTracing.Enter(_invocationId, this, "CreateTag", tracingParameters);
 8132            }
 8133            // Construct URL
 188134            var _baseUrl = BaseUri;
 188135            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/tags";
 188136            _url = _url.Replace("{Endpoint}", Endpoint);
 188137            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 188138            List<string> _queryParameters = new List<string>();
 188139            if (name != null)
 8140            {
 188141                _queryParameters.Add(string.Format("name={0}", System.Uri.EscapeDataString(name)));
 8142            }
 188143            if (description != null)
 8144            {
 108145                _queryParameters.Add(string.Format("description={0}", System.Uri.EscapeDataString(description)));
 8146            }
 188147            if (type != null)
 8148            {
 08149                _queryParameters.Add(string.Format("type={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObje
 8150            }
 188151            if (_queryParameters.Count > 0)
 8152            {
 188153                _url += "?" + string.Join("&", _queryParameters);
 8154            }
 8155            // Create HTTP transport objects
 188156            var _httpRequest = new HttpRequestMessage();
 188157            HttpResponseMessage _httpResponse = null;
 188158            _httpRequest.Method = new HttpMethod("POST");
 188159            _httpRequest.RequestUri = new System.Uri(_url);
 8160            // Set Headers
 8161
 8162
 188163            if (customHeaders != null)
 8164            {
 08165                foreach(var _header in customHeaders)
 8166                {
 08167                    if (_httpRequest.Headers.Contains(_header.Key))
 8168                    {
 08169                        _httpRequest.Headers.Remove(_header.Key);
 8170                    }
 08171                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8172                }
 8173            }
 8174
 8175            // Serialize Request
 188176            string _requestContent = null;
 8177            // Set Credentials
 188178            if (Credentials != null)
 8179            {
 188180                cancellationToken.ThrowIfCancellationRequested();
 188181                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8182            }
 8183            // Send Request
 188184            if (_shouldTrace)
 8185            {
 08186                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8187            }
 188188            cancellationToken.ThrowIfCancellationRequested();
 188189            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 188190            if (_shouldTrace)
 8191            {
 08192                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8193            }
 188194            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 188195            cancellationToken.ThrowIfCancellationRequested();
 188196            string _responseContent = null;
 188197            if ((int)_statusCode != 200)
 8198            {
 08199                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 8200                try
 8201                {
 08202                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08203                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 08204                    if (_errorBody != null)
 8205                    {
 08206                        ex.Body = _errorBody;
 8207                    }
 08208                }
 08209                catch (JsonException)
 8210                {
 8211                    // Ignore the exception
 08212                }
 08213                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08214                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08215                if (_shouldTrace)
 8216                {
 08217                    ServiceClientTracing.Error(_invocationId, ex);
 8218                }
 08219                _httpRequest.Dispose();
 08220                if (_httpResponse != null)
 8221                {
 08222                    _httpResponse.Dispose();
 8223                }
 08224                throw ex;
 8225            }
 8226            // Create Result
 188227            var _result = new HttpOperationResponse<Tag>();
 188228            _result.Request = _httpRequest;
 188229            _result.Response = _httpResponse;
 8230            // Deserialize Response
 188231            if ((int)_statusCode == 200)
 8232            {
 188233                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8234                try
 8235                {
 188236                    _result.Body = SafeJsonConvert.DeserializeObject<Tag>(_responseContent, DeserializationSettings);
 188237                }
 08238                catch (JsonException ex)
 8239                {
 08240                    _httpRequest.Dispose();
 08241                    if (_httpResponse != null)
 8242                    {
 08243                        _httpResponse.Dispose();
 8244                    }
 08245                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8246                }
 8247            }
 188248            if (_shouldTrace)
 8249            {
 08250                ServiceClientTracing.Exit(_invocationId, _result);
 8251            }
 188252            return _result;
 188253        }
 8254
 8255        /// <summary>
 8256        /// Get information about a specific tag.
 8257        /// </summary>
 8258        /// <param name='projectId'>
 8259        /// The project this tag belongs to.
 8260        /// </param>
 8261        /// <param name='tagId'>
 8262        /// The tag id.
 8263        /// </param>
 8264        /// <param name='iterationId'>
 8265        /// The iteration to retrieve this tag from. Optional, defaults to current
 8266        /// training set.
 8267        /// </param>
 8268        /// <param name='customHeaders'>
 8269        /// Headers that will be added to request.
 8270        /// </param>
 8271        /// <param name='cancellationToken'>
 8272        /// The cancellation token.
 8273        /// </param>
 8274        /// <exception cref="CustomVisionErrorException">
 8275        /// Thrown when the operation returned an invalid status code
 8276        /// </exception>
 8277        /// <exception cref="SerializationException">
 8278        /// Thrown when unable to deserialize the response
 8279        /// </exception>
 8280        /// <exception cref="ValidationException">
 8281        /// Thrown when a required parameter is null
 8282        /// </exception>
 8283        /// <exception cref="System.ArgumentNullException">
 8284        /// Thrown when a required parameter is null
 8285        /// </exception>
 8286        /// <return>
 8287        /// A response object containing the response body and response headers.
 8288        /// </return>
 8289        public async Task<HttpOperationResponse<Tag>> GetTagWithHttpMessagesAsync(System.Guid projectId, System.Guid tag
 8290        {
 48291            if (Endpoint == null)
 8292            {
 08293                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 8294            }
 8295            // Tracing
 48296            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 48297            string _invocationId = null;
 48298            if (_shouldTrace)
 8299            {
 08300                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08301                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08302                tracingParameters.Add("projectId", projectId);
 08303                tracingParameters.Add("tagId", tagId);
 08304                tracingParameters.Add("iterationId", iterationId);
 08305                tracingParameters.Add("cancellationToken", cancellationToken);
 08306                ServiceClientTracing.Enter(_invocationId, this, "GetTag", tracingParameters);
 8307            }
 8308            // Construct URL
 48309            var _baseUrl = BaseUri;
 48310            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/tags/{tagId}";
 48311            _url = _url.Replace("{Endpoint}", Endpoint);
 48312            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 48313            _url = _url.Replace("{tagId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(tagId, Serializat
 48314            List<string> _queryParameters = new List<string>();
 48315            if (iterationId != null)
 8316            {
 48317                _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.Serial
 8318            }
 48319            if (_queryParameters.Count > 0)
 8320            {
 48321                _url += "?" + string.Join("&", _queryParameters);
 8322            }
 8323            // Create HTTP transport objects
 48324            var _httpRequest = new HttpRequestMessage();
 48325            HttpResponseMessage _httpResponse = null;
 48326            _httpRequest.Method = new HttpMethod("GET");
 48327            _httpRequest.RequestUri = new System.Uri(_url);
 8328            // Set Headers
 8329
 8330
 48331            if (customHeaders != null)
 8332            {
 08333                foreach(var _header in customHeaders)
 8334                {
 08335                    if (_httpRequest.Headers.Contains(_header.Key))
 8336                    {
 08337                        _httpRequest.Headers.Remove(_header.Key);
 8338                    }
 08339                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8340                }
 8341            }
 8342
 8343            // Serialize Request
 48344            string _requestContent = null;
 8345            // Set Credentials
 48346            if (Credentials != null)
 8347            {
 48348                cancellationToken.ThrowIfCancellationRequested();
 48349                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8350            }
 8351            // Send Request
 48352            if (_shouldTrace)
 8353            {
 08354                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8355            }
 48356            cancellationToken.ThrowIfCancellationRequested();
 48357            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 48358            if (_shouldTrace)
 8359            {
 08360                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8361            }
 48362            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 48363            cancellationToken.ThrowIfCancellationRequested();
 48364            string _responseContent = null;
 48365            if ((int)_statusCode != 200)
 8366            {
 08367                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 8368                try
 8369                {
 08370                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08371                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 08372                    if (_errorBody != null)
 8373                    {
 08374                        ex.Body = _errorBody;
 8375                    }
 08376                }
 08377                catch (JsonException)
 8378                {
 8379                    // Ignore the exception
 08380                }
 08381                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08382                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08383                if (_shouldTrace)
 8384                {
 08385                    ServiceClientTracing.Error(_invocationId, ex);
 8386                }
 08387                _httpRequest.Dispose();
 08388                if (_httpResponse != null)
 8389                {
 08390                    _httpResponse.Dispose();
 8391                }
 08392                throw ex;
 8393            }
 8394            // Create Result
 48395            var _result = new HttpOperationResponse<Tag>();
 48396            _result.Request = _httpRequest;
 48397            _result.Response = _httpResponse;
 8398            // Deserialize Response
 48399            if ((int)_statusCode == 200)
 8400            {
 48401                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8402                try
 8403                {
 48404                    _result.Body = SafeJsonConvert.DeserializeObject<Tag>(_responseContent, DeserializationSettings);
 48405                }
 08406                catch (JsonException ex)
 8407                {
 08408                    _httpRequest.Dispose();
 08409                    if (_httpResponse != null)
 8410                    {
 08411                        _httpResponse.Dispose();
 8412                    }
 08413                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8414                }
 8415            }
 48416            if (_shouldTrace)
 8417            {
 08418                ServiceClientTracing.Exit(_invocationId, _result);
 8419            }
 48420            return _result;
 48421        }
 8422
 8423        /// <summary>
 8424        /// Delete a tag from the project.
 8425        /// </summary>
 8426        /// <param name='projectId'>
 8427        /// The project id.
 8428        /// </param>
 8429        /// <param name='tagId'>
 8430        /// Id of the tag to be deleted.
 8431        /// </param>
 8432        /// <param name='customHeaders'>
 8433        /// Headers that will be added to request.
 8434        /// </param>
 8435        /// <param name='cancellationToken'>
 8436        /// The cancellation token.
 8437        /// </param>
 8438        /// <exception cref="CustomVisionErrorException">
 8439        /// Thrown when the operation returned an invalid status code
 8440        /// </exception>
 8441        /// <exception cref="ValidationException">
 8442        /// Thrown when a required parameter is null
 8443        /// </exception>
 8444        /// <exception cref="System.ArgumentNullException">
 8445        /// Thrown when a required parameter is null
 8446        /// </exception>
 8447        /// <return>
 8448        /// A response object containing the response body and response headers.
 8449        /// </return>
 8450        public async Task<HttpOperationResponse> DeleteTagWithHttpMessagesAsync(System.Guid projectId, System.Guid tagId
 8451        {
 48452            if (Endpoint == null)
 8453            {
 08454                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 8455            }
 8456            // Tracing
 48457            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 48458            string _invocationId = null;
 48459            if (_shouldTrace)
 8460            {
 08461                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08462                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08463                tracingParameters.Add("projectId", projectId);
 08464                tracingParameters.Add("tagId", tagId);
 08465                tracingParameters.Add("cancellationToken", cancellationToken);
 08466                ServiceClientTracing.Enter(_invocationId, this, "DeleteTag", tracingParameters);
 8467            }
 8468            // Construct URL
 48469            var _baseUrl = BaseUri;
 48470            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/tags/{tagId}";
 48471            _url = _url.Replace("{Endpoint}", Endpoint);
 48472            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 48473            _url = _url.Replace("{tagId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(tagId, Serializat
 8474            // Create HTTP transport objects
 48475            var _httpRequest = new HttpRequestMessage();
 48476            HttpResponseMessage _httpResponse = null;
 48477            _httpRequest.Method = new HttpMethod("DELETE");
 48478            _httpRequest.RequestUri = new System.Uri(_url);
 8479            // Set Headers
 8480
 8481
 48482            if (customHeaders != null)
 8483            {
 08484                foreach(var _header in customHeaders)
 8485                {
 08486                    if (_httpRequest.Headers.Contains(_header.Key))
 8487                    {
 08488                        _httpRequest.Headers.Remove(_header.Key);
 8489                    }
 08490                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8491                }
 8492            }
 8493
 8494            // Serialize Request
 48495            string _requestContent = null;
 8496            // Set Credentials
 48497            if (Credentials != null)
 8498            {
 48499                cancellationToken.ThrowIfCancellationRequested();
 48500                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8501            }
 8502            // Send Request
 48503            if (_shouldTrace)
 8504            {
 08505                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8506            }
 48507            cancellationToken.ThrowIfCancellationRequested();
 48508            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 48509            if (_shouldTrace)
 8510            {
 08511                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8512            }
 48513            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 48514            cancellationToken.ThrowIfCancellationRequested();
 48515            string _responseContent = null;
 48516            if ((int)_statusCode != 204)
 8517            {
 08518                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 8519                try
 8520                {
 08521                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08522                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 08523                    if (_errorBody != null)
 8524                    {
 08525                        ex.Body = _errorBody;
 8526                    }
 08527                }
 08528                catch (JsonException)
 8529                {
 8530                    // Ignore the exception
 08531                }
 08532                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08533                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08534                if (_shouldTrace)
 8535                {
 08536                    ServiceClientTracing.Error(_invocationId, ex);
 8537                }
 08538                _httpRequest.Dispose();
 08539                if (_httpResponse != null)
 8540                {
 08541                    _httpResponse.Dispose();
 8542                }
 08543                throw ex;
 8544            }
 8545            // Create Result
 48546            var _result = new HttpOperationResponse();
 48547            _result.Request = _httpRequest;
 48548            _result.Response = _httpResponse;
 48549            if (_shouldTrace)
 8550            {
 08551                ServiceClientTracing.Exit(_invocationId, _result);
 8552            }
 48553            return _result;
 48554        }
 8555
 8556        /// <summary>
 8557        /// Update a tag.
 8558        /// </summary>
 8559        /// <param name='projectId'>
 8560        /// The project id.
 8561        /// </param>
 8562        /// <param name='tagId'>
 8563        /// The id of the target tag.
 8564        /// </param>
 8565        /// <param name='updatedTag'>
 8566        /// The updated tag model.
 8567        /// </param>
 8568        /// <param name='customHeaders'>
 8569        /// Headers that will be added to request.
 8570        /// </param>
 8571        /// <param name='cancellationToken'>
 8572        /// The cancellation token.
 8573        /// </param>
 8574        /// <exception cref="CustomVisionErrorException">
 8575        /// Thrown when the operation returned an invalid status code
 8576        /// </exception>
 8577        /// <exception cref="SerializationException">
 8578        /// Thrown when unable to deserialize the response
 8579        /// </exception>
 8580        /// <exception cref="ValidationException">
 8581        /// Thrown when a required parameter is null
 8582        /// </exception>
 8583        /// <exception cref="System.ArgumentNullException">
 8584        /// Thrown when a required parameter is null
 8585        /// </exception>
 8586        /// <return>
 8587        /// A response object containing the response body and response headers.
 8588        /// </return>
 8589        public async Task<HttpOperationResponse<Tag>> UpdateTagWithHttpMessagesAsync(System.Guid projectId, System.Guid 
 8590        {
 28591            if (Endpoint == null)
 8592            {
 08593                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 8594            }
 28595            if (updatedTag == null)
 8596            {
 08597                throw new ValidationException(ValidationRules.CannotBeNull, "updatedTag");
 8598            }
 8599            // Tracing
 28600            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 28601            string _invocationId = null;
 28602            if (_shouldTrace)
 8603            {
 08604                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08605                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08606                tracingParameters.Add("projectId", projectId);
 08607                tracingParameters.Add("tagId", tagId);
 08608                tracingParameters.Add("updatedTag", updatedTag);
 08609                tracingParameters.Add("cancellationToken", cancellationToken);
 08610                ServiceClientTracing.Enter(_invocationId, this, "UpdateTag", tracingParameters);
 8611            }
 8612            // Construct URL
 28613            var _baseUrl = BaseUri;
 28614            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/tags/{tagId}";
 28615            _url = _url.Replace("{Endpoint}", Endpoint);
 28616            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 28617            _url = _url.Replace("{tagId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(tagId, Serializat
 8618            // Create HTTP transport objects
 28619            var _httpRequest = new HttpRequestMessage();
 28620            HttpResponseMessage _httpResponse = null;
 28621            _httpRequest.Method = new HttpMethod("PATCH");
 28622            _httpRequest.RequestUri = new System.Uri(_url);
 8623            // Set Headers
 8624
 8625
 28626            if (customHeaders != null)
 8627            {
 08628                foreach(var _header in customHeaders)
 8629                {
 08630                    if (_httpRequest.Headers.Contains(_header.Key))
 8631                    {
 08632                        _httpRequest.Headers.Remove(_header.Key);
 8633                    }
 08634                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8635                }
 8636            }
 8637
 8638            // Serialize Request
 28639            string _requestContent = null;
 28640            if(updatedTag != null)
 8641            {
 28642                _requestContent = SafeJsonConvert.SerializeObject(updatedTag, SerializationSettings);
 28643                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 28644                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 8645            }
 8646            // Set Credentials
 28647            if (Credentials != null)
 8648            {
 28649                cancellationToken.ThrowIfCancellationRequested();
 28650                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8651            }
 8652            // Send Request
 28653            if (_shouldTrace)
 8654            {
 08655                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8656            }
 28657            cancellationToken.ThrowIfCancellationRequested();
 28658            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 28659            if (_shouldTrace)
 8660            {
 08661                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8662            }
 28663            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 28664            cancellationToken.ThrowIfCancellationRequested();
 28665            string _responseContent = null;
 28666            if ((int)_statusCode != 200)
 8667            {
 08668                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 8669                try
 8670                {
 08671                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08672                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 08673                    if (_errorBody != null)
 8674                    {
 08675                        ex.Body = _errorBody;
 8676                    }
 08677                }
 08678                catch (JsonException)
 8679                {
 8680                    // Ignore the exception
 08681                }
 08682                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08683                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08684                if (_shouldTrace)
 8685                {
 08686                    ServiceClientTracing.Error(_invocationId, ex);
 8687                }
 08688                _httpRequest.Dispose();
 08689                if (_httpResponse != null)
 8690                {
 08691                    _httpResponse.Dispose();
 8692                }
 08693                throw ex;
 8694            }
 8695            // Create Result
 28696            var _result = new HttpOperationResponse<Tag>();
 28697            _result.Request = _httpRequest;
 28698            _result.Response = _httpResponse;
 8699            // Deserialize Response
 28700            if ((int)_statusCode == 200)
 8701            {
 28702                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8703                try
 8704                {
 28705                    _result.Body = SafeJsonConvert.DeserializeObject<Tag>(_responseContent, DeserializationSettings);
 28706                }
 08707                catch (JsonException ex)
 8708                {
 08709                    _httpRequest.Dispose();
 08710                    if (_httpResponse != null)
 8711                    {
 08712                        _httpResponse.Dispose();
 8713                    }
 08714                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8715                }
 8716            }
 28717            if (_shouldTrace)
 8718            {
 08719                ServiceClientTracing.Exit(_invocationId, _result);
 8720            }
 28721            return _result;
 28722        }
 8723
 8724        /// <summary>
 8725        /// Suggest tags and regions for an array/batch of untagged images. Returns
 8726        /// empty array if no tags are found.
 8727        /// </summary>
 8728        /// <remarks>
 8729        /// This API will get suggested tags and regions for an array/batch of untagged
 8730        /// images along with confidences for the tags. It returns an empty array if no
 8731        /// tags are found.
 8732        /// There is a limit of 64 images in the batch.
 8733        /// </remarks>
 8734        /// <param name='projectId'>
 8735        /// The project id.
 8736        /// </param>
 8737        /// <param name='iterationId'>
 8738        /// IterationId to use for tag and region suggestion.
 8739        /// </param>
 8740        /// <param name='imageIds'>
 8741        /// Array of image ids tag suggestion are needed for. Use GetUntaggedImages API
 8742        /// to get imageIds.
 8743        /// </param>
 8744        /// <param name='customHeaders'>
 8745        /// Headers that will be added to request.
 8746        /// </param>
 8747        /// <param name='cancellationToken'>
 8748        /// The cancellation token.
 8749        /// </param>
 8750        /// <exception cref="CustomVisionErrorException">
 8751        /// Thrown when the operation returned an invalid status code
 8752        /// </exception>
 8753        /// <exception cref="SerializationException">
 8754        /// Thrown when unable to deserialize the response
 8755        /// </exception>
 8756        /// <exception cref="ValidationException">
 8757        /// Thrown when a required parameter is null
 8758        /// </exception>
 8759        /// <exception cref="System.ArgumentNullException">
 8760        /// Thrown when a required parameter is null
 8761        /// </exception>
 8762        /// <return>
 8763        /// A response object containing the response body and response headers.
 8764        /// </return>
 8765        public async Task<HttpOperationResponse<IList<SuggestedTagAndRegion>>> SuggestTagsAndRegionsWithHttpMessagesAsyn
 8766        {
 68767            if (Endpoint == null)
 8768            {
 08769                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 8770            }
 68771            if (imageIds == null)
 8772            {
 08773                throw new ValidationException(ValidationRules.CannotBeNull, "imageIds");
 8774            }
 68775            if (imageIds != null)
 8776            {
 68777                if (imageIds.Count > 64)
 8778                {
 08779                    throw new ValidationException(ValidationRules.MaxItems, "imageIds", 64);
 8780                }
 68781                if (imageIds.Count < 0)
 8782                {
 08783                    throw new ValidationException(ValidationRules.MinItems, "imageIds", 0);
 8784                }
 8785            }
 8786            // Tracing
 68787            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 68788            string _invocationId = null;
 68789            if (_shouldTrace)
 8790            {
 08791                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08792                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08793                tracingParameters.Add("projectId", projectId);
 08794                tracingParameters.Add("iterationId", iterationId);
 08795                tracingParameters.Add("imageIds", imageIds);
 08796                tracingParameters.Add("cancellationToken", cancellationToken);
 08797                ServiceClientTracing.Enter(_invocationId, this, "SuggestTagsAndRegions", tracingParameters);
 8798            }
 8799            // Construct URL
 68800            var _baseUrl = BaseUri;
 68801            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/tagsandregions/suggestions
 68802            _url = _url.Replace("{Endpoint}", Endpoint);
 68803            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 68804            List<string> _queryParameters = new List<string>();
 68805            _queryParameters.Add(string.Format("iterationId={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeO
 68806            if (imageIds != null)
 8807            {
 68808                _queryParameters.Add(string.Format("imageIds={0}", System.Uri.EscapeDataString(string.Join(",", imageIds
 8809            }
 68810            if (_queryParameters.Count > 0)
 8811            {
 68812                _url += "?" + string.Join("&", _queryParameters);
 8813            }
 8814            // Create HTTP transport objects
 68815            var _httpRequest = new HttpRequestMessage();
 68816            HttpResponseMessage _httpResponse = null;
 68817            _httpRequest.Method = new HttpMethod("POST");
 68818            _httpRequest.RequestUri = new System.Uri(_url);
 8819            // Set Headers
 8820
 8821
 68822            if (customHeaders != null)
 8823            {
 08824                foreach(var _header in customHeaders)
 8825                {
 08826                    if (_httpRequest.Headers.Contains(_header.Key))
 8827                    {
 08828                        _httpRequest.Headers.Remove(_header.Key);
 8829                    }
 08830                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 8831                }
 8832            }
 8833
 8834            // Serialize Request
 68835            string _requestContent = null;
 8836            // Set Credentials
 68837            if (Credentials != null)
 8838            {
 68839                cancellationToken.ThrowIfCancellationRequested();
 68840                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8841            }
 8842            // Send Request
 68843            if (_shouldTrace)
 8844            {
 08845                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 8846            }
 68847            cancellationToken.ThrowIfCancellationRequested();
 68848            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 68849            if (_shouldTrace)
 8850            {
 08851                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 8852            }
 68853            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 68854            cancellationToken.ThrowIfCancellationRequested();
 68855            string _responseContent = null;
 68856            if ((int)_statusCode != 200)
 8857            {
 08858                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 8859                try
 8860                {
 08861                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 08862                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 08863                    if (_errorBody != null)
 8864                    {
 08865                        ex.Body = _errorBody;
 8866                    }
 08867                }
 08868                catch (JsonException)
 8869                {
 8870                    // Ignore the exception
 08871                }
 08872                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 08873                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 08874                if (_shouldTrace)
 8875                {
 08876                    ServiceClientTracing.Error(_invocationId, ex);
 8877                }
 08878                _httpRequest.Dispose();
 08879                if (_httpResponse != null)
 8880                {
 08881                    _httpResponse.Dispose();
 8882                }
 08883                throw ex;
 8884            }
 8885            // Create Result
 68886            var _result = new HttpOperationResponse<IList<SuggestedTagAndRegion>>();
 68887            _result.Request = _httpRequest;
 68888            _result.Response = _httpResponse;
 8889            // Deserialize Response
 68890            if ((int)_statusCode == 200)
 8891            {
 68892                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 8893                try
 8894                {
 68895                    _result.Body = SafeJsonConvert.DeserializeObject<IList<SuggestedTagAndRegion>>(_responseContent, Des
 68896                }
 08897                catch (JsonException ex)
 8898                {
 08899                    _httpRequest.Dispose();
 08900                    if (_httpResponse != null)
 8901                    {
 08902                        _httpResponse.Dispose();
 8903                    }
 08904                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 8905                }
 8906            }
 68907            if (_shouldTrace)
 8908            {
 08909                ServiceClientTracing.Exit(_invocationId, _result);
 8910            }
 68911            return _result;
 68912        }
 8913
 8914        /// <summary>
 8915        /// Queues project for training.
 8916        /// </summary>
 8917        /// <param name='projectId'>
 8918        /// The project id.
 8919        /// </param>
 8920        /// <param name='trainingType'>
 8921        /// The type of training to use to train the project (default: Regular).
 8922        /// Possible values include: 'Regular', 'Advanced'
 8923        /// </param>
 8924        /// <param name='reservedBudgetInHours'>
 8925        /// The number of hours reserved as budget for training (if applicable).
 8926        /// </param>
 8927        /// <param name='forceTrain'>
 8928        /// Whether to force train even if dataset and configuration does not change
 8929        /// (default: false).
 8930        /// </param>
 8931        /// <param name='notificationEmailAddress'>
 8932        /// The email address to send notification to when training finishes (default:
 8933        /// null).
 8934        /// </param>
 8935        /// <param name='trainingParameters'>
 8936        /// Additional training parameters passed in to control how the project is
 8937        /// trained.
 8938        /// </param>
 8939        /// <param name='customHeaders'>
 8940        /// Headers that will be added to request.
 8941        /// </param>
 8942        /// <param name='cancellationToken'>
 8943        /// The cancellation token.
 8944        /// </param>
 8945        /// <exception cref="CustomVisionErrorException">
 8946        /// Thrown when the operation returned an invalid status code
 8947        /// </exception>
 8948        /// <exception cref="SerializationException">
 8949        /// Thrown when unable to deserialize the response
 8950        /// </exception>
 8951        /// <exception cref="ValidationException">
 8952        /// Thrown when a required parameter is null
 8953        /// </exception>
 8954        /// <exception cref="System.ArgumentNullException">
 8955        /// Thrown when a required parameter is null
 8956        /// </exception>
 8957        /// <return>
 8958        /// A response object containing the response body and response headers.
 8959        /// </return>
 8960        public async Task<HttpOperationResponse<Iteration>> TrainProjectWithHttpMessagesAsync(System.Guid projectId, str
 8961        {
 28962            if (Endpoint == null)
 8963            {
 08964                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 8965            }
 8966            // Tracing
 28967            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 28968            string _invocationId = null;
 28969            if (_shouldTrace)
 8970            {
 08971                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 08972                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 08973                tracingParameters.Add("projectId", projectId);
 08974                tracingParameters.Add("trainingType", trainingType);
 08975                tracingParameters.Add("reservedBudgetInHours", reservedBudgetInHours);
 08976                tracingParameters.Add("forceTrain", forceTrain);
 08977                tracingParameters.Add("notificationEmailAddress", notificationEmailAddress);
 08978                tracingParameters.Add("trainingParameters", trainingParameters);
 08979                tracingParameters.Add("cancellationToken", cancellationToken);
 08980                ServiceClientTracing.Enter(_invocationId, this, "TrainProject", tracingParameters);
 8981            }
 8982            // Construct URL
 28983            var _baseUrl = BaseUri;
 28984            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/{projectId}/train";
 28985            _url = _url.Replace("{Endpoint}", Endpoint);
 28986            _url = _url.Replace("{projectId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(projectId, Se
 28987            List<string> _queryParameters = new List<string>();
 28988            if (trainingType != null)
 8989            {
 08990                _queryParameters.Add(string.Format("trainingType={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seria
 8991            }
 28992            if (reservedBudgetInHours != null)
 8993            {
 28994                _queryParameters.Add(string.Format("reservedBudgetInHours={0}", System.Uri.EscapeDataString(SafeJsonConv
 8995            }
 28996            if (forceTrain != null)
 8997            {
 28998                _queryParameters.Add(string.Format("forceTrain={0}", System.Uri.EscapeDataString(SafeJsonConvert.Seriali
 8999            }
 29000            if (notificationEmailAddress != null)
 9001            {
 09002                _queryParameters.Add(string.Format("notificationEmailAddress={0}", System.Uri.EscapeDataString(notificat
 9003            }
 29004            if (_queryParameters.Count > 0)
 9005            {
 29006                _url += "?" + string.Join("&", _queryParameters);
 9007            }
 9008            // Create HTTP transport objects
 29009            var _httpRequest = new HttpRequestMessage();
 29010            HttpResponseMessage _httpResponse = null;
 29011            _httpRequest.Method = new HttpMethod("POST");
 29012            _httpRequest.RequestUri = new System.Uri(_url);
 9013            // Set Headers
 9014
 9015
 29016            if (customHeaders != null)
 9017            {
 09018                foreach(var _header in customHeaders)
 9019                {
 09020                    if (_httpRequest.Headers.Contains(_header.Key))
 9021                    {
 09022                        _httpRequest.Headers.Remove(_header.Key);
 9023                    }
 09024                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 9025                }
 9026            }
 9027
 9028            // Serialize Request
 29029            string _requestContent = null;
 29030            if(trainingParameters != null)
 9031            {
 09032                _requestContent = SafeJsonConvert.SerializeObject(trainingParameters, SerializationSettings);
 09033                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 09034                _httpRequest.Content.Headers.ContentType =MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
 9035            }
 9036            // Set Credentials
 29037            if (Credentials != null)
 9038            {
 29039                cancellationToken.ThrowIfCancellationRequested();
 29040                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 9041            }
 9042            // Send Request
 29043            if (_shouldTrace)
 9044            {
 09045                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 9046            }
 29047            cancellationToken.ThrowIfCancellationRequested();
 29048            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 29049            if (_shouldTrace)
 9050            {
 09051                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 9052            }
 29053            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 29054            cancellationToken.ThrowIfCancellationRequested();
 29055            string _responseContent = null;
 29056            if ((int)_statusCode != 200)
 9057            {
 09058                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 9059                try
 9060                {
 09061                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 09062                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 09063                    if (_errorBody != null)
 9064                    {
 09065                        ex.Body = _errorBody;
 9066                    }
 09067                }
 09068                catch (JsonException)
 9069                {
 9070                    // Ignore the exception
 09071                }
 09072                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 09073                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 09074                if (_shouldTrace)
 9075                {
 09076                    ServiceClientTracing.Error(_invocationId, ex);
 9077                }
 09078                _httpRequest.Dispose();
 09079                if (_httpResponse != null)
 9080                {
 09081                    _httpResponse.Dispose();
 9082                }
 09083                throw ex;
 9084            }
 9085            // Create Result
 29086            var _result = new HttpOperationResponse<Iteration>();
 29087            _result.Request = _httpRequest;
 29088            _result.Response = _httpResponse;
 9089            // Deserialize Response
 29090            if ((int)_statusCode == 200)
 9091            {
 29092                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 9093                try
 9094                {
 29095                    _result.Body = SafeJsonConvert.DeserializeObject<Iteration>(_responseContent, DeserializationSetting
 29096                }
 09097                catch (JsonException ex)
 9098                {
 09099                    _httpRequest.Dispose();
 09100                    if (_httpResponse != null)
 9101                    {
 09102                        _httpResponse.Dispose();
 9103                    }
 09104                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 9105                }
 9106            }
 29107            if (_shouldTrace)
 9108            {
 09109                ServiceClientTracing.Exit(_invocationId, _result);
 9110            }
 29111            return _result;
 29112        }
 9113
 9114        /// <summary>
 9115        /// Imports a project.
 9116        /// </summary>
 9117        /// <param name='token'>
 9118        /// Token generated from the export project call.
 9119        /// </param>
 9120        /// <param name='name'>
 9121        /// Optional, name of the project to use instead of auto-generated name.
 9122        /// </param>
 9123        /// <param name='customHeaders'>
 9124        /// Headers that will be added to request.
 9125        /// </param>
 9126        /// <param name='cancellationToken'>
 9127        /// The cancellation token.
 9128        /// </param>
 9129        /// <exception cref="CustomVisionErrorException">
 9130        /// Thrown when the operation returned an invalid status code
 9131        /// </exception>
 9132        /// <exception cref="SerializationException">
 9133        /// Thrown when unable to deserialize the response
 9134        /// </exception>
 9135        /// <exception cref="ValidationException">
 9136        /// Thrown when a required parameter is null
 9137        /// </exception>
 9138        /// <exception cref="System.ArgumentNullException">
 9139        /// Thrown when a required parameter is null
 9140        /// </exception>
 9141        /// <return>
 9142        /// A response object containing the response body and response headers.
 9143        /// </return>
 9144        public async Task<HttpOperationResponse<Project>> ImportProjectWithHttpMessagesAsync(string token, string name =
 9145        {
 29146            if (Endpoint == null)
 9147            {
 09148                throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
 9149            }
 29150            if (token == null)
 9151            {
 09152                throw new ValidationException(ValidationRules.CannotBeNull, "token");
 9153            }
 9154            // Tracing
 29155            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 29156            string _invocationId = null;
 29157            if (_shouldTrace)
 9158            {
 09159                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 09160                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 09161                tracingParameters.Add("token", token);
 09162                tracingParameters.Add("name", name);
 09163                tracingParameters.Add("cancellationToken", cancellationToken);
 09164                ServiceClientTracing.Enter(_invocationId, this, "ImportProject", tracingParameters);
 9165            }
 9166            // Construct URL
 29167            var _baseUrl = BaseUri;
 29168            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "projects/import";
 29169            _url = _url.Replace("{Endpoint}", Endpoint);
 29170            List<string> _queryParameters = new List<string>();
 29171            if (token != null)
 9172            {
 29173                _queryParameters.Add(string.Format("token={0}", System.Uri.EscapeDataString(token)));
 9174            }
 29175            if (name != null)
 9176            {
 09177                _queryParameters.Add(string.Format("name={0}", System.Uri.EscapeDataString(name)));
 9178            }
 29179            if (_queryParameters.Count > 0)
 9180            {
 29181                _url += "?" + string.Join("&", _queryParameters);
 9182            }
 9183            // Create HTTP transport objects
 29184            var _httpRequest = new HttpRequestMessage();
 29185            HttpResponseMessage _httpResponse = null;
 29186            _httpRequest.Method = new HttpMethod("POST");
 29187            _httpRequest.RequestUri = new System.Uri(_url);
 9188            // Set Headers
 9189
 9190
 29191            if (customHeaders != null)
 9192            {
 09193                foreach(var _header in customHeaders)
 9194                {
 09195                    if (_httpRequest.Headers.Contains(_header.Key))
 9196                    {
 09197                        _httpRequest.Headers.Remove(_header.Key);
 9198                    }
 09199                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 9200                }
 9201            }
 9202
 9203            // Serialize Request
 29204            string _requestContent = null;
 9205            // Set Credentials
 29206            if (Credentials != null)
 9207            {
 29208                cancellationToken.ThrowIfCancellationRequested();
 29209                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 9210            }
 9211            // Send Request
 29212            if (_shouldTrace)
 9213            {
 09214                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 9215            }
 29216            cancellationToken.ThrowIfCancellationRequested();
 29217            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 29218            if (_shouldTrace)
 9219            {
 09220                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 9221            }
 29222            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 29223            cancellationToken.ThrowIfCancellationRequested();
 29224            string _responseContent = null;
 29225            if ((int)_statusCode != 200)
 9226            {
 09227                var ex = new CustomVisionErrorException(string.Format("Operation returned an invalid status code '{0}'",
 9228                try
 9229                {
 09230                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 09231                    CustomVisionError _errorBody =  SafeJsonConvert.DeserializeObject<CustomVisionError>(_responseConten
 09232                    if (_errorBody != null)
 9233                    {
 09234                        ex.Body = _errorBody;
 9235                    }
 09236                }
 09237                catch (JsonException)
 9238                {
 9239                    // Ignore the exception
 09240                }
 09241                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 09242                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 09243                if (_shouldTrace)
 9244                {
 09245                    ServiceClientTracing.Error(_invocationId, ex);
 9246                }
 09247                _httpRequest.Dispose();
 09248                if (_httpResponse != null)
 9249                {
 09250                    _httpResponse.Dispose();
 9251                }
 09252                throw ex;
 9253            }
 9254            // Create Result
 29255            var _result = new HttpOperationResponse<Project>();
 29256            _result.Request = _httpRequest;
 29257            _result.Response = _httpResponse;
 9258            // Deserialize Response
 29259            if ((int)_statusCode == 200)
 9260            {
 29261                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 9262                try
 9263                {
 29264                    _result.Body = SafeJsonConvert.DeserializeObject<Project>(_responseContent, DeserializationSettings)
 29265                }
 09266                catch (JsonException ex)
 9267                {
 09268                    _httpRequest.Dispose();
 09269                    if (_httpResponse != null)
 9270                    {
 09271                        _httpResponse.Dispose();
 9272                    }
 09273                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 9274                }
 9275            }
 29276            if (_shouldTrace)
 9277            {
 09278                ServiceClientTracing.Exit(_invocationId, _result);
 9279            }
 29280            return _result;
 29281        }
 9282
 9283    }
 9284}

Methods/Properties

get_BaseUri()
get_SerializationSettings()
get_DeserializationSettings()
get_Endpoint()
get_Credentials()
.ctor(...)
.ctor(...)
.ctor(...)
.ctor(...)
.ctor(...)
.ctor(...)
Initialize()
GetDomainsWithHttpMessagesAsync()
GetDomainWithHttpMessagesAsync()
GetProjectsWithHttpMessagesAsync()
CreateProjectWithHttpMessagesAsync()
GetProjectWithHttpMessagesAsync()
DeleteProjectWithHttpMessagesAsync()
UpdateProjectWithHttpMessagesAsync()
GetArtifactWithHttpMessagesAsync()
ExportProjectWithHttpMessagesAsync()
GetImagesWithHttpMessagesAsync()
DeleteImagesWithHttpMessagesAsync()
GetImageRegionProposalsWithHttpMessagesAsync()
GetImageCountWithHttpMessagesAsync()
CreateImagesFromFilesWithHttpMessagesAsync()
GetImagesByIdsWithHttpMessagesAsync()
UpdateImageMetadataWithHttpMessagesAsync()
CreateImagesFromPredictionsWithHttpMessagesAsync()
CreateImageRegionsWithHttpMessagesAsync()
DeleteImageRegionsWithHttpMessagesAsync()
QuerySuggestedImagesWithHttpMessagesAsync()
QuerySuggestedImageCountWithHttpMessagesAsync()
GetTaggedImagesWithHttpMessagesAsync()
GetTaggedImageCountWithHttpMessagesAsync()
CreateImageTagsWithHttpMessagesAsync()
DeleteImageTagsWithHttpMessagesAsync()
GetUntaggedImagesWithHttpMessagesAsync()
GetUntaggedImageCountWithHttpMessagesAsync()
CreateImagesFromUrlsWithHttpMessagesAsync()
GetIterationsWithHttpMessagesAsync()
GetIterationWithHttpMessagesAsync()
DeleteIterationWithHttpMessagesAsync()
UpdateIterationWithHttpMessagesAsync()
GetExportsWithHttpMessagesAsync()
ExportIterationWithHttpMessagesAsync()
GetIterationPerformanceWithHttpMessagesAsync()
GetImagePerformancesWithHttpMessagesAsync()
GetImagePerformanceCountWithHttpMessagesAsync()
PublishIterationWithHttpMessagesAsync()
UnpublishIterationWithHttpMessagesAsync()
DeletePredictionWithHttpMessagesAsync()
QueryPredictionsWithHttpMessagesAsync()
QuickTestImageUrlWithHttpMessagesAsync()
GetTagsWithHttpMessagesAsync()
CreateTagWithHttpMessagesAsync()
GetTagWithHttpMessagesAsync()
DeleteTagWithHttpMessagesAsync()
UpdateTagWithHttpMessagesAsync()
SuggestTagsAndRegionsWithHttpMessagesAsync()
TrainProjectWithHttpMessagesAsync()
ImportProjectWithHttpMessagesAsync()