< Summary

Class:Azure.ResourceManager.Network.BgpServiceCommunitiesOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\BgpServiceCommunitiesOperations.cs
Covered lines:20
Uncovered lines:22
Coverable lines:42
Total lines:114
Line coverage:47.6% (20 of 42)
Covered branches:0
Total branches:0

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\BgpServiceCommunitiesOperations.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 BgpServiceCommunities service client. </summary>
 19    public partial class BgpServiceCommunitiesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 423        internal BgpServiceCommunitiesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of BgpServiceCommunitiesOperations for mocking. </summary>
 425        protected BgpServiceCommunitiesOperations()
 26        {
 427        }
 28        /// <summary> Initializes a new instance of BgpServiceCommunitiesOperations. </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 BgpServiceCommunitiesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subs
 34        {
 435            RestClient = new BgpServiceCommunitiesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 436            _clientDiagnostics = clientDiagnostics;
 437            _pipeline = pipeline;
 438        }
 39
 40        /// <summary> Gets all the available bgp service communities. </summary>
 41        /// <param name="cancellationToken"> The cancellation token to use. </param>
 42        public virtual AsyncPageable<BgpServiceCommunity> ListAsync(CancellationToken cancellationToken = default)
 43        {
 44            async Task<Page<BgpServiceCommunity>> FirstPageFunc(int? pageSizeHint)
 45            {
 246                using var scope = _clientDiagnostics.CreateScope("BgpServiceCommunitiesOperations.List");
 247                scope.Start();
 48                try
 49                {
 250                    var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false);
 251                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 52                }
 053                catch (Exception e)
 54                {
 055                    scope.Failed(e);
 056                    throw;
 57                }
 258            }
 59            async Task<Page<BgpServiceCommunity>> NextPageFunc(string nextLink, int? pageSizeHint)
 60            {
 061                using var scope = _clientDiagnostics.CreateScope("BgpServiceCommunitiesOperations.List");
 062                scope.Start();
 63                try
 64                {
 065                    var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false)
 066                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 67                }
 068                catch (Exception e)
 69                {
 070                    scope.Failed(e);
 071                    throw;
 72                }
 073            }
 274            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 75        }
 76
 77        /// <summary> Gets all the available bgp service communities. </summary>
 78        /// <param name="cancellationToken"> The cancellation token to use. </param>
 79        public virtual Pageable<BgpServiceCommunity> List(CancellationToken cancellationToken = default)
 80        {
 81            Page<BgpServiceCommunity> FirstPageFunc(int? pageSizeHint)
 82            {
 283                using var scope = _clientDiagnostics.CreateScope("BgpServiceCommunitiesOperations.List");
 284                scope.Start();
 85                try
 86                {
 287                    var response = RestClient.List(cancellationToken);
 288                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 89                }
 090                catch (Exception e)
 91                {
 092                    scope.Failed(e);
 093                    throw;
 94                }
 295            }
 96            Page<BgpServiceCommunity> NextPageFunc(string nextLink, int? pageSizeHint)
 97            {
 098                using var scope = _clientDiagnostics.CreateScope("BgpServiceCommunitiesOperations.List");
 099                scope.Start();
 100                try
 101                {
 0102                    var response = RestClient.ListNextPage(nextLink, cancellationToken);
 0103                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 104                }
 0105                catch (Exception e)
 106                {
 0107                    scope.Failed(e);
 0108                    throw;
 109                }
 0110            }
 2111            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 112        }
 113    }
 114}