< Summary

Class:Azure.ResourceManager.Compute.VirtualMachineSizesRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineSizesRestOperations.cs
Covered lines:41
Uncovered lines:7
Coverable lines:48
Total lines:129
Line coverage:85.4% (41 of 48)
Covered branches:8
Total branches:16
Branch coverage:50% (8 of 16)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineSizesRestOperations.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.Compute.Models;
 16
 17namespace Azure.ResourceManager.Compute
 18{
 19    internal partial class VirtualMachineSizesRestOperations
 20    {
 21        private string subscriptionId;
 22        private Uri endpoint;
 23        private ClientDiagnostics _clientDiagnostics;
 24        private HttpPipeline _pipeline;
 25
 26        /// <summary> Initializes a new instance of VirtualMachineSizesRestOperations. </summary>
 27        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 28        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 29        /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 39632        public VirtualMachineSizesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subs
 33        {
 39634            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 39638            endpoint ??= new Uri("https://management.azure.com");
 39
 39640            this.subscriptionId = subscriptionId;
 39641            this.endpoint = endpoint;
 39642            _clientDiagnostics = clientDiagnostics;
 39643            _pipeline = pipeline;
 39644        }
 45
 46        internal HttpMessage CreateListRequest(string location)
 47        {
 448            var message = _pipeline.CreateMessage();
 449            var request = message.Request;
 450            request.Method = RequestMethod.Get;
 451            var uri = new RawRequestUriBuilder();
 452            uri.Reset(endpoint);
 453            uri.AppendPath("/subscriptions/", false);
 454            uri.AppendPath(subscriptionId, true);
 455            uri.AppendPath("/providers/Microsoft.Compute/locations/", false);
 456            uri.AppendPath(location, true);
 457            uri.AppendPath("/vmSizes", false);
 458            uri.AppendQuery("api-version", "2019-12-01", true);
 459            request.Uri = uri;
 460            return message;
 61        }
 62
 63        /// <summary> This API is deprecated. Use [Resources Skus](https://docs.microsoft.com/en-us/rest/api/compute/res
 64        /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param>
 65        /// <param name="cancellationToken"> The cancellation token to use. </param>
 66        public async Task<Response<VirtualMachineSizeListResult>> ListAsync(string location, CancellationToken cancellat
 67        {
 268            if (location == null)
 69            {
 070                throw new ArgumentNullException(nameof(location));
 71            }
 72
 273            using var message = CreateListRequest(location);
 274            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 275            switch (message.Response.Status)
 76            {
 77                case 200:
 78                    {
 279                        VirtualMachineSizeListResult value = default;
 280                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 281                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 82                        {
 083                            value = null;
 84                        }
 85                        else
 86                        {
 287                            value = VirtualMachineSizeListResult.DeserializeVirtualMachineSizeListResult(document.RootEl
 88                        }
 289                        return Response.FromValue(value, message.Response);
 90                    }
 91                default:
 092                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 93            }
 294        }
 95
 96        /// <summary> This API is deprecated. Use [Resources Skus](https://docs.microsoft.com/en-us/rest/api/compute/res
 97        /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param>
 98        /// <param name="cancellationToken"> The cancellation token to use. </param>
 99        public Response<VirtualMachineSizeListResult> List(string location, CancellationToken cancellationToken = defaul
 100        {
 2101            if (location == null)
 102            {
 0103                throw new ArgumentNullException(nameof(location));
 104            }
 105
 2106            using var message = CreateListRequest(location);
 2107            _pipeline.Send(message, cancellationToken);
 2108            switch (message.Response.Status)
 109            {
 110                case 200:
 111                    {
 2112                        VirtualMachineSizeListResult value = default;
 2113                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2114                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 115                        {
 0116                            value = null;
 117                        }
 118                        else
 119                        {
 2120                            value = VirtualMachineSizeListResult.DeserializeVirtualMachineSizeListResult(document.RootEl
 121                        }
 2122                        return Response.FromValue(value, message.Response);
 123                    }
 124                default:
 0125                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 126            }
 2127        }
 128    }
 129}