< Summary

Class:Azure.ResourceManager.Compute.RestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\RestOperations.cs
Covered lines:33
Uncovered lines:4
Coverable lines:37
Total lines:105
Line coverage:89.1% (33 of 37)
Covered branches:5
Total branches:10
Branch coverage:50% (5 of 10)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\RestOperations.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 RestOperations
 20    {
 21        private Uri endpoint;
 22        private ClientDiagnostics _clientDiagnostics;
 23        private HttpPipeline _pipeline;
 24
 25        /// <summary> Initializes a new instance of RestOperations. </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="endpoint"> server parameter. </param>
 39629        public RestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null)
 30        {
 39631            endpoint ??= new Uri("https://management.azure.com");
 32
 39633            this.endpoint = endpoint;
 39634            _clientDiagnostics = clientDiagnostics;
 39635            _pipeline = pipeline;
 39636        }
 37
 38        internal HttpMessage CreateListRequest()
 39        {
 440            var message = _pipeline.CreateMessage();
 441            var request = message.Request;
 442            request.Method = RequestMethod.Get;
 443            var uri = new RawRequestUriBuilder();
 444            uri.Reset(endpoint);
 445            uri.AppendPath("/providers/Microsoft.Compute/operations", false);
 446            uri.AppendQuery("api-version", "2019-12-01", true);
 447            request.Uri = uri;
 448            return message;
 49        }
 50
 51        /// <summary> Gets a list of compute operations. </summary>
 52        /// <param name="cancellationToken"> The cancellation token to use. </param>
 53        public async Task<Response<ComputeOperationListResult>> ListAsync(CancellationToken cancellationToken = default)
 54        {
 255            using var message = CreateListRequest();
 256            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 257            switch (message.Response.Status)
 58            {
 59                case 200:
 60                    {
 261                        ComputeOperationListResult value = default;
 262                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 263                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 64                        {
 065                            value = null;
 66                        }
 67                        else
 68                        {
 269                            value = ComputeOperationListResult.DeserializeComputeOperationListResult(document.RootElemen
 70                        }
 271                        return Response.FromValue(value, message.Response);
 72                    }
 73                default:
 074                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 75            }
 276        }
 77
 78        /// <summary> Gets a list of compute operations. </summary>
 79        /// <param name="cancellationToken"> The cancellation token to use. </param>
 80        public Response<ComputeOperationListResult> List(CancellationToken cancellationToken = default)
 81        {
 282            using var message = CreateListRequest();
 283            _pipeline.Send(message, cancellationToken);
 284            switch (message.Response.Status)
 85            {
 86                case 200:
 87                    {
 288                        ComputeOperationListResult value = default;
 289                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 290                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 91                        {
 092                            value = null;
 93                        }
 94                        else
 95                        {
 296                            value = ComputeOperationListResult.DeserializeComputeOperationListResult(document.RootElemen
 97                        }
 298                        return Response.FromValue(value, message.Response);
 99                    }
 100                default:
 0101                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 102            }
 2103        }
 104    }
 105}