< Summary

Class:Microsoft.Azure.Management.Search.ServicesOperations
Assembly:Microsoft.Azure.Management.Search
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\src\Generated\ServicesOperations.cs
Covered lines:120
Uncovered lines:780
Coverable lines:900
Total lines:1996
Line coverage:13.3% (120 of 900)
Covered branches:71
Total branches:552
Branch coverage:12.8% (71 of 552)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
CreateOrUpdateWithHttpMessagesAsync()-100%100%
UpdateWithHttpMessagesAsync()-0%0%
GetWithHttpMessagesAsync()-0%0%
DeleteWithHttpMessagesAsync()-54.35%50%
ListByResourceGroupWithHttpMessagesAsync()-0%0%
ListBySubscriptionWithHttpMessagesAsync()-0%0%
CheckNameAvailabilityWithHttpMessagesAsync()-0%0%
BeginCreateOrUpdateWithHttpMessagesAsync()-52.1%52.7%
ListByResourceGroupNextWithHttpMessagesAsync()-0%0%
ListBySubscriptionNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\src\Generated\ServicesOperations.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.Management.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    /// ServicesOperations operations.
 27    /// </summary>
 28    internal partial class ServicesOperations : IServiceOperations<SearchManagementClient>, IServicesOperations
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the ServicesOperations 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>
 120439        internal ServicesOperations(SearchManagementClient client)
 40        {
 120441            if (client == null)
 42            {
 043                throw new System.ArgumentNullException("client");
 44            }
 120445            Client = client;
 120446        }
 47
 48        /// <summary>
 49        /// Gets a reference to the SearchManagementClient
 50        /// </summary>
 1866251        public SearchManagementClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Creates or updates a Search service in the given resource group. If the
 55        /// Search service already exists, all properties will be updated with the
 56        /// given values.
 57        /// <see href="https://aka.ms/search-manage" />
 58        /// </summary>
 59        /// <param name='resourceGroupName'>
 60        /// The name of the resource group within the current subscription. You can
 61        /// obtain this value from the Azure Resource Manager API or the portal.
 62        /// </param>
 63        /// <param name='searchServiceName'>
 64        /// The name of the Azure Cognitive Search service to create or update. Search
 65        /// service names must only contain lowercase letters, digits or dashes, cannot
 66        /// use dash as the first two or last one characters, cannot contain
 67        /// consecutive dashes, and must be between 2 and 60 characters in length.
 68        /// Search service names must be globally unique since they are part of the
 69        /// service URI (https://&lt;name&gt;.search.windows.net). You cannot change
 70        /// the service name after the service is created.
 71        /// </param>
 72        /// <param name='service'>
 73        /// The definition of the Search service to create or update.
 74        /// </param>
 75        /// <param name='searchManagementRequestOptions'>
 76        /// Additional parameters for the operation
 77        /// </param>
 78        /// <param name='customHeaders'>
 79        /// The headers that will be added to request.
 80        /// </param>
 81        /// <param name='cancellationToken'>
 82        /// The cancellation token.
 83        /// </param>
 84        public async Task<AzureOperationResponse<SearchService>> CreateOrUpdateWithHttpMessagesAsync(string resourceGrou
 85        {
 86            // Send Request
 60287            AzureOperationResponse<SearchService> _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGro
 60288            return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).Configure
 60289        }
 90
 91        /// <summary>
 92        /// Updates an existing Search service in the given resource group.
 93        /// <see href="https://aka.ms/search-manage" />
 94        /// </summary>
 95        /// <param name='resourceGroupName'>
 96        /// The name of the resource group within the current subscription. You can
 97        /// obtain this value from the Azure Resource Manager API or the portal.
 98        /// </param>
 99        /// <param name='searchServiceName'>
 100        /// The name of the Azure Cognitive Search service to update.
 101        /// </param>
 102        /// <param name='service'>
 103        /// The definition of the Search service to update.
 104        /// </param>
 105        /// <param name='searchManagementRequestOptions'>
 106        /// Additional parameters for the operation
 107        /// </param>
 108        /// <param name='customHeaders'>
 109        /// Headers that will be added to request.
 110        /// </param>
 111        /// <param name='cancellationToken'>
 112        /// The cancellation token.
 113        /// </param>
 114        /// <exception cref="CloudException">
 115        /// Thrown when the operation returned an invalid status code
 116        /// </exception>
 117        /// <exception cref="SerializationException">
 118        /// Thrown when unable to deserialize the response
 119        /// </exception>
 120        /// <exception cref="ValidationException">
 121        /// Thrown when a required parameter is null
 122        /// </exception>
 123        /// <exception cref="System.ArgumentNullException">
 124        /// Thrown when a required parameter is null
 125        /// </exception>
 126        /// <return>
 127        /// A response object containing the response body and response headers.
 128        /// </return>
 129        public async Task<AzureOperationResponse<SearchService>> UpdateWithHttpMessagesAsync(string resourceGroupName, s
 130        {
 0131            if (resourceGroupName == null)
 132            {
 0133                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 134            }
 0135            if (searchServiceName == null)
 136            {
 0137                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 138            }
 0139            if (service == null)
 140            {
 0141                throw new ValidationException(ValidationRules.CannotBeNull, "service");
 142            }
 0143            if (Client.ApiVersion == null)
 144            {
 0145                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 146            }
 0147            if (Client.SubscriptionId == null)
 148            {
 0149                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 150            }
 0151            System.Guid? clientRequestId = default(System.Guid?);
 0152            if (searchManagementRequestOptions != null)
 153            {
 0154                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 155            }
 156            // Tracing
 0157            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0158            string _invocationId = null;
 0159            if (_shouldTrace)
 160            {
 0161                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0162                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0163                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0164                tracingParameters.Add("searchServiceName", searchServiceName);
 0165                tracingParameters.Add("service", service);
 0166                tracingParameters.Add("clientRequestId", clientRequestId);
 0167                tracingParameters.Add("cancellationToken", cancellationToken);
 0168                ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
 169            }
 170            // Construct URL
 0171            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0172            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0173            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0174            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 0175            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0176            List<string> _queryParameters = new List<string>();
 0177            if (Client.ApiVersion != null)
 178            {
 0179                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 180            }
 0181            if (_queryParameters.Count > 0)
 182            {
 0183                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 184            }
 185            // Create HTTP transport objects
 0186            var _httpRequest = new HttpRequestMessage();
 0187            HttpResponseMessage _httpResponse = null;
 0188            _httpRequest.Method = new HttpMethod("PATCH");
 0189            _httpRequest.RequestUri = new System.Uri(_url);
 190            // Set Headers
 0191            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 192            {
 0193                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 194            }
 0195            if (Client.AcceptLanguage != null)
 196            {
 0197                if (_httpRequest.Headers.Contains("accept-language"))
 198                {
 0199                    _httpRequest.Headers.Remove("accept-language");
 200                }
 0201                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 202            }
 0203            if (clientRequestId != null)
 204            {
 0205                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 206                {
 0207                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 208                }
 0209                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 210            }
 211
 212
 0213            if (customHeaders != null)
 214            {
 0215                foreach(var _header in customHeaders)
 216                {
 0217                    if (_httpRequest.Headers.Contains(_header.Key))
 218                    {
 0219                        _httpRequest.Headers.Remove(_header.Key);
 220                    }
 0221                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 222                }
 223            }
 224
 225            // Serialize Request
 0226            string _requestContent = null;
 0227            if(service != null)
 228            {
 0229                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(service, Client.SerializationSettin
 0230                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0231                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 232            }
 233            // Set Credentials
 0234            if (Client.Credentials != null)
 235            {
 0236                cancellationToken.ThrowIfCancellationRequested();
 0237                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 238            }
 239            // Send Request
 0240            if (_shouldTrace)
 241            {
 0242                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 243            }
 0244            cancellationToken.ThrowIfCancellationRequested();
 0245            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0246            if (_shouldTrace)
 247            {
 0248                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 249            }
 0250            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0251            cancellationToken.ThrowIfCancellationRequested();
 0252            string _responseContent = null;
 0253            if ((int)_statusCode != 200)
 254            {
 0255                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 256                try
 257                {
 0258                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0259                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0260                    if (_errorBody != null)
 261                    {
 0262                        ex = new CloudException(_errorBody.Message);
 0263                        ex.Body = _errorBody;
 264                    }
 0265                }
 0266                catch (JsonException)
 267                {
 268                    // Ignore the exception
 0269                }
 0270                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0271                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0272                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 273                {
 0274                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 275                }
 0276                if (_shouldTrace)
 277                {
 0278                    ServiceClientTracing.Error(_invocationId, ex);
 279                }
 0280                _httpRequest.Dispose();
 0281                if (_httpResponse != null)
 282                {
 0283                    _httpResponse.Dispose();
 284                }
 0285                throw ex;
 286            }
 287            // Create Result
 0288            var _result = new AzureOperationResponse<SearchService>();
 0289            _result.Request = _httpRequest;
 0290            _result.Response = _httpResponse;
 0291            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 292            {
 0293                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 294            }
 295            // Deserialize Response
 0296            if ((int)_statusCode == 200)
 297            {
 0298                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 299                try
 300                {
 0301                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SearchService>(_responseContent,
 0302                }
 0303                catch (JsonException ex)
 304                {
 0305                    _httpRequest.Dispose();
 0306                    if (_httpResponse != null)
 307                    {
 0308                        _httpResponse.Dispose();
 309                    }
 0310                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 311                }
 312            }
 0313            if (_shouldTrace)
 314            {
 0315                ServiceClientTracing.Exit(_invocationId, _result);
 316            }
 0317            return _result;
 0318        }
 319
 320        /// <summary>
 321        /// Gets the Search service with the given name in the given resource group.
 322        /// <see href="https://aka.ms/search-manage" />
 323        /// </summary>
 324        /// <param name='resourceGroupName'>
 325        /// The name of the resource group within the current subscription. You can
 326        /// obtain this value from the Azure Resource Manager API or the portal.
 327        /// </param>
 328        /// <param name='searchServiceName'>
 329        /// The name of the Azure Cognitive Search service associated with the
 330        /// specified resource group.
 331        /// </param>
 332        /// <param name='searchManagementRequestOptions'>
 333        /// Additional parameters for the operation
 334        /// </param>
 335        /// <param name='customHeaders'>
 336        /// Headers that will be added to request.
 337        /// </param>
 338        /// <param name='cancellationToken'>
 339        /// The cancellation token.
 340        /// </param>
 341        /// <exception cref="CloudException">
 342        /// Thrown when the operation returned an invalid status code
 343        /// </exception>
 344        /// <exception cref="SerializationException">
 345        /// Thrown when unable to deserialize the response
 346        /// </exception>
 347        /// <exception cref="ValidationException">
 348        /// Thrown when a required parameter is null
 349        /// </exception>
 350        /// <exception cref="System.ArgumentNullException">
 351        /// Thrown when a required parameter is null
 352        /// </exception>
 353        /// <return>
 354        /// A response object containing the response body and response headers.
 355        /// </return>
 356        public async Task<AzureOperationResponse<SearchService>> GetWithHttpMessagesAsync(string resourceGroupName, stri
 357        {
 0358            if (resourceGroupName == null)
 359            {
 0360                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 361            }
 0362            if (searchServiceName == null)
 363            {
 0364                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 365            }
 0366            if (Client.ApiVersion == null)
 367            {
 0368                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 369            }
 0370            if (Client.SubscriptionId == null)
 371            {
 0372                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 373            }
 0374            System.Guid? clientRequestId = default(System.Guid?);
 0375            if (searchManagementRequestOptions != null)
 376            {
 0377                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 378            }
 379            // Tracing
 0380            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0381            string _invocationId = null;
 0382            if (_shouldTrace)
 383            {
 0384                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0385                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0386                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0387                tracingParameters.Add("searchServiceName", searchServiceName);
 0388                tracingParameters.Add("clientRequestId", clientRequestId);
 0389                tracingParameters.Add("cancellationToken", cancellationToken);
 0390                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 391            }
 392            // Construct URL
 0393            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0394            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0395            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0396            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 0397            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0398            List<string> _queryParameters = new List<string>();
 0399            if (Client.ApiVersion != null)
 400            {
 0401                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 402            }
 0403            if (_queryParameters.Count > 0)
 404            {
 0405                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 406            }
 407            // Create HTTP transport objects
 0408            var _httpRequest = new HttpRequestMessage();
 0409            HttpResponseMessage _httpResponse = null;
 0410            _httpRequest.Method = new HttpMethod("GET");
 0411            _httpRequest.RequestUri = new System.Uri(_url);
 412            // Set Headers
 0413            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 414            {
 0415                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 416            }
 0417            if (Client.AcceptLanguage != null)
 418            {
 0419                if (_httpRequest.Headers.Contains("accept-language"))
 420                {
 0421                    _httpRequest.Headers.Remove("accept-language");
 422                }
 0423                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 424            }
 0425            if (clientRequestId != null)
 426            {
 0427                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 428                {
 0429                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 430                }
 0431                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 432            }
 433
 434
 0435            if (customHeaders != null)
 436            {
 0437                foreach(var _header in customHeaders)
 438                {
 0439                    if (_httpRequest.Headers.Contains(_header.Key))
 440                    {
 0441                        _httpRequest.Headers.Remove(_header.Key);
 442                    }
 0443                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 444                }
 445            }
 446
 447            // Serialize Request
 0448            string _requestContent = null;
 449            // Set Credentials
 0450            if (Client.Credentials != null)
 451            {
 0452                cancellationToken.ThrowIfCancellationRequested();
 0453                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 454            }
 455            // Send Request
 0456            if (_shouldTrace)
 457            {
 0458                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 459            }
 0460            cancellationToken.ThrowIfCancellationRequested();
 0461            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0462            if (_shouldTrace)
 463            {
 0464                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 465            }
 0466            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0467            cancellationToken.ThrowIfCancellationRequested();
 0468            string _responseContent = null;
 0469            if ((int)_statusCode != 200)
 470            {
 0471                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 472                try
 473                {
 0474                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0475                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0476                    if (_errorBody != null)
 477                    {
 0478                        ex = new CloudException(_errorBody.Message);
 0479                        ex.Body = _errorBody;
 480                    }
 0481                }
 0482                catch (JsonException)
 483                {
 484                    // Ignore the exception
 0485                }
 0486                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0487                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0488                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 489                {
 0490                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 491                }
 0492                if (_shouldTrace)
 493                {
 0494                    ServiceClientTracing.Error(_invocationId, ex);
 495                }
 0496                _httpRequest.Dispose();
 0497                if (_httpResponse != null)
 498                {
 0499                    _httpResponse.Dispose();
 500                }
 0501                throw ex;
 502            }
 503            // Create Result
 0504            var _result = new AzureOperationResponse<SearchService>();
 0505            _result.Request = _httpRequest;
 0506            _result.Response = _httpResponse;
 0507            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 508            {
 0509                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 510            }
 511            // Deserialize Response
 0512            if ((int)_statusCode == 200)
 513            {
 0514                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 515                try
 516                {
 0517                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SearchService>(_responseContent,
 0518                }
 0519                catch (JsonException ex)
 520                {
 0521                    _httpRequest.Dispose();
 0522                    if (_httpResponse != null)
 523                    {
 0524                        _httpResponse.Dispose();
 525                    }
 0526                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 527                }
 528            }
 0529            if (_shouldTrace)
 530            {
 0531                ServiceClientTracing.Exit(_invocationId, _result);
 532            }
 0533            return _result;
 0534        }
 535
 536        /// <summary>
 537        /// Deletes a Search service in the given resource group, along with its
 538        /// associated resources.
 539        /// <see href="https://aka.ms/search-manage" />
 540        /// </summary>
 541        /// <param name='resourceGroupName'>
 542        /// The name of the resource group within the current subscription. You can
 543        /// obtain this value from the Azure Resource Manager API or the portal.
 544        /// </param>
 545        /// <param name='searchServiceName'>
 546        /// The name of the Azure Cognitive Search service associated with the
 547        /// specified resource group.
 548        /// </param>
 549        /// <param name='searchManagementRequestOptions'>
 550        /// Additional parameters for the operation
 551        /// </param>
 552        /// <param name='customHeaders'>
 553        /// Headers that will be added to request.
 554        /// </param>
 555        /// <param name='cancellationToken'>
 556        /// The cancellation token.
 557        /// </param>
 558        /// <exception cref="CloudException">
 559        /// Thrown when the operation returned an invalid status code
 560        /// </exception>
 561        /// <exception cref="ValidationException">
 562        /// Thrown when a required parameter is null
 563        /// </exception>
 564        /// <exception cref="System.ArgumentNullException">
 565        /// Thrown when a required parameter is null
 566        /// </exception>
 567        /// <return>
 568        /// A response object containing the response body and response headers.
 569        /// </return>
 570        public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string resourceGroupName, string searchSer
 571        {
 602572            if (resourceGroupName == null)
 573            {
 0574                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 575            }
 602576            if (searchServiceName == null)
 577            {
 0578                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 579            }
 602580            if (Client.ApiVersion == null)
 581            {
 0582                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 583            }
 602584            if (Client.SubscriptionId == null)
 585            {
 0586                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 587            }
 602588            System.Guid? clientRequestId = default(System.Guid?);
 602589            if (searchManagementRequestOptions != null)
 590            {
 0591                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 592            }
 593            // Tracing
 602594            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 602595            string _invocationId = null;
 602596            if (_shouldTrace)
 597            {
 0598                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0599                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0600                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0601                tracingParameters.Add("searchServiceName", searchServiceName);
 0602                tracingParameters.Add("clientRequestId", clientRequestId);
 0603                tracingParameters.Add("cancellationToken", cancellationToken);
 0604                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 605            }
 606            // Construct URL
 602607            var _baseUrl = Client.BaseUri.AbsoluteUri;
 602608            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 602609            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 602610            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 602611            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 602612            List<string> _queryParameters = new List<string>();
 602613            if (Client.ApiVersion != null)
 614            {
 602615                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 616            }
 602617            if (_queryParameters.Count > 0)
 618            {
 602619                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 620            }
 621            // Create HTTP transport objects
 602622            var _httpRequest = new HttpRequestMessage();
 602623            HttpResponseMessage _httpResponse = null;
 602624            _httpRequest.Method = new HttpMethod("DELETE");
 602625            _httpRequest.RequestUri = new System.Uri(_url);
 626            // Set Headers
 602627            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 628            {
 602629                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 630            }
 602631            if (Client.AcceptLanguage != null)
 632            {
 602633                if (_httpRequest.Headers.Contains("accept-language"))
 634                {
 0635                    _httpRequest.Headers.Remove("accept-language");
 636                }
 602637                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 638            }
 602639            if (clientRequestId != null)
 640            {
 0641                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 642                {
 0643                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 644                }
 0645                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 646            }
 647
 648
 602649            if (customHeaders != null)
 650            {
 0651                foreach(var _header in customHeaders)
 652                {
 0653                    if (_httpRequest.Headers.Contains(_header.Key))
 654                    {
 0655                        _httpRequest.Headers.Remove(_header.Key);
 656                    }
 0657                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 658                }
 659            }
 660
 661            // Serialize Request
 602662            string _requestContent = null;
 663            // Set Credentials
 602664            if (Client.Credentials != null)
 665            {
 602666                cancellationToken.ThrowIfCancellationRequested();
 602667                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 668            }
 669            // Send Request
 602670            if (_shouldTrace)
 671            {
 0672                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 673            }
 602674            cancellationToken.ThrowIfCancellationRequested();
 602675            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 602676            if (_shouldTrace)
 677            {
 0678                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 679            }
 602680            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 602681            cancellationToken.ThrowIfCancellationRequested();
 602682            string _responseContent = null;
 602683            if ((int)_statusCode != 200 && (int)_statusCode != 204 && (int)_statusCode != 404)
 684            {
 0685                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 686                try
 687                {
 0688                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0689                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0690                    if (_errorBody != null)
 691                    {
 0692                        ex = new CloudException(_errorBody.Message);
 0693                        ex.Body = _errorBody;
 694                    }
 0695                }
 0696                catch (JsonException)
 697                {
 698                    // Ignore the exception
 0699                }
 0700                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0701                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0702                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 703                {
 0704                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 705                }
 0706                if (_shouldTrace)
 707                {
 0708                    ServiceClientTracing.Error(_invocationId, ex);
 709                }
 0710                _httpRequest.Dispose();
 0711                if (_httpResponse != null)
 712                {
 0713                    _httpResponse.Dispose();
 714                }
 0715                throw ex;
 716            }
 717            // Create Result
 602718            var _result = new AzureOperationResponse();
 602719            _result.Request = _httpRequest;
 602720            _result.Response = _httpResponse;
 602721            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 722            {
 602723                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 724            }
 602725            if (_shouldTrace)
 726            {
 0727                ServiceClientTracing.Exit(_invocationId, _result);
 728            }
 602729            return _result;
 602730        }
 731
 732        /// <summary>
 733        /// Gets a list of all Search services in the given resource group.
 734        /// <see href="https://aka.ms/search-manage" />
 735        /// </summary>
 736        /// <param name='resourceGroupName'>
 737        /// The name of the resource group within the current subscription. You can
 738        /// obtain this value from the Azure Resource Manager API or the portal.
 739        /// </param>
 740        /// <param name='searchManagementRequestOptions'>
 741        /// Additional parameters for the operation
 742        /// </param>
 743        /// <param name='customHeaders'>
 744        /// Headers that will be added to request.
 745        /// </param>
 746        /// <param name='cancellationToken'>
 747        /// The cancellation token.
 748        /// </param>
 749        /// <exception cref="CloudException">
 750        /// Thrown when the operation returned an invalid status code
 751        /// </exception>
 752        /// <exception cref="SerializationException">
 753        /// Thrown when unable to deserialize the response
 754        /// </exception>
 755        /// <exception cref="ValidationException">
 756        /// Thrown when a required parameter is null
 757        /// </exception>
 758        /// <exception cref="System.ArgumentNullException">
 759        /// Thrown when a required parameter is null
 760        /// </exception>
 761        /// <return>
 762        /// A response object containing the response body and response headers.
 763        /// </return>
 764        public async Task<AzureOperationResponse<IPage<SearchService>>> ListByResourceGroupWithHttpMessagesAsync(string 
 765        {
 0766            if (resourceGroupName == null)
 767            {
 0768                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 769            }
 0770            if (Client.ApiVersion == null)
 771            {
 0772                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 773            }
 0774            if (Client.SubscriptionId == null)
 775            {
 0776                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 777            }
 0778            System.Guid? clientRequestId = default(System.Guid?);
 0779            if (searchManagementRequestOptions != null)
 780            {
 0781                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 782            }
 783            // Tracing
 0784            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0785            string _invocationId = null;
 0786            if (_shouldTrace)
 787            {
 0788                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0789                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0790                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0791                tracingParameters.Add("clientRequestId", clientRequestId);
 0792                tracingParameters.Add("cancellationToken", cancellationToken);
 0793                ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters);
 794            }
 795            // Construct URL
 0796            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0797            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0798            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0799            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0800            List<string> _queryParameters = new List<string>();
 0801            if (Client.ApiVersion != null)
 802            {
 0803                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 804            }
 0805            if (_queryParameters.Count > 0)
 806            {
 0807                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 808            }
 809            // Create HTTP transport objects
 0810            var _httpRequest = new HttpRequestMessage();
 0811            HttpResponseMessage _httpResponse = null;
 0812            _httpRequest.Method = new HttpMethod("GET");
 0813            _httpRequest.RequestUri = new System.Uri(_url);
 814            // Set Headers
 0815            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 816            {
 0817                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 818            }
 0819            if (Client.AcceptLanguage != null)
 820            {
 0821                if (_httpRequest.Headers.Contains("accept-language"))
 822                {
 0823                    _httpRequest.Headers.Remove("accept-language");
 824                }
 0825                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 826            }
 0827            if (clientRequestId != null)
 828            {
 0829                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 830                {
 0831                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 832                }
 0833                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 834            }
 835
 836
 0837            if (customHeaders != null)
 838            {
 0839                foreach(var _header in customHeaders)
 840                {
 0841                    if (_httpRequest.Headers.Contains(_header.Key))
 842                    {
 0843                        _httpRequest.Headers.Remove(_header.Key);
 844                    }
 0845                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 846                }
 847            }
 848
 849            // Serialize Request
 0850            string _requestContent = null;
 851            // Set Credentials
 0852            if (Client.Credentials != null)
 853            {
 0854                cancellationToken.ThrowIfCancellationRequested();
 0855                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 856            }
 857            // Send Request
 0858            if (_shouldTrace)
 859            {
 0860                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 861            }
 0862            cancellationToken.ThrowIfCancellationRequested();
 0863            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0864            if (_shouldTrace)
 865            {
 0866                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 867            }
 0868            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0869            cancellationToken.ThrowIfCancellationRequested();
 0870            string _responseContent = null;
 0871            if ((int)_statusCode != 200)
 872            {
 0873                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 874                try
 875                {
 0876                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0877                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0878                    if (_errorBody != null)
 879                    {
 0880                        ex = new CloudException(_errorBody.Message);
 0881                        ex.Body = _errorBody;
 882                    }
 0883                }
 0884                catch (JsonException)
 885                {
 886                    // Ignore the exception
 0887                }
 0888                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0889                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0890                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 891                {
 0892                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 893                }
 0894                if (_shouldTrace)
 895                {
 0896                    ServiceClientTracing.Error(_invocationId, ex);
 897                }
 0898                _httpRequest.Dispose();
 0899                if (_httpResponse != null)
 900                {
 0901                    _httpResponse.Dispose();
 902                }
 0903                throw ex;
 904            }
 905            // Create Result
 0906            var _result = new AzureOperationResponse<IPage<SearchService>>();
 0907            _result.Request = _httpRequest;
 0908            _result.Response = _httpResponse;
 0909            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 910            {
 0911                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 912            }
 913            // Deserialize Response
 0914            if ((int)_statusCode == 200)
 915            {
 0916                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 917                try
 918                {
 0919                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<SearchService>>(_responseC
 0920                }
 0921                catch (JsonException ex)
 922                {
 0923                    _httpRequest.Dispose();
 0924                    if (_httpResponse != null)
 925                    {
 0926                        _httpResponse.Dispose();
 927                    }
 0928                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 929                }
 930            }
 0931            if (_shouldTrace)
 932            {
 0933                ServiceClientTracing.Exit(_invocationId, _result);
 934            }
 0935            return _result;
 0936        }
 937
 938        /// <summary>
 939        /// Gets a list of all Search services in the given subscription.
 940        /// <see href="https://aka.ms/search-manage" />
 941        /// </summary>
 942        /// <param name='searchManagementRequestOptions'>
 943        /// Additional parameters for the operation
 944        /// </param>
 945        /// <param name='customHeaders'>
 946        /// Headers that will be added to request.
 947        /// </param>
 948        /// <param name='cancellationToken'>
 949        /// The cancellation token.
 950        /// </param>
 951        /// <exception cref="CloudException">
 952        /// Thrown when the operation returned an invalid status code
 953        /// </exception>
 954        /// <exception cref="SerializationException">
 955        /// Thrown when unable to deserialize the response
 956        /// </exception>
 957        /// <exception cref="ValidationException">
 958        /// Thrown when a required parameter is null
 959        /// </exception>
 960        /// <exception cref="System.ArgumentNullException">
 961        /// Thrown when a required parameter is null
 962        /// </exception>
 963        /// <return>
 964        /// A response object containing the response body and response headers.
 965        /// </return>
 966        public async Task<AzureOperationResponse<IPage<SearchService>>> ListBySubscriptionWithHttpMessagesAsync(SearchMa
 967        {
 0968            if (Client.ApiVersion == null)
 969            {
 0970                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 971            }
 0972            if (Client.SubscriptionId == null)
 973            {
 0974                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 975            }
 0976            System.Guid? clientRequestId = default(System.Guid?);
 0977            if (searchManagementRequestOptions != null)
 978            {
 0979                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 980            }
 981            // Tracing
 0982            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0983            string _invocationId = null;
 0984            if (_shouldTrace)
 985            {
 0986                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0987                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0988                tracingParameters.Add("clientRequestId", clientRequestId);
 0989                tracingParameters.Add("cancellationToken", cancellationToken);
 0990                ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters);
 991            }
 992            // Construct URL
 0993            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0994            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0995            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0996            List<string> _queryParameters = new List<string>();
 0997            if (Client.ApiVersion != null)
 998            {
 0999                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1000            }
 01001            if (_queryParameters.Count > 0)
 1002            {
 01003                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1004            }
 1005            // Create HTTP transport objects
 01006            var _httpRequest = new HttpRequestMessage();
 01007            HttpResponseMessage _httpResponse = null;
 01008            _httpRequest.Method = new HttpMethod("GET");
 01009            _httpRequest.RequestUri = new System.Uri(_url);
 1010            // Set Headers
 01011            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1012            {
 01013                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1014            }
 01015            if (Client.AcceptLanguage != null)
 1016            {
 01017                if (_httpRequest.Headers.Contains("accept-language"))
 1018                {
 01019                    _httpRequest.Headers.Remove("accept-language");
 1020                }
 01021                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1022            }
 01023            if (clientRequestId != null)
 1024            {
 01025                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 1026                {
 01027                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 1028                }
 01029                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 1030            }
 1031
 1032
 01033            if (customHeaders != null)
 1034            {
 01035                foreach(var _header in customHeaders)
 1036                {
 01037                    if (_httpRequest.Headers.Contains(_header.Key))
 1038                    {
 01039                        _httpRequest.Headers.Remove(_header.Key);
 1040                    }
 01041                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1042                }
 1043            }
 1044
 1045            // Serialize Request
 01046            string _requestContent = null;
 1047            // Set Credentials
 01048            if (Client.Credentials != null)
 1049            {
 01050                cancellationToken.ThrowIfCancellationRequested();
 01051                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1052            }
 1053            // Send Request
 01054            if (_shouldTrace)
 1055            {
 01056                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1057            }
 01058            cancellationToken.ThrowIfCancellationRequested();
 01059            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01060            if (_shouldTrace)
 1061            {
 01062                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1063            }
 01064            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01065            cancellationToken.ThrowIfCancellationRequested();
 01066            string _responseContent = null;
 01067            if ((int)_statusCode != 200)
 1068            {
 01069                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1070                try
 1071                {
 01072                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01073                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 01074                    if (_errorBody != null)
 1075                    {
 01076                        ex = new CloudException(_errorBody.Message);
 01077                        ex.Body = _errorBody;
 1078                    }
 01079                }
 01080                catch (JsonException)
 1081                {
 1082                    // Ignore the exception
 01083                }
 01084                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01085                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01086                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1087                {
 01088                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1089                }
 01090                if (_shouldTrace)
 1091                {
 01092                    ServiceClientTracing.Error(_invocationId, ex);
 1093                }
 01094                _httpRequest.Dispose();
 01095                if (_httpResponse != null)
 1096                {
 01097                    _httpResponse.Dispose();
 1098                }
 01099                throw ex;
 1100            }
 1101            // Create Result
 01102            var _result = new AzureOperationResponse<IPage<SearchService>>();
 01103            _result.Request = _httpRequest;
 01104            _result.Response = _httpResponse;
 01105            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1106            {
 01107                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1108            }
 1109            // Deserialize Response
 01110            if ((int)_statusCode == 200)
 1111            {
 01112                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1113                try
 1114                {
 01115                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<SearchService>>(_responseC
 01116                }
 01117                catch (JsonException ex)
 1118                {
 01119                    _httpRequest.Dispose();
 01120                    if (_httpResponse != null)
 1121                    {
 01122                        _httpResponse.Dispose();
 1123                    }
 01124                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1125                }
 1126            }
 01127            if (_shouldTrace)
 1128            {
 01129                ServiceClientTracing.Exit(_invocationId, _result);
 1130            }
 01131            return _result;
 01132        }
 1133
 1134        /// <summary>
 1135        /// Checks whether or not the given Search service name is available for use.
 1136        /// Search service names must be globally unique since they are part of the
 1137        /// service URI (https://&lt;name&gt;.search.windows.net).
 1138        /// <see href="https://aka.ms/search-manage" />
 1139        /// </summary>
 1140        /// <param name='name'>
 1141        /// The Search service name to validate. Search service names must only contain
 1142        /// lowercase letters, digits or dashes, cannot use dash as the first two or
 1143        /// last one characters, cannot contain consecutive dashes, and must be between
 1144        /// 2 and 60 characters in length.
 1145        /// </param>
 1146        /// <param name='searchManagementRequestOptions'>
 1147        /// Additional parameters for the operation
 1148        /// </param>
 1149        /// <param name='customHeaders'>
 1150        /// Headers that will be added to request.
 1151        /// </param>
 1152        /// <param name='cancellationToken'>
 1153        /// The cancellation token.
 1154        /// </param>
 1155        /// <exception cref="CloudException">
 1156        /// Thrown when the operation returned an invalid status code
 1157        /// </exception>
 1158        /// <exception cref="SerializationException">
 1159        /// Thrown when unable to deserialize the response
 1160        /// </exception>
 1161        /// <exception cref="ValidationException">
 1162        /// Thrown when a required parameter is null
 1163        /// </exception>
 1164        /// <exception cref="System.ArgumentNullException">
 1165        /// Thrown when a required parameter is null
 1166        /// </exception>
 1167        /// <return>
 1168        /// A response object containing the response body and response headers.
 1169        /// </return>
 1170        public async Task<AzureOperationResponse<CheckNameAvailabilityOutput>> CheckNameAvailabilityWithHttpMessagesAsyn
 1171        {
 01172            if (Client.ApiVersion == null)
 1173            {
 01174                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1175            }
 01176            if (Client.SubscriptionId == null)
 1177            {
 01178                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 1179            }
 01180            if (name == null)
 1181            {
 01182                throw new ValidationException(ValidationRules.CannotBeNull, "name");
 1183            }
 01184            System.Guid? clientRequestId = default(System.Guid?);
 01185            if (searchManagementRequestOptions != null)
 1186            {
 01187                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 1188            }
 01189            CheckNameAvailabilityInput checkNameAvailabilityInput = new CheckNameAvailabilityInput();
 01190            if (name != null)
 1191            {
 01192                checkNameAvailabilityInput.Name = name;
 1193            }
 1194            // Tracing
 01195            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01196            string _invocationId = null;
 01197            if (_shouldTrace)
 1198            {
 01199                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01200                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01201                tracingParameters.Add("clientRequestId", clientRequestId);
 01202                tracingParameters.Add("checkNameAvailabilityInput", checkNameAvailabilityInput);
 01203                tracingParameters.Add("cancellationToken", cancellationToken);
 01204                ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters);
 1205            }
 1206            // Construct URL
 01207            var _baseUrl = Client.BaseUri.AbsoluteUri;
 01208            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 01209            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 01210            List<string> _queryParameters = new List<string>();
 01211            if (Client.ApiVersion != null)
 1212            {
 01213                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1214            }
 01215            if (_queryParameters.Count > 0)
 1216            {
 01217                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1218            }
 1219            // Create HTTP transport objects
 01220            var _httpRequest = new HttpRequestMessage();
 01221            HttpResponseMessage _httpResponse = null;
 01222            _httpRequest.Method = new HttpMethod("POST");
 01223            _httpRequest.RequestUri = new System.Uri(_url);
 1224            // Set Headers
 01225            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1226            {
 01227                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1228            }
 01229            if (Client.AcceptLanguage != null)
 1230            {
 01231                if (_httpRequest.Headers.Contains("accept-language"))
 1232                {
 01233                    _httpRequest.Headers.Remove("accept-language");
 1234                }
 01235                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1236            }
 01237            if (clientRequestId != null)
 1238            {
 01239                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 1240                {
 01241                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 1242                }
 01243                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 1244            }
 1245
 1246
 01247            if (customHeaders != null)
 1248            {
 01249                foreach(var _header in customHeaders)
 1250                {
 01251                    if (_httpRequest.Headers.Contains(_header.Key))
 1252                    {
 01253                        _httpRequest.Headers.Remove(_header.Key);
 1254                    }
 01255                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1256                }
 1257            }
 1258
 1259            // Serialize Request
 01260            string _requestContent = null;
 01261            if(checkNameAvailabilityInput != null)
 1262            {
 01263                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(checkNameAvailabilityInput, Client.
 01264                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 01265                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1266            }
 1267            // Set Credentials
 01268            if (Client.Credentials != null)
 1269            {
 01270                cancellationToken.ThrowIfCancellationRequested();
 01271                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1272            }
 1273            // Send Request
 01274            if (_shouldTrace)
 1275            {
 01276                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1277            }
 01278            cancellationToken.ThrowIfCancellationRequested();
 01279            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01280            if (_shouldTrace)
 1281            {
 01282                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1283            }
 01284            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01285            cancellationToken.ThrowIfCancellationRequested();
 01286            string _responseContent = null;
 01287            if ((int)_statusCode != 200)
 1288            {
 01289                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1290                try
 1291                {
 01292                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01293                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 01294                    if (_errorBody != null)
 1295                    {
 01296                        ex = new CloudException(_errorBody.Message);
 01297                        ex.Body = _errorBody;
 1298                    }
 01299                }
 01300                catch (JsonException)
 1301                {
 1302                    // Ignore the exception
 01303                }
 01304                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01305                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01306                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1307                {
 01308                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1309                }
 01310                if (_shouldTrace)
 1311                {
 01312                    ServiceClientTracing.Error(_invocationId, ex);
 1313                }
 01314                _httpRequest.Dispose();
 01315                if (_httpResponse != null)
 1316                {
 01317                    _httpResponse.Dispose();
 1318                }
 01319                throw ex;
 1320            }
 1321            // Create Result
 01322            var _result = new AzureOperationResponse<CheckNameAvailabilityOutput>();
 01323            _result.Request = _httpRequest;
 01324            _result.Response = _httpResponse;
 01325            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1326            {
 01327                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1328            }
 1329            // Deserialize Response
 01330            if ((int)_statusCode == 200)
 1331            {
 01332                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1333                try
 1334                {
 01335                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<CheckNameAvailabilityOutput>(_re
 01336                }
 01337                catch (JsonException ex)
 1338                {
 01339                    _httpRequest.Dispose();
 01340                    if (_httpResponse != null)
 1341                    {
 01342                        _httpResponse.Dispose();
 1343                    }
 01344                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1345                }
 1346            }
 01347            if (_shouldTrace)
 1348            {
 01349                ServiceClientTracing.Exit(_invocationId, _result);
 1350            }
 01351            return _result;
 01352        }
 1353
 1354        /// <summary>
 1355        /// Creates or updates a Search service in the given resource group. If the
 1356        /// Search service already exists, all properties will be updated with the
 1357        /// given values.
 1358        /// <see href="https://aka.ms/search-manage" />
 1359        /// </summary>
 1360        /// <param name='resourceGroupName'>
 1361        /// The name of the resource group within the current subscription. You can
 1362        /// obtain this value from the Azure Resource Manager API or the portal.
 1363        /// </param>
 1364        /// <param name='searchServiceName'>
 1365        /// The name of the Azure Cognitive Search service to create or update. Search
 1366        /// service names must only contain lowercase letters, digits or dashes, cannot
 1367        /// use dash as the first two or last one characters, cannot contain
 1368        /// consecutive dashes, and must be between 2 and 60 characters in length.
 1369        /// Search service names must be globally unique since they are part of the
 1370        /// service URI (https://&lt;name&gt;.search.windows.net). You cannot change
 1371        /// the service name after the service is created.
 1372        /// </param>
 1373        /// <param name='service'>
 1374        /// The definition of the Search service to create or update.
 1375        /// </param>
 1376        /// <param name='searchManagementRequestOptions'>
 1377        /// Additional parameters for the operation
 1378        /// </param>
 1379        /// <param name='customHeaders'>
 1380        /// Headers that will be added to request.
 1381        /// </param>
 1382        /// <param name='cancellationToken'>
 1383        /// The cancellation token.
 1384        /// </param>
 1385        /// <exception cref="CloudException">
 1386        /// Thrown when the operation returned an invalid status code
 1387        /// </exception>
 1388        /// <exception cref="SerializationException">
 1389        /// Thrown when unable to deserialize the response
 1390        /// </exception>
 1391        /// <exception cref="ValidationException">
 1392        /// Thrown when a required parameter is null
 1393        /// </exception>
 1394        /// <exception cref="System.ArgumentNullException">
 1395        /// Thrown when a required parameter is null
 1396        /// </exception>
 1397        /// <return>
 1398        /// A response object containing the response body and response headers.
 1399        /// </return>
 1400        public async Task<AzureOperationResponse<SearchService>> BeginCreateOrUpdateWithHttpMessagesAsync(string resourc
 1401        {
 6021402            if (resourceGroupName == null)
 1403            {
 01404                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 1405            }
 6021406            if (searchServiceName == null)
 1407            {
 01408                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 1409            }
 6021410            if (service == null)
 1411            {
 01412                throw new ValidationException(ValidationRules.CannotBeNull, "service");
 1413            }
 6021414            if (service != null)
 1415            {
 6021416                service.Validate();
 1417            }
 6021418            if (Client.ApiVersion == null)
 1419            {
 01420                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1421            }
 6021422            if (Client.SubscriptionId == null)
 1423            {
 01424                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 1425            }
 6021426            System.Guid? clientRequestId = default(System.Guid?);
 6021427            if (searchManagementRequestOptions != null)
 1428            {
 01429                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 1430            }
 1431            // Tracing
 6021432            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 6021433            string _invocationId = null;
 6021434            if (_shouldTrace)
 1435            {
 01436                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01437                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01438                tracingParameters.Add("resourceGroupName", resourceGroupName);
 01439                tracingParameters.Add("searchServiceName", searchServiceName);
 01440                tracingParameters.Add("service", service);
 01441                tracingParameters.Add("clientRequestId", clientRequestId);
 01442                tracingParameters.Add("cancellationToken", cancellationToken);
 01443                ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters);
 1444            }
 1445            // Construct URL
 6021446            var _baseUrl = Client.BaseUri.AbsoluteUri;
 6021447            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 6021448            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 6021449            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 6021450            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 6021451            List<string> _queryParameters = new List<string>();
 6021452            if (Client.ApiVersion != null)
 1453            {
 6021454                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1455            }
 6021456            if (_queryParameters.Count > 0)
 1457            {
 6021458                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1459            }
 1460            // Create HTTP transport objects
 6021461            var _httpRequest = new HttpRequestMessage();
 6021462            HttpResponseMessage _httpResponse = null;
 6021463            _httpRequest.Method = new HttpMethod("PUT");
 6021464            _httpRequest.RequestUri = new System.Uri(_url);
 1465            // Set Headers
 6021466            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1467            {
 6021468                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1469            }
 6021470            if (Client.AcceptLanguage != null)
 1471            {
 6021472                if (_httpRequest.Headers.Contains("accept-language"))
 1473                {
 01474                    _httpRequest.Headers.Remove("accept-language");
 1475                }
 6021476                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1477            }
 6021478            if (clientRequestId != null)
 1479            {
 01480                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 1481                {
 01482                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 1483                }
 01484                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 1485            }
 1486
 1487
 6021488            if (customHeaders != null)
 1489            {
 01490                foreach(var _header in customHeaders)
 1491                {
 01492                    if (_httpRequest.Headers.Contains(_header.Key))
 1493                    {
 01494                        _httpRequest.Headers.Remove(_header.Key);
 1495                    }
 01496                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1497                }
 1498            }
 1499
 1500            // Serialize Request
 6021501            string _requestContent = null;
 6021502            if(service != null)
 1503            {
 6021504                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(service, Client.SerializationSettin
 6021505                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 6021506                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1507            }
 1508            // Set Credentials
 6021509            if (Client.Credentials != null)
 1510            {
 6021511                cancellationToken.ThrowIfCancellationRequested();
 6021512                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1513            }
 1514            // Send Request
 6021515            if (_shouldTrace)
 1516            {
 01517                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1518            }
 6021519            cancellationToken.ThrowIfCancellationRequested();
 6021520            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6021521            if (_shouldTrace)
 1522            {
 01523                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1524            }
 6021525            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 6021526            cancellationToken.ThrowIfCancellationRequested();
 6021527            string _responseContent = null;
 6021528            if ((int)_statusCode != 200 && (int)_statusCode != 201)
 1529            {
 01530                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1531                try
 1532                {
 01533                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01534                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 01535                    if (_errorBody != null)
 1536                    {
 01537                        ex = new CloudException(_errorBody.Message);
 01538                        ex.Body = _errorBody;
 1539                    }
 01540                }
 01541                catch (JsonException)
 1542                {
 1543                    // Ignore the exception
 01544                }
 01545                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01546                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01547                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1548                {
 01549                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1550                }
 01551                if (_shouldTrace)
 1552                {
 01553                    ServiceClientTracing.Error(_invocationId, ex);
 1554                }
 01555                _httpRequest.Dispose();
 01556                if (_httpResponse != null)
 1557                {
 01558                    _httpResponse.Dispose();
 1559                }
 01560                throw ex;
 1561            }
 1562            // Create Result
 6021563            var _result = new AzureOperationResponse<SearchService>();
 6021564            _result.Request = _httpRequest;
 6021565            _result.Response = _httpResponse;
 6021566            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1567            {
 6021568                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1569            }
 1570            // Deserialize Response
 6021571            if ((int)_statusCode == 200)
 1572            {
 01573                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1574                try
 1575                {
 01576                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SearchService>(_responseContent,
 01577                }
 01578                catch (JsonException ex)
 1579                {
 01580                    _httpRequest.Dispose();
 01581                    if (_httpResponse != null)
 1582                    {
 01583                        _httpResponse.Dispose();
 1584                    }
 01585                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1586                }
 1587            }
 1588            // Deserialize Response
 6021589            if ((int)_statusCode == 201)
 1590            {
 6021591                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1592                try
 1593                {
 6021594                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SearchService>(_responseContent,
 6021595                }
 01596                catch (JsonException ex)
 1597                {
 01598                    _httpRequest.Dispose();
 01599                    if (_httpResponse != null)
 1600                    {
 01601                        _httpResponse.Dispose();
 1602                    }
 01603                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1604                }
 1605            }
 6021606            if (_shouldTrace)
 1607            {
 01608                ServiceClientTracing.Exit(_invocationId, _result);
 1609            }
 6021610            return _result;
 6021611        }
 1612
 1613        /// <summary>
 1614        /// Gets a list of all Search services in the given resource group.
 1615        /// <see href="https://aka.ms/search-manage" />
 1616        /// </summary>
 1617        /// <param name='nextPageLink'>
 1618        /// The NextLink from the previous successful call to List operation.
 1619        /// </param>
 1620        /// <param name='searchManagementRequestOptions'>
 1621        /// Additional parameters for the operation
 1622        /// </param>
 1623        /// <param name='customHeaders'>
 1624        /// Headers that will be added to request.
 1625        /// </param>
 1626        /// <param name='cancellationToken'>
 1627        /// The cancellation token.
 1628        /// </param>
 1629        /// <exception cref="CloudException">
 1630        /// Thrown when the operation returned an invalid status code
 1631        /// </exception>
 1632        /// <exception cref="SerializationException">
 1633        /// Thrown when unable to deserialize the response
 1634        /// </exception>
 1635        /// <exception cref="ValidationException">
 1636        /// Thrown when a required parameter is null
 1637        /// </exception>
 1638        /// <exception cref="System.ArgumentNullException">
 1639        /// Thrown when a required parameter is null
 1640        /// </exception>
 1641        /// <return>
 1642        /// A response object containing the response body and response headers.
 1643        /// </return>
 1644        public async Task<AzureOperationResponse<IPage<SearchService>>> ListByResourceGroupNextWithHttpMessagesAsync(str
 1645        {
 01646            if (nextPageLink == null)
 1647            {
 01648                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 1649            }
 01650            System.Guid? clientRequestId = default(System.Guid?);
 01651            if (searchManagementRequestOptions != null)
 1652            {
 01653                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 1654            }
 1655            // Tracing
 01656            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01657            string _invocationId = null;
 01658            if (_shouldTrace)
 1659            {
 01660                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01661                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01662                tracingParameters.Add("nextPageLink", nextPageLink);
 01663                tracingParameters.Add("clientRequestId", clientRequestId);
 01664                tracingParameters.Add("cancellationToken", cancellationToken);
 01665                ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters);
 1666            }
 1667            // Construct URL
 01668            string _url = "{nextLink}";
 01669            _url = _url.Replace("{nextLink}", nextPageLink);
 01670            List<string> _queryParameters = new List<string>();
 01671            if (_queryParameters.Count > 0)
 1672            {
 01673                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1674            }
 1675            // Create HTTP transport objects
 01676            var _httpRequest = new HttpRequestMessage();
 01677            HttpResponseMessage _httpResponse = null;
 01678            _httpRequest.Method = new HttpMethod("GET");
 01679            _httpRequest.RequestUri = new System.Uri(_url);
 1680            // Set Headers
 01681            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1682            {
 01683                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1684            }
 01685            if (Client.AcceptLanguage != null)
 1686            {
 01687                if (_httpRequest.Headers.Contains("accept-language"))
 1688                {
 01689                    _httpRequest.Headers.Remove("accept-language");
 1690                }
 01691                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1692            }
 01693            if (clientRequestId != null)
 1694            {
 01695                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 1696                {
 01697                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 1698                }
 01699                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 1700            }
 1701
 1702
 01703            if (customHeaders != null)
 1704            {
 01705                foreach(var _header in customHeaders)
 1706                {
 01707                    if (_httpRequest.Headers.Contains(_header.Key))
 1708                    {
 01709                        _httpRequest.Headers.Remove(_header.Key);
 1710                    }
 01711                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1712                }
 1713            }
 1714
 1715            // Serialize Request
 01716            string _requestContent = null;
 1717            // Set Credentials
 01718            if (Client.Credentials != null)
 1719            {
 01720                cancellationToken.ThrowIfCancellationRequested();
 01721                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1722            }
 1723            // Send Request
 01724            if (_shouldTrace)
 1725            {
 01726                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1727            }
 01728            cancellationToken.ThrowIfCancellationRequested();
 01729            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01730            if (_shouldTrace)
 1731            {
 01732                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1733            }
 01734            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01735            cancellationToken.ThrowIfCancellationRequested();
 01736            string _responseContent = null;
 01737            if ((int)_statusCode != 200)
 1738            {
 01739                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1740                try
 1741                {
 01742                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01743                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 01744                    if (_errorBody != null)
 1745                    {
 01746                        ex = new CloudException(_errorBody.Message);
 01747                        ex.Body = _errorBody;
 1748                    }
 01749                }
 01750                catch (JsonException)
 1751                {
 1752                    // Ignore the exception
 01753                }
 01754                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01755                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01756                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1757                {
 01758                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1759                }
 01760                if (_shouldTrace)
 1761                {
 01762                    ServiceClientTracing.Error(_invocationId, ex);
 1763                }
 01764                _httpRequest.Dispose();
 01765                if (_httpResponse != null)
 1766                {
 01767                    _httpResponse.Dispose();
 1768                }
 01769                throw ex;
 1770            }
 1771            // Create Result
 01772            var _result = new AzureOperationResponse<IPage<SearchService>>();
 01773            _result.Request = _httpRequest;
 01774            _result.Response = _httpResponse;
 01775            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1776            {
 01777                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1778            }
 1779            // Deserialize Response
 01780            if ((int)_statusCode == 200)
 1781            {
 01782                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1783                try
 1784                {
 01785                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<SearchService>>(_responseC
 01786                }
 01787                catch (JsonException ex)
 1788                {
 01789                    _httpRequest.Dispose();
 01790                    if (_httpResponse != null)
 1791                    {
 01792                        _httpResponse.Dispose();
 1793                    }
 01794                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1795                }
 1796            }
 01797            if (_shouldTrace)
 1798            {
 01799                ServiceClientTracing.Exit(_invocationId, _result);
 1800            }
 01801            return _result;
 01802        }
 1803
 1804        /// <summary>
 1805        /// Gets a list of all Search services in the given subscription.
 1806        /// <see href="https://aka.ms/search-manage" />
 1807        /// </summary>
 1808        /// <param name='nextPageLink'>
 1809        /// The NextLink from the previous successful call to List operation.
 1810        /// </param>
 1811        /// <param name='searchManagementRequestOptions'>
 1812        /// Additional parameters for the operation
 1813        /// </param>
 1814        /// <param name='customHeaders'>
 1815        /// Headers that will be added to request.
 1816        /// </param>
 1817        /// <param name='cancellationToken'>
 1818        /// The cancellation token.
 1819        /// </param>
 1820        /// <exception cref="CloudException">
 1821        /// Thrown when the operation returned an invalid status code
 1822        /// </exception>
 1823        /// <exception cref="SerializationException">
 1824        /// Thrown when unable to deserialize the response
 1825        /// </exception>
 1826        /// <exception cref="ValidationException">
 1827        /// Thrown when a required parameter is null
 1828        /// </exception>
 1829        /// <exception cref="System.ArgumentNullException">
 1830        /// Thrown when a required parameter is null
 1831        /// </exception>
 1832        /// <return>
 1833        /// A response object containing the response body and response headers.
 1834        /// </return>
 1835        public async Task<AzureOperationResponse<IPage<SearchService>>> ListBySubscriptionNextWithHttpMessagesAsync(stri
 1836        {
 01837            if (nextPageLink == null)
 1838            {
 01839                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 1840            }
 01841            System.Guid? clientRequestId = default(System.Guid?);
 01842            if (searchManagementRequestOptions != null)
 1843            {
 01844                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 1845            }
 1846            // Tracing
 01847            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01848            string _invocationId = null;
 01849            if (_shouldTrace)
 1850            {
 01851                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01852                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01853                tracingParameters.Add("nextPageLink", nextPageLink);
 01854                tracingParameters.Add("clientRequestId", clientRequestId);
 01855                tracingParameters.Add("cancellationToken", cancellationToken);
 01856                ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionNext", tracingParameters);
 1857            }
 1858            // Construct URL
 01859            string _url = "{nextLink}";
 01860            _url = _url.Replace("{nextLink}", nextPageLink);
 01861            List<string> _queryParameters = new List<string>();
 01862            if (_queryParameters.Count > 0)
 1863            {
 01864                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1865            }
 1866            // Create HTTP transport objects
 01867            var _httpRequest = new HttpRequestMessage();
 01868            HttpResponseMessage _httpResponse = null;
 01869            _httpRequest.Method = new HttpMethod("GET");
 01870            _httpRequest.RequestUri = new System.Uri(_url);
 1871            // Set Headers
 01872            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1873            {
 01874                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1875            }
 01876            if (Client.AcceptLanguage != null)
 1877            {
 01878                if (_httpRequest.Headers.Contains("accept-language"))
 1879                {
 01880                    _httpRequest.Headers.Remove("accept-language");
 1881                }
 01882                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1883            }
 01884            if (clientRequestId != null)
 1885            {
 01886                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 1887                {
 01888                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 1889                }
 01890                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 1891            }
 1892
 1893
 01894            if (customHeaders != null)
 1895            {
 01896                foreach(var _header in customHeaders)
 1897                {
 01898                    if (_httpRequest.Headers.Contains(_header.Key))
 1899                    {
 01900                        _httpRequest.Headers.Remove(_header.Key);
 1901                    }
 01902                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1903                }
 1904            }
 1905
 1906            // Serialize Request
 01907            string _requestContent = null;
 1908            // Set Credentials
 01909            if (Client.Credentials != null)
 1910            {
 01911                cancellationToken.ThrowIfCancellationRequested();
 01912                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1913            }
 1914            // Send Request
 01915            if (_shouldTrace)
 1916            {
 01917                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1918            }
 01919            cancellationToken.ThrowIfCancellationRequested();
 01920            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01921            if (_shouldTrace)
 1922            {
 01923                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1924            }
 01925            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01926            cancellationToken.ThrowIfCancellationRequested();
 01927            string _responseContent = null;
 01928            if ((int)_statusCode != 200)
 1929            {
 01930                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1931                try
 1932                {
 01933                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01934                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 01935                    if (_errorBody != null)
 1936                    {
 01937                        ex = new CloudException(_errorBody.Message);
 01938                        ex.Body = _errorBody;
 1939                    }
 01940                }
 01941                catch (JsonException)
 1942                {
 1943                    // Ignore the exception
 01944                }
 01945                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01946                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01947                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1948                {
 01949                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1950                }
 01951                if (_shouldTrace)
 1952                {
 01953                    ServiceClientTracing.Error(_invocationId, ex);
 1954                }
 01955                _httpRequest.Dispose();
 01956                if (_httpResponse != null)
 1957                {
 01958                    _httpResponse.Dispose();
 1959                }
 01960                throw ex;
 1961            }
 1962            // Create Result
 01963            var _result = new AzureOperationResponse<IPage<SearchService>>();
 01964            _result.Request = _httpRequest;
 01965            _result.Response = _httpResponse;
 01966            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1967            {
 01968                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1969            }
 1970            // Deserialize Response
 01971            if ((int)_statusCode == 200)
 1972            {
 01973                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1974                try
 1975                {
 01976                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<SearchService>>(_responseC
 01977                }
 01978                catch (JsonException ex)
 1979                {
 01980                    _httpRequest.Dispose();
 01981                    if (_httpResponse != null)
 1982                    {
 01983                        _httpResponse.Dispose();
 1984                    }
 01985                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1986                }
 1987            }
 01988            if (_shouldTrace)
 1989            {
 01990                ServiceClientTracing.Exit(_invocationId, _result);
 1991            }
 01992            return _result;
 01993        }
 1994
 1995    }
 1996}