< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateListRequest()-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ExpressRouteServiceProvidersRestOperations.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 ExpressRouteServiceProvidersRestOperations
 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 ExpressRouteServiceProvidersRestOperations. </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
 032        public ExpressRouteServiceProvidersRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, st
 33        {
 034            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 038            endpoint ??= new Uri("https://management.azure.com");
 39
 040            this.subscriptionId = subscriptionId;
 041            this.endpoint = endpoint;
 042            _clientDiagnostics = clientDiagnostics;
 043            _pipeline = pipeline;
 044        }
 45
 46        internal HttpMessage CreateListRequest()
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Get;
 051            var uri = new RawRequestUriBuilder();
 052            uri.Reset(endpoint);
 053            uri.AppendPath("/subscriptions/", false);
 054            uri.AppendPath(subscriptionId, true);
 055            uri.AppendPath("/providers/Microsoft.Network/expressRouteServiceProviders", false);
 056            uri.AppendQuery("api-version", "2020-04-01", true);
 057            request.Uri = uri;
 058            return message;
 59        }
 60
 61        /// <summary> Gets all the available express route service providers. </summary>
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        public async Task<Response<ExpressRouteServiceProviderListResult>> ListAsync(CancellationToken cancellationToken
 64        {
 065            using var message = CreateListRequest();
 066            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 067            switch (message.Response.Status)
 68            {
 69                case 200:
 70                    {
 071                        ExpressRouteServiceProviderListResult value = default;
 072                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 073                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 74                        {
 075                            value = null;
 76                        }
 77                        else
 78                        {
 079                            value = ExpressRouteServiceProviderListResult.DeserializeExpressRouteServiceProviderListResu
 80                        }
 081                        return Response.FromValue(value, message.Response);
 82                    }
 83                default:
 084                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 85            }
 086        }
 87
 88        /// <summary> Gets all the available express route service providers. </summary>
 89        /// <param name="cancellationToken"> The cancellation token to use. </param>
 90        public Response<ExpressRouteServiceProviderListResult> List(CancellationToken cancellationToken = default)
 91        {
 092            using var message = CreateListRequest();
 093            _pipeline.Send(message, cancellationToken);
 094            switch (message.Response.Status)
 95            {
 96                case 200:
 97                    {
 098                        ExpressRouteServiceProviderListResult value = default;
 099                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0100                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 101                        {
 0102                            value = null;
 103                        }
 104                        else
 105                        {
 0106                            value = ExpressRouteServiceProviderListResult.DeserializeExpressRouteServiceProviderListResu
 107                        }
 0108                        return Response.FromValue(value, message.Response);
 109                    }
 110                default:
 0111                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 112            }
 0113        }
 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 express route service providers. </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<ExpressRouteServiceProviderListResult>> ListNextPageAsync(string nextLink, Cancellati
 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                        ExpressRouteServiceProviderListResult 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 = ExpressRouteServiceProviderListResult.DeserializeExpressRouteServiceProviderListResu
 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 express route service providers. </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<ExpressRouteServiceProviderListResult> ListNextPage(string nextLink, CancellationToken cancellat
 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                        ExpressRouteServiceProviderListResult 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 = ExpressRouteServiceProviderListResult.DeserializeExpressRouteServiceProviderListResu
 185                        }
 0186                        return Response.FromValue(value, message.Response);
 187                    }
 188                default:
 0189                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 190            }
 0191        }
 192    }
 193}