< Summary

Class:Microsoft.Azure.Management.Search.SharedPrivateLinkResourcesOperations
Assembly:Microsoft.Azure.Management.Search
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\src\Generated\SharedPrivateLinkResourcesOperations.cs
Covered lines:4
Uncovered lines:514
Coverable lines:518
Total lines:1154
Line coverage:0.7% (4 of 518)
Covered branches:1
Total branches:316
Branch coverage:0.3% (1 of 316)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-0%100%
CreateOrUpdateWithHttpMessagesAsync()-0%0%
GetWithHttpMessagesAsync()-0%0%
DeleteWithHttpMessagesAsync()-0%0%
ListByServiceWithHttpMessagesAsync()-0%0%
ListByServiceNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\src\Generated\SharedPrivateLinkResourcesOperations.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    /// SharedPrivateLinkResourcesOperations operations.
 27    /// </summary>
 28    internal partial class SharedPrivateLinkResourcesOperations : IServiceOperations<SearchManagementClient>, ISharedPri
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the SharedPrivateLinkResourcesOperations 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 SharedPrivateLinkResourcesOperations(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>
 051        public SearchManagementClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Creates or updates a shared private link resource managed by the Search
 55        /// service in the given resource group.
 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='sharedPrivateLinkResourceName'>
 67        /// The name of the shared private link resource managed by the Azure Cognitive
 68        /// Search service within the specified resource group.
 69        /// </param>
 70        /// <param name='sharedPrivateLinkResource'>
 71        /// The definition of the shared private link resource to create or update.
 72        /// </param>
 73        /// <param name='searchManagementRequestOptions'>
 74        /// Additional parameters for the operation
 75        /// </param>
 76        /// <param name='customHeaders'>
 77        /// Headers that will be added to request.
 78        /// </param>
 79        /// <param name='cancellationToken'>
 80        /// The cancellation token.
 81        /// </param>
 82        /// <exception cref="CloudException">
 83        /// Thrown when the operation returned an invalid status code
 84        /// </exception>
 85        /// <exception cref="SerializationException">
 86        /// Thrown when unable to deserialize the response
 87        /// </exception>
 88        /// <exception cref="ValidationException">
 89        /// Thrown when a required parameter is null
 90        /// </exception>
 91        /// <exception cref="System.ArgumentNullException">
 92        /// Thrown when a required parameter is null
 93        /// </exception>
 94        /// <return>
 95        /// A response object containing the response body and response headers.
 96        /// </return>
 97        public async Task<AzureOperationResponse<SharedPrivateLinkResource>> CreateOrUpdateWithHttpMessagesAsync(string 
 98        {
 099            if (resourceGroupName == null)
 100            {
 0101                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 102            }
 0103            if (searchServiceName == null)
 104            {
 0105                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 106            }
 0107            if (sharedPrivateLinkResourceName == null)
 108            {
 0109                throw new ValidationException(ValidationRules.CannotBeNull, "sharedPrivateLinkResourceName");
 110            }
 0111            if (sharedPrivateLinkResource == null)
 112            {
 0113                throw new ValidationException(ValidationRules.CannotBeNull, "sharedPrivateLinkResource");
 114            }
 0115            if (Client.ApiVersion == null)
 116            {
 0117                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 118            }
 0119            if (Client.SubscriptionId == null)
 120            {
 0121                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 122            }
 0123            System.Guid? clientRequestId = default(System.Guid?);
 0124            if (searchManagementRequestOptions != null)
 125            {
 0126                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 127            }
 128            // Tracing
 0129            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0130            string _invocationId = null;
 0131            if (_shouldTrace)
 132            {
 0133                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0134                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0135                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0136                tracingParameters.Add("searchServiceName", searchServiceName);
 0137                tracingParameters.Add("sharedPrivateLinkResourceName", sharedPrivateLinkResourceName);
 0138                tracingParameters.Add("sharedPrivateLinkResource", sharedPrivateLinkResource);
 0139                tracingParameters.Add("clientRequestId", clientRequestId);
 0140                tracingParameters.Add("cancellationToken", cancellationToken);
 0141                ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters);
 142            }
 143            // Construct URL
 0144            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0145            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0146            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0147            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 0148            _url = _url.Replace("{sharedPrivateLinkResourceName}", System.Uri.EscapeDataString(sharedPrivateLinkResource
 0149            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0150            List<string> _queryParameters = new List<string>();
 0151            if (Client.ApiVersion != null)
 152            {
 0153                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 154            }
 0155            if (_queryParameters.Count > 0)
 156            {
 0157                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 158            }
 159            // Create HTTP transport objects
 0160            var _httpRequest = new HttpRequestMessage();
 0161            HttpResponseMessage _httpResponse = null;
 0162            _httpRequest.Method = new HttpMethod("PUT");
 0163            _httpRequest.RequestUri = new System.Uri(_url);
 164            // Set Headers
 0165            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 166            {
 0167                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 168            }
 0169            if (Client.AcceptLanguage != null)
 170            {
 0171                if (_httpRequest.Headers.Contains("accept-language"))
 172                {
 0173                    _httpRequest.Headers.Remove("accept-language");
 174                }
 0175                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 176            }
 0177            if (clientRequestId != null)
 178            {
 0179                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 180                {
 0181                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 182                }
 0183                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 184            }
 185
 186
 0187            if (customHeaders != null)
 188            {
 0189                foreach(var _header in customHeaders)
 190                {
 0191                    if (_httpRequest.Headers.Contains(_header.Key))
 192                    {
 0193                        _httpRequest.Headers.Remove(_header.Key);
 194                    }
 0195                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 196                }
 197            }
 198
 199            // Serialize Request
 0200            string _requestContent = null;
 0201            if(sharedPrivateLinkResource != null)
 202            {
 0203                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(sharedPrivateLinkResource, Client.S
 0204                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 0205                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 206            }
 207            // Set Credentials
 0208            if (Client.Credentials != null)
 209            {
 0210                cancellationToken.ThrowIfCancellationRequested();
 0211                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 212            }
 213            // Send Request
 0214            if (_shouldTrace)
 215            {
 0216                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 217            }
 0218            cancellationToken.ThrowIfCancellationRequested();
 0219            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0220            if (_shouldTrace)
 221            {
 0222                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 223            }
 0224            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0225            cancellationToken.ThrowIfCancellationRequested();
 0226            string _responseContent = null;
 0227            if ((int)_statusCode != 200 && (int)_statusCode != 201)
 228            {
 0229                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 230                try
 231                {
 0232                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0233                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0234                    if (_errorBody != null)
 235                    {
 0236                        ex = new CloudException(_errorBody.Message);
 0237                        ex.Body = _errorBody;
 238                    }
 0239                }
 0240                catch (JsonException)
 241                {
 242                    // Ignore the exception
 0243                }
 0244                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0245                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0246                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 247                {
 0248                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 249                }
 0250                if (_shouldTrace)
 251                {
 0252                    ServiceClientTracing.Error(_invocationId, ex);
 253                }
 0254                _httpRequest.Dispose();
 0255                if (_httpResponse != null)
 256                {
 0257                    _httpResponse.Dispose();
 258                }
 0259                throw ex;
 260            }
 261            // Create Result
 0262            var _result = new AzureOperationResponse<SharedPrivateLinkResource>();
 0263            _result.Request = _httpRequest;
 0264            _result.Response = _httpResponse;
 0265            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 266            {
 0267                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 268            }
 269            // Deserialize Response
 0270            if ((int)_statusCode == 200)
 271            {
 0272                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 273                try
 274                {
 0275                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SharedPrivateLinkResource>(_resp
 0276                }
 0277                catch (JsonException ex)
 278                {
 0279                    _httpRequest.Dispose();
 0280                    if (_httpResponse != null)
 281                    {
 0282                        _httpResponse.Dispose();
 283                    }
 0284                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 285                }
 286            }
 287            // Deserialize Response
 0288            if ((int)_statusCode == 201)
 289            {
 0290                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 291                try
 292                {
 0293                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SharedPrivateLinkResource>(_resp
 0294                }
 0295                catch (JsonException ex)
 296                {
 0297                    _httpRequest.Dispose();
 0298                    if (_httpResponse != null)
 299                    {
 0300                        _httpResponse.Dispose();
 301                    }
 0302                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 303                }
 304            }
 0305            if (_shouldTrace)
 306            {
 0307                ServiceClientTracing.Exit(_invocationId, _result);
 308            }
 0309            return _result;
 0310        }
 311
 312        /// <summary>
 313        /// Gets the details of the shared private link resource managed by the Search
 314        /// service in the given resource group.
 315        /// <see href="https://aka.ms/search-manage" />
 316        /// </summary>
 317        /// <param name='resourceGroupName'>
 318        /// The name of the resource group within the current subscription. You can
 319        /// obtain this value from the Azure Resource Manager API or the portal.
 320        /// </param>
 321        /// <param name='searchServiceName'>
 322        /// The name of the Azure Cognitive Search service associated with the
 323        /// specified resource group.
 324        /// </param>
 325        /// <param name='sharedPrivateLinkResourceName'>
 326        /// The name of the shared private link resource managed by the Azure Cognitive
 327        /// Search service within the specified resource group.
 328        /// </param>
 329        /// <param name='searchManagementRequestOptions'>
 330        /// Additional parameters for the operation
 331        /// </param>
 332        /// <param name='customHeaders'>
 333        /// Headers that will be added to request.
 334        /// </param>
 335        /// <param name='cancellationToken'>
 336        /// The cancellation token.
 337        /// </param>
 338        /// <exception cref="CloudException">
 339        /// Thrown when the operation returned an invalid status code
 340        /// </exception>
 341        /// <exception cref="SerializationException">
 342        /// Thrown when unable to deserialize the response
 343        /// </exception>
 344        /// <exception cref="ValidationException">
 345        /// Thrown when a required parameter is null
 346        /// </exception>
 347        /// <exception cref="System.ArgumentNullException">
 348        /// Thrown when a required parameter is null
 349        /// </exception>
 350        /// <return>
 351        /// A response object containing the response body and response headers.
 352        /// </return>
 353        public async Task<AzureOperationResponse<SharedPrivateLinkResource>> GetWithHttpMessagesAsync(string resourceGro
 354        {
 0355            if (resourceGroupName == null)
 356            {
 0357                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 358            }
 0359            if (searchServiceName == null)
 360            {
 0361                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 362            }
 0363            if (sharedPrivateLinkResourceName == null)
 364            {
 0365                throw new ValidationException(ValidationRules.CannotBeNull, "sharedPrivateLinkResourceName");
 366            }
 0367            if (Client.ApiVersion == null)
 368            {
 0369                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 370            }
 0371            if (Client.SubscriptionId == null)
 372            {
 0373                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 374            }
 0375            System.Guid? clientRequestId = default(System.Guid?);
 0376            if (searchManagementRequestOptions != null)
 377            {
 0378                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 379            }
 380            // Tracing
 0381            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0382            string _invocationId = null;
 0383            if (_shouldTrace)
 384            {
 0385                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0386                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0387                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0388                tracingParameters.Add("searchServiceName", searchServiceName);
 0389                tracingParameters.Add("sharedPrivateLinkResourceName", sharedPrivateLinkResourceName);
 0390                tracingParameters.Add("clientRequestId", clientRequestId);
 0391                tracingParameters.Add("cancellationToken", cancellationToken);
 0392                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 393            }
 394            // Construct URL
 0395            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0396            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0397            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0398            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 0399            _url = _url.Replace("{sharedPrivateLinkResourceName}", System.Uri.EscapeDataString(sharedPrivateLinkResource
 0400            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0401            List<string> _queryParameters = new List<string>();
 0402            if (Client.ApiVersion != null)
 403            {
 0404                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 405            }
 0406            if (_queryParameters.Count > 0)
 407            {
 0408                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 409            }
 410            // Create HTTP transport objects
 0411            var _httpRequest = new HttpRequestMessage();
 0412            HttpResponseMessage _httpResponse = null;
 0413            _httpRequest.Method = new HttpMethod("GET");
 0414            _httpRequest.RequestUri = new System.Uri(_url);
 415            // Set Headers
 0416            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 417            {
 0418                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 419            }
 0420            if (Client.AcceptLanguage != null)
 421            {
 0422                if (_httpRequest.Headers.Contains("accept-language"))
 423                {
 0424                    _httpRequest.Headers.Remove("accept-language");
 425                }
 0426                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 427            }
 0428            if (clientRequestId != null)
 429            {
 0430                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 431                {
 0432                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 433                }
 0434                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 435            }
 436
 437
 0438            if (customHeaders != null)
 439            {
 0440                foreach(var _header in customHeaders)
 441                {
 0442                    if (_httpRequest.Headers.Contains(_header.Key))
 443                    {
 0444                        _httpRequest.Headers.Remove(_header.Key);
 445                    }
 0446                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 447                }
 448            }
 449
 450            // Serialize Request
 0451            string _requestContent = null;
 452            // Set Credentials
 0453            if (Client.Credentials != null)
 454            {
 0455                cancellationToken.ThrowIfCancellationRequested();
 0456                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 457            }
 458            // Send Request
 0459            if (_shouldTrace)
 460            {
 0461                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 462            }
 0463            cancellationToken.ThrowIfCancellationRequested();
 0464            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0465            if (_shouldTrace)
 466            {
 0467                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 468            }
 0469            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0470            cancellationToken.ThrowIfCancellationRequested();
 0471            string _responseContent = null;
 0472            if ((int)_statusCode != 200)
 473            {
 0474                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 475                try
 476                {
 0477                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0478                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0479                    if (_errorBody != null)
 480                    {
 0481                        ex = new CloudException(_errorBody.Message);
 0482                        ex.Body = _errorBody;
 483                    }
 0484                }
 0485                catch (JsonException)
 486                {
 487                    // Ignore the exception
 0488                }
 0489                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0490                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0491                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 492                {
 0493                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 494                }
 0495                if (_shouldTrace)
 496                {
 0497                    ServiceClientTracing.Error(_invocationId, ex);
 498                }
 0499                _httpRequest.Dispose();
 0500                if (_httpResponse != null)
 501                {
 0502                    _httpResponse.Dispose();
 503                }
 0504                throw ex;
 505            }
 506            // Create Result
 0507            var _result = new AzureOperationResponse<SharedPrivateLinkResource>();
 0508            _result.Request = _httpRequest;
 0509            _result.Response = _httpResponse;
 0510            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 511            {
 0512                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 513            }
 514            // Deserialize Response
 0515            if ((int)_statusCode == 200)
 516            {
 0517                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 518                try
 519                {
 0520                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SharedPrivateLinkResource>(_resp
 0521                }
 0522                catch (JsonException ex)
 523                {
 0524                    _httpRequest.Dispose();
 0525                    if (_httpResponse != null)
 526                    {
 0527                        _httpResponse.Dispose();
 528                    }
 0529                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 530                }
 531            }
 0532            if (_shouldTrace)
 533            {
 0534                ServiceClientTracing.Exit(_invocationId, _result);
 535            }
 0536            return _result;
 0537        }
 538
 539        /// <summary>
 540        /// Deletes the shared private link resource from the Search service.
 541        /// <see href="https://aka.ms/search-manage" />
 542        /// </summary>
 543        /// <param name='resourceGroupName'>
 544        /// The name of the resource group within the current subscription. You can
 545        /// obtain this value from the Azure Resource Manager API or the portal.
 546        /// </param>
 547        /// <param name='searchServiceName'>
 548        /// The name of the Azure Cognitive Search service associated with the
 549        /// specified resource group.
 550        /// </param>
 551        /// <param name='sharedPrivateLinkResourceName'>
 552        /// The name of the shared private link resource managed by the Azure Cognitive
 553        /// Search service within the specified resource group.
 554        /// </param>
 555        /// <param name='searchManagementRequestOptions'>
 556        /// Additional parameters for the operation
 557        /// </param>
 558        /// <param name='customHeaders'>
 559        /// Headers that will be added to request.
 560        /// </param>
 561        /// <param name='cancellationToken'>
 562        /// The cancellation token.
 563        /// </param>
 564        /// <exception cref="CloudException">
 565        /// Thrown when the operation returned an invalid status code
 566        /// </exception>
 567        /// <exception cref="ValidationException">
 568        /// Thrown when a required parameter is null
 569        /// </exception>
 570        /// <exception cref="System.ArgumentNullException">
 571        /// Thrown when a required parameter is null
 572        /// </exception>
 573        /// <return>
 574        /// A response object containing the response body and response headers.
 575        /// </return>
 576        public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string resourceGroupName, string searchSer
 577        {
 0578            if (resourceGroupName == null)
 579            {
 0580                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 581            }
 0582            if (searchServiceName == null)
 583            {
 0584                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 585            }
 0586            if (sharedPrivateLinkResourceName == null)
 587            {
 0588                throw new ValidationException(ValidationRules.CannotBeNull, "sharedPrivateLinkResourceName");
 589            }
 0590            if (Client.ApiVersion == null)
 591            {
 0592                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 593            }
 0594            if (Client.SubscriptionId == null)
 595            {
 0596                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 597            }
 0598            System.Guid? clientRequestId = default(System.Guid?);
 0599            if (searchManagementRequestOptions != null)
 600            {
 0601                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 602            }
 603            // Tracing
 0604            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0605            string _invocationId = null;
 0606            if (_shouldTrace)
 607            {
 0608                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0609                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0610                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0611                tracingParameters.Add("searchServiceName", searchServiceName);
 0612                tracingParameters.Add("sharedPrivateLinkResourceName", sharedPrivateLinkResourceName);
 0613                tracingParameters.Add("clientRequestId", clientRequestId);
 0614                tracingParameters.Add("cancellationToken", cancellationToken);
 0615                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 616            }
 617            // Construct URL
 0618            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0619            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0620            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0621            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 0622            _url = _url.Replace("{sharedPrivateLinkResourceName}", System.Uri.EscapeDataString(sharedPrivateLinkResource
 0623            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0624            List<string> _queryParameters = new List<string>();
 0625            if (Client.ApiVersion != null)
 626            {
 0627                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 628            }
 0629            if (_queryParameters.Count > 0)
 630            {
 0631                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 632            }
 633            // Create HTTP transport objects
 0634            var _httpRequest = new HttpRequestMessage();
 0635            HttpResponseMessage _httpResponse = null;
 0636            _httpRequest.Method = new HttpMethod("DELETE");
 0637            _httpRequest.RequestUri = new System.Uri(_url);
 638            // Set Headers
 0639            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 640            {
 0641                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 642            }
 0643            if (Client.AcceptLanguage != null)
 644            {
 0645                if (_httpRequest.Headers.Contains("accept-language"))
 646                {
 0647                    _httpRequest.Headers.Remove("accept-language");
 648                }
 0649                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 650            }
 0651            if (clientRequestId != null)
 652            {
 0653                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 654                {
 0655                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 656                }
 0657                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 658            }
 659
 660
 0661            if (customHeaders != null)
 662            {
 0663                foreach(var _header in customHeaders)
 664                {
 0665                    if (_httpRequest.Headers.Contains(_header.Key))
 666                    {
 0667                        _httpRequest.Headers.Remove(_header.Key);
 668                    }
 0669                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 670                }
 671            }
 672
 673            // Serialize Request
 0674            string _requestContent = null;
 675            // Set Credentials
 0676            if (Client.Credentials != null)
 677            {
 0678                cancellationToken.ThrowIfCancellationRequested();
 0679                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 680            }
 681            // Send Request
 0682            if (_shouldTrace)
 683            {
 0684                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 685            }
 0686            cancellationToken.ThrowIfCancellationRequested();
 0687            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0688            if (_shouldTrace)
 689            {
 0690                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 691            }
 0692            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0693            cancellationToken.ThrowIfCancellationRequested();
 0694            string _responseContent = null;
 0695            if ((int)_statusCode != 200 && (int)_statusCode != 404)
 696            {
 0697                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 698                try
 699                {
 0700                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0701                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0702                    if (_errorBody != null)
 703                    {
 0704                        ex = new CloudException(_errorBody.Message);
 0705                        ex.Body = _errorBody;
 706                    }
 0707                }
 0708                catch (JsonException)
 709                {
 710                    // Ignore the exception
 0711                }
 0712                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0713                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0714                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 715                {
 0716                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 717                }
 0718                if (_shouldTrace)
 719                {
 0720                    ServiceClientTracing.Error(_invocationId, ex);
 721                }
 0722                _httpRequest.Dispose();
 0723                if (_httpResponse != null)
 724                {
 0725                    _httpResponse.Dispose();
 726                }
 0727                throw ex;
 728            }
 729            // Create Result
 0730            var _result = new AzureOperationResponse();
 0731            _result.Request = _httpRequest;
 0732            _result.Response = _httpResponse;
 0733            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 734            {
 0735                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 736            }
 0737            if (_shouldTrace)
 738            {
 0739                ServiceClientTracing.Exit(_invocationId, _result);
 740            }
 0741            return _result;
 0742        }
 743
 744        /// <summary>
 745        /// Gets a list of all shared private link resources managed by the given
 746        /// service.
 747        /// <see href="https://aka.ms/search-manage" />
 748        /// </summary>
 749        /// <param name='resourceGroupName'>
 750        /// The name of the resource group within the current subscription. You can
 751        /// obtain this value from the Azure Resource Manager API or the portal.
 752        /// </param>
 753        /// <param name='searchServiceName'>
 754        /// The name of the Azure Cognitive Search service associated with the
 755        /// specified resource group.
 756        /// </param>
 757        /// <param name='searchManagementRequestOptions'>
 758        /// Additional parameters for the operation
 759        /// </param>
 760        /// <param name='customHeaders'>
 761        /// Headers that will be added to request.
 762        /// </param>
 763        /// <param name='cancellationToken'>
 764        /// The cancellation token.
 765        /// </param>
 766        /// <exception cref="CloudException">
 767        /// Thrown when the operation returned an invalid status code
 768        /// </exception>
 769        /// <exception cref="SerializationException">
 770        /// Thrown when unable to deserialize the response
 771        /// </exception>
 772        /// <exception cref="ValidationException">
 773        /// Thrown when a required parameter is null
 774        /// </exception>
 775        /// <exception cref="System.ArgumentNullException">
 776        /// Thrown when a required parameter is null
 777        /// </exception>
 778        /// <return>
 779        /// A response object containing the response body and response headers.
 780        /// </return>
 781        public async Task<AzureOperationResponse<IPage<SharedPrivateLinkResource>>> ListByServiceWithHttpMessagesAsync(s
 782        {
 0783            if (Client.ApiVersion == null)
 784            {
 0785                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 786            }
 0787            if (Client.SubscriptionId == null)
 788            {
 0789                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 790            }
 0791            if (resourceGroupName == null)
 792            {
 0793                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 794            }
 0795            if (searchServiceName == null)
 796            {
 0797                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 798            }
 0799            System.Guid? clientRequestId = default(System.Guid?);
 0800            if (searchManagementRequestOptions != null)
 801            {
 0802                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 803            }
 804            // Tracing
 0805            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0806            string _invocationId = null;
 0807            if (_shouldTrace)
 808            {
 0809                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0810                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0811                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0812                tracingParameters.Add("searchServiceName", searchServiceName);
 0813                tracingParameters.Add("clientRequestId", clientRequestId);
 0814                tracingParameters.Add("cancellationToken", cancellationToken);
 0815                ServiceClientTracing.Enter(_invocationId, this, "ListByService", tracingParameters);
 816            }
 817            // Construct URL
 0818            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0819            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0820            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0821            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0822            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 0823            List<string> _queryParameters = new List<string>();
 0824            if (Client.ApiVersion != null)
 825            {
 0826                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 827            }
 0828            if (_queryParameters.Count > 0)
 829            {
 0830                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 831            }
 832            // Create HTTP transport objects
 0833            var _httpRequest = new HttpRequestMessage();
 0834            HttpResponseMessage _httpResponse = null;
 0835            _httpRequest.Method = new HttpMethod("GET");
 0836            _httpRequest.RequestUri = new System.Uri(_url);
 837            // Set Headers
 0838            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 839            {
 0840                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 841            }
 0842            if (Client.AcceptLanguage != null)
 843            {
 0844                if (_httpRequest.Headers.Contains("accept-language"))
 845                {
 0846                    _httpRequest.Headers.Remove("accept-language");
 847                }
 0848                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 849            }
 0850            if (clientRequestId != null)
 851            {
 0852                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 853                {
 0854                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 855                }
 0856                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 857            }
 858
 859
 0860            if (customHeaders != null)
 861            {
 0862                foreach(var _header in customHeaders)
 863                {
 0864                    if (_httpRequest.Headers.Contains(_header.Key))
 865                    {
 0866                        _httpRequest.Headers.Remove(_header.Key);
 867                    }
 0868                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 869                }
 870            }
 871
 872            // Serialize Request
 0873            string _requestContent = null;
 874            // Set Credentials
 0875            if (Client.Credentials != null)
 876            {
 0877                cancellationToken.ThrowIfCancellationRequested();
 0878                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 879            }
 880            // Send Request
 0881            if (_shouldTrace)
 882            {
 0883                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 884            }
 0885            cancellationToken.ThrowIfCancellationRequested();
 0886            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0887            if (_shouldTrace)
 888            {
 0889                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 890            }
 0891            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0892            cancellationToken.ThrowIfCancellationRequested();
 0893            string _responseContent = null;
 0894            if ((int)_statusCode != 200)
 895            {
 0896                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 897                try
 898                {
 0899                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0900                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0901                    if (_errorBody != null)
 902                    {
 0903                        ex = new CloudException(_errorBody.Message);
 0904                        ex.Body = _errorBody;
 905                    }
 0906                }
 0907                catch (JsonException)
 908                {
 909                    // Ignore the exception
 0910                }
 0911                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0912                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0913                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 914                {
 0915                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 916                }
 0917                if (_shouldTrace)
 918                {
 0919                    ServiceClientTracing.Error(_invocationId, ex);
 920                }
 0921                _httpRequest.Dispose();
 0922                if (_httpResponse != null)
 923                {
 0924                    _httpResponse.Dispose();
 925                }
 0926                throw ex;
 927            }
 928            // Create Result
 0929            var _result = new AzureOperationResponse<IPage<SharedPrivateLinkResource>>();
 0930            _result.Request = _httpRequest;
 0931            _result.Response = _httpResponse;
 0932            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 933            {
 0934                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 935            }
 936            // Deserialize Response
 0937            if ((int)_statusCode == 200)
 938            {
 0939                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 940                try
 941                {
 0942                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<SharedPrivateLinkResource>
 0943                }
 0944                catch (JsonException ex)
 945                {
 0946                    _httpRequest.Dispose();
 0947                    if (_httpResponse != null)
 948                    {
 0949                        _httpResponse.Dispose();
 950                    }
 0951                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 952                }
 953            }
 0954            if (_shouldTrace)
 955            {
 0956                ServiceClientTracing.Exit(_invocationId, _result);
 957            }
 0958            return _result;
 0959        }
 960
 961        /// <summary>
 962        /// Gets a list of all shared private link resources managed by the given
 963        /// service.
 964        /// <see href="https://aka.ms/search-manage" />
 965        /// </summary>
 966        /// <param name='nextPageLink'>
 967        /// The NextLink from the previous successful call to List operation.
 968        /// </param>
 969        /// <param name='searchManagementRequestOptions'>
 970        /// Additional parameters for the operation
 971        /// </param>
 972        /// <param name='customHeaders'>
 973        /// Headers that will be added to request.
 974        /// </param>
 975        /// <param name='cancellationToken'>
 976        /// The cancellation token.
 977        /// </param>
 978        /// <exception cref="CloudException">
 979        /// Thrown when the operation returned an invalid status code
 980        /// </exception>
 981        /// <exception cref="SerializationException">
 982        /// Thrown when unable to deserialize the response
 983        /// </exception>
 984        /// <exception cref="ValidationException">
 985        /// Thrown when a required parameter is null
 986        /// </exception>
 987        /// <exception cref="System.ArgumentNullException">
 988        /// Thrown when a required parameter is null
 989        /// </exception>
 990        /// <return>
 991        /// A response object containing the response body and response headers.
 992        /// </return>
 993        public async Task<AzureOperationResponse<IPage<SharedPrivateLinkResource>>> ListByServiceNextWithHttpMessagesAsy
 994        {
 0995            if (nextPageLink == null)
 996            {
 0997                throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
 998            }
 0999            System.Guid? clientRequestId = default(System.Guid?);
 01000            if (searchManagementRequestOptions != null)
 1001            {
 01002                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 1003            }
 1004            // Tracing
 01005            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 01006            string _invocationId = null;
 01007            if (_shouldTrace)
 1008            {
 01009                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01010                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01011                tracingParameters.Add("nextPageLink", nextPageLink);
 01012                tracingParameters.Add("clientRequestId", clientRequestId);
 01013                tracingParameters.Add("cancellationToken", cancellationToken);
 01014                ServiceClientTracing.Enter(_invocationId, this, "ListByServiceNext", tracingParameters);
 1015            }
 1016            // Construct URL
 01017            string _url = "{nextLink}";
 01018            _url = _url.Replace("{nextLink}", nextPageLink);
 01019            List<string> _queryParameters = new List<string>();
 01020            if (_queryParameters.Count > 0)
 1021            {
 01022                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1023            }
 1024            // Create HTTP transport objects
 01025            var _httpRequest = new HttpRequestMessage();
 01026            HttpResponseMessage _httpResponse = null;
 01027            _httpRequest.Method = new HttpMethod("GET");
 01028            _httpRequest.RequestUri = new System.Uri(_url);
 1029            // Set Headers
 01030            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1031            {
 01032                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 1033            }
 01034            if (Client.AcceptLanguage != null)
 1035            {
 01036                if (_httpRequest.Headers.Contains("accept-language"))
 1037                {
 01038                    _httpRequest.Headers.Remove("accept-language");
 1039                }
 01040                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1041            }
 01042            if (clientRequestId != null)
 1043            {
 01044                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 1045                {
 01046                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 1047                }
 01048                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 1049            }
 1050
 1051
 01052            if (customHeaders != null)
 1053            {
 01054                foreach(var _header in customHeaders)
 1055                {
 01056                    if (_httpRequest.Headers.Contains(_header.Key))
 1057                    {
 01058                        _httpRequest.Headers.Remove(_header.Key);
 1059                    }
 01060                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1061                }
 1062            }
 1063
 1064            // Serialize Request
 01065            string _requestContent = null;
 1066            // Set Credentials
 01067            if (Client.Credentials != null)
 1068            {
 01069                cancellationToken.ThrowIfCancellationRequested();
 01070                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1071            }
 1072            // Send Request
 01073            if (_shouldTrace)
 1074            {
 01075                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1076            }
 01077            cancellationToken.ThrowIfCancellationRequested();
 01078            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 01079            if (_shouldTrace)
 1080            {
 01081                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1082            }
 01083            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 01084            cancellationToken.ThrowIfCancellationRequested();
 01085            string _responseContent = null;
 01086            if ((int)_statusCode != 200)
 1087            {
 01088                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1089                try
 1090                {
 01091                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 01092                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 01093                    if (_errorBody != null)
 1094                    {
 01095                        ex = new CloudException(_errorBody.Message);
 01096                        ex.Body = _errorBody;
 1097                    }
 01098                }
 01099                catch (JsonException)
 1100                {
 1101                    // Ignore the exception
 01102                }
 01103                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 01104                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 01105                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1106                {
 01107                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1108                }
 01109                if (_shouldTrace)
 1110                {
 01111                    ServiceClientTracing.Error(_invocationId, ex);
 1112                }
 01113                _httpRequest.Dispose();
 01114                if (_httpResponse != null)
 1115                {
 01116                    _httpResponse.Dispose();
 1117                }
 01118                throw ex;
 1119            }
 1120            // Create Result
 01121            var _result = new AzureOperationResponse<IPage<SharedPrivateLinkResource>>();
 01122            _result.Request = _httpRequest;
 01123            _result.Response = _httpResponse;
 01124            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 1125            {
 01126                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 1127            }
 1128            // Deserialize Response
 01129            if ((int)_statusCode == 200)
 1130            {
 01131                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1132                try
 1133                {
 01134                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<SharedPrivateLinkResource>
 01135                }
 01136                catch (JsonException ex)
 1137                {
 01138                    _httpRequest.Dispose();
 01139                    if (_httpResponse != null)
 1140                    {
 01141                        _httpResponse.Dispose();
 1142                    }
 01143                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1144                }
 1145            }
 01146            if (_shouldTrace)
 1147            {
 01148                ServiceClientTracing.Exit(_invocationId, _result);
 1149            }
 01150            return _result;
 01151        }
 1152
 1153    }
 1154}