< Summary

Class:Azure.Data.Tables.ServiceRestClient
Assembly:Azure.Data.Tables
File(s):C:\Git\azure-sdk-for-net\sdk\tables\Azure.Data.Tables\src\Generated\ServiceRestClient.cs
Covered lines:105
Uncovered lines:16
Coverable lines:121
Total lines:275
Line coverage:86.7% (105 of 121)
Covered branches:24
Total branches:40
Branch coverage:60% (24 of 40)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
CreateSetPropertiesRequest(...)-89.47%50%
SetPropertiesAsync()-77.78%50%
SetProperties(...)-77.78%50%
CreateGetPropertiesRequest(...)-86.67%50%
GetPropertiesAsync()-90.91%75%
GetProperties(...)-90.91%75%
CreateGetStatisticsRequest(...)-86.67%50%
GetStatisticsAsync()-90.91%75%
GetStatistics(...)-90.91%75%

File(s)

C:\Git\azure-sdk-for-net\sdk\tables\Azure.Data.Tables\src\Generated\ServiceRestClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Threading;
 10using System.Threading.Tasks;
 11using System.Xml.Linq;
 12using Azure.Core;
 13using Azure.Core.Pipeline;
 14using Azure.Data.Tables.Models;
 15
 16namespace Azure.Data.Tables
 17{
 18    internal partial class ServiceRestClient
 19    {
 20        private string url;
 21        private string version;
 22        private ClientDiagnostics _clientDiagnostics;
 23        private HttpPipeline _pipeline;
 24
 25        /// <summary> Initializes a new instance of ServiceRestClient. </summary>
 26        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 27        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 28        /// <param name="url"> The URL of the service account or table that is the targe of the desired operation. </par
 29        /// <param name="version"> Specifies the version of the operation to use for this request. </param>
 30        /// <exception cref="ArgumentNullException"> <paramref name="url"/> or <paramref name="version"/> is null. </exc
 94431        public ServiceRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string url, string version 
 32        {
 94433            if (url == null)
 34            {
 035                throw new ArgumentNullException(nameof(url));
 36            }
 94437            if (version == null)
 38            {
 039                throw new ArgumentNullException(nameof(version));
 40            }
 41
 94442            this.url = url;
 94443            this.version = version;
 94444            _clientDiagnostics = clientDiagnostics;
 94445            _pipeline = pipeline;
 94446        }
 47
 48        internal HttpMessage CreateSetPropertiesRequest(TableServiceProperties tableServiceProperties, int? timeout, str
 49        {
 450            var message = _pipeline.CreateMessage();
 451            var request = message.Request;
 452            request.Method = RequestMethod.Put;
 453            var uri = new RawRequestUriBuilder();
 454            uri.AppendRaw(url, false);
 455            uri.AppendPath("/", false);
 456            uri.AppendQuery("restype", "service", true);
 457            uri.AppendQuery("comp", "properties", true);
 458            if (timeout != null)
 59            {
 060                uri.AppendQuery("timeout", timeout.Value, true);
 61            }
 462            request.Uri = uri;
 463            request.Headers.Add("x-ms-version", version);
 464            if (requestId != null)
 65            {
 066                request.Headers.Add("x-ms-client-request-id", requestId);
 67            }
 468            request.Headers.Add("Content-Type", "application/xml");
 469            var content = new XmlWriterContent();
 470            content.XmlWriter.WriteObjectValue(tableServiceProperties, "StorageServiceProperties");
 471            request.Content = content;
 472            return message;
 73        }
 74
 75        /// <summary> Sets properties for an account&apos;s Table service endpoint, including properties for Analytics a
 76        /// <param name="tableServiceProperties"> The Table Service properties. </param>
 77        /// <param name="timeout"> The timeout parameter is expressed in seconds. </param>
 78        /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor
 79        /// <param name="cancellationToken"> The cancellation token to use. </param>
 80        /// <exception cref="ArgumentNullException"> <paramref name="tableServiceProperties"/> is null. </exception>
 81        public async Task<ResponseWithHeaders<ServiceSetPropertiesHeaders>> SetPropertiesAsync(TableServiceProperties ta
 82        {
 283            if (tableServiceProperties == null)
 84            {
 085                throw new ArgumentNullException(nameof(tableServiceProperties));
 86            }
 87
 288            using var message = CreateSetPropertiesRequest(tableServiceProperties, timeout, requestId);
 289            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 290            var headers = new ServiceSetPropertiesHeaders(message.Response);
 291            switch (message.Response.Status)
 92            {
 93                case 202:
 294                    return ResponseWithHeaders.FromValue(headers, message.Response);
 95                default:
 096                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 97            }
 298        }
 99
 100        /// <summary> Sets properties for an account&apos;s Table service endpoint, including properties for Analytics a
 101        /// <param name="tableServiceProperties"> The Table Service properties. </param>
 102        /// <param name="timeout"> The timeout parameter is expressed in seconds. </param>
 103        /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor
 104        /// <param name="cancellationToken"> The cancellation token to use. </param>
 105        /// <exception cref="ArgumentNullException"> <paramref name="tableServiceProperties"/> is null. </exception>
 106        public ResponseWithHeaders<ServiceSetPropertiesHeaders> SetProperties(TableServiceProperties tableServicePropert
 107        {
 2108            if (tableServiceProperties == null)
 109            {
 0110                throw new ArgumentNullException(nameof(tableServiceProperties));
 111            }
 112
 2113            using var message = CreateSetPropertiesRequest(tableServiceProperties, timeout, requestId);
 2114            _pipeline.Send(message, cancellationToken);
 2115            var headers = new ServiceSetPropertiesHeaders(message.Response);
 2116            switch (message.Response.Status)
 117            {
 118                case 202:
 2119                    return ResponseWithHeaders.FromValue(headers, message.Response);
 120                default:
 0121                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 122            }
 2123        }
 124
 125        internal HttpMessage CreateGetPropertiesRequest(int? timeout, string requestId)
 126        {
 24127            var message = _pipeline.CreateMessage();
 24128            var request = message.Request;
 24129            request.Method = RequestMethod.Get;
 24130            var uri = new RawRequestUriBuilder();
 24131            uri.AppendRaw(url, false);
 24132            uri.AppendPath("/", false);
 24133            uri.AppendQuery("restype", "service", true);
 24134            uri.AppendQuery("comp", "properties", true);
 24135            if (timeout != null)
 136            {
 0137                uri.AppendQuery("timeout", timeout.Value, true);
 138            }
 24139            request.Uri = uri;
 24140            request.Headers.Add("x-ms-version", version);
 24141            if (requestId != null)
 142            {
 0143                request.Headers.Add("x-ms-client-request-id", requestId);
 144            }
 24145            return message;
 146        }
 147
 148        /// <summary> Gets the properties of an account&apos;s Table service, including properties for Analytics and COR
 149        /// <param name="timeout"> The timeout parameter is expressed in seconds. </param>
 150        /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor
 151        /// <param name="cancellationToken"> The cancellation token to use. </param>
 152        public async Task<ResponseWithHeaders<TableServiceProperties, ServiceGetPropertiesHeaders>> GetPropertiesAsync(i
 153        {
 12154            using var message = CreateGetPropertiesRequest(timeout, requestId);
 12155            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 12156            var headers = new ServiceGetPropertiesHeaders(message.Response);
 12157            switch (message.Response.Status)
 158            {
 159                case 200:
 160                    {
 12161                        TableServiceProperties value = default;
 12162                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
 12163                        if (document.Element("StorageServiceProperties") is XElement storageServicePropertiesElement)
 164                        {
 12165                            value = TableServiceProperties.DeserializeTableServiceProperties(storageServicePropertiesEle
 166                        }
 12167                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 168                    }
 169                default:
 0170                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 171            }
 12172        }
 173
 174        /// <summary> Gets the properties of an account&apos;s Table service, including properties for Analytics and COR
 175        /// <param name="timeout"> The timeout parameter is expressed in seconds. </param>
 176        /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor
 177        /// <param name="cancellationToken"> The cancellation token to use. </param>
 178        public ResponseWithHeaders<TableServiceProperties, ServiceGetPropertiesHeaders> GetProperties(int? timeout = nul
 179        {
 12180            using var message = CreateGetPropertiesRequest(timeout, requestId);
 12181            _pipeline.Send(message, cancellationToken);
 12182            var headers = new ServiceGetPropertiesHeaders(message.Response);
 12183            switch (message.Response.Status)
 184            {
 185                case 200:
 186                    {
 12187                        TableServiceProperties value = default;
 12188                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
 12189                        if (document.Element("StorageServiceProperties") is XElement storageServicePropertiesElement)
 190                        {
 12191                            value = TableServiceProperties.DeserializeTableServiceProperties(storageServicePropertiesEle
 192                        }
 12193                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 194                    }
 195                default:
 0196                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 197            }
 12198        }
 199
 200        internal HttpMessage CreateGetStatisticsRequest(int? timeout, string requestId)
 201        {
 4202            var message = _pipeline.CreateMessage();
 4203            var request = message.Request;
 4204            request.Method = RequestMethod.Get;
 4205            var uri = new RawRequestUriBuilder();
 4206            uri.AppendRaw(url, false);
 4207            uri.AppendPath("/", false);
 4208            uri.AppendQuery("restype", "service", true);
 4209            uri.AppendQuery("comp", "stats", true);
 4210            if (timeout != null)
 211            {
 0212                uri.AppendQuery("timeout", timeout.Value, true);
 213            }
 4214            request.Uri = uri;
 4215            request.Headers.Add("x-ms-version", version);
 4216            if (requestId != null)
 217            {
 0218                request.Headers.Add("x-ms-client-request-id", requestId);
 219            }
 4220            return message;
 221        }
 222
 223        /// <summary> Retrieves statistics related to replication for the Table service. It is only available on the sec
 224        /// <param name="timeout"> The timeout parameter is expressed in seconds. </param>
 225        /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor
 226        /// <param name="cancellationToken"> The cancellation token to use. </param>
 227        public async Task<ResponseWithHeaders<TableServiceStatistics, ServiceGetStatisticsHeaders>> GetStatisticsAsync(i
 228        {
 2229            using var message = CreateGetStatisticsRequest(timeout, requestId);
 2230            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2231            var headers = new ServiceGetStatisticsHeaders(message.Response);
 2232            switch (message.Response.Status)
 233            {
 234                case 200:
 235                    {
 2236                        TableServiceStatistics value = default;
 2237                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
 2238                        if (document.Element("StorageServiceStats") is XElement storageServiceStatsElement)
 239                        {
 2240                            value = TableServiceStatistics.DeserializeTableServiceStatistics(storageServiceStatsElement)
 241                        }
 2242                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 243                    }
 244                default:
 0245                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 246            }
 2247        }
 248
 249        /// <summary> Retrieves statistics related to replication for the Table service. It is only available on the sec
 250        /// <param name="timeout"> The timeout parameter is expressed in seconds. </param>
 251        /// <param name="requestId"> Provides a client-generated, opaque value with a 1 KB character limit that is recor
 252        /// <param name="cancellationToken"> The cancellation token to use. </param>
 253        public ResponseWithHeaders<TableServiceStatistics, ServiceGetStatisticsHeaders> GetStatistics(int? timeout = nul
 254        {
 2255            using var message = CreateGetStatisticsRequest(timeout, requestId);
 2256            _pipeline.Send(message, cancellationToken);
 2257            var headers = new ServiceGetStatisticsHeaders(message.Response);
 2258            switch (message.Response.Status)
 259            {
 260                case 200:
 261                    {
 2262                        TableServiceStatistics value = default;
 2263                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
 2264                        if (document.Element("StorageServiceStats") is XElement storageServiceStatsElement)
 265                        {
 2266                            value = TableServiceStatistics.DeserializeTableServiceStatistics(storageServiceStatsElement)
 267                        }
 2268                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 269                    }
 270                default:
 0271                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 272            }
 2273        }
 274    }
 275}