< Summary

Class:Azure.ResourceManager.Network.DefaultSecurityRulesOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\DefaultSecurityRulesOperations.cs
Covered lines:32
Uncovered lines:32
Coverable lines:64
Total lines:176
Line coverage:50% (32 of 64)
Covered branches:4
Total branches:8
Branch coverage:50% (4 of 8)

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%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\DefaultSecurityRulesOperations.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 DefaultSecurityRules service client. </summary>
 19    public partial class DefaultSecurityRulesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 823        internal DefaultSecurityRulesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of DefaultSecurityRulesOperations for mocking. </summary>
 825        protected DefaultSecurityRulesOperations()
 26        {
 827        }
 28        /// <summary> Initializes a new instance of DefaultSecurityRulesOperations. </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>
 833        internal DefaultSecurityRulesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subsc
 34        {
 835            RestClient = new DefaultSecurityRulesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 836            _clientDiagnostics = clientDiagnostics;
 837            _pipeline = pipeline;
 838        }
 39
 40        /// <summary> Get the specified default 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="defaultSecurityRuleName"> The name of the default 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        {
 247            using var scope = _clientDiagnostics.CreateScope("DefaultSecurityRulesOperations.Get");
 248            scope.Start();
 49            try
 50            {
 251                return await RestClient.GetAsync(resourceGroupName, networkSecurityGroupName, defaultSecurityRuleName, c
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 258        }
 59
 60        /// <summary> Get the specified default 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="defaultSecurityRuleName"> The name of the default security rule. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<SecurityRule> Get(string resourceGroupName, string networkSecurityGroupName, string defa
 66        {
 267            using var scope = _clientDiagnostics.CreateScope("DefaultSecurityRulesOperations.Get");
 268            scope.Start();
 69            try
 70            {
 271                return RestClient.Get(resourceGroupName, networkSecurityGroupName, defaultSecurityRuleName, cancellation
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 278        }
 79
 80        /// <summary> Gets all default 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        {
 286            if (resourceGroupName == null)
 87            {
 088                throw new ArgumentNullException(nameof(resourceGroupName));
 89            }
 290            if (networkSecurityGroupName == null)
 91            {
 092                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 93            }
 94
 95            async Task<Page<SecurityRule>> FirstPageFunc(int? pageSizeHint)
 96            {
 297                using var scope = _clientDiagnostics.CreateScope("DefaultSecurityRulesOperations.List");
 298                scope.Start();
 99                try
 100                {
 2101                    var response = await RestClient.ListAsync(resourceGroupName, networkSecurityGroupName, cancellationT
 2102                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 103                }
 0104                catch (Exception e)
 105                {
 0106                    scope.Failed(e);
 0107                    throw;
 108                }
 2109            }
 110            async Task<Page<SecurityRule>> NextPageFunc(string nextLink, int? pageSizeHint)
 111            {
 0112                using var scope = _clientDiagnostics.CreateScope("DefaultSecurityRulesOperations.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            }
 2125            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 126        }
 127
 128        /// <summary> Gets all default 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        {
 2134            if (resourceGroupName == null)
 135            {
 0136                throw new ArgumentNullException(nameof(resourceGroupName));
 137            }
 2138            if (networkSecurityGroupName == null)
 139            {
 0140                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 141            }
 142
 143            Page<SecurityRule> FirstPageFunc(int? pageSizeHint)
 144            {
 2145                using var scope = _clientDiagnostics.CreateScope("DefaultSecurityRulesOperations.List");
 2146                scope.Start();
 147                try
 148                {
 2149                    var response = RestClient.List(resourceGroupName, networkSecurityGroupName, cancellationToken);
 2150                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 151                }
 0152                catch (Exception e)
 153                {
 0154                    scope.Failed(e);
 0155                    throw;
 156                }
 2157            }
 158            Page<SecurityRule> NextPageFunc(string nextLink, int? pageSizeHint)
 159            {
 0160                using var scope = _clientDiagnostics.CreateScope("DefaultSecurityRulesOperations.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            }
 2173            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 174        }
 175    }
 176}