< Summary

Class:Azure.ResourceManager.Network.NetworkInterfaceLoadBalancersRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\NetworkInterfaceLoadBalancersRestOperations.cs
Covered lines:45
Uncovered lines:51
Coverable lines:96
Total lines:239
Line coverage:46.8% (45 of 96)
Covered branches:10
Total branches:40
Branch coverage:25% (10 of 40)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateListRequest(...)-100%100%
ListAsync()-73.33%50%
List(...)-73.33%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\NetworkInterfaceLoadBalancersRestOperations.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 NetworkInterfaceLoadBalancersRestOperations
 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 NetworkInterfaceLoadBalancersRestOperations. </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 NetworkInterfaceLoadBalancersRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, s
 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(string resourceGroupName, string networkInterfaceName)
 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("/resourceGroups/", false);
 456            uri.AppendPath(resourceGroupName, true);
 457            uri.AppendPath("/providers/Microsoft.Network/networkInterfaces/", false);
 458            uri.AppendPath(networkInterfaceName, true);
 459            uri.AppendPath("/loadBalancers", false);
 460            uri.AppendQuery("api-version", "2020-04-01", true);
 461            request.Uri = uri;
 462            return message;
 63        }
 64
 65        /// <summary> List all load balancers in a network interface. </summary>
 66        /// <param name="resourceGroupName"> The name of the resource group. </param>
 67        /// <param name="networkInterfaceName"> The name of the network interface. </param>
 68        /// <param name="cancellationToken"> The cancellation token to use. </param>
 69        public async Task<Response<NetworkInterfaceLoadBalancerListResult>> ListAsync(string resourceGroupName, string n
 70        {
 271            if (resourceGroupName == null)
 72            {
 073                throw new ArgumentNullException(nameof(resourceGroupName));
 74            }
 275            if (networkInterfaceName == null)
 76            {
 077                throw new ArgumentNullException(nameof(networkInterfaceName));
 78            }
 79
 280            using var message = CreateListRequest(resourceGroupName, networkInterfaceName);
 281            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 282            switch (message.Response.Status)
 83            {
 84                case 200:
 85                    {
 286                        NetworkInterfaceLoadBalancerListResult value = default;
 287                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 288                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 89                        {
 090                            value = null;
 91                        }
 92                        else
 93                        {
 294                            value = NetworkInterfaceLoadBalancerListResult.DeserializeNetworkInterfaceLoadBalancerListRe
 95                        }
 296                        return Response.FromValue(value, message.Response);
 97                    }
 98                default:
 099                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 100            }
 2101        }
 102
 103        /// <summary> List all load balancers in a network interface. </summary>
 104        /// <param name="resourceGroupName"> The name of the resource group. </param>
 105        /// <param name="networkInterfaceName"> The name of the network interface. </param>
 106        /// <param name="cancellationToken"> The cancellation token to use. </param>
 107        public Response<NetworkInterfaceLoadBalancerListResult> List(string resourceGroupName, string networkInterfaceNa
 108        {
 2109            if (resourceGroupName == null)
 110            {
 0111                throw new ArgumentNullException(nameof(resourceGroupName));
 112            }
 2113            if (networkInterfaceName == null)
 114            {
 0115                throw new ArgumentNullException(nameof(networkInterfaceName));
 116            }
 117
 2118            using var message = CreateListRequest(resourceGroupName, networkInterfaceName);
 2119            _pipeline.Send(message, cancellationToken);
 2120            switch (message.Response.Status)
 121            {
 122                case 200:
 123                    {
 2124                        NetworkInterfaceLoadBalancerListResult value = default;
 2125                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2126                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 127                        {
 0128                            value = null;
 129                        }
 130                        else
 131                        {
 2132                            value = NetworkInterfaceLoadBalancerListResult.DeserializeNetworkInterfaceLoadBalancerListRe
 133                        }
 2134                        return Response.FromValue(value, message.Response);
 135                    }
 136                default:
 0137                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 138            }
 2139        }
 140
 141        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string networkInterfac
 142        {
 0143            var message = _pipeline.CreateMessage();
 0144            var request = message.Request;
 0145            request.Method = RequestMethod.Get;
 0146            var uri = new RawRequestUriBuilder();
 0147            uri.Reset(endpoint);
 0148            uri.AppendRawNextLink(nextLink, false);
 0149            request.Uri = uri;
 0150            return message;
 151        }
 152
 153        /// <summary> List all load balancers in a network interface. </summary>
 154        /// <param name="nextLink"> The URL to the next page of results. </param>
 155        /// <param name="resourceGroupName"> The name of the resource group. </param>
 156        /// <param name="networkInterfaceName"> The name of the network interface. </param>
 157        /// <param name="cancellationToken"> The cancellation token to use. </param>
 158        public async Task<Response<NetworkInterfaceLoadBalancerListResult>> ListNextPageAsync(string nextLink, string re
 159        {
 0160            if (nextLink == null)
 161            {
 0162                throw new ArgumentNullException(nameof(nextLink));
 163            }
 0164            if (resourceGroupName == null)
 165            {
 0166                throw new ArgumentNullException(nameof(resourceGroupName));
 167            }
 0168            if (networkInterfaceName == null)
 169            {
 0170                throw new ArgumentNullException(nameof(networkInterfaceName));
 171            }
 172
 0173            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, networkInterfaceName);
 0174            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0175            switch (message.Response.Status)
 176            {
 177                case 200:
 178                    {
 0179                        NetworkInterfaceLoadBalancerListResult value = default;
 0180                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0181                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 182                        {
 0183                            value = null;
 184                        }
 185                        else
 186                        {
 0187                            value = NetworkInterfaceLoadBalancerListResult.DeserializeNetworkInterfaceLoadBalancerListRe
 188                        }
 0189                        return Response.FromValue(value, message.Response);
 190                    }
 191                default:
 0192                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 193            }
 0194        }
 195
 196        /// <summary> List all load balancers in a network interface. </summary>
 197        /// <param name="nextLink"> The URL to the next page of results. </param>
 198        /// <param name="resourceGroupName"> The name of the resource group. </param>
 199        /// <param name="networkInterfaceName"> The name of the network interface. </param>
 200        /// <param name="cancellationToken"> The cancellation token to use. </param>
 201        public Response<NetworkInterfaceLoadBalancerListResult> ListNextPage(string nextLink, string resourceGroupName, 
 202        {
 0203            if (nextLink == null)
 204            {
 0205                throw new ArgumentNullException(nameof(nextLink));
 206            }
 0207            if (resourceGroupName == null)
 208            {
 0209                throw new ArgumentNullException(nameof(resourceGroupName));
 210            }
 0211            if (networkInterfaceName == null)
 212            {
 0213                throw new ArgumentNullException(nameof(networkInterfaceName));
 214            }
 215
 0216            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, networkInterfaceName);
 0217            _pipeline.Send(message, cancellationToken);
 0218            switch (message.Response.Status)
 219            {
 220                case 200:
 221                    {
 0222                        NetworkInterfaceLoadBalancerListResult value = default;
 0223                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0224                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 225                        {
 0226                            value = null;
 227                        }
 228                        else
 229                        {
 0230                            value = NetworkInterfaceLoadBalancerListResult.DeserializeNetworkInterfaceLoadBalancerListRe
 231                        }
 0232                        return Response.FromValue(value, message.Response);
 233                    }
 234                default:
 0235                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 236            }
 0237        }
 238    }
 239}