< Summary

Class:Azure.ResourceManager.Network.SecurityRulesOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\SecurityRulesOperations.cs
Covered lines:66
Uncovered lines:58
Coverable lines:124
Total lines:322
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\SecurityRulesOperations.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 SecurityRules service client. </summary>
 19    public partial class SecurityRulesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 3223        internal SecurityRulesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of SecurityRulesOperations for mocking. </summary>
 2425        protected SecurityRulesOperations()
 26        {
 2427        }
 28        /// <summary> Initializes a new instance of SecurityRulesOperations. </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>
 2433        internal SecurityRulesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription
 34        {
 2435            RestClient = new SecurityRulesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 2436            _clientDiagnostics = clientDiagnostics;
 2437            _pipeline = pipeline;
 2438        }
 39
 40        /// <summary> Get the specified network security rule. </summary>
 41        /// <param name="resourceGroupName"> The name of the resource group. </param>
 42        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 43        /// <param name="securityRuleName"> The name of the security rule. </param>
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<SecurityRule>> GetAsync(string resourceGroupName, string networkSecurityGroup
 46        {
 447            using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.Get");
 448            scope.Start();
 49            try
 50            {
 451                return await RestClient.GetAsync(resourceGroupName, networkSecurityGroupName, securityRuleName, cancella
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 458        }
 59
 60        /// <summary> Get the specified network security rule. </summary>
 61        /// <param name="resourceGroupName"> The name of the resource group. </param>
 62        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 63        /// <param name="securityRuleName"> The name of the security rule. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<SecurityRule> Get(string resourceGroupName, string networkSecurityGroupName, string secu
 66        {
 467            using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.Get");
 468            scope.Start();
 69            try
 70            {
 471                return RestClient.Get(resourceGroupName, networkSecurityGroupName, securityRuleName, cancellationToken);
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 478        }
 79
 80        /// <summary> Gets all security rules in a network security group. </summary>
 81        /// <param name="resourceGroupName"> The name of the resource group. </param>
 82        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 83        /// <param name="cancellationToken"> The cancellation token to use. </param>
 84        public virtual AsyncPageable<SecurityRule> ListAsync(string resourceGroupName, string networkSecurityGroupName, 
 85        {
 486            if (resourceGroupName == null)
 87            {
 088                throw new ArgumentNullException(nameof(resourceGroupName));
 89            }
 490            if (networkSecurityGroupName == null)
 91            {
 092                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 93            }
 94
 95            async Task<Page<SecurityRule>> FirstPageFunc(int? pageSizeHint)
 96            {
 497                using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.List");
 498                scope.Start();
 99                try
 100                {
 4101                    var response = await RestClient.ListAsync(resourceGroupName, networkSecurityGroupName, cancellationT
 4102                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 103                }
 0104                catch (Exception e)
 105                {
 0106                    scope.Failed(e);
 0107                    throw;
 108                }
 4109            }
 110            async Task<Page<SecurityRule>> NextPageFunc(string nextLink, int? pageSizeHint)
 111            {
 0112                using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.List");
 0113                scope.Start();
 114                try
 115                {
 0116                    var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, networkSecurityGroupN
 0117                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 118                }
 0119                catch (Exception e)
 120                {
 0121                    scope.Failed(e);
 0122                    throw;
 123                }
 0124            }
 4125            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 126        }
 127
 128        /// <summary> Gets all security rules in a network security group. </summary>
 129        /// <param name="resourceGroupName"> The name of the resource group. </param>
 130        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 131        /// <param name="cancellationToken"> The cancellation token to use. </param>
 132        public virtual Pageable<SecurityRule> List(string resourceGroupName, string networkSecurityGroupName, Cancellati
 133        {
 4134            if (resourceGroupName == null)
 135            {
 0136                throw new ArgumentNullException(nameof(resourceGroupName));
 137            }
 4138            if (networkSecurityGroupName == null)
 139            {
 0140                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 141            }
 142
 143            Page<SecurityRule> FirstPageFunc(int? pageSizeHint)
 144            {
 4145                using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.List");
 4146                scope.Start();
 147                try
 148                {
 4149                    var response = RestClient.List(resourceGroupName, networkSecurityGroupName, cancellationToken);
 4150                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 151                }
 0152                catch (Exception e)
 153                {
 0154                    scope.Failed(e);
 0155                    throw;
 156                }
 4157            }
 158            Page<SecurityRule> NextPageFunc(string nextLink, int? pageSizeHint)
 159            {
 0160                using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.List");
 0161                scope.Start();
 162                try
 163                {
 0164                    var response = RestClient.ListNextPage(nextLink, resourceGroupName, networkSecurityGroupName, cancel
 0165                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 166                }
 0167                catch (Exception e)
 168                {
 0169                    scope.Failed(e);
 0170                    throw;
 171                }
 0172            }
 4173            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 174        }
 175
 176        /// <summary> Deletes the specified network security rule. </summary>
 177        /// <param name="resourceGroupName"> The name of the resource group. </param>
 178        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 179        /// <param name="securityRuleName"> The name of the security rule. </param>
 180        /// <param name="cancellationToken"> The cancellation token to use. </param>
 181        public virtual async Task<SecurityRulesDeleteOperation> StartDeleteAsync(string resourceGroupName, string networ
 182        {
 2183            if (resourceGroupName == null)
 184            {
 0185                throw new ArgumentNullException(nameof(resourceGroupName));
 186            }
 2187            if (networkSecurityGroupName == null)
 188            {
 0189                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 190            }
 2191            if (securityRuleName == null)
 192            {
 0193                throw new ArgumentNullException(nameof(securityRuleName));
 194            }
 195
 2196            using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.StartDelete");
 2197            scope.Start();
 198            try
 199            {
 2200                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, networkSecurityGroupName, securit
 2201                return new SecurityRulesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(re
 202            }
 0203            catch (Exception e)
 204            {
 0205                scope.Failed(e);
 0206                throw;
 207            }
 2208        }
 209
 210        /// <summary> Deletes the specified network security rule. </summary>
 211        /// <param name="resourceGroupName"> The name of the resource group. </param>
 212        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 213        /// <param name="securityRuleName"> The name of the security rule. </param>
 214        /// <param name="cancellationToken"> The cancellation token to use. </param>
 215        public virtual SecurityRulesDeleteOperation StartDelete(string resourceGroupName, string networkSecurityGroupNam
 216        {
 2217            if (resourceGroupName == null)
 218            {
 0219                throw new ArgumentNullException(nameof(resourceGroupName));
 220            }
 2221            if (networkSecurityGroupName == null)
 222            {
 0223                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 224            }
 2225            if (securityRuleName == null)
 226            {
 0227                throw new ArgumentNullException(nameof(securityRuleName));
 228            }
 229
 2230            using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.StartDelete");
 2231            scope.Start();
 232            try
 233            {
 2234                var originalResponse = RestClient.Delete(resourceGroupName, networkSecurityGroupName, securityRuleName, 
 2235                return new SecurityRulesDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(re
 236            }
 0237            catch (Exception e)
 238            {
 0239                scope.Failed(e);
 0240                throw;
 241            }
 2242        }
 243
 244        /// <summary> Creates or updates a security rule in the specified network security group. </summary>
 245        /// <param name="resourceGroupName"> The name of the resource group. </param>
 246        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 247        /// <param name="securityRuleName"> The name of the security rule. </param>
 248        /// <param name="securityRuleParameters"> Parameters supplied to the create or update network security rule oper
 249        /// <param name="cancellationToken"> The cancellation token to use. </param>
 250        public virtual async Task<SecurityRulesCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupNam
 251        {
 2252            if (resourceGroupName == null)
 253            {
 0254                throw new ArgumentNullException(nameof(resourceGroupName));
 255            }
 2256            if (networkSecurityGroupName == null)
 257            {
 0258                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 259            }
 2260            if (securityRuleName == null)
 261            {
 0262                throw new ArgumentNullException(nameof(securityRuleName));
 263            }
 2264            if (securityRuleParameters == null)
 265            {
 0266                throw new ArgumentNullException(nameof(securityRuleParameters));
 267            }
 268
 2269            using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.StartCreateOrUpdate");
 2270            scope.Start();
 271            try
 272            {
 2273                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, networkSecurityGroupName,
 2274                return new SecurityRulesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOr
 275            }
 0276            catch (Exception e)
 277            {
 0278                scope.Failed(e);
 0279                throw;
 280            }
 2281        }
 282
 283        /// <summary> Creates or updates a security rule in the specified network security group. </summary>
 284        /// <param name="resourceGroupName"> The name of the resource group. </param>
 285        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 286        /// <param name="securityRuleName"> The name of the security rule. </param>
 287        /// <param name="securityRuleParameters"> Parameters supplied to the create or update network security rule oper
 288        /// <param name="cancellationToken"> The cancellation token to use. </param>
 289        public virtual SecurityRulesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string network
 290        {
 2291            if (resourceGroupName == null)
 292            {
 0293                throw new ArgumentNullException(nameof(resourceGroupName));
 294            }
 2295            if (networkSecurityGroupName == null)
 296            {
 0297                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 298            }
 2299            if (securityRuleName == null)
 300            {
 0301                throw new ArgumentNullException(nameof(securityRuleName));
 302            }
 2303            if (securityRuleParameters == null)
 304            {
 0305                throw new ArgumentNullException(nameof(securityRuleParameters));
 306            }
 307
 2308            using var scope = _clientDiagnostics.CreateScope("SecurityRulesOperations.StartCreateOrUpdate");
 2309            scope.Start();
 310            try
 311            {
 2312                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, networkSecurityGroupName, securityRu
 2313                return new SecurityRulesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOr
 314            }
 0315            catch (Exception e)
 316            {
 0317                scope.Failed(e);
 0318                throw;
 319            }
 2320        }
 321    }
 322}