< Summary

Class:Azure.ResourceManager.Network.LoadBalancersOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\LoadBalancersOperations.cs
Covered lines:72
Uncovered lines:88
Coverable lines:160
Total lines:406
Line coverage:45% (72 of 160)
Covered branches:12
Total branches:24
Branch coverage:50% (12 of 24)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
GetAsync()-57.14%100%
Get(...)-57.14%100%
UpdateTagsAsync()-0%100%
UpdateTags(...)-0%100%
<ListAllAsync()-62.5%100%
<ListAllAsync()-0%100%
ListAllAsync(...)-100%100%
ListAll(...)-100%100%
ListAsync(...)-36.84%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
List(...)-36.84%50%
StartDeleteAsync()-58.33%50%
StartDelete(...)-58.33%50%
StartCreateOrUpdateAsync()-57.14%50%
StartCreateOrUpdate(...)-57.14%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\LoadBalancersOperations.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.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Core;
 13using Azure.Core.Pipeline;
 14using Azure.ResourceManager.Network.Models;
 15
 16namespace Azure.ResourceManager.Network
 17{
 18    /// <summary> The LoadBalancers service client. </summary>
 19    public partial class LoadBalancersOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 30423        internal LoadBalancersRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of LoadBalancersOperations for mocking. </summary>
 21625        protected LoadBalancersOperations()
 26        {
 21627        }
 28        /// <summary> Initializes a new instance of LoadBalancersOperations. </summary>
 29        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 30        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 31        /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 32        /// <param name="endpoint"> server parameter. </param>
 21633        internal LoadBalancersOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription
 34        {
 21635            RestClient = new LoadBalancersRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 21636            _clientDiagnostics = clientDiagnostics;
 21637            _pipeline = pipeline;
 21638        }
 39
 40        /// <summary> Gets the specified load balancer. </summary>
 41        /// <param name="resourceGroupName"> The name of the resource group. </param>
 42        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 43        /// <param name="expand"> Expands referenced resources. </param>
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<LoadBalancer>> GetAsync(string resourceGroupName, string loadBalancerName, st
 46        {
 3247            using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.Get");
 3248            scope.Start();
 49            try
 50            {
 3251                return await RestClient.GetAsync(resourceGroupName, loadBalancerName, expand, cancellationToken).Configu
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 3258        }
 59
 60        /// <summary> Gets the specified load balancer. </summary>
 61        /// <param name="resourceGroupName"> The name of the resource group. </param>
 62        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 63        /// <param name="expand"> Expands referenced resources. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<LoadBalancer> Get(string resourceGroupName, string loadBalancerName, string expand = nul
 66        {
 3267            using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.Get");
 3268            scope.Start();
 69            try
 70            {
 3271                return RestClient.Get(resourceGroupName, loadBalancerName, expand, cancellationToken);
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 3278        }
 79
 80        /// <summary> Updates a load balancer tags. </summary>
 81        /// <param name="resourceGroupName"> The name of the resource group. </param>
 82        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 83        /// <param name="parameters"> Parameters supplied to update load balancer tags. </param>
 84        /// <param name="cancellationToken"> The cancellation token to use. </param>
 85        public virtual async Task<Response<LoadBalancer>> UpdateTagsAsync(string resourceGroupName, string loadBalancerN
 86        {
 087            using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.UpdateTags");
 088            scope.Start();
 89            try
 90            {
 091                return await RestClient.UpdateTagsAsync(resourceGroupName, loadBalancerName, parameters, cancellationTok
 92            }
 093            catch (Exception e)
 94            {
 095                scope.Failed(e);
 096                throw;
 97            }
 098        }
 99
 100        /// <summary> Updates a load balancer tags. </summary>
 101        /// <param name="resourceGroupName"> The name of the resource group. </param>
 102        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 103        /// <param name="parameters"> Parameters supplied to update load balancer tags. </param>
 104        /// <param name="cancellationToken"> The cancellation token to use. </param>
 105        public virtual Response<LoadBalancer> UpdateTags(string resourceGroupName, string loadBalancerName, TagsObject p
 106        {
 0107            using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.UpdateTags");
 0108            scope.Start();
 109            try
 110            {
 0111                return RestClient.UpdateTags(resourceGroupName, loadBalancerName, parameters, cancellationToken);
 112            }
 0113            catch (Exception e)
 114            {
 0115                scope.Failed(e);
 0116                throw;
 117            }
 0118        }
 119
 120        /// <summary> Gets all the load balancers in a subscription. </summary>
 121        /// <param name="cancellationToken"> The cancellation token to use. </param>
 122        public virtual AsyncPageable<LoadBalancer> ListAllAsync(CancellationToken cancellationToken = default)
 123        {
 124            async Task<Page<LoadBalancer>> FirstPageFunc(int? pageSizeHint)
 125            {
 6126                using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.ListAll");
 6127                scope.Start();
 128                try
 129                {
 6130                    var response = await RestClient.ListAllAsync(cancellationToken).ConfigureAwait(false);
 6131                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 132                }
 0133                catch (Exception e)
 134                {
 0135                    scope.Failed(e);
 0136                    throw;
 137                }
 6138            }
 139            async Task<Page<LoadBalancer>> NextPageFunc(string nextLink, int? pageSizeHint)
 140            {
 0141                using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.ListAll");
 0142                scope.Start();
 143                try
 144                {
 0145                    var response = await RestClient.ListAllNextPageAsync(nextLink, cancellationToken).ConfigureAwait(fal
 0146                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 147                }
 0148                catch (Exception e)
 149                {
 0150                    scope.Failed(e);
 0151                    throw;
 152                }
 0153            }
 6154            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 155        }
 156
 157        /// <summary> Gets all the load balancers in a subscription. </summary>
 158        /// <param name="cancellationToken"> The cancellation token to use. </param>
 159        public virtual Pageable<LoadBalancer> ListAll(CancellationToken cancellationToken = default)
 160        {
 161            Page<LoadBalancer> FirstPageFunc(int? pageSizeHint)
 162            {
 6163                using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.ListAll");
 6164                scope.Start();
 165                try
 166                {
 6167                    var response = RestClient.ListAll(cancellationToken);
 6168                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 169                }
 0170                catch (Exception e)
 171                {
 0172                    scope.Failed(e);
 0173                    throw;
 174                }
 6175            }
 176            Page<LoadBalancer> NextPageFunc(string nextLink, int? pageSizeHint)
 177            {
 0178                using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.ListAll");
 0179                scope.Start();
 180                try
 181                {
 0182                    var response = RestClient.ListAllNextPage(nextLink, cancellationToken);
 0183                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 184                }
 0185                catch (Exception e)
 186                {
 0187                    scope.Failed(e);
 0188                    throw;
 189                }
 0190            }
 6191            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 192        }
 193
 194        /// <summary> Gets all the load balancers in a resource group. </summary>
 195        /// <param name="resourceGroupName"> The name of the resource group. </param>
 196        /// <param name="cancellationToken"> The cancellation token to use. </param>
 197        public virtual AsyncPageable<LoadBalancer> ListAsync(string resourceGroupName, CancellationToken cancellationTok
 198        {
 26199            if (resourceGroupName == null)
 200            {
 0201                throw new ArgumentNullException(nameof(resourceGroupName));
 202            }
 203
 204            async Task<Page<LoadBalancer>> FirstPageFunc(int? pageSizeHint)
 205            {
 26206                using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.List");
 26207                scope.Start();
 208                try
 209                {
 26210                    var response = await RestClient.ListAsync(resourceGroupName, cancellationToken).ConfigureAwait(false
 26211                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 212                }
 0213                catch (Exception e)
 214                {
 0215                    scope.Failed(e);
 0216                    throw;
 217                }
 26218            }
 219            async Task<Page<LoadBalancer>> NextPageFunc(string nextLink, int? pageSizeHint)
 220            {
 0221                using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.List");
 0222                scope.Start();
 223                try
 224                {
 0225                    var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, cancellationToken).Co
 0226                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 227                }
 0228                catch (Exception e)
 229                {
 0230                    scope.Failed(e);
 0231                    throw;
 232                }
 0233            }
 26234            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 235        }
 236
 237        /// <summary> Gets all the load balancers in a resource group. </summary>
 238        /// <param name="resourceGroupName"> The name of the resource group. </param>
 239        /// <param name="cancellationToken"> The cancellation token to use. </param>
 240        public virtual Pageable<LoadBalancer> List(string resourceGroupName, CancellationToken cancellationToken = defau
 241        {
 26242            if (resourceGroupName == null)
 243            {
 0244                throw new ArgumentNullException(nameof(resourceGroupName));
 245            }
 246
 247            Page<LoadBalancer> FirstPageFunc(int? pageSizeHint)
 248            {
 26249                using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.List");
 26250                scope.Start();
 251                try
 252                {
 26253                    var response = RestClient.List(resourceGroupName, cancellationToken);
 26254                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 255                }
 0256                catch (Exception e)
 257                {
 0258                    scope.Failed(e);
 0259                    throw;
 260                }
 26261            }
 262            Page<LoadBalancer> NextPageFunc(string nextLink, int? pageSizeHint)
 263            {
 0264                using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.List");
 0265                scope.Start();
 266                try
 267                {
 0268                    var response = RestClient.ListNextPage(nextLink, resourceGroupName, cancellationToken);
 0269                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 270                }
 0271                catch (Exception e)
 272                {
 0273                    scope.Failed(e);
 0274                    throw;
 275                }
 0276            }
 26277            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 278        }
 279
 280        /// <summary> Deletes the specified load balancer. </summary>
 281        /// <param name="resourceGroupName"> The name of the resource group. </param>
 282        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 283        /// <param name="cancellationToken"> The cancellation token to use. </param>
 284        public virtual async Task<LoadBalancersDeleteOperation> StartDeleteAsync(string resourceGroupName, string loadBa
 285        {
 18286            if (resourceGroupName == null)
 287            {
 0288                throw new ArgumentNullException(nameof(resourceGroupName));
 289            }
 18290            if (loadBalancerName == null)
 291            {
 0292                throw new ArgumentNullException(nameof(loadBalancerName));
 293            }
 294
 18295            using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.StartDelete");
 18296            scope.Start();
 297            try
 298            {
 18299                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, loadBalancerName, cancellationTok
 18300                return new LoadBalancersDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(re
 301            }
 0302            catch (Exception e)
 303            {
 0304                scope.Failed(e);
 0305                throw;
 306            }
 18307        }
 308
 309        /// <summary> Deletes the specified load balancer. </summary>
 310        /// <param name="resourceGroupName"> The name of the resource group. </param>
 311        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 312        /// <param name="cancellationToken"> The cancellation token to use. </param>
 313        public virtual LoadBalancersDeleteOperation StartDelete(string resourceGroupName, string loadBalancerName, Cance
 314        {
 18315            if (resourceGroupName == null)
 316            {
 0317                throw new ArgumentNullException(nameof(resourceGroupName));
 318            }
 18319            if (loadBalancerName == null)
 320            {
 0321                throw new ArgumentNullException(nameof(loadBalancerName));
 322            }
 323
 18324            using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.StartDelete");
 18325            scope.Start();
 326            try
 327            {
 18328                var originalResponse = RestClient.Delete(resourceGroupName, loadBalancerName, cancellationToken);
 18329                return new LoadBalancersDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(re
 330            }
 0331            catch (Exception e)
 332            {
 0333                scope.Failed(e);
 0334                throw;
 335            }
 18336        }
 337
 338        /// <summary> Creates or updates a load balancer. </summary>
 339        /// <param name="resourceGroupName"> The name of the resource group. </param>
 340        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 341        /// <param name="parameters"> Parameters supplied to the create or update load balancer operation. </param>
 342        /// <param name="cancellationToken"> The cancellation token to use. </param>
 343        public virtual async Task<LoadBalancersCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupNam
 344        {
 26345            if (resourceGroupName == null)
 346            {
 0347                throw new ArgumentNullException(nameof(resourceGroupName));
 348            }
 26349            if (loadBalancerName == null)
 350            {
 0351                throw new ArgumentNullException(nameof(loadBalancerName));
 352            }
 26353            if (parameters == null)
 354            {
 0355                throw new ArgumentNullException(nameof(parameters));
 356            }
 357
 26358            using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.StartCreateOrUpdate");
 26359            scope.Start();
 360            try
 361            {
 26362                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, loadBalancerName, paramet
 26363                return new LoadBalancersCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOr
 364            }
 0365            catch (Exception e)
 366            {
 0367                scope.Failed(e);
 0368                throw;
 369            }
 26370        }
 371
 372        /// <summary> Creates or updates a load balancer. </summary>
 373        /// <param name="resourceGroupName"> The name of the resource group. </param>
 374        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 375        /// <param name="parameters"> Parameters supplied to the create or update load balancer operation. </param>
 376        /// <param name="cancellationToken"> The cancellation token to use. </param>
 377        public virtual LoadBalancersCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string loadBal
 378        {
 26379            if (resourceGroupName == null)
 380            {
 0381                throw new ArgumentNullException(nameof(resourceGroupName));
 382            }
 26383            if (loadBalancerName == null)
 384            {
 0385                throw new ArgumentNullException(nameof(loadBalancerName));
 386            }
 26387            if (parameters == null)
 388            {
 0389                throw new ArgumentNullException(nameof(parameters));
 390            }
 391
 26392            using var scope = _clientDiagnostics.CreateScope("LoadBalancersOperations.StartCreateOrUpdate");
 26393            scope.Start();
 394            try
 395            {
 26396                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, loadBalancerName, parameters, cancel
 26397                return new LoadBalancersCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOr
 398            }
 0399            catch (Exception e)
 400            {
 0401                scope.Failed(e);
 0402                throw;
 403            }
 26404        }
 405    }
 406}