< Summary

Class:Azure.ResourceManager.Compute.UsageOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\UsageOperations.cs
Covered lines:22
Uncovered lines:24
Coverable lines:46
Total lines:126
Line coverage:47.8% (22 of 46)
Covered branches:2
Total branches:4
Branch coverage:50% (2 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
ListAsync(...)-36.84%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
List(...)-36.84%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\UsageOperations.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.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Core;
 13using Azure.Core.Pipeline;
 14using Azure.ResourceManager.Compute.Models;
 15
 16namespace Azure.ResourceManager.Compute
 17{
 18    /// <summary> The Usage service client. </summary>
 19    public partial class UsageOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 423        internal UsageRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of UsageOperations for mocking. </summary>
 39625        protected UsageOperations()
 26        {
 39627        }
 28        /// <summary> Initializes a new instance of UsageOperations. </summary>
 29        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 30        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 31        /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 32        /// <param name="endpoint"> server parameter. </param>
 39633        internal UsageOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri 
 34        {
 39635            RestClient = new UsageRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 39636            _clientDiagnostics = clientDiagnostics;
 39637            _pipeline = pipeline;
 39638        }
 39
 40        /// <summary> Gets, for the specified location, the current compute resource usage information as well as the li
 41        /// <param name="location"> The location for which resource usage is queried. </param>
 42        /// <param name="cancellationToken"> The cancellation token to use. </param>
 43        public virtual AsyncPageable<Usage> ListAsync(string location, CancellationToken cancellationToken = default)
 44        {
 245            if (location == null)
 46            {
 047                throw new ArgumentNullException(nameof(location));
 48            }
 49
 50            async Task<Page<Usage>> FirstPageFunc(int? pageSizeHint)
 51            {
 252                using var scope = _clientDiagnostics.CreateScope("UsageOperations.List");
 253                scope.Start();
 54                try
 55                {
 256                    var response = await RestClient.ListAsync(location, cancellationToken).ConfigureAwait(false);
 257                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 58                }
 059                catch (Exception e)
 60                {
 061                    scope.Failed(e);
 062                    throw;
 63                }
 264            }
 65            async Task<Page<Usage>> NextPageFunc(string nextLink, int? pageSizeHint)
 66            {
 067                using var scope = _clientDiagnostics.CreateScope("UsageOperations.List");
 068                scope.Start();
 69                try
 70                {
 071                    var response = await RestClient.ListNextPageAsync(nextLink, location, cancellationToken).ConfigureAw
 072                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 73                }
 074                catch (Exception e)
 75                {
 076                    scope.Failed(e);
 077                    throw;
 78                }
 079            }
 280            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 81        }
 82
 83        /// <summary> Gets, for the specified location, the current compute resource usage information as well as the li
 84        /// <param name="location"> The location for which resource usage is queried. </param>
 85        /// <param name="cancellationToken"> The cancellation token to use. </param>
 86        public virtual Pageable<Usage> List(string location, CancellationToken cancellationToken = default)
 87        {
 288            if (location == null)
 89            {
 090                throw new ArgumentNullException(nameof(location));
 91            }
 92
 93            Page<Usage> FirstPageFunc(int? pageSizeHint)
 94            {
 295                using var scope = _clientDiagnostics.CreateScope("UsageOperations.List");
 296                scope.Start();
 97                try
 98                {
 299                    var response = RestClient.List(location, cancellationToken);
 2100                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 101                }
 0102                catch (Exception e)
 103                {
 0104                    scope.Failed(e);
 0105                    throw;
 106                }
 2107            }
 108            Page<Usage> NextPageFunc(string nextLink, int? pageSizeHint)
 109            {
 0110                using var scope = _clientDiagnostics.CreateScope("UsageOperations.List");
 0111                scope.Start();
 112                try
 113                {
 0114                    var response = RestClient.ListNextPage(nextLink, location, cancellationToken);
 0115                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 116                }
 0117                catch (Exception e)
 118                {
 0119                    scope.Failed(e);
 0120                    throw;
 121                }
 0122            }
 2123            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 124        }
 125    }
 126}