< Summary

Class:Azure.ResourceManager.Network.LoadBalancerBackendAddressPoolsRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\LoadBalancerBackendAddressPoolsRestOperations.cs
Covered lines:85
Uncovered lines:149
Coverable lines:234
Total lines:529
Line coverage:36.3% (85 of 234)
Covered branches:20
Total branches:104
Branch coverage:19.2% (20 of 104)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateListRequest(...)-100%100%
ListAsync()-73.33%50%
List(...)-73.33%50%
CreateGetRequest(...)-100%100%
GetAsync()-70.59%50%
Get(...)-70.59%50%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-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\LoadBalancerBackendAddressPoolsRestOperations.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 LoadBalancerBackendAddressPoolsRestOperations
 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 LoadBalancerBackendAddressPoolsRestOperations. </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
 832        public LoadBalancerBackendAddressPoolsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline,
 33        {
 834            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 838            endpoint ??= new Uri("https://management.azure.com");
 39
 840            this.subscriptionId = subscriptionId;
 841            this.endpoint = endpoint;
 842            _clientDiagnostics = clientDiagnostics;
 843            _pipeline = pipeline;
 844        }
 45
 46        internal HttpMessage CreateListRequest(string resourceGroupName, string loadBalancerName)
 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/loadBalancers/", false);
 458            uri.AppendPath(loadBalancerName, true);
 459            uri.AppendPath("/backendAddressPools", false);
 460            uri.AppendQuery("api-version", "2020-04-01", true);
 461            request.Uri = uri;
 462            return message;
 63        }
 64
 65        /// <summary> Gets all the load balancer backed address pools. </summary>
 66        /// <param name="resourceGroupName"> The name of the resource group. </param>
 67        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 68        /// <param name="cancellationToken"> The cancellation token to use. </param>
 69        public async Task<Response<LoadBalancerBackendAddressPoolListResult>> ListAsync(string resourceGroupName, string
 70        {
 271            if (resourceGroupName == null)
 72            {
 073                throw new ArgumentNullException(nameof(resourceGroupName));
 74            }
 275            if (loadBalancerName == null)
 76            {
 077                throw new ArgumentNullException(nameof(loadBalancerName));
 78            }
 79
 280            using var message = CreateListRequest(resourceGroupName, loadBalancerName);
 281            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 282            switch (message.Response.Status)
 83            {
 84                case 200:
 85                    {
 286                        LoadBalancerBackendAddressPoolListResult 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 = LoadBalancerBackendAddressPoolListResult.DeserializeLoadBalancerBackendAddressPoolLi
 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> Gets all the load balancer backed address pools. </summary>
 104        /// <param name="resourceGroupName"> The name of the resource group. </param>
 105        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 106        /// <param name="cancellationToken"> The cancellation token to use. </param>
 107        public Response<LoadBalancerBackendAddressPoolListResult> List(string resourceGroupName, string loadBalancerName
 108        {
 2109            if (resourceGroupName == null)
 110            {
 0111                throw new ArgumentNullException(nameof(resourceGroupName));
 112            }
 2113            if (loadBalancerName == null)
 114            {
 0115                throw new ArgumentNullException(nameof(loadBalancerName));
 116            }
 117
 2118            using var message = CreateListRequest(resourceGroupName, loadBalancerName);
 2119            _pipeline.Send(message, cancellationToken);
 2120            switch (message.Response.Status)
 121            {
 122                case 200:
 123                    {
 2124                        LoadBalancerBackendAddressPoolListResult 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 = LoadBalancerBackendAddressPoolListResult.DeserializeLoadBalancerBackendAddressPoolLi
 133                        }
 2134                        return Response.FromValue(value, message.Response);
 135                    }
 136                default:
 0137                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 138            }
 2139        }
 140
 141        internal HttpMessage CreateGetRequest(string resourceGroupName, string loadBalancerName, string backendAddressPo
 142        {
 4143            var message = _pipeline.CreateMessage();
 4144            var request = message.Request;
 4145            request.Method = RequestMethod.Get;
 4146            var uri = new RawRequestUriBuilder();
 4147            uri.Reset(endpoint);
 4148            uri.AppendPath("/subscriptions/", false);
 4149            uri.AppendPath(subscriptionId, true);
 4150            uri.AppendPath("/resourceGroups/", false);
 4151            uri.AppendPath(resourceGroupName, true);
 4152            uri.AppendPath("/providers/Microsoft.Network/loadBalancers/", false);
 4153            uri.AppendPath(loadBalancerName, true);
 4154            uri.AppendPath("/backendAddressPools/", false);
 4155            uri.AppendPath(backendAddressPoolName, true);
 4156            uri.AppendQuery("api-version", "2020-04-01", true);
 4157            request.Uri = uri;
 4158            return message;
 159        }
 160
 161        /// <summary> Gets load balancer backend address pool. </summary>
 162        /// <param name="resourceGroupName"> The name of the resource group. </param>
 163        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 164        /// <param name="backendAddressPoolName"> The name of the backend address pool. </param>
 165        /// <param name="cancellationToken"> The cancellation token to use. </param>
 166        public async Task<Response<BackendAddressPool>> GetAsync(string resourceGroupName, string loadBalancerName, stri
 167        {
 2168            if (resourceGroupName == null)
 169            {
 0170                throw new ArgumentNullException(nameof(resourceGroupName));
 171            }
 2172            if (loadBalancerName == null)
 173            {
 0174                throw new ArgumentNullException(nameof(loadBalancerName));
 175            }
 2176            if (backendAddressPoolName == null)
 177            {
 0178                throw new ArgumentNullException(nameof(backendAddressPoolName));
 179            }
 180
 2181            using var message = CreateGetRequest(resourceGroupName, loadBalancerName, backendAddressPoolName);
 2182            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2183            switch (message.Response.Status)
 184            {
 185                case 200:
 186                    {
 2187                        BackendAddressPool value = default;
 2188                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2189                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 190                        {
 0191                            value = null;
 192                        }
 193                        else
 194                        {
 2195                            value = BackendAddressPool.DeserializeBackendAddressPool(document.RootElement);
 196                        }
 2197                        return Response.FromValue(value, message.Response);
 198                    }
 199                default:
 0200                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 201            }
 2202        }
 203
 204        /// <summary> Gets load balancer backend address pool. </summary>
 205        /// <param name="resourceGroupName"> The name of the resource group. </param>
 206        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 207        /// <param name="backendAddressPoolName"> The name of the backend address pool. </param>
 208        /// <param name="cancellationToken"> The cancellation token to use. </param>
 209        public Response<BackendAddressPool> Get(string resourceGroupName, string loadBalancerName, string backendAddress
 210        {
 2211            if (resourceGroupName == null)
 212            {
 0213                throw new ArgumentNullException(nameof(resourceGroupName));
 214            }
 2215            if (loadBalancerName == null)
 216            {
 0217                throw new ArgumentNullException(nameof(loadBalancerName));
 218            }
 2219            if (backendAddressPoolName == null)
 220            {
 0221                throw new ArgumentNullException(nameof(backendAddressPoolName));
 222            }
 223
 2224            using var message = CreateGetRequest(resourceGroupName, loadBalancerName, backendAddressPoolName);
 2225            _pipeline.Send(message, cancellationToken);
 2226            switch (message.Response.Status)
 227            {
 228                case 200:
 229                    {
 2230                        BackendAddressPool value = default;
 2231                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2232                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 233                        {
 0234                            value = null;
 235                        }
 236                        else
 237                        {
 2238                            value = BackendAddressPool.DeserializeBackendAddressPool(document.RootElement);
 239                        }
 2240                        return Response.FromValue(value, message.Response);
 241                    }
 242                default:
 0243                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 244            }
 2245        }
 246
 247        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string loadBalancerName, string backe
 248        {
 0249            var message = _pipeline.CreateMessage();
 0250            var request = message.Request;
 0251            request.Method = RequestMethod.Put;
 0252            var uri = new RawRequestUriBuilder();
 0253            uri.Reset(endpoint);
 0254            uri.AppendPath("/subscriptions/", false);
 0255            uri.AppendPath(subscriptionId, true);
 0256            uri.AppendPath("/resourceGroups/", false);
 0257            uri.AppendPath(resourceGroupName, true);
 0258            uri.AppendPath("/providers/Microsoft.Network/loadBalancers/", false);
 0259            uri.AppendPath(loadBalancerName, true);
 0260            uri.AppendPath("/backendAddressPools/", false);
 0261            uri.AppendPath(backendAddressPoolName, true);
 0262            uri.AppendQuery("api-version", "2020-04-01", true);
 0263            request.Uri = uri;
 0264            request.Headers.Add("Content-Type", "application/json");
 0265            var content = new Utf8JsonRequestContent();
 0266            content.JsonWriter.WriteObjectValue(parameters);
 0267            request.Content = content;
 0268            return message;
 269        }
 270
 271        /// <summary> Creates or updates a load balancer backend address pool. </summary>
 272        /// <param name="resourceGroupName"> The name of the resource group. </param>
 273        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 274        /// <param name="backendAddressPoolName"> The name of the backend address pool. </param>
 275        /// <param name="parameters"> Parameters supplied to the create or update load balancer backend address pool ope
 276        /// <param name="cancellationToken"> The cancellation token to use. </param>
 277        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string loadBalancerName, string backen
 278        {
 0279            if (resourceGroupName == null)
 280            {
 0281                throw new ArgumentNullException(nameof(resourceGroupName));
 282            }
 0283            if (loadBalancerName == null)
 284            {
 0285                throw new ArgumentNullException(nameof(loadBalancerName));
 286            }
 0287            if (backendAddressPoolName == null)
 288            {
 0289                throw new ArgumentNullException(nameof(backendAddressPoolName));
 290            }
 0291            if (parameters == null)
 292            {
 0293                throw new ArgumentNullException(nameof(parameters));
 294            }
 295
 0296            using var message = CreateCreateOrUpdateRequest(resourceGroupName, loadBalancerName, backendAddressPoolName,
 0297            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0298            switch (message.Response.Status)
 299            {
 300                case 200:
 301                case 201:
 0302                    return message.Response;
 303                default:
 0304                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 305            }
 0306        }
 307
 308        /// <summary> Creates or updates a load balancer backend address pool. </summary>
 309        /// <param name="resourceGroupName"> The name of the resource group. </param>
 310        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 311        /// <param name="backendAddressPoolName"> The name of the backend address pool. </param>
 312        /// <param name="parameters"> Parameters supplied to the create or update load balancer backend address pool ope
 313        /// <param name="cancellationToken"> The cancellation token to use. </param>
 314        public Response CreateOrUpdate(string resourceGroupName, string loadBalancerName, string backendAddressPoolName,
 315        {
 0316            if (resourceGroupName == null)
 317            {
 0318                throw new ArgumentNullException(nameof(resourceGroupName));
 319            }
 0320            if (loadBalancerName == null)
 321            {
 0322                throw new ArgumentNullException(nameof(loadBalancerName));
 323            }
 0324            if (backendAddressPoolName == null)
 325            {
 0326                throw new ArgumentNullException(nameof(backendAddressPoolName));
 327            }
 0328            if (parameters == null)
 329            {
 0330                throw new ArgumentNullException(nameof(parameters));
 331            }
 332
 0333            using var message = CreateCreateOrUpdateRequest(resourceGroupName, loadBalancerName, backendAddressPoolName,
 0334            _pipeline.Send(message, cancellationToken);
 0335            switch (message.Response.Status)
 336            {
 337                case 200:
 338                case 201:
 0339                    return message.Response;
 340                default:
 0341                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 342            }
 0343        }
 344
 345        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string loadBalancerName, string backendAddres
 346        {
 0347            var message = _pipeline.CreateMessage();
 0348            var request = message.Request;
 0349            request.Method = RequestMethod.Delete;
 0350            var uri = new RawRequestUriBuilder();
 0351            uri.Reset(endpoint);
 0352            uri.AppendPath("/subscriptions/", false);
 0353            uri.AppendPath(subscriptionId, true);
 0354            uri.AppendPath("/resourceGroups/", false);
 0355            uri.AppendPath(resourceGroupName, true);
 0356            uri.AppendPath("/providers/Microsoft.Network/loadBalancers/", false);
 0357            uri.AppendPath(loadBalancerName, true);
 0358            uri.AppendPath("/backendAddressPools/", false);
 0359            uri.AppendPath(backendAddressPoolName, true);
 0360            uri.AppendQuery("api-version", "2020-04-01", true);
 0361            request.Uri = uri;
 0362            return message;
 363        }
 364
 365        /// <summary> Deletes the specified load balancer backend address pool. </summary>
 366        /// <param name="resourceGroupName"> The name of the resource group. </param>
 367        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 368        /// <param name="backendAddressPoolName"> The name of the backend address pool. </param>
 369        /// <param name="cancellationToken"> The cancellation token to use. </param>
 370        public async Task<Response> DeleteAsync(string resourceGroupName, string loadBalancerName, string backendAddress
 371        {
 0372            if (resourceGroupName == null)
 373            {
 0374                throw new ArgumentNullException(nameof(resourceGroupName));
 375            }
 0376            if (loadBalancerName == null)
 377            {
 0378                throw new ArgumentNullException(nameof(loadBalancerName));
 379            }
 0380            if (backendAddressPoolName == null)
 381            {
 0382                throw new ArgumentNullException(nameof(backendAddressPoolName));
 383            }
 384
 0385            using var message = CreateDeleteRequest(resourceGroupName, loadBalancerName, backendAddressPoolName);
 0386            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0387            switch (message.Response.Status)
 388            {
 389                case 200:
 390                case 202:
 391                case 204:
 0392                    return message.Response;
 393                default:
 0394                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 395            }
 0396        }
 397
 398        /// <summary> Deletes the specified load balancer backend address pool. </summary>
 399        /// <param name="resourceGroupName"> The name of the resource group. </param>
 400        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 401        /// <param name="backendAddressPoolName"> The name of the backend address pool. </param>
 402        /// <param name="cancellationToken"> The cancellation token to use. </param>
 403        public Response Delete(string resourceGroupName, string loadBalancerName, string backendAddressPoolName, Cancell
 404        {
 0405            if (resourceGroupName == null)
 406            {
 0407                throw new ArgumentNullException(nameof(resourceGroupName));
 408            }
 0409            if (loadBalancerName == null)
 410            {
 0411                throw new ArgumentNullException(nameof(loadBalancerName));
 412            }
 0413            if (backendAddressPoolName == null)
 414            {
 0415                throw new ArgumentNullException(nameof(backendAddressPoolName));
 416            }
 417
 0418            using var message = CreateDeleteRequest(resourceGroupName, loadBalancerName, backendAddressPoolName);
 0419            _pipeline.Send(message, cancellationToken);
 0420            switch (message.Response.Status)
 421            {
 422                case 200:
 423                case 202:
 424                case 204:
 0425                    return message.Response;
 426                default:
 0427                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 428            }
 0429        }
 430
 431        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string loadBalancerNam
 432        {
 0433            var message = _pipeline.CreateMessage();
 0434            var request = message.Request;
 0435            request.Method = RequestMethod.Get;
 0436            var uri = new RawRequestUriBuilder();
 0437            uri.Reset(endpoint);
 0438            uri.AppendRawNextLink(nextLink, false);
 0439            request.Uri = uri;
 0440            return message;
 441        }
 442
 443        /// <summary> Gets all the load balancer backed address pools. </summary>
 444        /// <param name="nextLink"> The URL to the next page of results. </param>
 445        /// <param name="resourceGroupName"> The name of the resource group. </param>
 446        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 447        /// <param name="cancellationToken"> The cancellation token to use. </param>
 448        public async Task<Response<LoadBalancerBackendAddressPoolListResult>> ListNextPageAsync(string nextLink, string 
 449        {
 0450            if (nextLink == null)
 451            {
 0452                throw new ArgumentNullException(nameof(nextLink));
 453            }
 0454            if (resourceGroupName == null)
 455            {
 0456                throw new ArgumentNullException(nameof(resourceGroupName));
 457            }
 0458            if (loadBalancerName == null)
 459            {
 0460                throw new ArgumentNullException(nameof(loadBalancerName));
 461            }
 462
 0463            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, loadBalancerName);
 0464            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0465            switch (message.Response.Status)
 466            {
 467                case 200:
 468                    {
 0469                        LoadBalancerBackendAddressPoolListResult value = default;
 0470                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0471                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 472                        {
 0473                            value = null;
 474                        }
 475                        else
 476                        {
 0477                            value = LoadBalancerBackendAddressPoolListResult.DeserializeLoadBalancerBackendAddressPoolLi
 478                        }
 0479                        return Response.FromValue(value, message.Response);
 480                    }
 481                default:
 0482                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 483            }
 0484        }
 485
 486        /// <summary> Gets all the load balancer backed address pools. </summary>
 487        /// <param name="nextLink"> The URL to the next page of results. </param>
 488        /// <param name="resourceGroupName"> The name of the resource group. </param>
 489        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 490        /// <param name="cancellationToken"> The cancellation token to use. </param>
 491        public Response<LoadBalancerBackendAddressPoolListResult> ListNextPage(string nextLink, string resourceGroupName
 492        {
 0493            if (nextLink == null)
 494            {
 0495                throw new ArgumentNullException(nameof(nextLink));
 496            }
 0497            if (resourceGroupName == null)
 498            {
 0499                throw new ArgumentNullException(nameof(resourceGroupName));
 500            }
 0501            if (loadBalancerName == null)
 502            {
 0503                throw new ArgumentNullException(nameof(loadBalancerName));
 504            }
 505
 0506            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, loadBalancerName);
 0507            _pipeline.Send(message, cancellationToken);
 0508            switch (message.Response.Status)
 509            {
 510                case 200:
 511                    {
 0512                        LoadBalancerBackendAddressPoolListResult value = default;
 0513                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0514                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 515                        {
 0516                            value = null;
 517                        }
 518                        else
 519                        {
 0520                            value = LoadBalancerBackendAddressPoolListResult.DeserializeLoadBalancerBackendAddressPoolLi
 521                        }
 0522                        return Response.FromValue(value, message.Response);
 523                    }
 524                default:
 0525                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 526            }
 0527        }
 528    }
 529}