< Summary

Class:Azure.ResourceManager.Compute.ResourceSkusRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\ResourceSkusRestOperations.cs
Covered lines:38
Uncovered lines:40
Coverable lines:78
Total lines:201
Line coverage:48.7% (38 of 78)
Covered branches:7
Total branches:26
Branch coverage:26.9% (7 of 26)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateListRequest(...)-92.31%50%
ListAsync()-81.82%50%
List(...)-81.82%50%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\ResourceSkusRestOperations.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 ResourceSkusRestOperations
 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 ResourceSkusRestOperations. </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 ResourceSkusRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio
 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 filter)
 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/skus", false);
 456            uri.AppendQuery("api-version", "2019-04-01", true);
 457            if (filter != null)
 58            {
 059                uri.AppendQuery("$filter", filter, true);
 60            }
 461            request.Uri = uri;
 462            return message;
 63        }
 64
 65        /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary>
 66        /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently.
 67        /// <param name="cancellationToken"> The cancellation token to use. </param>
 68        public async Task<Response<ResourceSkusResult>> ListAsync(string filter = null, CancellationToken cancellationTo
 69        {
 270            using var message = CreateListRequest(filter);
 271            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 272            switch (message.Response.Status)
 73            {
 74                case 200:
 75                    {
 276                        ResourceSkusResult value = default;
 277                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 278                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 79                        {
 080                            value = null;
 81                        }
 82                        else
 83                        {
 284                            value = ResourceSkusResult.DeserializeResourceSkusResult(document.RootElement);
 85                        }
 286                        return Response.FromValue(value, message.Response);
 87                    }
 88                default:
 089                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 90            }
 291        }
 92
 93        /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary>
 94        /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently.
 95        /// <param name="cancellationToken"> The cancellation token to use. </param>
 96        public Response<ResourceSkusResult> List(string filter = null, CancellationToken cancellationToken = default)
 97        {
 298            using var message = CreateListRequest(filter);
 299            _pipeline.Send(message, cancellationToken);
 2100            switch (message.Response.Status)
 101            {
 102                case 200:
 103                    {
 2104                        ResourceSkusResult value = default;
 2105                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2106                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 107                        {
 0108                            value = null;
 109                        }
 110                        else
 111                        {
 2112                            value = ResourceSkusResult.DeserializeResourceSkusResult(document.RootElement);
 113                        }
 2114                        return Response.FromValue(value, message.Response);
 115                    }
 116                default:
 0117                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 118            }
 2119        }
 120
 121        internal HttpMessage CreateListNextPageRequest(string nextLink, string filter)
 122        {
 0123            var message = _pipeline.CreateMessage();
 0124            var request = message.Request;
 0125            request.Method = RequestMethod.Get;
 0126            var uri = new RawRequestUriBuilder();
 0127            uri.Reset(endpoint);
 0128            uri.AppendRawNextLink(nextLink, false);
 0129            request.Uri = uri;
 0130            return message;
 131        }
 132
 133        /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary>
 134        /// <param name="nextLink"> The URL to the next page of results. </param>
 135        /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently.
 136        /// <param name="cancellationToken"> The cancellation token to use. </param>
 137        public async Task<Response<ResourceSkusResult>> ListNextPageAsync(string nextLink, string filter = null, Cancell
 138        {
 0139            if (nextLink == null)
 140            {
 0141                throw new ArgumentNullException(nameof(nextLink));
 142            }
 143
 0144            using var message = CreateListNextPageRequest(nextLink, filter);
 0145            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0146            switch (message.Response.Status)
 147            {
 148                case 200:
 149                    {
 0150                        ResourceSkusResult value = default;
 0151                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0152                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 153                        {
 0154                            value = null;
 155                        }
 156                        else
 157                        {
 0158                            value = ResourceSkusResult.DeserializeResourceSkusResult(document.RootElement);
 159                        }
 0160                        return Response.FromValue(value, message.Response);
 161                    }
 162                default:
 0163                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 164            }
 0165        }
 166
 167        /// <summary> Gets the list of Microsoft.Compute SKUs available for your Subscription. </summary>
 168        /// <param name="nextLink"> The URL to the next page of results. </param>
 169        /// <param name="filter"> The filter to apply on the operation. Only **location** filter is supported currently.
 170        /// <param name="cancellationToken"> The cancellation token to use. </param>
 171        public Response<ResourceSkusResult> ListNextPage(string nextLink, string filter = null, CancellationToken cancel
 172        {
 0173            if (nextLink == null)
 174            {
 0175                throw new ArgumentNullException(nameof(nextLink));
 176            }
 177
 0178            using var message = CreateListNextPageRequest(nextLink, filter);
 0179            _pipeline.Send(message, cancellationToken);
 0180            switch (message.Response.Status)
 181            {
 182                case 200:
 183                    {
 0184                        ResourceSkusResult value = default;
 0185                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0186                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 187                        {
 0188                            value = null;
 189                        }
 190                        else
 191                        {
 0192                            value = ResourceSkusResult.DeserializeResourceSkusResult(document.RootElement);
 193                        }
 0194                        return Response.FromValue(value, message.Response);
 195                    }
 196                default:
 0197                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 198            }
 0199        }
 200    }
 201}