< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateListRequest()-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-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\ExpressRoutePortsLocationsRestOperations.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 ExpressRoutePortsLocationsRestOperations
 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 ExpressRoutePortsLocationsRestOperations. </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 ExpressRoutePortsLocationsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, stri
 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/ExpressRoutePortsLocations", false);
 056            uri.AppendQuery("api-version", "2020-04-01", true);
 057            request.Uri = uri;
 058            return message;
 59        }
 60
 61        /// <summary> Retrieves all ExpressRoutePort peering locations. Does not return available bandwidths for each lo
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        public async Task<Response<ExpressRoutePortsLocationListResult>> 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                        ExpressRoutePortsLocationListResult 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 = ExpressRoutePortsLocationListResult.DeserializeExpressRoutePortsLocationListResult(d
 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> Retrieves all ExpressRoutePort peering locations. Does not return available bandwidths for each lo
 89        /// <param name="cancellationToken"> The cancellation token to use. </param>
 90        public Response<ExpressRoutePortsLocationListResult> 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                        ExpressRoutePortsLocationListResult 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 = ExpressRoutePortsLocationListResult.DeserializeExpressRoutePortsLocationListResult(d
 107                        }
 0108                        return Response.FromValue(value, message.Response);
 109                    }
 110                default:
 0111                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 112            }
 0113        }
 114
 115        internal HttpMessage CreateGetRequest(string locationName)
 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.AppendPath("/subscriptions/", false);
 0123            uri.AppendPath(subscriptionId, true);
 0124            uri.AppendPath("/providers/Microsoft.Network/ExpressRoutePortsLocations/", false);
 0125            uri.AppendPath(locationName, true);
 0126            uri.AppendQuery("api-version", "2020-04-01", true);
 0127            request.Uri = uri;
 0128            return message;
 129        }
 130
 131        /// <summary> Retrieves a single ExpressRoutePort peering location, including the list of available bandwidths a
 132        /// <param name="locationName"> Name of the requested ExpressRoutePort peering location. </param>
 133        /// <param name="cancellationToken"> The cancellation token to use. </param>
 134        public async Task<Response<ExpressRoutePortsLocation>> GetAsync(string locationName, CancellationToken cancellat
 135        {
 0136            if (locationName == null)
 137            {
 0138                throw new ArgumentNullException(nameof(locationName));
 139            }
 140
 0141            using var message = CreateGetRequest(locationName);
 0142            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0143            switch (message.Response.Status)
 144            {
 145                case 200:
 146                    {
 0147                        ExpressRoutePortsLocation value = default;
 0148                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0149                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 150                        {
 0151                            value = null;
 152                        }
 153                        else
 154                        {
 0155                            value = ExpressRoutePortsLocation.DeserializeExpressRoutePortsLocation(document.RootElement)
 156                        }
 0157                        return Response.FromValue(value, message.Response);
 158                    }
 159                default:
 0160                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 161            }
 0162        }
 163
 164        /// <summary> Retrieves a single ExpressRoutePort peering location, including the list of available bandwidths a
 165        /// <param name="locationName"> Name of the requested ExpressRoutePort peering location. </param>
 166        /// <param name="cancellationToken"> The cancellation token to use. </param>
 167        public Response<ExpressRoutePortsLocation> Get(string locationName, CancellationToken cancellationToken = defaul
 168        {
 0169            if (locationName == null)
 170            {
 0171                throw new ArgumentNullException(nameof(locationName));
 172            }
 173
 0174            using var message = CreateGetRequest(locationName);
 0175            _pipeline.Send(message, cancellationToken);
 0176            switch (message.Response.Status)
 177            {
 178                case 200:
 179                    {
 0180                        ExpressRoutePortsLocation value = default;
 0181                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0182                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 183                        {
 0184                            value = null;
 185                        }
 186                        else
 187                        {
 0188                            value = ExpressRoutePortsLocation.DeserializeExpressRoutePortsLocation(document.RootElement)
 189                        }
 0190                        return Response.FromValue(value, message.Response);
 191                    }
 192                default:
 0193                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 194            }
 0195        }
 196
 197        internal HttpMessage CreateListNextPageRequest(string nextLink)
 198        {
 0199            var message = _pipeline.CreateMessage();
 0200            var request = message.Request;
 0201            request.Method = RequestMethod.Get;
 0202            var uri = new RawRequestUriBuilder();
 0203            uri.Reset(endpoint);
 0204            uri.AppendRawNextLink(nextLink, false);
 0205            request.Uri = uri;
 0206            return message;
 207        }
 208
 209        /// <summary> Retrieves all ExpressRoutePort peering locations. Does not return available bandwidths for each lo
 210        /// <param name="nextLink"> The URL to the next page of results. </param>
 211        /// <param name="cancellationToken"> The cancellation token to use. </param>
 212        public async Task<Response<ExpressRoutePortsLocationListResult>> ListNextPageAsync(string nextLink, Cancellation
 213        {
 0214            if (nextLink == null)
 215            {
 0216                throw new ArgumentNullException(nameof(nextLink));
 217            }
 218
 0219            using var message = CreateListNextPageRequest(nextLink);
 0220            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0221            switch (message.Response.Status)
 222            {
 223                case 200:
 224                    {
 0225                        ExpressRoutePortsLocationListResult value = default;
 0226                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0227                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 228                        {
 0229                            value = null;
 230                        }
 231                        else
 232                        {
 0233                            value = ExpressRoutePortsLocationListResult.DeserializeExpressRoutePortsLocationListResult(d
 234                        }
 0235                        return Response.FromValue(value, message.Response);
 236                    }
 237                default:
 0238                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 239            }
 0240        }
 241
 242        /// <summary> Retrieves all ExpressRoutePort peering locations. Does not return available bandwidths for each lo
 243        /// <param name="nextLink"> The URL to the next page of results. </param>
 244        /// <param name="cancellationToken"> The cancellation token to use. </param>
 245        public Response<ExpressRoutePortsLocationListResult> ListNextPage(string nextLink, CancellationToken cancellatio
 246        {
 0247            if (nextLink == null)
 248            {
 0249                throw new ArgumentNullException(nameof(nextLink));
 250            }
 251
 0252            using var message = CreateListNextPageRequest(nextLink);
 0253            _pipeline.Send(message, cancellationToken);
 0254            switch (message.Response.Status)
 255            {
 256                case 200:
 257                    {
 0258                        ExpressRoutePortsLocationListResult value = default;
 0259                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0260                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 261                        {
 0262                            value = null;
 263                        }
 264                        else
 265                        {
 0266                            value = ExpressRoutePortsLocationListResult.DeserializeExpressRoutePortsLocationListResult(d
 267                        }
 0268                        return Response.FromValue(value, message.Response);
 269                    }
 270                default:
 0271                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 272            }
 0273        }
 274    }
 275}