public ResponseWithHeaders <StorageServiceStats, ServiceGetStatisticsHeaders> GetStatistics(int?timeout = null, string requestId = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetStatistics"); scope.Start(); try { using var message = CreateGetStatisticsRequest(timeout, requestId); _pipeline.Send(message, cancellationToken); var headers = new ServiceGetStatisticsHeaders(message.Response); switch (message.Response.Status) { case 200: { StorageServiceStats value = default; var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); if (document.Element("StorageServiceStats") is XElement storageServiceStatsElement) { value = StorageServiceStats.DeserializeStorageServiceStats(storageServiceStatsElement); } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } } catch (Exception e) { scope.Failed(e); throw; } }
public async ValueTask <ResponseWithHeaders <StorageServiceStats, ServiceGetStatisticsHeaders> > GetStatisticsAsync(int?timeout = null, string requestId = null, CancellationToken cancellationToken = default) { using var message = CreateGetStatisticsRequest(timeout, requestId); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); var headers = new ServiceGetStatisticsHeaders(message.Response); switch (message.Response.Status) { case 200: { StorageServiceStats value = default; var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace); if (document.Element("StorageServiceStats") is XElement storageServiceStatsElement) { value = StorageServiceStats.DeserializeStorageServiceStats(storageServiceStatsElement); } return(ResponseWithHeaders.FromValue(value, headers, message.Response)); } default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }