< Summary

Class:Azure.ResourceManager.Network.InboundNatRulesOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\InboundNatRulesOperations.cs
Covered lines:66
Uncovered lines:58
Coverable lines:124
Total lines:324
Line coverage:53.2% (66 of 124)
Covered branches:18
Total branches:36
Branch coverage:50% (18 of 36)

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%
ListAsync(...)-38.1%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
List(...)-38.1%50%
StartDeleteAsync()-57.14%50%
StartDelete(...)-57.14%50%
StartCreateOrUpdateAsync()-56.25%50%
StartCreateOrUpdate(...)-56.25%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\InboundNatRulesOperations.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 InboundNatRules service client. </summary>
 19    public partial class InboundNatRulesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 2423        internal InboundNatRulesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of InboundNatRulesOperations for mocking. </summary>
 1625        protected InboundNatRulesOperations()
 26        {
 1627        }
 28        /// <summary> Initializes a new instance of InboundNatRulesOperations. </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>
 1633        internal InboundNatRulesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscripti
 34        {
 1635            RestClient = new InboundNatRulesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 1636            _clientDiagnostics = clientDiagnostics;
 1637            _pipeline = pipeline;
 1638        }
 39
 40        /// <summary> Gets the specified load balancer inbound nat rule. </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="inboundNatRuleName"> The name of the inbound nat rule. </param>
 44        /// <param name="expand"> Expands referenced resources. </param>
 45        /// <param name="cancellationToken"> The cancellation token to use. </param>
 46        public virtual async Task<Response<InboundNatRule>> GetAsync(string resourceGroupName, string loadBalancerName, 
 47        {
 248            using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.Get");
 249            scope.Start();
 50            try
 51            {
 252                return await RestClient.GetAsync(resourceGroupName, loadBalancerName, inboundNatRuleName, expand, cancel
 53            }
 054            catch (Exception e)
 55            {
 056                scope.Failed(e);
 057                throw;
 58            }
 259        }
 60
 61        /// <summary> Gets the specified load balancer inbound nat rule. </summary>
 62        /// <param name="resourceGroupName"> The name of the resource group. </param>
 63        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 64        /// <param name="inboundNatRuleName"> The name of the inbound nat rule. </param>
 65        /// <param name="expand"> Expands referenced resources. </param>
 66        /// <param name="cancellationToken"> The cancellation token to use. </param>
 67        public virtual Response<InboundNatRule> Get(string resourceGroupName, string loadBalancerName, string inboundNat
 68        {
 269            using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.Get");
 270            scope.Start();
 71            try
 72            {
 273                return RestClient.Get(resourceGroupName, loadBalancerName, inboundNatRuleName, expand, cancellationToken
 74            }
 075            catch (Exception e)
 76            {
 077                scope.Failed(e);
 078                throw;
 79            }
 280        }
 81
 82        /// <summary> Gets all the inbound nat rules in a load balancer. </summary>
 83        /// <param name="resourceGroupName"> The name of the resource group. </param>
 84        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 85        /// <param name="cancellationToken"> The cancellation token to use. </param>
 86        public virtual AsyncPageable<InboundNatRule> ListAsync(string resourceGroupName, string loadBalancerName, Cancel
 87        {
 288            if (resourceGroupName == null)
 89            {
 090                throw new ArgumentNullException(nameof(resourceGroupName));
 91            }
 292            if (loadBalancerName == null)
 93            {
 094                throw new ArgumentNullException(nameof(loadBalancerName));
 95            }
 96
 97            async Task<Page<InboundNatRule>> FirstPageFunc(int? pageSizeHint)
 98            {
 299                using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.List");
 2100                scope.Start();
 101                try
 102                {
 2103                    var response = await RestClient.ListAsync(resourceGroupName, loadBalancerName, cancellationToken).Co
 2104                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 105                }
 0106                catch (Exception e)
 107                {
 0108                    scope.Failed(e);
 0109                    throw;
 110                }
 2111            }
 112            async Task<Page<InboundNatRule>> NextPageFunc(string nextLink, int? pageSizeHint)
 113            {
 0114                using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.List");
 0115                scope.Start();
 116                try
 117                {
 0118                    var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, loadBalancerName, can
 0119                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 120                }
 0121                catch (Exception e)
 122                {
 0123                    scope.Failed(e);
 0124                    throw;
 125                }
 0126            }
 2127            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 128        }
 129
 130        /// <summary> Gets all the inbound nat rules in a load balancer. </summary>
 131        /// <param name="resourceGroupName"> The name of the resource group. </param>
 132        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 133        /// <param name="cancellationToken"> The cancellation token to use. </param>
 134        public virtual Pageable<InboundNatRule> List(string resourceGroupName, string loadBalancerName, CancellationToke
 135        {
 2136            if (resourceGroupName == null)
 137            {
 0138                throw new ArgumentNullException(nameof(resourceGroupName));
 139            }
 2140            if (loadBalancerName == null)
 141            {
 0142                throw new ArgumentNullException(nameof(loadBalancerName));
 143            }
 144
 145            Page<InboundNatRule> FirstPageFunc(int? pageSizeHint)
 146            {
 2147                using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.List");
 2148                scope.Start();
 149                try
 150                {
 2151                    var response = RestClient.List(resourceGroupName, loadBalancerName, cancellationToken);
 2152                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 153                }
 0154                catch (Exception e)
 155                {
 0156                    scope.Failed(e);
 0157                    throw;
 158                }
 2159            }
 160            Page<InboundNatRule> NextPageFunc(string nextLink, int? pageSizeHint)
 161            {
 0162                using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.List");
 0163                scope.Start();
 164                try
 165                {
 0166                    var response = RestClient.ListNextPage(nextLink, resourceGroupName, loadBalancerName, cancellationTo
 0167                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 168                }
 0169                catch (Exception e)
 170                {
 0171                    scope.Failed(e);
 0172                    throw;
 173                }
 0174            }
 2175            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 176        }
 177
 178        /// <summary> Deletes the specified load balancer inbound nat rule. </summary>
 179        /// <param name="resourceGroupName"> The name of the resource group. </param>
 180        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 181        /// <param name="inboundNatRuleName"> The name of the inbound nat rule. </param>
 182        /// <param name="cancellationToken"> The cancellation token to use. </param>
 183        public virtual async Task<InboundNatRulesDeleteOperation> StartDeleteAsync(string resourceGroupName, string load
 184        {
 2185            if (resourceGroupName == null)
 186            {
 0187                throw new ArgumentNullException(nameof(resourceGroupName));
 188            }
 2189            if (loadBalancerName == null)
 190            {
 0191                throw new ArgumentNullException(nameof(loadBalancerName));
 192            }
 2193            if (inboundNatRuleName == null)
 194            {
 0195                throw new ArgumentNullException(nameof(inboundNatRuleName));
 196            }
 197
 2198            using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.StartDelete");
 2199            scope.Start();
 200            try
 201            {
 2202                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, loadBalancerName, inboundNatRuleN
 2203                return new InboundNatRulesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(
 204            }
 0205            catch (Exception e)
 206            {
 0207                scope.Failed(e);
 0208                throw;
 209            }
 2210        }
 211
 212        /// <summary> Deletes the specified load balancer inbound nat rule. </summary>
 213        /// <param name="resourceGroupName"> The name of the resource group. </param>
 214        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 215        /// <param name="inboundNatRuleName"> The name of the inbound nat rule. </param>
 216        /// <param name="cancellationToken"> The cancellation token to use. </param>
 217        public virtual InboundNatRulesDeleteOperation StartDelete(string resourceGroupName, string loadBalancerName, str
 218        {
 2219            if (resourceGroupName == null)
 220            {
 0221                throw new ArgumentNullException(nameof(resourceGroupName));
 222            }
 2223            if (loadBalancerName == null)
 224            {
 0225                throw new ArgumentNullException(nameof(loadBalancerName));
 226            }
 2227            if (inboundNatRuleName == null)
 228            {
 0229                throw new ArgumentNullException(nameof(inboundNatRuleName));
 230            }
 231
 2232            using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.StartDelete");
 2233            scope.Start();
 234            try
 235            {
 2236                var originalResponse = RestClient.Delete(resourceGroupName, loadBalancerName, inboundNatRuleName, cancel
 2237                return new InboundNatRulesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(
 238            }
 0239            catch (Exception e)
 240            {
 0241                scope.Failed(e);
 0242                throw;
 243            }
 2244        }
 245
 246        /// <summary> Creates or updates a load balancer inbound nat rule. </summary>
 247        /// <param name="resourceGroupName"> The name of the resource group. </param>
 248        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 249        /// <param name="inboundNatRuleName"> The name of the inbound nat rule. </param>
 250        /// <param name="inboundNatRuleParameters"> Parameters supplied to the create or update inbound nat rule operati
 251        /// <param name="cancellationToken"> The cancellation token to use. </param>
 252        public virtual async Task<InboundNatRulesCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupN
 253        {
 2254            if (resourceGroupName == null)
 255            {
 0256                throw new ArgumentNullException(nameof(resourceGroupName));
 257            }
 2258            if (loadBalancerName == null)
 259            {
 0260                throw new ArgumentNullException(nameof(loadBalancerName));
 261            }
 2262            if (inboundNatRuleName == null)
 263            {
 0264                throw new ArgumentNullException(nameof(inboundNatRuleName));
 265            }
 2266            if (inboundNatRuleParameters == null)
 267            {
 0268                throw new ArgumentNullException(nameof(inboundNatRuleParameters));
 269            }
 270
 2271            using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.StartCreateOrUpdate");
 2272            scope.Start();
 273            try
 274            {
 2275                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, loadBalancerName, inbound
 2276                return new InboundNatRulesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreate
 277            }
 0278            catch (Exception e)
 279            {
 0280                scope.Failed(e);
 0281                throw;
 282            }
 2283        }
 284
 285        /// <summary> Creates or updates a load balancer inbound nat rule. </summary>
 286        /// <param name="resourceGroupName"> The name of the resource group. </param>
 287        /// <param name="loadBalancerName"> The name of the load balancer. </param>
 288        /// <param name="inboundNatRuleName"> The name of the inbound nat rule. </param>
 289        /// <param name="inboundNatRuleParameters"> Parameters supplied to the create or update inbound nat rule operati
 290        /// <param name="cancellationToken"> The cancellation token to use. </param>
 291        public virtual InboundNatRulesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string loadB
 292        {
 2293            if (resourceGroupName == null)
 294            {
 0295                throw new ArgumentNullException(nameof(resourceGroupName));
 296            }
 2297            if (loadBalancerName == null)
 298            {
 0299                throw new ArgumentNullException(nameof(loadBalancerName));
 300            }
 2301            if (inboundNatRuleName == null)
 302            {
 0303                throw new ArgumentNullException(nameof(inboundNatRuleName));
 304            }
 2305            if (inboundNatRuleParameters == null)
 306            {
 0307                throw new ArgumentNullException(nameof(inboundNatRuleParameters));
 308            }
 309
 2310            using var scope = _clientDiagnostics.CreateScope("InboundNatRulesOperations.StartCreateOrUpdate");
 2311            scope.Start();
 312            try
 313            {
 2314                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, loadBalancerName, inboundNatRuleName
 2315                return new InboundNatRulesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreate
 316            }
 0317            catch (Exception e)
 318            {
 0319                scope.Failed(e);
 0320                throw;
 321            }
 2322        }
 323    }
 324}