< Summary

Class:Azure.ResourceManager.Storage.SkusRestOperations
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\SkusRestOperations.cs
Covered lines:39
Uncovered lines:6
Coverable lines:45
Total lines:122
Line coverage:86.6% (39 of 45)
Covered branches:7
Total branches:14
Branch coverage:50% (7 of 14)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
CreateListRequest()-100%100%
ListAsync()-81.82%50%
List(...)-81.82%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\SkusRestOperations.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 SkusRestOperations
 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 SkusRestOperations. </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 SkusRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri
 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()
 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("/providers/Microsoft.Storage/skus", false);
 463            uri.AppendQuery("api-version", apiVersion, true);
 464            request.Uri = uri;
 465            return message;
 66        }
 67
 68        /// <summary> Lists the available SKUs supported by Microsoft.Storage for given subscription. </summary>
 69        /// <param name="cancellationToken"> The cancellation token to use. </param>
 70        public async Task<Response<StorageSkuListResult>> ListAsync(CancellationToken cancellationToken = default)
 71        {
 272            using var message = CreateListRequest();
 273            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 274            switch (message.Response.Status)
 75            {
 76                case 200:
 77                    {
 278                        StorageSkuListResult value = default;
 279                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 280                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 81                        {
 082                            value = null;
 83                        }
 84                        else
 85                        {
 286                            value = StorageSkuListResult.DeserializeStorageSkuListResult(document.RootElement);
 87                        }
 288                        return Response.FromValue(value, message.Response);
 89                    }
 90                default:
 091                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 92            }
 293        }
 94
 95        /// <summary> Lists the available SKUs supported by Microsoft.Storage for given subscription. </summary>
 96        /// <param name="cancellationToken"> The cancellation token to use. </param>
 97        public Response<StorageSkuListResult> List(CancellationToken cancellationToken = default)
 98        {
 299            using var message = CreateListRequest();
 2100            _pipeline.Send(message, cancellationToken);
 2101            switch (message.Response.Status)
 102            {
 103                case 200:
 104                    {
 2105                        StorageSkuListResult value = default;
 2106                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2107                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 108                        {
 0109                            value = null;
 110                        }
 111                        else
 112                        {
 2113                            value = StorageSkuListResult.DeserializeStorageSkuListResult(document.RootElement);
 114                        }
 2115                        return Response.FromValue(value, message.Response);
 116                    }
 117                default:
 0118                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 119            }
 2120        }
 121    }
 122}