< Summary

Class:Microsoft.Azure.Search.IndexersOperations
Assembly:Microsoft.Azure.Search.Service
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Customizations\Indexers\IndexersOperations.Customization.cs
C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\IndexersOperations.cs
Covered lines:532
Uncovered lines:307
Coverable lines:839
Total lines:1874
Line coverage:63.4% (532 of 839)
Covered branches:311
Total branches:532
Branch coverage:58.4% (311 of 532)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
CreateOrUpdateWithHttpMessagesAsync(...)-100%50%
ExistsWithHttpMessagesAsync(...)-100%100%
.ctor(...)-80%50%
get_Client()-100%100%
ResetWithHttpMessagesAsync()-54.95%50%
RunWithHttpMessagesAsync()-54.95%50%
CreateOrUpdateWithHttpMessagesAsync()-69.29%67.78%
DeleteWithHttpMessagesAsync()-71.03%65.28%
GetWithHttpMessagesAsync()-70%62.9%
ListWithHttpMessagesAsync()-54.17%50%
CreateWithHttpMessagesAsync()-71.43%65.15%
GetStatusWithHttpMessagesAsync()-54%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Customizations\Indexers\IndexersOperations.Customization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for
 3// license information.
 4
 5namespace Microsoft.Azure.Search
 6{
 7    using System.Collections.Generic;
 8    using System.Threading;
 9    using System.Threading.Tasks;
 10    using Microsoft.Rest.Azure;
 11    using Models;
 12
 13    internal partial class IndexersOperations
 14    {
 15        /// <summary>
 16        /// Creates a new indexer or updates an indexer if it already
 17        /// exists.
 18        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Create-Indexer" />
 19        /// </summary>
 20        /// <param name='indexer'>
 21        /// The definition of the indexer to create or update.
 22        /// </param>
 23        /// <param name='searchRequestOptions'>
 24        /// Additional parameters for the operation.
 25        /// </param>
 26        /// <param name='accessCondition'>
 27        /// Additional parameters for the operation.
 28        /// </param>
 29        /// <param name='customHeaders'>
 30        /// Headers that will be added to request.
 31        /// </param>
 32        /// <param name='cancellationToken'>
 33        /// The cancellation token.
 34        /// </param>
 35        /// <exception cref="CloudException">
 36        /// Thrown when the operation returned an invalid status code.
 37        /// </exception>
 38        /// <exception cref="Microsoft.Rest.SerializationException">
 39        /// Thrown when unable to deserialize the response.
 40        /// </exception>
 41        /// <exception cref="Microsoft.Rest.ValidationException">
 42        /// Thrown when a required parameter is null.
 43        /// </exception>
 44        /// <exception cref="System.ArgumentNullException">
 45        /// Thrown when a required parameter is null.
 46        /// </exception>
 47        /// <returns>
 48        /// A response object containing the response body and response headers.
 49        /// </returns>
 50        public Task<AzureOperationResponse<Indexer>> CreateOrUpdateWithHttpMessagesAsync(Indexer indexer, SearchRequestO
 51        {
 3452            return CreateOrUpdateWithHttpMessagesAsync(indexer?.Name, indexer, searchRequestOptions, accessCondition, cu
 53        }
 54
 55        /// <summary>
 56        /// Determines whether or not the given indexer exists in the search service.
 57        /// </summary>
 58        /// <param name="indexerName">
 59        /// The name of the indexer.
 60        /// </param>
 61        /// <param name='searchRequestOptions'>
 62        /// Additional parameters for the operation.
 63        /// </param>
 64        /// <param name='customHeaders'>
 65        /// The headers that will be added to request.
 66        /// </param>
 67        /// <param name='cancellationToken'>
 68        /// The cancellation token.
 69        /// </param>
 70        /// <exception cref="CloudException">
 71        /// Thrown when the operation returned an invalid status code.
 72        /// </exception>
 73        /// <exception cref="Microsoft.Rest.SerializationException">
 74        /// Thrown when unable to deserialize the response.
 75        /// </exception>
 76        /// <exception cref="Microsoft.Rest.ValidationException">
 77        /// Thrown when a required parameter is null.
 78        /// </exception>
 79        /// <exception cref="System.ArgumentNullException">
 80        /// Thrown when a required parameter is null.
 81        /// </exception>
 82        /// <returns>
 83        /// A response with the value <c>true</c> if the indexer exists; <c>false</c> otherwise.
 84        /// </returns>
 85        public Task<AzureOperationResponse<bool>> ExistsWithHttpMessagesAsync(
 86            string indexerName,
 87            SearchRequestOptions searchRequestOptions = default(SearchRequestOptions),
 88            Dictionary<string, List<string>> customHeaders = null,
 89            CancellationToken cancellationToken = default(CancellationToken))
 90        {
 491            return ExistsHelper.ExistsFromGetResponse(() =>
 892                this.GetWithHttpMessagesAsync(indexerName, searchRequestOptions, customHeaders, cancellationToken));
 93        }
 94    }
 95}

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\IndexersOperations.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.Search
 12{
 13    using Microsoft.Rest;
 14    using Microsoft.Rest.Azure;
 15    using Models;
 16    using Newtonsoft.Json;
 17    using System.Collections;
 18    using System.Collections.Generic;
 19    using System.Linq;
 20    using System.Net;
 21    using System.Net.Http;
 22    using System.Threading;
 23    using System.Threading.Tasks;
 24
 25    /// <summary>
 26    /// IndexersOperations operations.
 27    /// </summary>
 28    internal partial class IndexersOperations : IServiceOperations<SearchServiceClient>, IIndexersOperations
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the IndexersOperations class.
 32        /// </summary>
 33        /// <param name='client'>
 34        /// Reference to the service client.
 35        /// </param>
 36        /// <exception cref="System.ArgumentNullException">
 37        /// Thrown when a required parameter is null
 38        /// </exception>
 82439        internal IndexersOperations(SearchServiceClient client)
 40        {
 82441            if (client == null)
 42            {
 043                throw new System.ArgumentNullException("client");
 44            }
 82445            Client = client;
 82446        }
 47
 48        /// <summary>
 49        /// Gets a reference to the SearchServiceClient
 50        /// </summary>
 230651        public SearchServiceClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Resets the change tracking state associated with an indexer.
 55        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Reset-Indexer" />
 56        /// </summary>
 57        /// <param name='indexerName'>
 58        /// The name of the indexer to reset.
 59        /// </param>
 60        /// <param name='searchRequestOptions'>
 61        /// Additional parameters for the operation
 62        /// </param>
 63        /// <param name='customHeaders'>
 64        /// Headers that will be added to request.
 65        /// </param>
 66        /// <param name='cancellationToken'>
 67        /// The cancellation token.
 68        /// </param>
 69        /// <exception cref="CloudException">
 70        /// Thrown when the operation returned an invalid status code
 71        /// </exception>
 72        /// <exception cref="ValidationException">
 73        /// Thrown when a required parameter is null
 74        /// </exception>
 75        /// <exception cref="System.ArgumentNullException">
 76        /// Thrown when a required parameter is null
 77        /// </exception>
 78        /// <return>
 79        /// A response object containing the response body and response headers.
 80        /// </return>
 81        public async Task<AzureOperationResponse> ResetWithHttpMessagesAsync(string indexerName, SearchRequestOptions se
 82        {
 283            if (Client.SearchServiceName == null)
 84            {
 085                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 86            }
 287            if (Client.SearchDnsSuffix == null)
 88            {
 089                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 90            }
 291            if (indexerName == null)
 92            {
 093                throw new ValidationException(ValidationRules.CannotBeNull, "indexerName");
 94            }
 295            if (Client.ApiVersion == null)
 96            {
 097                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 98            }
 299            System.Guid? clientRequestId = default(System.Guid?);
 2100            if (searchRequestOptions != null)
 101            {
 0102                clientRequestId = searchRequestOptions.ClientRequestId;
 103            }
 104            // Tracing
 2105            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2106            string _invocationId = null;
 2107            if (_shouldTrace)
 108            {
 0109                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0110                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0111                tracingParameters.Add("indexerName", indexerName);
 0112                tracingParameters.Add("clientRequestId", clientRequestId);
 0113                tracingParameters.Add("cancellationToken", cancellationToken);
 0114                ServiceClientTracing.Enter(_invocationId, this, "Reset", tracingParameters);
 115            }
 116            // Construct URL
 2117            var _baseUrl = Client.BaseUri;
 2118            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "indexers('{indexerName}')/search.reset";
 2119            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 2120            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 2121            _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName));
 2122            List<string> _queryParameters = new List<string>();
 2123            if (Client.ApiVersion != null)
 124            {
 2125                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 126            }
 2127            if (_queryParameters.Count > 0)
 128            {
 2129                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 130            }
 131            // Create HTTP transport objects
 2132            var _httpRequest = new HttpRequestMessage();
 2133            HttpResponseMessage _httpResponse = null;
 2134            _httpRequest.Method = new HttpMethod("POST");
 2135            _httpRequest.RequestUri = new System.Uri(_url);
 136            // Set Headers
 2137            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 138            {
 2139                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 140            }
 2141            if (Client.AcceptLanguage != null)
 142            {
 2143                if (_httpRequest.Headers.Contains("accept-language"))
 144                {
 0145                    _httpRequest.Headers.Remove("accept-language");
 146                }
 2147                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 148            }
 2149            if (clientRequestId != null)
 150            {
 0151                if (_httpRequest.Headers.Contains("client-request-id"))
 152                {
 0153                    _httpRequest.Headers.Remove("client-request-id");
 154                }
 0155                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 156            }
 157
 158
 2159            if (customHeaders != null)
 160            {
 0161                foreach(var _header in customHeaders)
 162                {
 0163                    if (_httpRequest.Headers.Contains(_header.Key))
 164                    {
 0165                        _httpRequest.Headers.Remove(_header.Key);
 166                    }
 0167                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 168                }
 169            }
 170
 171            // Serialize Request
 2172            string _requestContent = null;
 173            // Set Credentials
 2174            if (Client.Credentials != null)
 175            {
 2176                cancellationToken.ThrowIfCancellationRequested();
 2177                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 178            }
 179            // Send Request
 2180            if (_shouldTrace)
 181            {
 0182                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 183            }
 2184            cancellationToken.ThrowIfCancellationRequested();
 2185            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2186            if (_shouldTrace)
 187            {
 0188                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 189            }
 2190            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2191            cancellationToken.ThrowIfCancellationRequested();
 2192            string _responseContent = null;
 2193            if ((int)_statusCode != 204)
 194            {
 0195                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 196                try
 197                {
 0198                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0199                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0200                    if (_errorBody != null)
 201                    {
 0202                        ex = new CloudException(_errorBody.Message);
 0203                        ex.Body = _errorBody;
 204                    }
 0205                }
 0206                catch (JsonException)
 207                {
 208                    // Ignore the exception
 0209                }
 0210                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0211                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0212                if (_httpResponse.Headers.Contains("request-id"))
 213                {
 0214                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 215                }
 0216                if (_shouldTrace)
 217                {
 0218                    ServiceClientTracing.Error(_invocationId, ex);
 219                }
 0220                _httpRequest.Dispose();
 0221                if (_httpResponse != null)
 222                {
 0223                    _httpResponse.Dispose();
 224                }
 0225                throw ex;
 226            }
 227            // Create Result
 2228            var _result = new AzureOperationResponse();
 2229            _result.Request = _httpRequest;
 2230            _result.Response = _httpResponse;
 2231            if (_httpResponse.Headers.Contains("request-id"))
 232            {
 2233                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 234            }
 2235            if (_shouldTrace)
 236            {
 0237                ServiceClientTracing.Exit(_invocationId, _result);
 238            }
 2239            return _result;
 2240        }
 241
 242        /// <summary>
 243        /// Runs an indexer on-demand.
 244        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Run-Indexer" />
 245        /// </summary>
 246        /// <param name='indexerName'>
 247        /// The name of the indexer to run.
 248        /// </param>
 249        /// <param name='searchRequestOptions'>
 250        /// Additional parameters for the operation
 251        /// </param>
 252        /// <param name='customHeaders'>
 253        /// Headers that will be added to request.
 254        /// </param>
 255        /// <param name='cancellationToken'>
 256        /// The cancellation token.
 257        /// </param>
 258        /// <exception cref="CloudException">
 259        /// Thrown when the operation returned an invalid status code
 260        /// </exception>
 261        /// <exception cref="ValidationException">
 262        /// Thrown when a required parameter is null
 263        /// </exception>
 264        /// <exception cref="System.ArgumentNullException">
 265        /// Thrown when a required parameter is null
 266        /// </exception>
 267        /// <return>
 268        /// A response object containing the response body and response headers.
 269        /// </return>
 270        public async Task<AzureOperationResponse> RunWithHttpMessagesAsync(string indexerName, SearchRequestOptions sear
 271        {
 2272            if (Client.SearchServiceName == null)
 273            {
 0274                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 275            }
 2276            if (Client.SearchDnsSuffix == null)
 277            {
 0278                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 279            }
 2280            if (indexerName == null)
 281            {
 0282                throw new ValidationException(ValidationRules.CannotBeNull, "indexerName");
 283            }
 2284            if (Client.ApiVersion == null)
 285            {
 0286                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 287            }
 2288            System.Guid? clientRequestId = default(System.Guid?);
 2289            if (searchRequestOptions != null)
 290            {
 0291                clientRequestId = searchRequestOptions.ClientRequestId;
 292            }
 293            // Tracing
 2294            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2295            string _invocationId = null;
 2296            if (_shouldTrace)
 297            {
 0298                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0299                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0300                tracingParameters.Add("indexerName", indexerName);
 0301                tracingParameters.Add("clientRequestId", clientRequestId);
 0302                tracingParameters.Add("cancellationToken", cancellationToken);
 0303                ServiceClientTracing.Enter(_invocationId, this, "Run", tracingParameters);
 304            }
 305            // Construct URL
 2306            var _baseUrl = Client.BaseUri;
 2307            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "indexers('{indexerName}')/search.run";
 2308            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 2309            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 2310            _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName));
 2311            List<string> _queryParameters = new List<string>();
 2312            if (Client.ApiVersion != null)
 313            {
 2314                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 315            }
 2316            if (_queryParameters.Count > 0)
 317            {
 2318                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 319            }
 320            // Create HTTP transport objects
 2321            var _httpRequest = new HttpRequestMessage();
 2322            HttpResponseMessage _httpResponse = null;
 2323            _httpRequest.Method = new HttpMethod("POST");
 2324            _httpRequest.RequestUri = new System.Uri(_url);
 325            // Set Headers
 2326            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 327            {
 2328                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 329            }
 2330            if (Client.AcceptLanguage != null)
 331            {
 2332                if (_httpRequest.Headers.Contains("accept-language"))
 333                {
 0334                    _httpRequest.Headers.Remove("accept-language");
 335                }
 2336                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 337            }
 2338            if (clientRequestId != null)
 339            {
 0340                if (_httpRequest.Headers.Contains("client-request-id"))
 341                {
 0342                    _httpRequest.Headers.Remove("client-request-id");
 343                }
 0344                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 345            }
 346
 347
 2348            if (customHeaders != null)
 349            {
 0350                foreach(var _header in customHeaders)
 351                {
 0352                    if (_httpRequest.Headers.Contains(_header.Key))
 353                    {
 0354                        _httpRequest.Headers.Remove(_header.Key);
 355                    }
 0356                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 357                }
 358            }
 359
 360            // Serialize Request
 2361            string _requestContent = null;
 362            // Set Credentials
 2363            if (Client.Credentials != null)
 364            {
 2365                cancellationToken.ThrowIfCancellationRequested();
 2366                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 367            }
 368            // Send Request
 2369            if (_shouldTrace)
 370            {
 0371                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 372            }
 2373            cancellationToken.ThrowIfCancellationRequested();
 2374            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2375            if (_shouldTrace)
 376            {
 0377                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 378            }
 2379            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2380            cancellationToken.ThrowIfCancellationRequested();
 2381            string _responseContent = null;
 2382            if ((int)_statusCode != 202)
 383            {
 0384                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 385                try
 386                {
 0387                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0388                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0389                    if (_errorBody != null)
 390                    {
 0391                        ex = new CloudException(_errorBody.Message);
 0392                        ex.Body = _errorBody;
 393                    }
 0394                }
 0395                catch (JsonException)
 396                {
 397                    // Ignore the exception
 0398                }
 0399                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0400                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0401                if (_httpResponse.Headers.Contains("request-id"))
 402                {
 0403                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 404                }
 0405                if (_shouldTrace)
 406                {
 0407                    ServiceClientTracing.Error(_invocationId, ex);
 408                }
 0409                _httpRequest.Dispose();
 0410                if (_httpResponse != null)
 411                {
 0412                    _httpResponse.Dispose();
 413                }
 0414                throw ex;
 415            }
 416            // Create Result
 2417            var _result = new AzureOperationResponse();
 2418            _result.Request = _httpRequest;
 2419            _result.Response = _httpResponse;
 2420            if (_httpResponse.Headers.Contains("request-id"))
 421            {
 2422                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 423            }
 2424            if (_shouldTrace)
 425            {
 0426                ServiceClientTracing.Exit(_invocationId, _result);
 427            }
 2428            return _result;
 2429        }
 430
 431        /// <summary>
 432        /// Creates a new indexer or updates an indexer if it already exists.
 433        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Create-Indexer" />
 434        /// </summary>
 435        /// <param name='indexerName'>
 436        /// The name of the indexer to create or update.
 437        /// </param>
 438        /// <param name='indexer'>
 439        /// The definition of the indexer to create or update.
 440        /// </param>
 441        /// <param name='searchRequestOptions'>
 442        /// Additional parameters for the operation
 443        /// </param>
 444        /// <param name='accessCondition'>
 445        /// Additional parameters for the operation
 446        /// </param>
 447        /// <param name='customHeaders'>
 448        /// Headers that will be added to request.
 449        /// </param>
 450        /// <param name='cancellationToken'>
 451        /// The cancellation token.
 452        /// </param>
 453        /// <exception cref="CloudException">
 454        /// Thrown when the operation returned an invalid status code
 455        /// </exception>
 456        /// <exception cref="SerializationException">
 457        /// Thrown when unable to deserialize the response
 458        /// </exception>
 459        /// <exception cref="ValidationException">
 460        /// Thrown when a required parameter is null
 461        /// </exception>
 462        /// <exception cref="System.ArgumentNullException">
 463        /// Thrown when a required parameter is null
 464        /// </exception>
 465        /// <return>
 466        /// A response object containing the response body and response headers.
 467        /// </return>
 468        public async Task<AzureOperationResponse<Indexer>> CreateOrUpdateWithHttpMessagesAsync(string indexerName, Index
 469        {
 34470            if (Client.SearchServiceName == null)
 471            {
 0472                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 473            }
 34474            if (Client.SearchDnsSuffix == null)
 475            {
 0476                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 477            }
 34478            if (indexerName == null)
 479            {
 0480                throw new ValidationException(ValidationRules.CannotBeNull, "indexerName");
 481            }
 34482            if (indexer == null)
 483            {
 0484                throw new ValidationException(ValidationRules.CannotBeNull, "indexer");
 485            }
 34486            if (indexer != null)
 487            {
 34488                indexer.Validate();
 489            }
 34490            if (Client.ApiVersion == null)
 491            {
 0492                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 493            }
 34494            string prefer = "return=representation";
 34495            System.Guid? clientRequestId = default(System.Guid?);
 34496            if (searchRequestOptions != null)
 497            {
 0498                clientRequestId = searchRequestOptions.ClientRequestId;
 499            }
 34500            string ifMatch = default(string);
 34501            if (accessCondition != null)
 502            {
 22503                ifMatch = accessCondition.IfMatch;
 504            }
 34505            string ifNoneMatch = default(string);
 34506            if (accessCondition != null)
 507            {
 22508                ifNoneMatch = accessCondition.IfNoneMatch;
 509            }
 510            // Tracing
 34511            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 34512            string _invocationId = null;
 34513            if (_shouldTrace)
 514            {
 0515                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0516                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0517                tracingParameters.Add("indexerName", indexerName);
 0518                tracingParameters.Add("indexer", indexer);
 0519                tracingParameters.Add("prefer", prefer);
 0520                tracingParameters.Add("clientRequestId", clientRequestId);
 0521                tracingParameters.Add("ifMatch", ifMatch);
 0522                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 0523                tracingParameters.Add("cancellationToken", cancellationToken);
 0524                ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters);
 525            }
 526            // Construct URL
 34527            var _baseUrl = Client.BaseUri;
 34528            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "indexers('{indexerName}')";
 34529            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 34530            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 34531            _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName));
 34532            List<string> _queryParameters = new List<string>();
 34533            if (Client.ApiVersion != null)
 534            {
 34535                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 536            }
 34537            if (_queryParameters.Count > 0)
 538            {
 34539                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 540            }
 541            // Create HTTP transport objects
 34542            var _httpRequest = new HttpRequestMessage();
 34543            HttpResponseMessage _httpResponse = null;
 34544            _httpRequest.Method = new HttpMethod("PUT");
 34545            _httpRequest.RequestUri = new System.Uri(_url);
 546            // Set Headers
 34547            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 548            {
 34549                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 550            }
 34551            if (prefer != null)
 552            {
 34553                if (_httpRequest.Headers.Contains("Prefer"))
 554                {
 0555                    _httpRequest.Headers.Remove("Prefer");
 556                }
 34557                _httpRequest.Headers.TryAddWithoutValidation("Prefer", prefer);
 558            }
 34559            if (Client.AcceptLanguage != null)
 560            {
 34561                if (_httpRequest.Headers.Contains("accept-language"))
 562                {
 0563                    _httpRequest.Headers.Remove("accept-language");
 564                }
 34565                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 566            }
 34567            if (clientRequestId != null)
 568            {
 0569                if (_httpRequest.Headers.Contains("client-request-id"))
 570                {
 0571                    _httpRequest.Headers.Remove("client-request-id");
 572                }
 0573                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 574            }
 34575            if (ifMatch != null)
 576            {
 8577                if (_httpRequest.Headers.Contains("If-Match"))
 578                {
 0579                    _httpRequest.Headers.Remove("If-Match");
 580                }
 8581                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 582            }
 34583            if (ifNoneMatch != null)
 584            {
 4585                if (_httpRequest.Headers.Contains("If-None-Match"))
 586                {
 0587                    _httpRequest.Headers.Remove("If-None-Match");
 588                }
 4589                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 590            }
 591
 592
 34593            if (customHeaders != null)
 594            {
 0595                foreach(var _header in customHeaders)
 596                {
 0597                    if (_httpRequest.Headers.Contains(_header.Key))
 598                    {
 0599                        _httpRequest.Headers.Remove(_header.Key);
 600                    }
 0601                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 602                }
 603            }
 604
 605            // Serialize Request
 34606            string _requestContent = null;
 34607            if(indexer != null)
 608            {
 34609                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(indexer, Client.SerializationSettin
 34610                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 34611                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 612            }
 613            // Set Credentials
 34614            if (Client.Credentials != null)
 615            {
 34616                cancellationToken.ThrowIfCancellationRequested();
 34617                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 618            }
 619            // Send Request
 34620            if (_shouldTrace)
 621            {
 0622                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 623            }
 34624            cancellationToken.ThrowIfCancellationRequested();
 34625            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 34626            if (_shouldTrace)
 627            {
 0628                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 629            }
 34630            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 34631            cancellationToken.ThrowIfCancellationRequested();
 34632            string _responseContent = null;
 34633            if ((int)_statusCode != 200 && (int)_statusCode != 201)
 634            {
 6635                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 636                try
 637                {
 6638                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6639                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 6640                    if (_errorBody != null)
 641                    {
 6642                        ex = new CloudException(_errorBody.Message);
 6643                        ex.Body = _errorBody;
 644                    }
 6645                }
 0646                catch (JsonException)
 647                {
 648                    // Ignore the exception
 0649                }
 6650                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 6651                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 6652                if (_httpResponse.Headers.Contains("request-id"))
 653                {
 6654                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 655                }
 6656                if (_shouldTrace)
 657                {
 0658                    ServiceClientTracing.Error(_invocationId, ex);
 659                }
 6660                _httpRequest.Dispose();
 6661                if (_httpResponse != null)
 662                {
 6663                    _httpResponse.Dispose();
 664                }
 6665                throw ex;
 666            }
 667            // Create Result
 28668            var _result = new AzureOperationResponse<Indexer>();
 28669            _result.Request = _httpRequest;
 28670            _result.Response = _httpResponse;
 28671            if (_httpResponse.Headers.Contains("request-id"))
 672            {
 28673                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 674            }
 675            // Deserialize Response
 28676            if ((int)_statusCode == 200)
 677            {
 10678                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 679                try
 680                {
 10681                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Indexer>(_responseContent, Clien
 10682                }
 0683                catch (JsonException ex)
 684                {
 0685                    _httpRequest.Dispose();
 0686                    if (_httpResponse != null)
 687                    {
 0688                        _httpResponse.Dispose();
 689                    }
 0690                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 691                }
 692            }
 693            // Deserialize Response
 28694            if ((int)_statusCode == 201)
 695            {
 18696                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 697                try
 698                {
 18699                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Indexer>(_responseContent, Clien
 18700                }
 0701                catch (JsonException ex)
 702                {
 0703                    _httpRequest.Dispose();
 0704                    if (_httpResponse != null)
 705                    {
 0706                        _httpResponse.Dispose();
 707                    }
 0708                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 709                }
 710            }
 28711            if (_shouldTrace)
 712            {
 0713                ServiceClientTracing.Exit(_invocationId, _result);
 714            }
 28715            return _result;
 28716        }
 717
 718        /// <summary>
 719        /// Deletes an indexer.
 720        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Delete-Indexer" />
 721        /// </summary>
 722        /// <param name='indexerName'>
 723        /// The name of the indexer to delete.
 724        /// </param>
 725        /// <param name='searchRequestOptions'>
 726        /// Additional parameters for the operation
 727        /// </param>
 728        /// <param name='accessCondition'>
 729        /// Additional parameters for the operation
 730        /// </param>
 731        /// <param name='customHeaders'>
 732        /// Headers that will be added to request.
 733        /// </param>
 734        /// <param name='cancellationToken'>
 735        /// The cancellation token.
 736        /// </param>
 737        /// <exception cref="CloudException">
 738        /// Thrown when the operation returned an invalid status code
 739        /// </exception>
 740        /// <exception cref="ValidationException">
 741        /// Thrown when a required parameter is null
 742        /// </exception>
 743        /// <exception cref="System.ArgumentNullException">
 744        /// Thrown when a required parameter is null
 745        /// </exception>
 746        /// <return>
 747        /// A response object containing the response body and response headers.
 748        /// </return>
 749        public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string indexerName, SearchRequestOptions s
 750        {
 14751            if (Client.SearchServiceName == null)
 752            {
 0753                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 754            }
 14755            if (Client.SearchDnsSuffix == null)
 756            {
 0757                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 758            }
 14759            if (indexerName == null)
 760            {
 0761                throw new ValidationException(ValidationRules.CannotBeNull, "indexerName");
 762            }
 14763            if (Client.ApiVersion == null)
 764            {
 0765                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 766            }
 14767            System.Guid? clientRequestId = default(System.Guid?);
 14768            if (searchRequestOptions != null)
 769            {
 0770                clientRequestId = searchRequestOptions.ClientRequestId;
 771            }
 14772            string ifMatch = default(string);
 14773            if (accessCondition != null)
 774            {
 8775                ifMatch = accessCondition.IfMatch;
 776            }
 14777            string ifNoneMatch = default(string);
 14778            if (accessCondition != null)
 779            {
 8780                ifNoneMatch = accessCondition.IfNoneMatch;
 781            }
 782            // Tracing
 14783            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 14784            string _invocationId = null;
 14785            if (_shouldTrace)
 786            {
 0787                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0788                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0789                tracingParameters.Add("indexerName", indexerName);
 0790                tracingParameters.Add("clientRequestId", clientRequestId);
 0791                tracingParameters.Add("ifMatch", ifMatch);
 0792                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 0793                tracingParameters.Add("cancellationToken", cancellationToken);
 0794                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 795            }
 796            // Construct URL
 14797            var _baseUrl = Client.BaseUri;
 14798            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "indexers('{indexerName}')";
 14799            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 14800            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 14801            _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName));
 14802            List<string> _queryParameters = new List<string>();
 14803            if (Client.ApiVersion != null)
 804            {
 14805                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 806            }
 14807            if (_queryParameters.Count > 0)
 808            {
 14809                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 810            }
 811            // Create HTTP transport objects
 14812            var _httpRequest = new HttpRequestMessage();
 14813            HttpResponseMessage _httpResponse = null;
 14814            _httpRequest.Method = new HttpMethod("DELETE");
 14815            _httpRequest.RequestUri = new System.Uri(_url);
 816            // Set Headers
 14817            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 818            {
 14819                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 820            }
 14821            if (Client.AcceptLanguage != null)
 822            {
 14823                if (_httpRequest.Headers.Contains("accept-language"))
 824                {
 0825                    _httpRequest.Headers.Remove("accept-language");
 826                }
 14827                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 828            }
 14829            if (clientRequestId != null)
 830            {
 0831                if (_httpRequest.Headers.Contains("client-request-id"))
 832                {
 0833                    _httpRequest.Headers.Remove("client-request-id");
 834                }
 0835                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 836            }
 14837            if (ifMatch != null)
 838            {
 8839                if (_httpRequest.Headers.Contains("If-Match"))
 840                {
 0841                    _httpRequest.Headers.Remove("If-Match");
 842                }
 8843                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 844            }
 14845            if (ifNoneMatch != null)
 846            {
 0847                if (_httpRequest.Headers.Contains("If-None-Match"))
 848                {
 0849                    _httpRequest.Headers.Remove("If-None-Match");
 850                }
 0851                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 852            }
 853
 854
 14855            if (customHeaders != null)
 856            {
 0857                foreach(var _header in customHeaders)
 858                {
 0859                    if (_httpRequest.Headers.Contains(_header.Key))
 860                    {
 0861                        _httpRequest.Headers.Remove(_header.Key);
 862                    }
 0863                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 864                }
 865            }
 866
 867            // Serialize Request
 14868            string _requestContent = null;
 869            // Set Credentials
 14870            if (Client.Credentials != null)
 871            {
 14872                cancellationToken.ThrowIfCancellationRequested();
 14873                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 874            }
 875            // Send Request
 14876            if (_shouldTrace)
 877            {
 0878                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 879            }
 14880            cancellationToken.ThrowIfCancellationRequested();
 14881            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 14882            if (_shouldTrace)
 883            {
 0884                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 885            }
 14886            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 14887            cancellationToken.ThrowIfCancellationRequested();
 14888            string _responseContent = null;
 14889            if ((int)_statusCode != 204 && (int)_statusCode != 404)
 890            {
 4891                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 892                try
 893                {
 4894                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4895                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 4896                    if (_errorBody != null)
 897                    {
 4898                        ex = new CloudException(_errorBody.Message);
 4899                        ex.Body = _errorBody;
 900                    }
 4901                }
 0902                catch (JsonException)
 903                {
 904                    // Ignore the exception
 0905                }
 4906                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 4907                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 4908                if (_httpResponse.Headers.Contains("request-id"))
 909                {
 4910                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 911                }
 4912                if (_shouldTrace)
 913                {
 0914                    ServiceClientTracing.Error(_invocationId, ex);
 915                }
 4916                _httpRequest.Dispose();
 4917                if (_httpResponse != null)
 918                {
 4919                    _httpResponse.Dispose();
 920                }
 4921                throw ex;
 922            }
 923            // Create Result
 10924            var _result = new AzureOperationResponse();
 10925            _result.Request = _httpRequest;
 10926            _result.Response = _httpResponse;
 10927            if (_httpResponse.Headers.Contains("request-id"))
 928            {
 10929                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 930            }
 10931            if (_shouldTrace)
 932            {
 0933                ServiceClientTracing.Exit(_invocationId, _result);
 934            }
 10935            return _result;
 10936        }
 937
 938        /// <summary>
 939        /// Retrieves an indexer definition.
 940        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Get-Indexer" />
 941        /// </summary>
 942        /// <param name='indexerName'>
 943        /// The name of the indexer to retrieve.
 944        /// </param>
 945        /// <param name='searchRequestOptions'>
 946        /// Additional parameters for the operation
 947        /// </param>
 948        /// <param name='customHeaders'>
 949        /// Headers that will be added to request.
 950        /// </param>
 951        /// <param name='cancellationToken'>
 952        /// The cancellation token.
 953        /// </param>
 954        /// <exception cref="CloudException">
 955        /// Thrown when the operation returned an invalid status code
 956        /// </exception>
 957        /// <exception cref="SerializationException">
 958        /// Thrown when unable to deserialize the response
 959        /// </exception>
 960        /// <exception cref="ValidationException">
 961        /// Thrown when a required parameter is null
 962        /// </exception>
 963        /// <exception cref="System.ArgumentNullException">
 964        /// Thrown when a required parameter is null
 965        /// </exception>
 966        /// <return>
 967        /// A response object containing the response body and response headers.
 968        /// </return>
 969        public async Task<AzureOperationResponse<Indexer>> GetWithHttpMessagesAsync(string indexerName, SearchRequestOpt
 970        {
 8971            if (Client.SearchServiceName == null)
 972            {
 0973                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 974            }
 8975            if (Client.SearchDnsSuffix == null)
 976            {
 0977                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 978            }
 8979            if (indexerName == null)
 980            {
 0981                throw new ValidationException(ValidationRules.CannotBeNull, "indexerName");
 982            }
 8983            if (Client.ApiVersion == null)
 984            {
 0985                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 986            }
 8987            System.Guid? clientRequestId = default(System.Guid?);
 8988            if (searchRequestOptions != null)
 989            {
 0990                clientRequestId = searchRequestOptions.ClientRequestId;
 991            }
 992            // Tracing
 8993            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 8994            string _invocationId = null;
 8995            if (_shouldTrace)
 996            {
 0997                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0998                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0999                tracingParameters.Add("indexerName", indexerName);
 01000                tracingParameters.Add("clientRequestId", clientRequestId);
 01001                tracingParameters.Add("cancellationToken", cancellationToken);
 01002                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 1003            }
 1004            // Construct URL
 81005            var _baseUrl = Client.BaseUri;
 81006            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "indexers('{indexerName}')";
 81007            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 81008            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 81009            _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName));
 81010            List<string> _queryParameters = new List<string>();
 81011            if (Client.ApiVersion != null)
 1012            {
 81013                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1014            }
 81015            if (_queryParameters.Count > 0)
 1016            {
 81017                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1018            }
 1019            // Create HTTP transport objects
 81020            var _httpRequest = new HttpRequestMessage();
 81021            HttpResponseMessage _httpResponse = null;
 81022            _httpRequest.Method = new HttpMethod("GET");
 81023            _httpRequest.RequestUri = new System.Uri(_url);
 1024            // Set Headers
 81025            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1026            {
 81027                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1028            }
 81029            if (Client.AcceptLanguage != null)
 1030            {
 81031                if (_httpRequest.Headers.Contains("accept-language"))
 1032                {
 01033                    _httpRequest.Headers.Remove("accept-language");
 1034                }
 81035                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1036            }
 81037            if (clientRequestId != null)
 1038            {
 01039                if (_httpRequest.Headers.Contains("client-request-id"))
 1040                {
 01041                    _httpRequest.Headers.Remove("client-request-id");
 1042                }
 01043                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 1044            }
 1045
 1046
 81047            if (customHeaders != null)
 1048            {
 01049                foreach(var _header in customHeaders)
 1050                {
 01051                    if (_httpRequest.Headers.Contains(_header.Key))
 1052                    {
 01053                        _httpRequest.Headers.Remove(_header.Key);
 1054                    }
 01055                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1056                }
 1057            }
 1058
 1059            // Serialize Request
 81060            string _requestContent = null;
 1061            // Set Credentials
 81062            if (Client.Credentials != null)
 1063            {
 81064                cancellationToken.ThrowIfCancellationRequested();
 81065                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1066            }
 1067            // Send Request
 81068            if (_shouldTrace)
 1069            {
 01070                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1071            }
 81072            cancellationToken.ThrowIfCancellationRequested();
 81073            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 81074            if (_shouldTrace)
 1075            {
 01076                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1077            }
 81078            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 81079            cancellationToken.ThrowIfCancellationRequested();
 81080            string _responseContent = null;
 81081            if ((int)_statusCode != 200)
 1082            {
 41083                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1084                try
 1085                {
 41086                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 41087                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 41088                    if (_errorBody != null)
 1089                    {
 41090                        ex = new CloudException(_errorBody.Message);
 41091                        ex.Body = _errorBody;
 1092                    }
 41093                }
 01094                catch (JsonException)
 1095                {
 1096                    // Ignore the exception
 01097                }
 41098                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 41099                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 41100                if (_httpResponse.Headers.Contains("request-id"))
 1101                {
 41102                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1103                }
 41104                if (_shouldTrace)
 1105                {
 01106                    ServiceClientTracing.Error(_invocationId, ex);
 1107                }
 41108                _httpRequest.Dispose();
 41109                if (_httpResponse != null)
 1110                {
 41111                    _httpResponse.Dispose();
 1112                }
 41113                throw ex;
 1114            }
 1115            // Create Result
 41116            var _result = new AzureOperationResponse<Indexer>();
 41117            _result.Request = _httpRequest;
 41118            _result.Response = _httpResponse;
 41119            if (_httpResponse.Headers.Contains("request-id"))
 1120            {
 41121                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1122            }
 1123            // Deserialize Response
 41124            if ((int)_statusCode == 200)
 1125            {
 41126                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1127                try
 1128                {
 41129                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Indexer>(_responseContent, Clien
 41130                }
 01131                catch (JsonException ex)
 1132                {
 01133                    _httpRequest.Dispose();
 01134                    if (_httpResponse != null)
 1135                    {
 01136                        _httpResponse.Dispose();
 1137                    }
 01138                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1139                }
 1140            }
 41141            if (_shouldTrace)
 1142            {
 01143                ServiceClientTracing.Exit(_invocationId, _result);
 1144            }
 41145            return _result;
 41146        }
 1147
 1148        /// <summary>
 1149        /// Lists all indexers available for a search service.
 1150        /// <see href="https://docs.microsoft.com/rest/api/searchservice/List-Indexers" />
 1151        /// </summary>
 1152        /// <param name='searchRequestOptions'>
 1153        /// Additional parameters for the operation
 1154        /// </param>
 1155        /// <param name='customHeaders'>
 1156        /// Headers that will be added to request.
 1157        /// </param>
 1158        /// <param name='cancellationToken'>
 1159        /// The cancellation token.
 1160        /// </param>
 1161        /// <exception cref="CloudException">
 1162        /// Thrown when the operation returned an invalid status code
 1163        /// </exception>
 1164        /// <exception cref="SerializationException">
 1165        /// Thrown when unable to deserialize the response
 1166        /// </exception>
 1167        /// <exception cref="ValidationException">
 1168        /// Thrown when a required parameter is null
 1169        /// </exception>
 1170        /// <exception cref="System.ArgumentNullException">
 1171        /// Thrown when a required parameter is null
 1172        /// </exception>
 1173        /// <return>
 1174        /// A response object containing the response body and response headers.
 1175        /// </return>
 1176        public async Task<AzureOperationResponse<IndexerListResult>> ListWithHttpMessagesAsync(SearchRequestOptions sear
 1177        {
 21178            if (Client.SearchServiceName == null)
 1179            {
 01180                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 1181            }
 21182            if (Client.SearchDnsSuffix == null)
 1183            {
 01184                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 1185            }
 21186            if (Client.ApiVersion == null)
 1187            {
 01188                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1189            }
 21190            System.Guid? clientRequestId = default(System.Guid?);
 21191            if (searchRequestOptions != null)
 1192            {
 01193                clientRequestId = searchRequestOptions.ClientRequestId;
 1194            }
 1195            // Tracing
 21196            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 21197            string _invocationId = null;
 21198            if (_shouldTrace)
 1199            {
 01200                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01201                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01202                tracingParameters.Add("clientRequestId", clientRequestId);
 01203                tracingParameters.Add("cancellationToken", cancellationToken);
 01204                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 1205            }
 1206            // Construct URL
 21207            var _baseUrl = Client.BaseUri;
 21208            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "indexers";
 21209            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 21210            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 21211            List<string> _queryParameters = new List<string>();
 21212            if (Client.ApiVersion != null)
 1213            {
 21214                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1215            }
 21216            if (_queryParameters.Count > 0)
 1217            {
 21218                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1219            }
 1220            // Create HTTP transport objects
 21221            var _httpRequest = new HttpRequestMessage();
 21222            HttpResponseMessage _httpResponse = null;
 21223            _httpRequest.Method = new HttpMethod("GET");
 21224            _httpRequest.RequestUri = new System.Uri(_url);
 1225            // Set Headers
 21226            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1227            {
 21228                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1229            }
 21230            if (Client.AcceptLanguage != null)
 1231            {
 21232                if (_httpRequest.Headers.Contains("accept-language"))
 1233                {
 01234                    _httpRequest.Headers.Remove("accept-language");
 1235                }
 21236                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1237            }
 21238            if (clientRequestId != null)
 1239            {
 01240                if (_httpRequest.Headers.Contains("client-request-id"))
 1241                {
 01242                    _httpRequest.Headers.Remove("client-request-id");
 1243                }
 01244                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 1245            }
 1246
 1247
 21248            if (customHeaders != null)
 1249            {
 01250                foreach(var _header in customHeaders)
 1251                {
 01252                    if (_httpRequest.Headers.Contains(_header.Key))
 1253                    {
 01254                        _httpRequest.Headers.Remove(_header.Key);
 1255                    }
 01256                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1257                }
 1258            }
 1259
 1260            // Serialize Request
 21261            string _requestContent = null;
 1262            // Set Credentials
 21263            if (Client.Credentials != null)
 1264            {
 21265                cancellationToken.ThrowIfCancellationRequested();
 21266                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1267            }
 1268            // Send Request
 21269            if (_shouldTrace)
 1270            {
 01271                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1272            }
 21273            cancellationToken.ThrowIfCancellationRequested();
 21274            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 21275            if (_shouldTrace)
 1276            {
 01277                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1278            }
 21279            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 21280            cancellationToken.ThrowIfCancellationRequested();
 21281            string _responseContent = null;
 21282            if ((int)_statusCode != 200)
 1283            {
 01284                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1285                try
 1286                {
 01287                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01288                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 01289                    if (_errorBody != null)
 1290                    {
 01291                        ex = new CloudException(_errorBody.Message);
 01292                        ex.Body = _errorBody;
 1293                    }
 01294                }
 01295                catch (JsonException)
 1296                {
 1297                    // Ignore the exception
 01298                }
 01299                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01300                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01301                if (_httpResponse.Headers.Contains("request-id"))
 1302                {
 01303                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1304                }
 01305                if (_shouldTrace)
 1306                {
 01307                    ServiceClientTracing.Error(_invocationId, ex);
 1308                }
 01309                _httpRequest.Dispose();
 01310                if (_httpResponse != null)
 1311                {
 01312                    _httpResponse.Dispose();
 1313                }
 01314                throw ex;
 1315            }
 1316            // Create Result
 21317            var _result = new AzureOperationResponse<IndexerListResult>();
 21318            _result.Request = _httpRequest;
 21319            _result.Response = _httpResponse;
 21320            if (_httpResponse.Headers.Contains("request-id"))
 1321            {
 21322                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1323            }
 1324            // Deserialize Response
 21325            if ((int)_statusCode == 200)
 1326            {
 21327                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1328                try
 1329                {
 21330                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IndexerListResult>(_responseCont
 21331                }
 01332                catch (JsonException ex)
 1333                {
 01334                    _httpRequest.Dispose();
 01335                    if (_httpResponse != null)
 1336                    {
 01337                        _httpResponse.Dispose();
 1338                    }
 01339                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1340                }
 1341            }
 21342            if (_shouldTrace)
 1343            {
 01344                ServiceClientTracing.Exit(_invocationId, _result);
 1345            }
 21346            return _result;
 21347        }
 1348
 1349        /// <summary>
 1350        /// Creates a new indexer.
 1351        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Create-Indexer" />
 1352        /// </summary>
 1353        /// <param name='indexer'>
 1354        /// The definition of the indexer to create.
 1355        /// </param>
 1356        /// <param name='searchRequestOptions'>
 1357        /// Additional parameters for the operation
 1358        /// </param>
 1359        /// <param name='customHeaders'>
 1360        /// Headers that will be added to request.
 1361        /// </param>
 1362        /// <param name='cancellationToken'>
 1363        /// The cancellation token.
 1364        /// </param>
 1365        /// <exception cref="CloudException">
 1366        /// Thrown when the operation returned an invalid status code
 1367        /// </exception>
 1368        /// <exception cref="SerializationException">
 1369        /// Thrown when unable to deserialize the response
 1370        /// </exception>
 1371        /// <exception cref="ValidationException">
 1372        /// Thrown when a required parameter is null
 1373        /// </exception>
 1374        /// <exception cref="System.ArgumentNullException">
 1375        /// Thrown when a required parameter is null
 1376        /// </exception>
 1377        /// <return>
 1378        /// A response object containing the response body and response headers.
 1379        /// </return>
 1380        public async Task<AzureOperationResponse<Indexer>> CreateWithHttpMessagesAsync(Indexer indexer, SearchRequestOpt
 1381        {
 221382            if (Client.SearchServiceName == null)
 1383            {
 01384                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 1385            }
 221386            if (Client.SearchDnsSuffix == null)
 1387            {
 01388                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 1389            }
 221390            if (indexer == null)
 1391            {
 01392                throw new ValidationException(ValidationRules.CannotBeNull, "indexer");
 1393            }
 221394            if (indexer != null)
 1395            {
 221396                indexer.Validate();
 1397            }
 221398            if (Client.ApiVersion == null)
 1399            {
 01400                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1401            }
 221402            System.Guid? clientRequestId = default(System.Guid?);
 221403            if (searchRequestOptions != null)
 1404            {
 01405                clientRequestId = searchRequestOptions.ClientRequestId;
 1406            }
 1407            // Tracing
 221408            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 221409            string _invocationId = null;
 221410            if (_shouldTrace)
 1411            {
 01412                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01413                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01414                tracingParameters.Add("indexer", indexer);
 01415                tracingParameters.Add("clientRequestId", clientRequestId);
 01416                tracingParameters.Add("cancellationToken", cancellationToken);
 01417                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
 1418            }
 1419            // Construct URL
 221420            var _baseUrl = Client.BaseUri;
 221421            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "indexers";
 221422            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 221423            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 221424            List<string> _queryParameters = new List<string>();
 221425            if (Client.ApiVersion != null)
 1426            {
 221427                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1428            }
 221429            if (_queryParameters.Count > 0)
 1430            {
 221431                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1432            }
 1433            // Create HTTP transport objects
 221434            var _httpRequest = new HttpRequestMessage();
 221435            HttpResponseMessage _httpResponse = null;
 221436            _httpRequest.Method = new HttpMethod("POST");
 221437            _httpRequest.RequestUri = new System.Uri(_url);
 1438            // Set Headers
 221439            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1440            {
 221441                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1442            }
 221443            if (Client.AcceptLanguage != null)
 1444            {
 221445                if (_httpRequest.Headers.Contains("accept-language"))
 1446                {
 01447                    _httpRequest.Headers.Remove("accept-language");
 1448                }
 221449                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1450            }
 221451            if (clientRequestId != null)
 1452            {
 01453                if (_httpRequest.Headers.Contains("client-request-id"))
 1454                {
 01455                    _httpRequest.Headers.Remove("client-request-id");
 1456                }
 01457                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 1458            }
 1459
 1460
 221461            if (customHeaders != null)
 1462            {
 01463                foreach(var _header in customHeaders)
 1464                {
 01465                    if (_httpRequest.Headers.Contains(_header.Key))
 1466                    {
 01467                        _httpRequest.Headers.Remove(_header.Key);
 1468                    }
 01469                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1470                }
 1471            }
 1472
 1473            // Serialize Request
 221474            string _requestContent = null;
 221475            if(indexer != null)
 1476            {
 221477                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(indexer, Client.SerializationSettin
 221478                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 221479                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1480            }
 1481            // Set Credentials
 221482            if (Client.Credentials != null)
 1483            {
 221484                cancellationToken.ThrowIfCancellationRequested();
 221485                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1486            }
 1487            // Send Request
 221488            if (_shouldTrace)
 1489            {
 01490                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1491            }
 221492            cancellationToken.ThrowIfCancellationRequested();
 221493            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 221494            if (_shouldTrace)
 1495            {
 01496                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1497            }
 221498            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 221499            cancellationToken.ThrowIfCancellationRequested();
 221500            string _responseContent = null;
 221501            if ((int)_statusCode != 201)
 1502            {
 21503                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1504                try
 1505                {
 21506                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 21507                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 21508                    if (_errorBody != null)
 1509                    {
 21510                        ex = new CloudException(_errorBody.Message);
 21511                        ex.Body = _errorBody;
 1512                    }
 21513                }
 01514                catch (JsonException)
 1515                {
 1516                    // Ignore the exception
 01517                }
 21518                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 21519                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 21520                if (_httpResponse.Headers.Contains("request-id"))
 1521                {
 21522                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1523                }
 21524                if (_shouldTrace)
 1525                {
 01526                    ServiceClientTracing.Error(_invocationId, ex);
 1527                }
 21528                _httpRequest.Dispose();
 21529                if (_httpResponse != null)
 1530                {
 21531                    _httpResponse.Dispose();
 1532                }
 21533                throw ex;
 1534            }
 1535            // Create Result
 201536            var _result = new AzureOperationResponse<Indexer>();
 201537            _result.Request = _httpRequest;
 201538            _result.Response = _httpResponse;
 201539            if (_httpResponse.Headers.Contains("request-id"))
 1540            {
 201541                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1542            }
 1543            // Deserialize Response
 201544            if ((int)_statusCode == 201)
 1545            {
 201546                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1547                try
 1548                {
 201549                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Indexer>(_responseContent, Clien
 201550                }
 01551                catch (JsonException ex)
 1552                {
 01553                    _httpRequest.Dispose();
 01554                    if (_httpResponse != null)
 1555                    {
 01556                        _httpResponse.Dispose();
 1557                    }
 01558                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1559                }
 1560            }
 201561            if (_shouldTrace)
 1562            {
 01563                ServiceClientTracing.Exit(_invocationId, _result);
 1564            }
 201565            return _result;
 201566        }
 1567
 1568        /// <summary>
 1569        /// Returns the current status and execution history of an indexer.
 1570        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Get-Indexer-Status" />
 1571        /// </summary>
 1572        /// <param name='indexerName'>
 1573        /// The name of the indexer for which to retrieve status.
 1574        /// </param>
 1575        /// <param name='searchRequestOptions'>
 1576        /// Additional parameters for the operation
 1577        /// </param>
 1578        /// <param name='customHeaders'>
 1579        /// Headers that will be added to request.
 1580        /// </param>
 1581        /// <param name='cancellationToken'>
 1582        /// The cancellation token.
 1583        /// </param>
 1584        /// <exception cref="CloudException">
 1585        /// Thrown when the operation returned an invalid status code
 1586        /// </exception>
 1587        /// <exception cref="SerializationException">
 1588        /// Thrown when unable to deserialize the response
 1589        /// </exception>
 1590        /// <exception cref="ValidationException">
 1591        /// Thrown when a required parameter is null
 1592        /// </exception>
 1593        /// <exception cref="System.ArgumentNullException">
 1594        /// Thrown when a required parameter is null
 1595        /// </exception>
 1596        /// <return>
 1597        /// A response object containing the response body and response headers.
 1598        /// </return>
 1599        public async Task<AzureOperationResponse<IndexerExecutionInfo>> GetStatusWithHttpMessagesAsync(string indexerNam
 1600        {
 61601            if (Client.SearchServiceName == null)
 1602            {
 01603                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 1604            }
 61605            if (Client.SearchDnsSuffix == null)
 1606            {
 01607                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 1608            }
 61609            if (indexerName == null)
 1610            {
 01611                throw new ValidationException(ValidationRules.CannotBeNull, "indexerName");
 1612            }
 61613            if (Client.ApiVersion == null)
 1614            {
 01615                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1616            }
 61617            System.Guid? clientRequestId = default(System.Guid?);
 61618            if (searchRequestOptions != null)
 1619            {
 01620                clientRequestId = searchRequestOptions.ClientRequestId;
 1621            }
 1622            // Tracing
 61623            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 61624            string _invocationId = null;
 61625            if (_shouldTrace)
 1626            {
 01627                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01628                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01629                tracingParameters.Add("indexerName", indexerName);
 01630                tracingParameters.Add("clientRequestId", clientRequestId);
 01631                tracingParameters.Add("cancellationToken", cancellationToken);
 01632                ServiceClientTracing.Enter(_invocationId, this, "GetStatus", tracingParameters);
 1633            }
 1634            // Construct URL
 61635            var _baseUrl = Client.BaseUri;
 61636            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "indexers('{indexerName}')/search.status";
 61637            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 61638            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 61639            _url = _url.Replace("{indexerName}", System.Uri.EscapeDataString(indexerName));
 61640            List<string> _queryParameters = new List<string>();
 61641            if (Client.ApiVersion != null)
 1642            {
 61643                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1644            }
 61645            if (_queryParameters.Count > 0)
 1646            {
 61647                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1648            }
 1649            // Create HTTP transport objects
 61650            var _httpRequest = new HttpRequestMessage();
 61651            HttpResponseMessage _httpResponse = null;
 61652            _httpRequest.Method = new HttpMethod("GET");
 61653            _httpRequest.RequestUri = new System.Uri(_url);
 1654            // Set Headers
 61655            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1656            {
 61657                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1658            }
 61659            if (Client.AcceptLanguage != null)
 1660            {
 61661                if (_httpRequest.Headers.Contains("accept-language"))
 1662                {
 01663                    _httpRequest.Headers.Remove("accept-language");
 1664                }
 61665                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1666            }
 61667            if (clientRequestId != null)
 1668            {
 01669                if (_httpRequest.Headers.Contains("client-request-id"))
 1670                {
 01671                    _httpRequest.Headers.Remove("client-request-id");
 1672                }
 01673                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 1674            }
 1675
 1676
 61677            if (customHeaders != null)
 1678            {
 01679                foreach(var _header in customHeaders)
 1680                {
 01681                    if (_httpRequest.Headers.Contains(_header.Key))
 1682                    {
 01683                        _httpRequest.Headers.Remove(_header.Key);
 1684                    }
 01685                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1686                }
 1687            }
 1688
 1689            // Serialize Request
 61690            string _requestContent = null;
 1691            // Set Credentials
 61692            if (Client.Credentials != null)
 1693            {
 61694                cancellationToken.ThrowIfCancellationRequested();
 61695                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1696            }
 1697            // Send Request
 61698            if (_shouldTrace)
 1699            {
 01700                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1701            }
 61702            cancellationToken.ThrowIfCancellationRequested();
 61703            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 61704            if (_shouldTrace)
 1705            {
 01706                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1707            }
 61708            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 61709            cancellationToken.ThrowIfCancellationRequested();
 61710            string _responseContent = null;
 61711            if ((int)_statusCode != 200)
 1712            {
 01713                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1714                try
 1715                {
 01716                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01717                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 01718                    if (_errorBody != null)
 1719                    {
 01720                        ex = new CloudException(_errorBody.Message);
 01721                        ex.Body = _errorBody;
 1722                    }
 01723                }
 01724                catch (JsonException)
 1725                {
 1726                    // Ignore the exception
 01727                }
 01728                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01729                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01730                if (_httpResponse.Headers.Contains("request-id"))
 1731                {
 01732                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1733                }
 01734                if (_shouldTrace)
 1735                {
 01736                    ServiceClientTracing.Error(_invocationId, ex);
 1737                }
 01738                _httpRequest.Dispose();
 01739                if (_httpResponse != null)
 1740                {
 01741                    _httpResponse.Dispose();
 1742                }
 01743                throw ex;
 1744            }
 1745            // Create Result
 61746            var _result = new AzureOperationResponse<IndexerExecutionInfo>();
 61747            _result.Request = _httpRequest;
 61748            _result.Response = _httpResponse;
 61749            if (_httpResponse.Headers.Contains("request-id"))
 1750            {
 61751                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1752            }
 1753            // Deserialize Response
 61754            if ((int)_statusCode == 200)
 1755            {
 61756                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1757                try
 1758                {
 61759                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IndexerExecutionInfo>(_responseC
 61760                }
 01761                catch (JsonException ex)
 1762                {
 01763                    _httpRequest.Dispose();
 01764                    if (_httpResponse != null)
 1765                    {
 01766                        _httpResponse.Dispose();
 1767                    }
 01768                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1769                }
 1770            }
 61771            if (_shouldTrace)
 1772            {
 01773                ServiceClientTracing.Exit(_invocationId, _result);
 1774            }
 61775            return _result;
 61776        }
 1777
 1778    }
 1779}