< Summary

Class:Microsoft.Azure.Management.Search.QueryKeysOperations
Assembly:Microsoft.Azure.Management.Search
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\src\Generated\QueryKeysOperations.cs
Covered lines:59
Uncovered lines:338
Coverable lines:397
Total lines:896
Line coverage:14.8% (59 of 397)
Covered branches:32
Total branches:244
Branch coverage:13.1% (32 of 244)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
CreateWithHttpMessagesAsync()-0%0%
ListBySearchServiceWithHttpMessagesAsync()-53.47%50%
DeleteWithHttpMessagesAsync()-0%0%
ListBySearchServiceNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\src\Generated\QueryKeysOperations.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    /// QueryKeysOperations operations.
 27    /// </summary>
 28    internal partial class QueryKeysOperations : IServiceOperations<SearchManagementClient>, IQueryKeysOperations
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the QueryKeysOperations 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 QueryKeysOperations(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>
 963251        public SearchManagementClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Generates a new query key for the specified Search service. You can create
 55        /// up to 50 query keys per service.
 56        /// <see href="https://aka.ms/search-manage" />
 57        /// </summary>
 58        /// <param name='resourceGroupName'>
 59        /// The name of the resource group within the current subscription. You can
 60        /// obtain this value from the Azure Resource Manager API or the portal.
 61        /// </param>
 62        /// <param name='searchServiceName'>
 63        /// The name of the Azure Cognitive Search service associated with the
 64        /// specified resource group.
 65        /// </param>
 66        /// <param name='name'>
 67        /// The name of the new query API key.
 68        /// </param>
 69        /// <param name='searchManagementRequestOptions'>
 70        /// Additional parameters for the operation
 71        /// </param>
 72        /// <param name='customHeaders'>
 73        /// Headers that will be added to request.
 74        /// </param>
 75        /// <param name='cancellationToken'>
 76        /// The cancellation token.
 77        /// </param>
 78        /// <exception cref="CloudException">
 79        /// Thrown when the operation returned an invalid status code
 80        /// </exception>
 81        /// <exception cref="SerializationException">
 82        /// Thrown when unable to deserialize the response
 83        /// </exception>
 84        /// <exception cref="ValidationException">
 85        /// Thrown when a required parameter is null
 86        /// </exception>
 87        /// <exception cref="System.ArgumentNullException">
 88        /// Thrown when a required parameter is null
 89        /// </exception>
 90        /// <return>
 91        /// A response object containing the response body and response headers.
 92        /// </return>
 93        public async Task<AzureOperationResponse<QueryKey>> CreateWithHttpMessagesAsync(string resourceGroupName, string
 94        {
 095            if (resourceGroupName == null)
 96            {
 097                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 98            }
 099            if (searchServiceName == null)
 100            {
 0101                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 102            }
 0103            if (name == null)
 104            {
 0105                throw new ValidationException(ValidationRules.CannotBeNull, "name");
 106            }
 0107            if (Client.ApiVersion == null)
 108            {
 0109                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 110            }
 0111            if (Client.SubscriptionId == null)
 112            {
 0113                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 114            }
 0115            System.Guid? clientRequestId = default(System.Guid?);
 0116            if (searchManagementRequestOptions != null)
 117            {
 0118                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 119            }
 120            // Tracing
 0121            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0122            string _invocationId = null;
 0123            if (_shouldTrace)
 124            {
 0125                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0126                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0127                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0128                tracingParameters.Add("searchServiceName", searchServiceName);
 0129                tracingParameters.Add("name", name);
 0130                tracingParameters.Add("clientRequestId", clientRequestId);
 0131                tracingParameters.Add("cancellationToken", cancellationToken);
 0132                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
 133            }
 134            // Construct URL
 0135            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0136            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0137            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0138            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 0139            _url = _url.Replace("{name}", System.Uri.EscapeDataString(name));
 0140            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0141            List<string> _queryParameters = new List<string>();
 0142            if (Client.ApiVersion != null)
 143            {
 0144                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 145            }
 0146            if (_queryParameters.Count > 0)
 147            {
 0148                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 149            }
 150            // Create HTTP transport objects
 0151            var _httpRequest = new HttpRequestMessage();
 0152            HttpResponseMessage _httpResponse = null;
 0153            _httpRequest.Method = new HttpMethod("POST");
 0154            _httpRequest.RequestUri = new System.Uri(_url);
 155            // Set Headers
 0156            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 157            {
 0158                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 159            }
 0160            if (Client.AcceptLanguage != null)
 161            {
 0162                if (_httpRequest.Headers.Contains("accept-language"))
 163                {
 0164                    _httpRequest.Headers.Remove("accept-language");
 165                }
 0166                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 167            }
 0168            if (clientRequestId != null)
 169            {
 0170                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 171                {
 0172                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 173                }
 0174                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 175            }
 176
 177
 0178            if (customHeaders != null)
 179            {
 0180                foreach(var _header in customHeaders)
 181                {
 0182                    if (_httpRequest.Headers.Contains(_header.Key))
 183                    {
 0184                        _httpRequest.Headers.Remove(_header.Key);
 185                    }
 0186                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 187                }
 188            }
 189
 190            // Serialize Request
 0191            string _requestContent = null;
 192            // Set Credentials
 0193            if (Client.Credentials != null)
 194            {
 0195                cancellationToken.ThrowIfCancellationRequested();
 0196                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 197            }
 198            // Send Request
 0199            if (_shouldTrace)
 200            {
 0201                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 202            }
 0203            cancellationToken.ThrowIfCancellationRequested();
 0204            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0205            if (_shouldTrace)
 206            {
 0207                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 208            }
 0209            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0210            cancellationToken.ThrowIfCancellationRequested();
 0211            string _responseContent = null;
 0212            if ((int)_statusCode != 200)
 213            {
 0214                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 215                try
 216                {
 0217                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0218                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0219                    if (_errorBody != null)
 220                    {
 0221                        ex = new CloudException(_errorBody.Message);
 0222                        ex.Body = _errorBody;
 223                    }
 0224                }
 0225                catch (JsonException)
 226                {
 227                    // Ignore the exception
 0228                }
 0229                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0230                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0231                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 232                {
 0233                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 234                }
 0235                if (_shouldTrace)
 236                {
 0237                    ServiceClientTracing.Error(_invocationId, ex);
 238                }
 0239                _httpRequest.Dispose();
 0240                if (_httpResponse != null)
 241                {
 0242                    _httpResponse.Dispose();
 243                }
 0244                throw ex;
 245            }
 246            // Create Result
 0247            var _result = new AzureOperationResponse<QueryKey>();
 0248            _result.Request = _httpRequest;
 0249            _result.Response = _httpResponse;
 0250            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 251            {
 0252                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 253            }
 254            // Deserialize Response
 0255            if ((int)_statusCode == 200)
 256            {
 0257                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 258                try
 259                {
 0260                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<QueryKey>(_responseContent, Clie
 0261                }
 0262                catch (JsonException ex)
 263                {
 0264                    _httpRequest.Dispose();
 0265                    if (_httpResponse != null)
 266                    {
 0267                        _httpResponse.Dispose();
 268                    }
 0269                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 270                }
 271            }
 0272            if (_shouldTrace)
 273            {
 0274                ServiceClientTracing.Exit(_invocationId, _result);
 275            }
 0276            return _result;
 0277        }
 278
 279        /// <summary>
 280        /// Returns the list of query API keys for the given Azure Cognitive Search
 281        /// service.
 282        /// <see href="https://aka.ms/search-manage" />
 283        /// </summary>
 284        /// <param name='resourceGroupName'>
 285        /// The name of the resource group within the current subscription. You can
 286        /// obtain this value from the Azure Resource Manager API or the portal.
 287        /// </param>
 288        /// <param name='searchServiceName'>
 289        /// The name of the Azure Cognitive Search service associated with the
 290        /// specified resource group.
 291        /// </param>
 292        /// <param name='searchManagementRequestOptions'>
 293        /// Additional parameters for the operation
 294        /// </param>
 295        /// <param name='customHeaders'>
 296        /// Headers that will be added to request.
 297        /// </param>
 298        /// <param name='cancellationToken'>
 299        /// The cancellation token.
 300        /// </param>
 301        /// <exception cref="CloudException">
 302        /// Thrown when the operation returned an invalid status code
 303        /// </exception>
 304        /// <exception cref="SerializationException">
 305        /// Thrown when unable to deserialize the response
 306        /// </exception>
 307        /// <exception cref="ValidationException">
 308        /// Thrown when a required parameter is null
 309        /// </exception>
 310        /// <exception cref="System.ArgumentNullException">
 311        /// Thrown when a required parameter is null
 312        /// </exception>
 313        /// <return>
 314        /// A response object containing the response body and response headers.
 315        /// </return>
 316        public async Task<AzureOperationResponse<IPage<QueryKey>>> ListBySearchServiceWithHttpMessagesAsync(string resou
 317        {
 602318            if (resourceGroupName == null)
 319            {
 0320                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 321            }
 602322            if (searchServiceName == null)
 323            {
 0324                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 325            }
 602326            if (Client.ApiVersion == null)
 327            {
 0328                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 329            }
 602330            if (Client.SubscriptionId == null)
 331            {
 0332                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 333            }
 602334            System.Guid? clientRequestId = default(System.Guid?);
 602335            if (searchManagementRequestOptions != null)
 336            {
 0337                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 338            }
 339            // Tracing
 602340            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 602341            string _invocationId = null;
 602342            if (_shouldTrace)
 343            {
 0344                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0345                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0346                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0347                tracingParameters.Add("searchServiceName", searchServiceName);
 0348                tracingParameters.Add("clientRequestId", clientRequestId);
 0349                tracingParameters.Add("cancellationToken", cancellationToken);
 0350                ServiceClientTracing.Enter(_invocationId, this, "ListBySearchService", tracingParameters);
 351            }
 352            // Construct URL
 602353            var _baseUrl = Client.BaseUri.AbsoluteUri;
 602354            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 602355            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 602356            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 602357            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 602358            List<string> _queryParameters = new List<string>();
 602359            if (Client.ApiVersion != null)
 360            {
 602361                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 362            }
 602363            if (_queryParameters.Count > 0)
 364            {
 602365                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 366            }
 367            // Create HTTP transport objects
 602368            var _httpRequest = new HttpRequestMessage();
 602369            HttpResponseMessage _httpResponse = null;
 602370            _httpRequest.Method = new HttpMethod("POST");
 602371            _httpRequest.RequestUri = new System.Uri(_url);
 372            // Set Headers
 602373            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 374            {
 602375                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 376            }
 602377            if (Client.AcceptLanguage != null)
 378            {
 602379                if (_httpRequest.Headers.Contains("accept-language"))
 380                {
 0381                    _httpRequest.Headers.Remove("accept-language");
 382                }
 602383                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 384            }
 602385            if (clientRequestId != null)
 386            {
 0387                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 388                {
 0389                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 390                }
 0391                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 392            }
 393
 394
 602395            if (customHeaders != null)
 396            {
 0397                foreach(var _header in customHeaders)
 398                {
 0399                    if (_httpRequest.Headers.Contains(_header.Key))
 400                    {
 0401                        _httpRequest.Headers.Remove(_header.Key);
 402                    }
 0403                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 404                }
 405            }
 406
 407            // Serialize Request
 602408            string _requestContent = null;
 409            // Set Credentials
 602410            if (Client.Credentials != null)
 411            {
 602412                cancellationToken.ThrowIfCancellationRequested();
 602413                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 414            }
 415            // Send Request
 602416            if (_shouldTrace)
 417            {
 0418                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 419            }
 602420            cancellationToken.ThrowIfCancellationRequested();
 602421            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 602422            if (_shouldTrace)
 423            {
 0424                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 425            }
 602426            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 602427            cancellationToken.ThrowIfCancellationRequested();
 602428            string _responseContent = null;
 602429            if ((int)_statusCode != 200)
 430            {
 0431                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 432                try
 433                {
 0434                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0435                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0436                    if (_errorBody != null)
 437                    {
 0438                        ex = new CloudException(_errorBody.Message);
 0439                        ex.Body = _errorBody;
 440                    }
 0441                }
 0442                catch (JsonException)
 443                {
 444                    // Ignore the exception
 0445                }
 0446                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0447                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0448                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 449                {
 0450                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 451                }
 0452                if (_shouldTrace)
 453                {
 0454                    ServiceClientTracing.Error(_invocationId, ex);
 455                }
 0456                _httpRequest.Dispose();
 0457                if (_httpResponse != null)
 458                {
 0459                    _httpResponse.Dispose();
 460                }
 0461                throw ex;
 462            }
 463            // Create Result
 602464            var _result = new AzureOperationResponse<IPage<QueryKey>>();
 602465            _result.Request = _httpRequest;
 602466            _result.Response = _httpResponse;
 602467            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 468            {
 602469                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 470            }
 471            // Deserialize Response
 602472            if ((int)_statusCode == 200)
 473            {
 602474                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 475                try
 476                {
 602477                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<QueryKey>>(_responseConten
 602478                }
 0479                catch (JsonException ex)
 480                {
 0481                    _httpRequest.Dispose();
 0482                    if (_httpResponse != null)
 483                    {
 0484                        _httpResponse.Dispose();
 485                    }
 0486                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 487                }
 488            }
 602489            if (_shouldTrace)
 490            {
 0491                ServiceClientTracing.Exit(_invocationId, _result);
 492            }
 602493            return _result;
 602494        }
 495
 496        /// <summary>
 497        /// Deletes the specified query key. Unlike admin keys, query keys are not
 498        /// regenerated. The process for regenerating a query key is to delete and then
 499        /// recreate it.
 500        /// <see href="https://aka.ms/search-manage" />
 501        /// </summary>
 502        /// <param name='resourceGroupName'>
 503        /// The name of the resource group within the current subscription. You can
 504        /// obtain this value from the Azure Resource Manager API or the portal.
 505        /// </param>
 506        /// <param name='searchServiceName'>
 507        /// The name of the Azure Cognitive Search service associated with the
 508        /// specified resource group.
 509        /// </param>
 510        /// <param name='key'>
 511        /// The query key to be deleted. Query keys are identified by value, not by
 512        /// name.
 513        /// </param>
 514        /// <param name='searchManagementRequestOptions'>
 515        /// Additional parameters for the operation
 516        /// </param>
 517        /// <param name='customHeaders'>
 518        /// Headers that will be added to request.
 519        /// </param>
 520        /// <param name='cancellationToken'>
 521        /// The cancellation token.
 522        /// </param>
 523        /// <exception cref="CloudException">
 524        /// Thrown when the operation returned an invalid status code
 525        /// </exception>
 526        /// <exception cref="ValidationException">
 527        /// Thrown when a required parameter is null
 528        /// </exception>
 529        /// <exception cref="System.ArgumentNullException">
 530        /// Thrown when a required parameter is null
 531        /// </exception>
 532        /// <return>
 533        /// A response object containing the response body and response headers.
 534        /// </return>
 535        public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string resourceGroupName, string searchSer
 536        {
 0537            if (resourceGroupName == null)
 538            {
 0539                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 540            }
 0541            if (searchServiceName == null)
 542            {
 0543                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 544            }
 0545            if (key == null)
 546            {
 0547                throw new ValidationException(ValidationRules.CannotBeNull, "key");
 548            }
 0549            if (Client.ApiVersion == null)
 550            {
 0551                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 552            }
 0553            if (Client.SubscriptionId == null)
 554            {
 0555                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 556            }
 0557            System.Guid? clientRequestId = default(System.Guid?);
 0558            if (searchManagementRequestOptions != null)
 559            {
 0560                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 561            }
 562            // Tracing
 0563            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0564            string _invocationId = null;
 0565            if (_shouldTrace)
 566            {
 0567                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0568                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0569                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0570                tracingParameters.Add("searchServiceName", searchServiceName);
 0571                tracingParameters.Add("key", key);
 0572                tracingParameters.Add("clientRequestId", clientRequestId);
 0573                tracingParameters.Add("cancellationToken", cancellationToken);
 0574                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 575            }
 576            // Construct URL
 0577            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0578            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0579            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0580            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 0581            _url = _url.Replace("{key}", System.Uri.EscapeDataString(key));
 0582            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0583            List<string> _queryParameters = new List<string>();
 0584            if (Client.ApiVersion != null)
 585            {
 0586                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 587            }
 0588            if (_queryParameters.Count > 0)
 589            {
 0590                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 591            }
 592            // Create HTTP transport objects
 0593            var _httpRequest = new HttpRequestMessage();
 0594            HttpResponseMessage _httpResponse = null;
 0595            _httpRequest.Method = new HttpMethod("DELETE");
 0596            _httpRequest.RequestUri = new System.Uri(_url);
 597            // Set Headers
 0598            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 599            {
 0600                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 601            }
 0602            if (Client.AcceptLanguage != null)
 603            {
 0604                if (_httpRequest.Headers.Contains("accept-language"))
 605                {
 0606                    _httpRequest.Headers.Remove("accept-language");
 607                }
 0608                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 609            }
 0610            if (clientRequestId != null)
 611            {
 0612                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 613                {
 0614                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 615                }
 0616                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 617            }
 618
 619
 0620            if (customHeaders != null)
 621            {
 0622                foreach(var _header in customHeaders)
 623                {
 0624                    if (_httpRequest.Headers.Contains(_header.Key))
 625                    {
 0626                        _httpRequest.Headers.Remove(_header.Key);
 627                    }
 0628                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 629                }
 630            }
 631
 632            // Serialize Request
 0633            string _requestContent = null;
 634            // Set Credentials
 0635            if (Client.Credentials != null)
 636            {
 0637                cancellationToken.ThrowIfCancellationRequested();
 0638                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 639            }
 640            // Send Request
 0641            if (_shouldTrace)
 642            {
 0643                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 644            }
 0645            cancellationToken.ThrowIfCancellationRequested();
 0646            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0647            if (_shouldTrace)
 648            {
 0649                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 650            }
 0651            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0652            cancellationToken.ThrowIfCancellationRequested();
 0653            string _responseContent = null;
 0654            if ((int)_statusCode != 200 && (int)_statusCode != 204 && (int)_statusCode != 404)
 655            {
 0656                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 657                try
 658                {
 0659                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0660                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0661                    if (_errorBody != null)
 662                    {
 0663                        ex = new CloudException(_errorBody.Message);
 0664                        ex.Body = _errorBody;
 665                    }
 0666                }
 0667                catch (JsonException)
 668                {
 669                    // Ignore the exception
 0670                }
 0671                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0672                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0673                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 674                {
 0675                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 676                }
 0677                if (_shouldTrace)
 678                {
 0679                    ServiceClientTracing.Error(_invocationId, ex);
 680                }
 0681                _httpRequest.Dispose();
 0682                if (_httpResponse != null)
 683                {
 0684                    _httpResponse.Dispose();
 685                }
 0686                throw ex;
 687            }
 688            // Create Result
 0689            var _result = new AzureOperationResponse();
 0690            _result.Request = _httpRequest;
 0691            _result.Response = _httpResponse;
 0692            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 693            {
 0694                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 695            }
 0696            if (_shouldTrace)
 697            {
 0698                ServiceClientTracing.Exit(_invocationId, _result);
 699            }
 0700            return _result;
 0701        }
 702
 703        /// <summary>
 704        /// Returns the list of query API keys for the given Azure Cognitive Search
 705        /// service.
 706        /// <see href="https://aka.ms/search-manage" />
 707        /// </summary>
 708        /// <param name='nextPageLink'>
 709        /// The NextLink from the previous successful call to List operation.
 710        /// </param>
 711        /// <param name='searchManagementRequestOptions'>
 712        /// Additional parameters for the operation
 713        /// </param>
 714        /// <param name='customHeaders'>
 715        /// Headers that will be added to request.
 716        /// </param>
 717        /// <param name='cancellationToken'>
 718        /// The cancellation token.
 719        /// </param>
 720        /// <exception cref="CloudException">
 721        /// Thrown when the operation returned an invalid status code
 722        /// </exception>
 723        /// <exception cref="SerializationException">
 724        /// Thrown when unable to deserialize the response
 725        /// </exception>
 726        /// <exception cref="ValidationException">
 727        /// Thrown when a required parameter is null
 728        /// </exception>
 729        /// <exception cref="System.ArgumentNullException">
 730        /// Thrown when a required parameter is null
 731        /// </exception>
 732        /// <return>
 733        /// A response object containing the response body and response headers.
 734        /// </return>
 735        public async Task<AzureOperationResponse<IPage<QueryKey>>> ListBySearchServiceNextWithHttpMessagesAsync(string n
 736        {
 0737            if (nextPageLink == null)
 738            {
 0739                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 740            }
 0741            System.Guid? clientRequestId = default(System.Guid?);
 0742            if (searchManagementRequestOptions != null)
 743            {
 0744                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 745            }
 746            // Tracing
 0747            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0748            string _invocationId = null;
 0749            if (_shouldTrace)
 750            {
 0751                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0752                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0753                tracingParameters.Add("nextPageLink", nextPageLink);
 0754                tracingParameters.Add("clientRequestId", clientRequestId);
 0755                tracingParameters.Add("cancellationToken", cancellationToken);
 0756                ServiceClientTracing.Enter(_invocationId, this, "ListBySearchServiceNext", tracingParameters);
 757            }
 758            // Construct URL
 0759            string _url = "{nextLink}";
 0760            _url = _url.Replace("{nextLink}", nextPageLink);
 0761            List<string> _queryParameters = new List<string>();
 0762            if (_queryParameters.Count > 0)
 763            {
 0764                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 765            }
 766            // Create HTTP transport objects
 0767            var _httpRequest = new HttpRequestMessage();
 0768            HttpResponseMessage _httpResponse = null;
 0769            _httpRequest.Method = new HttpMethod("POST");
 0770            _httpRequest.RequestUri = new System.Uri(_url);
 771            // Set Headers
 0772            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 773            {
 0774                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 775            }
 0776            if (Client.AcceptLanguage != null)
 777            {
 0778                if (_httpRequest.Headers.Contains("accept-language"))
 779                {
 0780                    _httpRequest.Headers.Remove("accept-language");
 781                }
 0782                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 783            }
 0784            if (clientRequestId != null)
 785            {
 0786                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 787                {
 0788                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 789                }
 0790                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 791            }
 792
 793
 0794            if (customHeaders != null)
 795            {
 0796                foreach(var _header in customHeaders)
 797                {
 0798                    if (_httpRequest.Headers.Contains(_header.Key))
 799                    {
 0800                        _httpRequest.Headers.Remove(_header.Key);
 801                    }
 0802                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 803                }
 804            }
 805
 806            // Serialize Request
 0807            string _requestContent = null;
 808            // Set Credentials
 0809            if (Client.Credentials != null)
 810            {
 0811                cancellationToken.ThrowIfCancellationRequested();
 0812                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 813            }
 814            // Send Request
 0815            if (_shouldTrace)
 816            {
 0817                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 818            }
 0819            cancellationToken.ThrowIfCancellationRequested();
 0820            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0821            if (_shouldTrace)
 822            {
 0823                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 824            }
 0825            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0826            cancellationToken.ThrowIfCancellationRequested();
 0827            string _responseContent = null;
 0828            if ((int)_statusCode != 200)
 829            {
 0830                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 831                try
 832                {
 0833                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0834                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0835                    if (_errorBody != null)
 836                    {
 0837                        ex = new CloudException(_errorBody.Message);
 0838                        ex.Body = _errorBody;
 839                    }
 0840                }
 0841                catch (JsonException)
 842                {
 843                    // Ignore the exception
 0844                }
 0845                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0846                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0847                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 848                {
 0849                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 850                }
 0851                if (_shouldTrace)
 852                {
 0853                    ServiceClientTracing.Error(_invocationId, ex);
 854                }
 0855                _httpRequest.Dispose();
 0856                if (_httpResponse != null)
 857                {
 0858                    _httpResponse.Dispose();
 859                }
 0860                throw ex;
 861            }
 862            // Create Result
 0863            var _result = new AzureOperationResponse<IPage<QueryKey>>();
 0864            _result.Request = _httpRequest;
 0865            _result.Response = _httpResponse;
 0866            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 867            {
 0868                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 869            }
 870            // Deserialize Response
 0871            if ((int)_statusCode == 200)
 872            {
 0873                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 874                try
 875                {
 0876                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<QueryKey>>(_responseConten
 0877                }
 0878                catch (JsonException ex)
 879                {
 0880                    _httpRequest.Dispose();
 0881                    if (_httpResponse != null)
 882                    {
 0883                        _httpResponse.Dispose();
 884                    }
 0885                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 886                }
 887            }
 0888            if (_shouldTrace)
 889            {
 0890                ServiceClientTracing.Exit(_invocationId, _result);
 891            }
 0892            return _result;
 0893        }
 894
 895    }
 896}