< Summary

Class:Azure.ResourceManager.Network.BgpServiceCommunitiesRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\BgpServiceCommunitiesRestOperations.cs
Covered lines:37
Uncovered lines:39
Coverable lines:76
Total lines:193
Line coverage:48.6% (37 of 76)
Covered branches:6
Total branches:24
Branch coverage:25% (6 of 24)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateListRequest()-100%100%
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\network\Azure.ResourceManager.Network\src\Generated\BgpServiceCommunitiesRestOperations.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.Network.Models;
 16
 17namespace Azure.ResourceManager.Network
 18{
 19    internal partial class BgpServiceCommunitiesRestOperations
 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 BgpServiceCommunitiesRestOperations. </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"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 432        public BgpServiceCommunitiesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string su
 33        {
 434            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 438            endpoint ??= new Uri("https://management.azure.com");
 39
 440            this.subscriptionId = subscriptionId;
 441            this.endpoint = endpoint;
 442            _clientDiagnostics = clientDiagnostics;
 443            _pipeline = pipeline;
 444        }
 45
 46        internal HttpMessage CreateListRequest()
 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.Network/bgpServiceCommunities", false);
 456            uri.AppendQuery("api-version", "2020-04-01", true);
 457            request.Uri = uri;
 458            return message;
 59        }
 60
 61        /// <summary> Gets all the available bgp service communities. </summary>
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        public async Task<Response<BgpServiceCommunityListResult>> ListAsync(CancellationToken cancellationToken = defau
 64        {
 265            using var message = CreateListRequest();
 266            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 267            switch (message.Response.Status)
 68            {
 69                case 200:
 70                    {
 271                        BgpServiceCommunityListResult value = default;
 272                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 273                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 74                        {
 075                            value = null;
 76                        }
 77                        else
 78                        {
 279                            value = BgpServiceCommunityListResult.DeserializeBgpServiceCommunityListResult(document.Root
 80                        }
 281                        return Response.FromValue(value, message.Response);
 82                    }
 83                default:
 084                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 85            }
 286        }
 87
 88        /// <summary> Gets all the available bgp service communities. </summary>
 89        /// <param name="cancellationToken"> The cancellation token to use. </param>
 90        public Response<BgpServiceCommunityListResult> List(CancellationToken cancellationToken = default)
 91        {
 292            using var message = CreateListRequest();
 293            _pipeline.Send(message, cancellationToken);
 294            switch (message.Response.Status)
 95            {
 96                case 200:
 97                    {
 298                        BgpServiceCommunityListResult value = default;
 299                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2100                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 101                        {
 0102                            value = null;
 103                        }
 104                        else
 105                        {
 2106                            value = BgpServiceCommunityListResult.DeserializeBgpServiceCommunityListResult(document.Root
 107                        }
 2108                        return Response.FromValue(value, message.Response);
 109                    }
 110                default:
 0111                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 112            }
 2113        }
 114
 115        internal HttpMessage CreateListNextPageRequest(string nextLink)
 116        {
 0117            var message = _pipeline.CreateMessage();
 0118            var request = message.Request;
 0119            request.Method = RequestMethod.Get;
 0120            var uri = new RawRequestUriBuilder();
 0121            uri.Reset(endpoint);
 0122            uri.AppendRawNextLink(nextLink, false);
 0123            request.Uri = uri;
 0124            return message;
 125        }
 126
 127        /// <summary> Gets all the available bgp service communities. </summary>
 128        /// <param name="nextLink"> The URL to the next page of results. </param>
 129        /// <param name="cancellationToken"> The cancellation token to use. </param>
 130        public async Task<Response<BgpServiceCommunityListResult>> ListNextPageAsync(string nextLink, CancellationToken 
 131        {
 0132            if (nextLink == null)
 133            {
 0134                throw new ArgumentNullException(nameof(nextLink));
 135            }
 136
 0137            using var message = CreateListNextPageRequest(nextLink);
 0138            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0139            switch (message.Response.Status)
 140            {
 141                case 200:
 142                    {
 0143                        BgpServiceCommunityListResult value = default;
 0144                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0145                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 146                        {
 0147                            value = null;
 148                        }
 149                        else
 150                        {
 0151                            value = BgpServiceCommunityListResult.DeserializeBgpServiceCommunityListResult(document.Root
 152                        }
 0153                        return Response.FromValue(value, message.Response);
 154                    }
 155                default:
 0156                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 157            }
 0158        }
 159
 160        /// <summary> Gets all the available bgp service communities. </summary>
 161        /// <param name="nextLink"> The URL to the next page of results. </param>
 162        /// <param name="cancellationToken"> The cancellation token to use. </param>
 163        public Response<BgpServiceCommunityListResult> ListNextPage(string nextLink, CancellationToken cancellationToken
 164        {
 0165            if (nextLink == null)
 166            {
 0167                throw new ArgumentNullException(nameof(nextLink));
 168            }
 169
 0170            using var message = CreateListNextPageRequest(nextLink);
 0171            _pipeline.Send(message, cancellationToken);
 0172            switch (message.Response.Status)
 173            {
 174                case 200:
 175                    {
 0176                        BgpServiceCommunityListResult value = default;
 0177                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0178                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 179                        {
 0180                            value = null;
 181                        }
 182                        else
 183                        {
 0184                            value = BgpServiceCommunityListResult.DeserializeBgpServiceCommunityListResult(document.Root
 185                        }
 0186                        return Response.FromValue(value, message.Response);
 187                    }
 188                default:
 0189                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 190            }
 0191        }
 192    }
 193}