< Summary

Class:Microsoft.Azure.Search.SearchServiceClient
Assembly:Microsoft.Azure.Search.Service
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Customizations\SearchServiceClient.Customization.cs
C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\SearchServiceClient.cs
Covered lines:158
Uncovered lines:59
Coverable lines:217
Total lines:578
Line coverage:72.8% (158 of 217)
Covered branches:37
Total branches:74
Branch coverage:50% (37 of 74)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
.ctor(...)-100%100%
get_SearchCredentials()-100%100%
Initialize(...)-100%100%
ValidateSearchServiceName(...)-100%100%
get_BaseUri()-100%100%
get_SerializationSettings()-100%100%
get_DeserializationSettings()-100%100%
get_Credentials()-100%100%
get_ApiVersion()-100%100%
get_SearchServiceName()-100%100%
get_SearchDnsSuffix()-100%100%
get_AcceptLanguage()-100%100%
get_LongRunningOperationRetryTimeout()-0%100%
get_GenerateClientRequestId()-100%100%
get_DataSources()-100%100%
get_Indexers()-100%100%
get_Skillsets()-100%100%
get_SynonymMaps()-100%100%
get_Indexes()-100%100%
.ctor(...)-0%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
.ctor(...)-0%0%
.ctor(...)-42.86%25%
Initialize()-100%100%
GetServiceStatisticsWithHttpMessagesAsync()-54.17%50%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for
 3// license information.
 4
 5namespace Microsoft.Azure.Search
 6{
 7    using System;
 8    using System.Net.Http;
 9    using Common;
 10    using Rest;
 11
 12    public partial class SearchServiceClient
 13    {
 14        /// <summary>
 15        /// Initializes a new instance of the SearchServiceClient class.
 16        /// </summary>
 17        /// <param name='searchServiceName'>Required. The name of the search service.</param>
 18        /// <param name='credentials'>Required. The credentials used to authenticate to a search service.
 19        /// <see href="https://docs.microsoft.com/rest/api/searchservice/" />
 20        /// </param>
 21        /// <param name='rootHandler'>
 22        /// Optional. The http client handler used to handle http transport.
 23        /// </param>
 24        /// <param name='handlers'>
 25        /// Optional. The set of delegating handlers to insert in the http
 26        /// client pipeline.
 27        /// </param>
 28        public SearchServiceClient(
 29            string searchServiceName,
 30            SearchCredentials credentials,
 31            HttpClientHandler rootHandler,
 1032            params DelegatingHandler[] handlers) : this(rootHandler, handlers)
 33        {
 1034            Initialize(searchServiceName, credentials);
 235        }
 36
 37        /// <summary>
 38        /// Initializes a new instance of the SearchServiceClient class.
 39        /// </summary>
 40        /// <param name='searchServiceName'>Required. The name of the search service.</param>
 41        /// <param name='credentials'>Required. The credentials used to authenticate to a search service.
 42        /// <see href="https://docs.microsoft.com/rest/api/searchservice/" />
 43        /// </param>
 44        public SearchServiceClient(string searchServiceName, SearchCredentials credentials)
 6645            : this()
 46        {
 6647            Initialize(searchServiceName, credentials);
 5848        }
 49
 50        /// <summary>
 51        /// Gets the credentials used to authenticate to a search service. This can be either a query API key or an admi
 52        /// </summary>
 53        /// <remarks>
 54        /// See <see href="https://docs.microsoft.com/azure/search/search-security-api-keys">Create and manage api-keys 
 55        /// </remarks>
 1256        public SearchCredentials SearchCredentials => (SearchCredentials)Credentials;
 57
 58        private void Initialize(string searchServiceName, SearchCredentials credentials)
 59        {
 7660            Throw.IfArgumentNull(credentials, nameof(credentials));
 7261            ValidateSearchServiceName(searchServiceName);
 62
 6063            Credentials = credentials;
 6064            SearchServiceName = searchServiceName;
 65
 6066            Credentials.InitializeServiceClient(this);
 6067        }
 68
 69        private static void ValidateSearchServiceName(string searchServiceName)
 70        {
 7271            Throw.IfNullOrEmptySearchServiceName(searchServiceName);
 72
 6473            Uri uri = TypeConversion.TryParseUri($"https://{searchServiceName}.search.windows.net/");
 74
 6475            if (uri == null)
 76            {
 477                throw new ArgumentException(
 478                    $"Invalid search service name: '{searchServiceName}' Name contains characters that are not valid in 
 479                    nameof(searchServiceName));
 80            }
 6081        }
 82    }
 83}

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\SearchServiceClient.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.Search
 12{
 13    using Microsoft.Rest;
 14    using Microsoft.Rest.Azure;
 15    using Microsoft.Rest.Serialization;
 16    using Models;
 17    using Newtonsoft.Json;
 18    using System.Collections;
 19    using System.Collections.Generic;
 20    using System.Linq;
 21    using System.Net;
 22    using System.Net.Http;
 23    using System.Threading;
 24    using System.Threading.Tasks;
 25
 26    /// <summary>
 27    /// Client that can be used to manage and query indexes and documents, as
 28    /// well as manage other resources, on a search service.
 29    /// </summary>
 30    public partial class SearchServiceClient : ServiceClient<SearchServiceClient>, ISearchServiceClient, IAzureClient
 31    {
 32        /// <summary>
 33        /// The base URI of the service.
 34        /// </summary>
 232035        internal string BaseUri {get; set;}
 36
 37        /// <summary>
 38        /// Gets or sets json serialization settings.
 39        /// </summary>
 940040        public JsonSerializerSettings SerializationSettings { get; private set; }
 41
 42        /// <summary>
 43        /// Gets or sets json deserialization settings.
 44        /// </summary>
 1034445        public JsonSerializerSettings DeserializationSettings { get; private set; }
 46
 47        /// <summary>
 48        /// Credentials needed for the client to connect to Azure.
 49        /// </summary>
 535650        public ServiceClientCredentials Credentials { get; private set; }
 51
 52        /// <summary>
 53        /// Client Api Version.
 54        /// </summary>
 536855        public string ApiVersion { get; private set; }
 56
 57        /// <summary>
 58        /// The name of the search service.
 59        /// </summary>
 380860        public string SearchServiceName { get; set; }
 61
 62        /// <summary>
 63        /// The DNS suffix of the search service. The default is search.windows.net.
 64        /// </summary>
 457265        public string SearchDnsSuffix { get; set; }
 66
 67        /// <summary>
 68        /// The preferred language for the response.
 69        /// </summary>
 381670        public string AcceptLanguage { get; set; }
 71
 72        /// <summary>
 73        /// The retry timeout in seconds for Long Running Operations. Default value is
 74        /// 30.
 75        /// </summary>
 076        public int? LongRunningOperationRetryTimeout { get; set; }
 77
 78        /// <summary>
 79        /// Whether a unique x-ms-client-request-id should be generated. When set to
 80        /// true a unique x-ms-client-request-id value is generated and included in
 81        /// each request. Default is true.
 82        /// </summary>
 381683        public bool? GenerateClientRequestId { get; set; }
 84
 85        /// <summary>
 86        /// Gets the IDataSourcesOperations.
 87        /// </summary>
 108088        public virtual IDataSourcesOperations DataSources { get; private set; }
 89
 90        /// <summary>
 91        /// Gets the IIndexersOperations.
 92        /// </summary>
 90093        public virtual IIndexersOperations Indexers { get; private set; }
 94
 95        /// <summary>
 96        /// Gets the ISkillsetsOperations.
 97        /// </summary>
 99098        public virtual ISkillsetsOperations Skillsets { get; private set; }
 99
 100        /// <summary>
 101        /// Gets the ISynonymMapsOperations.
 102        /// </summary>
 894103        public virtual ISynonymMapsOperations SynonymMaps { get; private set; }
 104
 105        /// <summary>
 106        /// Gets the IIndexesOperations.
 107        /// </summary>
 1712108        public virtual IIndexesOperations Indexes { get; private set; }
 109
 110        /// <summary>
 111        /// Initializes a new instance of the SearchServiceClient class.
 112        /// </summary>
 113        /// <param name='httpClient'>
 114        /// HttpClient to be used
 115        /// </param>
 116        /// <param name='disposeHttpClient'>
 117        /// True: will dispose the provided httpClient on calling SearchServiceClient.Dispose(). False: will not dispose
 0118        protected SearchServiceClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClien
 119        {
 0120            Initialize();
 0121        }
 122
 123        /// <summary>
 124        /// Initializes a new instance of the SearchServiceClient class.
 125        /// </summary>
 126        /// <param name='handlers'>
 127        /// Optional. The delegating handlers to add to the http client pipeline.
 128        /// </param>
 812129        protected SearchServiceClient(params DelegatingHandler[] handlers) : base(handlers)
 130        {
 812131            Initialize();
 812132        }
 133
 134        /// <summary>
 135        /// Initializes a new instance of the SearchServiceClient class.
 136        /// </summary>
 137        /// <param name='rootHandler'>
 138        /// Optional. The http client handler used to handle http transport.
 139        /// </param>
 140        /// <param name='handlers'>
 141        /// Optional. The delegating handlers to add to the http client pipeline.
 142        /// </param>
 12143        protected SearchServiceClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHan
 144        {
 12145            Initialize();
 12146        }
 147
 148        /// <summary>
 149        /// Initializes a new instance of the SearchServiceClient class.
 150        /// </summary>
 151        /// <param name='credentials'>
 152        /// Required. Credentials needed for the client to connect to Azure.
 153        /// </param>
 154        /// <param name='handlers'>
 155        /// Optional. The delegating handlers to add to the http client pipeline.
 156        /// </param>
 157        /// <exception cref="System.ArgumentNullException">
 158        /// Thrown when a required parameter is null
 159        /// </exception>
 746160        public SearchServiceClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(han
 161        {
 746162            if (credentials == null)
 163            {
 2164                throw new System.ArgumentNullException("credentials");
 165            }
 744166            Credentials = credentials;
 744167            if (Credentials != null)
 168            {
 744169                Credentials.InitializeServiceClient(this);
 170            }
 744171        }
 172
 173        /// <summary>
 174        /// Initializes a new instance of the SearchServiceClient class.
 175        /// </summary>
 176        /// <param name='credentials'>
 177        /// Required. Credentials needed for the client to connect to Azure.
 178        /// </param>
 179        /// <param name='httpClient'>
 180        /// HttpClient to be used
 181        /// </param>
 182        /// <param name='disposeHttpClient'>
 183        /// True: will dispose the provided httpClient on calling SearchServiceClient.Dispose(). False: will not dispose
 184        /// <exception cref="System.ArgumentNullException">
 185        /// Thrown when a required parameter is null
 186        /// </exception>
 0187        public SearchServiceClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) 
 188        {
 0189            if (credentials == null)
 190            {
 0191                throw new System.ArgumentNullException("credentials");
 192            }
 0193            Credentials = credentials;
 0194            if (Credentials != null)
 195            {
 0196                Credentials.InitializeServiceClient(this);
 197            }
 0198        }
 199
 200        /// <summary>
 201        /// Initializes a new instance of the SearchServiceClient class.
 202        /// </summary>
 203        /// <param name='credentials'>
 204        /// Required. Credentials needed for the client to connect to Azure.
 205        /// </param>
 206        /// <param name='rootHandler'>
 207        /// Optional. The http client handler used to handle http transport.
 208        /// </param>
 209        /// <param name='handlers'>
 210        /// Optional. The delegating handlers to add to the http client pipeline.
 211        /// </param>
 212        /// <exception cref="System.ArgumentNullException">
 213        /// Thrown when a required parameter is null
 214        /// </exception>
 2215        public SearchServiceClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params Delegatin
 216        {
 2217            if (credentials == null)
 218            {
 2219                throw new System.ArgumentNullException("credentials");
 220            }
 0221            Credentials = credentials;
 0222            if (Credentials != null)
 223            {
 0224                Credentials.InitializeServiceClient(this);
 225            }
 0226        }
 227
 228        /// <summary>
 229        /// An optional partial-method to perform custom initialization.
 230        /// </summary>
 231        partial void CustomInitialize();
 232        /// <summary>
 233        /// Initializes client properties.
 234        /// </summary>
 235        private void Initialize()
 236        {
 824237            DataSources = new DataSourcesOperations(this);
 824238            Indexers = new IndexersOperations(this);
 824239            Skillsets = new SkillsetsOperations(this);
 824240            SynonymMaps = new SynonymMapsOperations(this);
 824241            Indexes = new IndexesOperations(this);
 824242            BaseUri = "https://{searchServiceName}.{searchDnsSuffix}";
 824243            ApiVersion = "2019-05-06";
 824244            SearchDnsSuffix = "search.windows.net";
 824245            AcceptLanguage = "en-US";
 824246            LongRunningOperationRetryTimeout = 30;
 824247            GenerateClientRequestId = true;
 824248            SerializationSettings = new JsonSerializerSettings
 824249            {
 824250                Formatting = Newtonsoft.Json.Formatting.Indented,
 824251                DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
 824252                DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
 824253                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
 824254                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
 824255                ContractResolver = new ReadOnlyJsonContractResolver(),
 824256                Converters = new List<JsonConverter>
 824257                    {
 824258                        new Iso8601TimeSpanConverter()
 824259                    }
 824260            };
 824261            DeserializationSettings = new JsonSerializerSettings
 824262            {
 824263                DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
 824264                DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
 824265                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
 824266                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
 824267                ContractResolver = new ReadOnlyJsonContractResolver(),
 824268                Converters = new List<JsonConverter>
 824269                    {
 824270                        new Iso8601TimeSpanConverter()
 824271                    }
 824272            };
 824273            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<Analyzer>("@odata.type"));
 824274            DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<Analyzer>("@odata.type"));
 824275            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<Tokenizer>("@odata.type"));
 824276            DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<Tokenizer>("@odata.type"));
 824277            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<TokenFilter>("@odata.type"));
 824278            DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<TokenFilter>("@odata.type"));
 824279            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<CharFilter>("@odata.type"));
 824280            DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<CharFilter>("@odata.type"));
 824281            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<DataChangeDetectionPolicy>("@odat
 824282            DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<DataChangeDetectionPolicy>("@
 824283            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<DataDeletionDetectionPolicy>("@od
 824284            DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<DataDeletionDetectionPolicy>(
 824285            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<ScoringFunction>("type"));
 824286            DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<ScoringFunction>("type"));
 824287            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<Skill>("@odata.type"));
 824288            DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<Skill>("@odata.type"));
 824289            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<CognitiveServices>("@odata.type")
 824290            DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<CognitiveServices>("@odata.ty
 291            CustomInitialize();
 824292            DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 824293        }
 294        /// <summary>
 295        /// Gets service level statistics for a search service.
 296        /// </summary>
 297        /// <param name='searchRequestOptions'>
 298        /// Additional parameters for the operation
 299        /// </param>
 300        /// <param name='customHeaders'>
 301        /// Headers that will be added to request.
 302        /// </param>
 303        /// <param name='cancellationToken'>
 304        /// The cancellation token.
 305        /// </param>
 306        /// <exception cref="CloudException">
 307        /// Thrown when the operation returned an invalid status code
 308        /// </exception>
 309        /// <exception cref="SerializationException">
 310        /// Thrown when unable to deserialize the response
 311        /// </exception>
 312        /// <exception cref="ValidationException">
 313        /// Thrown when a required parameter is null
 314        /// </exception>
 315        /// <exception cref="System.ArgumentNullException">
 316        /// Thrown when a required parameter is null
 317        /// </exception>
 318        /// <return>
 319        /// A response object containing the response body and response headers.
 320        /// </return>
 321        public async Task<AzureOperationResponse<ServiceStatistics>> GetServiceStatisticsWithHttpMessagesAsync(SearchReq
 322        {
 2323            if (SearchServiceName == null)
 324            {
 0325                throw new ValidationException(ValidationRules.CannotBeNull, "this.SearchServiceName");
 326            }
 2327            if (SearchDnsSuffix == null)
 328            {
 0329                throw new ValidationException(ValidationRules.CannotBeNull, "this.SearchDnsSuffix");
 330            }
 2331            if (ApiVersion == null)
 332            {
 0333                throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
 334            }
 2335            System.Guid? clientRequestId = default(System.Guid?);
 2336            if (searchRequestOptions != null)
 337            {
 0338                clientRequestId = searchRequestOptions.ClientRequestId;
 339            }
 340            // Tracing
 2341            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2342            string _invocationId = null;
 2343            if (_shouldTrace)
 344            {
 0345                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0346                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0347                tracingParameters.Add("clientRequestId", clientRequestId);
 0348                tracingParameters.Add("cancellationToken", cancellationToken);
 0349                ServiceClientTracing.Enter(_invocationId, this, "GetServiceStatistics", tracingParameters);
 350            }
 351            // Construct URL
 2352            var _baseUrl = BaseUri;
 2353            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "servicestats";
 2354            _url = _url.Replace("{searchServiceName}", SearchServiceName);
 2355            _url = _url.Replace("{searchDnsSuffix}", SearchDnsSuffix);
 2356            List<string> _queryParameters = new List<string>();
 2357            if (ApiVersion != null)
 358            {
 2359                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
 360            }
 2361            if (_queryParameters.Count > 0)
 362            {
 2363                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 364            }
 365            // Create HTTP transport objects
 2366            var _httpRequest = new HttpRequestMessage();
 2367            HttpResponseMessage _httpResponse = null;
 2368            _httpRequest.Method = new HttpMethod("GET");
 2369            _httpRequest.RequestUri = new System.Uri(_url);
 370            // Set Headers
 2371            if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
 372            {
 2373                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 374            }
 2375            if (AcceptLanguage != null)
 376            {
 2377                if (_httpRequest.Headers.Contains("accept-language"))
 378                {
 0379                    _httpRequest.Headers.Remove("accept-language");
 380                }
 2381                _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
 382            }
 2383            if (clientRequestId != null)
 384            {
 0385                if (_httpRequest.Headers.Contains("client-request-id"))
 386                {
 0387                    _httpRequest.Headers.Remove("client-request-id");
 388                }
 0389                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", SafeJsonConvert.SerializeObject(client
 390            }
 391
 392
 2393            if (customHeaders != null)
 394            {
 0395                foreach(var _header in customHeaders)
 396                {
 0397                    if (_httpRequest.Headers.Contains(_header.Key))
 398                    {
 0399                        _httpRequest.Headers.Remove(_header.Key);
 400                    }
 0401                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 402                }
 403            }
 404
 405            // Serialize Request
 2406            string _requestContent = null;
 407            // Set Credentials
 2408            if (Credentials != null)
 409            {
 2410                cancellationToken.ThrowIfCancellationRequested();
 2411                await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 412            }
 413            // Send Request
 2414            if (_shouldTrace)
 415            {
 0416                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 417            }
 2418            cancellationToken.ThrowIfCancellationRequested();
 2419            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2420            if (_shouldTrace)
 421            {
 0422                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 423            }
 2424            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2425            cancellationToken.ThrowIfCancellationRequested();
 2426            string _responseContent = null;
 2427            if ((int)_statusCode != 200)
 428            {
 0429                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 430                try
 431                {
 0432                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0433                    CloudError _errorBody =  SafeJsonConvert.DeserializeObject<CloudError>(_responseContent, Deserializa
 0434                    if (_errorBody != null)
 435                    {
 0436                        ex = new CloudException(_errorBody.Message);
 0437                        ex.Body = _errorBody;
 438                    }
 0439                }
 0440                catch (JsonException)
 441                {
 442                    // Ignore the exception
 0443                }
 0444                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0445                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0446                if (_httpResponse.Headers.Contains("request-id"))
 447                {
 0448                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 449                }
 0450                if (_shouldTrace)
 451                {
 0452                    ServiceClientTracing.Error(_invocationId, ex);
 453                }
 0454                _httpRequest.Dispose();
 0455                if (_httpResponse != null)
 456                {
 0457                    _httpResponse.Dispose();
 458                }
 0459                throw ex;
 460            }
 461            // Create Result
 2462            var _result = new AzureOperationResponse<ServiceStatistics>();
 2463            _result.Request = _httpRequest;
 2464            _result.Response = _httpResponse;
 2465            if (_httpResponse.Headers.Contains("request-id"))
 466            {
 2467                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 468            }
 469            // Deserialize Response
 2470            if ((int)_statusCode == 200)
 471            {
 2472                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 473                try
 474                {
 2475                    _result.Body = SafeJsonConvert.DeserializeObject<ServiceStatistics>(_responseContent, Deserializatio
 2476                }
 0477                catch (JsonException ex)
 478                {
 0479                    _httpRequest.Dispose();
 0480                    if (_httpResponse != null)
 481                    {
 0482                        _httpResponse.Dispose();
 483                    }
 0484                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 485                }
 486            }
 2487            if (_shouldTrace)
 488            {
 0489                ServiceClientTracing.Exit(_invocationId, _result);
 490            }
 2491            return _result;
 2492        }
 493
 494    }
 495}