< Summary

Class:Azure.ResourceManager.Network.NetworkSecurityGroupsOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\NetworkSecurityGroupsOperations.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\NetworkSecurityGroupsOperations.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 NetworkSecurityGroups service client. </summary>
 19    public partial class NetworkSecurityGroupsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 13623        internal NetworkSecurityGroupsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of NetworkSecurityGroupsOperations for mocking. </summary>
 9625        protected NetworkSecurityGroupsOperations()
 26        {
 9627        }
 28        /// <summary> Initializes a new instance of NetworkSecurityGroupsOperations. </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>
 9633        internal NetworkSecurityGroupsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subs
 34        {
 9635            RestClient = new NetworkSecurityGroupsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 9636            _clientDiagnostics = clientDiagnostics;
 9637            _pipeline = pipeline;
 9638        }
 39
 40        /// <summary> Gets the specified network security group. </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="expand"> Expands referenced resources. </param>
 44        /// <param name="cancellationToken"> The cancellation token to use. </param>
 45        public virtual async Task<Response<NetworkSecurityGroup>> GetAsync(string resourceGroupName, string networkSecur
 46        {
 1447            using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.Get");
 1448            scope.Start();
 49            try
 50            {
 1451                return await RestClient.GetAsync(resourceGroupName, networkSecurityGroupName, expand, cancellationToken)
 52            }
 053            catch (Exception e)
 54            {
 055                scope.Failed(e);
 056                throw;
 57            }
 1458        }
 59
 60        /// <summary> Gets the specified network security group. </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="expand"> Expands referenced resources. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<NetworkSecurityGroup> Get(string resourceGroupName, string networkSecurityGroupName, str
 66        {
 1467            using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.Get");
 1468            scope.Start();
 69            try
 70            {
 1471                return RestClient.Get(resourceGroupName, networkSecurityGroupName, expand, cancellationToken);
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 1478        }
 79
 80        /// <summary> Updates a network security group tags. </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="parameters"> Parameters supplied to update network security group tags. </param>
 84        /// <param name="cancellationToken"> The cancellation token to use. </param>
 85        public virtual async Task<Response<NetworkSecurityGroup>> UpdateTagsAsync(string resourceGroupName, string netwo
 86        {
 087            using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.UpdateTags");
 088            scope.Start();
 89            try
 90            {
 091                return await RestClient.UpdateTagsAsync(resourceGroupName, networkSecurityGroupName, parameters, cancell
 92            }
 093            catch (Exception e)
 94            {
 095                scope.Failed(e);
 096                throw;
 97            }
 098        }
 99
 100        /// <summary> Updates a network security group tags. </summary>
 101        /// <param name="resourceGroupName"> The name of the resource group. </param>
 102        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 103        /// <param name="parameters"> Parameters supplied to update network security group tags. </param>
 104        /// <param name="cancellationToken"> The cancellation token to use. </param>
 105        public virtual Response<NetworkSecurityGroup> UpdateTags(string resourceGroupName, string networkSecurityGroupNa
 106        {
 0107            using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.UpdateTags");
 0108            scope.Start();
 109            try
 110            {
 0111                return RestClient.UpdateTags(resourceGroupName, networkSecurityGroupName, parameters, cancellationToken)
 112            }
 0113            catch (Exception e)
 114            {
 0115                scope.Failed(e);
 0116                throw;
 117            }
 0118        }
 119
 120        /// <summary> Gets all network security groups in a subscription. </summary>
 121        /// <param name="cancellationToken"> The cancellation token to use. </param>
 122        public virtual AsyncPageable<NetworkSecurityGroup> ListAllAsync(CancellationToken cancellationToken = default)
 123        {
 124            async Task<Page<NetworkSecurityGroup>> FirstPageFunc(int? pageSizeHint)
 125            {
 4126                using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.ListAll");
 4127                scope.Start();
 128                try
 129                {
 4130                    var response = await RestClient.ListAllAsync(cancellationToken).ConfigureAwait(false);
 4131                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 132                }
 0133                catch (Exception e)
 134                {
 0135                    scope.Failed(e);
 0136                    throw;
 137                }
 4138            }
 139            async Task<Page<NetworkSecurityGroup>> NextPageFunc(string nextLink, int? pageSizeHint)
 140            {
 0141                using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.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            }
 4154            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 155        }
 156
 157        /// <summary> Gets all network security groups in a subscription. </summary>
 158        /// <param name="cancellationToken"> The cancellation token to use. </param>
 159        public virtual Pageable<NetworkSecurityGroup> ListAll(CancellationToken cancellationToken = default)
 160        {
 161            Page<NetworkSecurityGroup> FirstPageFunc(int? pageSizeHint)
 162            {
 4163                using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.ListAll");
 4164                scope.Start();
 165                try
 166                {
 4167                    var response = RestClient.ListAll(cancellationToken);
 4168                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 169                }
 0170                catch (Exception e)
 171                {
 0172                    scope.Failed(e);
 0173                    throw;
 174                }
 4175            }
 176            Page<NetworkSecurityGroup> NextPageFunc(string nextLink, int? pageSizeHint)
 177            {
 0178                using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.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            }
 4191            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 192        }
 193
 194        /// <summary> Gets all network security groups 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<NetworkSecurityGroup> ListAsync(string resourceGroupName, CancellationToken cancell
 198        {
 10199            if (resourceGroupName == null)
 200            {
 0201                throw new ArgumentNullException(nameof(resourceGroupName));
 202            }
 203
 204            async Task<Page<NetworkSecurityGroup>> FirstPageFunc(int? pageSizeHint)
 205            {
 10206                using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.List");
 10207                scope.Start();
 208                try
 209                {
 10210                    var response = await RestClient.ListAsync(resourceGroupName, cancellationToken).ConfigureAwait(false
 10211                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 212                }
 0213                catch (Exception e)
 214                {
 0215                    scope.Failed(e);
 0216                    throw;
 217                }
 10218            }
 219            async Task<Page<NetworkSecurityGroup>> NextPageFunc(string nextLink, int? pageSizeHint)
 220            {
 0221                using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.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            }
 10234            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 235        }
 236
 237        /// <summary> Gets all network security groups 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<NetworkSecurityGroup> List(string resourceGroupName, CancellationToken cancellationToken
 241        {
 10242            if (resourceGroupName == null)
 243            {
 0244                throw new ArgumentNullException(nameof(resourceGroupName));
 245            }
 246
 247            Page<NetworkSecurityGroup> FirstPageFunc(int? pageSizeHint)
 248            {
 10249                using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.List");
 10250                scope.Start();
 251                try
 252                {
 10253                    var response = RestClient.List(resourceGroupName, cancellationToken);
 10254                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 255                }
 0256                catch (Exception e)
 257                {
 0258                    scope.Failed(e);
 0259                    throw;
 260                }
 10261            }
 262            Page<NetworkSecurityGroup> NextPageFunc(string nextLink, int? pageSizeHint)
 263            {
 0264                using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.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            }
 10277            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 278        }
 279
 280        /// <summary> Deletes the specified network security group. </summary>
 281        /// <param name="resourceGroupName"> The name of the resource group. </param>
 282        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 283        /// <param name="cancellationToken"> The cancellation token to use. </param>
 284        public virtual async Task<NetworkSecurityGroupsDeleteOperation> StartDeleteAsync(string resourceGroupName, strin
 285        {
 8286            if (resourceGroupName == null)
 287            {
 0288                throw new ArgumentNullException(nameof(resourceGroupName));
 289            }
 8290            if (networkSecurityGroupName == null)
 291            {
 0292                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 293            }
 294
 8295            using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.StartDelete");
 8296            scope.Start();
 297            try
 298            {
 8299                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, networkSecurityGroupName, cancell
 8300                return new NetworkSecurityGroupsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRe
 301            }
 0302            catch (Exception e)
 303            {
 0304                scope.Failed(e);
 0305                throw;
 306            }
 8307        }
 308
 309        /// <summary> Deletes the specified network security group. </summary>
 310        /// <param name="resourceGroupName"> The name of the resource group. </param>
 311        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 312        /// <param name="cancellationToken"> The cancellation token to use. </param>
 313        public virtual NetworkSecurityGroupsDeleteOperation StartDelete(string resourceGroupName, string networkSecurity
 314        {
 8315            if (resourceGroupName == null)
 316            {
 0317                throw new ArgumentNullException(nameof(resourceGroupName));
 318            }
 8319            if (networkSecurityGroupName == null)
 320            {
 0321                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 322            }
 323
 8324            using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.StartDelete");
 8325            scope.Start();
 326            try
 327            {
 8328                var originalResponse = RestClient.Delete(resourceGroupName, networkSecurityGroupName, cancellationToken)
 8329                return new NetworkSecurityGroupsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRe
 330            }
 0331            catch (Exception e)
 332            {
 0333                scope.Failed(e);
 0334                throw;
 335            }
 8336        }
 337
 338        /// <summary> Creates or updates a network security group in the specified resource group. </summary>
 339        /// <param name="resourceGroupName"> The name of the resource group. </param>
 340        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 341        /// <param name="parameters"> Parameters supplied to the create or update network security group operation. </pa
 342        /// <param name="cancellationToken"> The cancellation token to use. </param>
 343        public virtual async Task<NetworkSecurityGroupsCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resource
 344        {
 12345            if (resourceGroupName == null)
 346            {
 0347                throw new ArgumentNullException(nameof(resourceGroupName));
 348            }
 12349            if (networkSecurityGroupName == null)
 350            {
 0351                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 352            }
 12353            if (parameters == null)
 354            {
 0355                throw new ArgumentNullException(nameof(parameters));
 356            }
 357
 12358            using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.StartCreateOrUpdate");
 12359            scope.Start();
 360            try
 361            {
 12362                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, networkSecurityGroupName,
 12363                return new NetworkSecurityGroupsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.Create
 364            }
 0365            catch (Exception e)
 366            {
 0367                scope.Failed(e);
 0368                throw;
 369            }
 12370        }
 371
 372        /// <summary> Creates or updates a network security group in the specified resource group. </summary>
 373        /// <param name="resourceGroupName"> The name of the resource group. </param>
 374        /// <param name="networkSecurityGroupName"> The name of the network security group. </param>
 375        /// <param name="parameters"> Parameters supplied to the create or update network security group operation. </pa
 376        /// <param name="cancellationToken"> The cancellation token to use. </param>
 377        public virtual NetworkSecurityGroupsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string
 378        {
 12379            if (resourceGroupName == null)
 380            {
 0381                throw new ArgumentNullException(nameof(resourceGroupName));
 382            }
 12383            if (networkSecurityGroupName == null)
 384            {
 0385                throw new ArgumentNullException(nameof(networkSecurityGroupName));
 386            }
 12387            if (parameters == null)
 388            {
 0389                throw new ArgumentNullException(nameof(parameters));
 390            }
 391
 12392            using var scope = _clientDiagnostics.CreateScope("NetworkSecurityGroupsOperations.StartCreateOrUpdate");
 12393            scope.Start();
 394            try
 395            {
 12396                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, networkSecurityGroupName, parameters
 12397                return new NetworkSecurityGroupsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.Create
 398            }
 0399            catch (Exception e)
 400            {
 0401                scope.Failed(e);
 0402                throw;
 403            }
 12404        }
 405    }
 406}