< Summary

Class:Azure.ResourceManager.Storage.BlobServicesRestOperations
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\BlobServicesRestOperations.cs
Covered lines:129
Uncovered lines:28
Coverable lines:157
Total lines:354
Line coverage:82.1% (129 of 157)
Covered branches:29
Total branches:58
Branch coverage:50% (29 of 58)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
CreateListRequest(...)-100%100%
ListAsync()-73.33%50%
List(...)-73.33%50%
CreateSetServicePropertiesRequest(...)-100%100%
SetServicePropertiesAsync()-70.59%50%
SetServiceProperties(...)-70.59%50%
CreateGetServicePropertiesRequest(...)-100%100%
GetServicePropertiesAsync()-73.33%50%
GetServiceProperties(...)-73.33%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\BlobServicesRestOperations.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.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Core;
 14using Azure.Core.Pipeline;
 15using Azure.ResourceManager.Storage.Models;
 16
 17namespace Azure.ResourceManager.Storage
 18{
 19    internal partial class BlobServicesRestOperations
 20    {
 21        private string subscriptionId;
 22        private Uri endpoint;
 23        private string apiVersion;
 24        private ClientDiagnostics _clientDiagnostics;
 25        private HttpPipeline _pipeline;
 26
 27        /// <summary> Initializes a new instance of BlobServicesRestOperations. </summary>
 28        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 29        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 30        /// <param name="subscriptionId"> The ID of the target subscription. </param>
 31        /// <param name="endpoint"> server parameter. </param>
 32        /// <param name="apiVersion"> Api Version. </param>
 33        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 24034        public BlobServicesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio
 35        {
 24036            if (subscriptionId == null)
 37            {
 038                throw new ArgumentNullException(nameof(subscriptionId));
 39            }
 24040            endpoint ??= new Uri("https://management.azure.com");
 24041            if (apiVersion == null)
 42            {
 043                throw new ArgumentNullException(nameof(apiVersion));
 44            }
 45
 24046            this.subscriptionId = subscriptionId;
 24047            this.endpoint = endpoint;
 24048            this.apiVersion = apiVersion;
 24049            _clientDiagnostics = clientDiagnostics;
 24050            _pipeline = pipeline;
 24051        }
 52
 53        internal HttpMessage CreateListRequest(string resourceGroupName, string accountName)
 54        {
 455            var message = _pipeline.CreateMessage();
 456            var request = message.Request;
 457            request.Method = RequestMethod.Get;
 458            var uri = new RawRequestUriBuilder();
 459            uri.Reset(endpoint);
 460            uri.AppendPath("/subscriptions/", false);
 461            uri.AppendPath(subscriptionId, true);
 462            uri.AppendPath("/resourceGroups/", false);
 463            uri.AppendPath(resourceGroupName, true);
 464            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 465            uri.AppendPath(accountName, true);
 466            uri.AppendPath("/blobServices", false);
 467            uri.AppendQuery("api-version", apiVersion, true);
 468            request.Uri = uri;
 469            return message;
 70        }
 71
 72        /// <summary> List blob services of storage account. It returns a collection of one object named default. </summ
 73        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 74        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        public async Task<Response<BlobServiceItems>> ListAsync(string resourceGroupName, string accountName, Cancellati
 77        {
 278            if (resourceGroupName == null)
 79            {
 080                throw new ArgumentNullException(nameof(resourceGroupName));
 81            }
 282            if (accountName == null)
 83            {
 084                throw new ArgumentNullException(nameof(accountName));
 85            }
 86
 287            using var message = CreateListRequest(resourceGroupName, accountName);
 288            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 289            switch (message.Response.Status)
 90            {
 91                case 200:
 92                    {
 293                        BlobServiceItems value = default;
 294                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 295                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 96                        {
 097                            value = null;
 98                        }
 99                        else
 100                        {
 2101                            value = BlobServiceItems.DeserializeBlobServiceItems(document.RootElement);
 102                        }
 2103                        return Response.FromValue(value, message.Response);
 104                    }
 105                default:
 0106                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 107            }
 2108        }
 109
 110        /// <summary> List blob services of storage account. It returns a collection of one object named default. </summ
 111        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 112        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 113        /// <param name="cancellationToken"> The cancellation token to use. </param>
 114        public Response<BlobServiceItems> List(string resourceGroupName, string accountName, CancellationToken cancellat
 115        {
 2116            if (resourceGroupName == null)
 117            {
 0118                throw new ArgumentNullException(nameof(resourceGroupName));
 119            }
 2120            if (accountName == null)
 121            {
 0122                throw new ArgumentNullException(nameof(accountName));
 123            }
 124
 2125            using var message = CreateListRequest(resourceGroupName, accountName);
 2126            _pipeline.Send(message, cancellationToken);
 2127            switch (message.Response.Status)
 128            {
 129                case 200:
 130                    {
 2131                        BlobServiceItems value = default;
 2132                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2133                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 134                        {
 0135                            value = null;
 136                        }
 137                        else
 138                        {
 2139                            value = BlobServiceItems.DeserializeBlobServiceItems(document.RootElement);
 140                        }
 2141                        return Response.FromValue(value, message.Response);
 142                    }
 143                default:
 0144                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 145            }
 2146        }
 147
 148        internal HttpMessage CreateSetServicePropertiesRequest(string resourceGroupName, string accountName, BlobService
 149        {
 16150            var message = _pipeline.CreateMessage();
 16151            var request = message.Request;
 16152            request.Method = RequestMethod.Put;
 16153            var uri = new RawRequestUriBuilder();
 16154            uri.Reset(endpoint);
 16155            uri.AppendPath("/subscriptions/", false);
 16156            uri.AppendPath(subscriptionId, true);
 16157            uri.AppendPath("/resourceGroups/", false);
 16158            uri.AppendPath(resourceGroupName, true);
 16159            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 16160            uri.AppendPath(accountName, true);
 16161            uri.AppendPath("/blobServices/", false);
 16162            uri.AppendPath("default", true);
 16163            uri.AppendQuery("api-version", apiVersion, true);
 16164            request.Uri = uri;
 16165            request.Headers.Add("Content-Type", "application/json");
 16166            var content = new Utf8JsonRequestContent();
 16167            content.JsonWriter.WriteObjectValue(parameters);
 16168            request.Content = content;
 16169            return message;
 170        }
 171
 172        /// <summary> Sets the properties of a storage account’s Blob service, including properties for Storage Analytic
 173        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 174        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 175        /// <param name="parameters"> The properties of a storage account’s Blob service, including properties for Stora
 176        /// <param name="cancellationToken"> The cancellation token to use. </param>
 177        public async Task<Response<BlobServiceProperties>> SetServicePropertiesAsync(string resourceGroupName, string ac
 178        {
 8179            if (resourceGroupName == null)
 180            {
 0181                throw new ArgumentNullException(nameof(resourceGroupName));
 182            }
 8183            if (accountName == null)
 184            {
 0185                throw new ArgumentNullException(nameof(accountName));
 186            }
 8187            if (parameters == null)
 188            {
 0189                throw new ArgumentNullException(nameof(parameters));
 190            }
 191
 8192            using var message = CreateSetServicePropertiesRequest(resourceGroupName, accountName, parameters);
 8193            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8194            switch (message.Response.Status)
 195            {
 196                case 200:
 197                    {
 8198                        BlobServiceProperties value = default;
 8199                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8200                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 201                        {
 0202                            value = null;
 203                        }
 204                        else
 205                        {
 8206                            value = BlobServiceProperties.DeserializeBlobServiceProperties(document.RootElement);
 207                        }
 8208                        return Response.FromValue(value, message.Response);
 209                    }
 210                default:
 0211                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 212            }
 8213        }
 214
 215        /// <summary> Sets the properties of a storage account’s Blob service, including properties for Storage Analytic
 216        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 217        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 218        /// <param name="parameters"> The properties of a storage account’s Blob service, including properties for Stora
 219        /// <param name="cancellationToken"> The cancellation token to use. </param>
 220        public Response<BlobServiceProperties> SetServiceProperties(string resourceGroupName, string accountName, BlobSe
 221        {
 8222            if (resourceGroupName == null)
 223            {
 0224                throw new ArgumentNullException(nameof(resourceGroupName));
 225            }
 8226            if (accountName == null)
 227            {
 0228                throw new ArgumentNullException(nameof(accountName));
 229            }
 8230            if (parameters == null)
 231            {
 0232                throw new ArgumentNullException(nameof(parameters));
 233            }
 234
 8235            using var message = CreateSetServicePropertiesRequest(resourceGroupName, accountName, parameters);
 8236            _pipeline.Send(message, cancellationToken);
 8237            switch (message.Response.Status)
 238            {
 239                case 200:
 240                    {
 8241                        BlobServiceProperties value = default;
 8242                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8243                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 244                        {
 0245                            value = null;
 246                        }
 247                        else
 248                        {
 8249                            value = BlobServiceProperties.DeserializeBlobServiceProperties(document.RootElement);
 250                        }
 8251                        return Response.FromValue(value, message.Response);
 252                    }
 253                default:
 0254                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 255            }
 8256        }
 257
 258        internal HttpMessage CreateGetServicePropertiesRequest(string resourceGroupName, string accountName)
 259        {
 32260            var message = _pipeline.CreateMessage();
 32261            var request = message.Request;
 32262            request.Method = RequestMethod.Get;
 32263            var uri = new RawRequestUriBuilder();
 32264            uri.Reset(endpoint);
 32265            uri.AppendPath("/subscriptions/", false);
 32266            uri.AppendPath(subscriptionId, true);
 32267            uri.AppendPath("/resourceGroups/", false);
 32268            uri.AppendPath(resourceGroupName, true);
 32269            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 32270            uri.AppendPath(accountName, true);
 32271            uri.AppendPath("/blobServices/", false);
 32272            uri.AppendPath("default", true);
 32273            uri.AppendQuery("api-version", apiVersion, true);
 32274            request.Uri = uri;
 32275            return message;
 276        }
 277
 278        /// <summary> Gets the properties of a storage account’s Blob service, including properties for Storage Analytic
 279        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 280        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 281        /// <param name="cancellationToken"> The cancellation token to use. </param>
 282        public async Task<Response<BlobServiceProperties>> GetServicePropertiesAsync(string resourceGroupName, string ac
 283        {
 16284            if (resourceGroupName == null)
 285            {
 0286                throw new ArgumentNullException(nameof(resourceGroupName));
 287            }
 16288            if (accountName == null)
 289            {
 0290                throw new ArgumentNullException(nameof(accountName));
 291            }
 292
 16293            using var message = CreateGetServicePropertiesRequest(resourceGroupName, accountName);
 16294            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 16295            switch (message.Response.Status)
 296            {
 297                case 200:
 298                    {
 16299                        BlobServiceProperties value = default;
 16300                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 16301                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 302                        {
 0303                            value = null;
 304                        }
 305                        else
 306                        {
 16307                            value = BlobServiceProperties.DeserializeBlobServiceProperties(document.RootElement);
 308                        }
 16309                        return Response.FromValue(value, message.Response);
 310                    }
 311                default:
 0312                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 313            }
 16314        }
 315
 316        /// <summary> Gets the properties of a storage account’s Blob service, including properties for Storage Analytic
 317        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 318        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 319        /// <param name="cancellationToken"> The cancellation token to use. </param>
 320        public Response<BlobServiceProperties> GetServiceProperties(string resourceGroupName, string accountName, Cancel
 321        {
 16322            if (resourceGroupName == null)
 323            {
 0324                throw new ArgumentNullException(nameof(resourceGroupName));
 325            }
 16326            if (accountName == null)
 327            {
 0328                throw new ArgumentNullException(nameof(accountName));
 329            }
 330
 16331            using var message = CreateGetServicePropertiesRequest(resourceGroupName, accountName);
 16332            _pipeline.Send(message, cancellationToken);
 16333            switch (message.Response.Status)
 334            {
 335                case 200:
 336                    {
 16337                        BlobServiceProperties value = default;
 16338                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 16339                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 340                        {
 0341                            value = null;
 342                        }
 343                        else
 344                        {
 16345                            value = BlobServiceProperties.DeserializeBlobServiceProperties(document.RootElement);
 346                        }
 16347                        return Response.FromValue(value, message.Response);
 348                    }
 349                default:
 0350                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 351            }
 16352        }
 353    }
 354}