< Summary

Class:Azure.ResourceManager.Network.UsagesOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\UsagesOperations.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\network\Azure.ResourceManager.Network\src\Generated\UsagesOperations.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.Network.Models;
 15
 16namespace Azure.ResourceManager.Network
 17{
 18    /// <summary> The Usages service client. </summary>
 19    public partial class UsagesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 423        internal UsagesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of UsagesOperations for mocking. </summary>
 425        protected UsagesOperations()
 26        {
 427        }
 28        /// <summary> Initializes a new instance of UsagesOperations. </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"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 32        /// <param name="endpoint"> server parameter. </param>
 433        internal UsagesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri
 34        {
 435            RestClient = new UsagesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 436            _clientDiagnostics = clientDiagnostics;
 437            _pipeline = pipeline;
 438        }
 39
 40        /// <summary> List network usages for a subscription. </summary>
 41        /// <param name="location"> The location where 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("UsagesOperations.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("UsagesOperations.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> List network usages for a subscription. </summary>
 84        /// <param name="location"> The location where 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("UsagesOperations.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("UsagesOperations.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}