< Summary

Class:Azure.ResourceManager.Network.SubnetsOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\SubnetsOperations.cs
Covered lines:66
Uncovered lines:122
Coverable lines:188
Total lines:480
Line coverage:35.1% (66 of 188)
Covered branches:18
Total branches:68
Branch coverage:26.4% (18 of 68)

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%
StartPrepareNetworkPoliciesAsync()-0%0%
StartPrepareNetworkPolicies(...)-0%0%
StartUnprepareNetworkPoliciesAsync()-0%0%
StartUnprepareNetworkPolicies(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\SubnetsOperations.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 Subnets service client. </summary>
 19    public partial class SubnetsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 9223        internal SubnetsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of SubnetsOperations for mocking. </summary>
 8425        protected SubnetsOperations()
 26        {
 8427        }
 28        /// <summary> Initializes a new instance of SubnetsOperations. </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>
 8433        internal SubnetsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Ur
 34        {
 8435            RestClient = new SubnetsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 8436            _clientDiagnostics = clientDiagnostics;
 8437            _pipeline = pipeline;
 8438        }
 39
 40        /// <summary> Gets the specified subnet by virtual network and resource group. </summary>
 41        /// <param name="resourceGroupName"> The name of the resource group. </param>
 42        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 43        /// <param name="subnetName"> The name of the subnet. </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<Subnet>> GetAsync(string resourceGroupName, string virtualNetworkName, string
 47        {
 3448            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.Get");
 3449            scope.Start();
 50            try
 51            {
 3452                return await RestClient.GetAsync(resourceGroupName, virtualNetworkName, subnetName, expand, cancellation
 53            }
 054            catch (Exception e)
 55            {
 056                scope.Failed(e);
 057                throw;
 58            }
 3459        }
 60
 61        /// <summary> Gets the specified subnet by virtual network and resource group. </summary>
 62        /// <param name="resourceGroupName"> The name of the resource group. </param>
 63        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 64        /// <param name="subnetName"> The name of the subnet. </param>
 65        /// <param name="expand"> Expands referenced resources. </param>
 66        /// <param name="cancellationToken"> The cancellation token to use. </param>
 67        public virtual Response<Subnet> Get(string resourceGroupName, string virtualNetworkName, string subnetName, stri
 68        {
 3469            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.Get");
 3470            scope.Start();
 71            try
 72            {
 3473                return RestClient.Get(resourceGroupName, virtualNetworkName, subnetName, expand, cancellationToken);
 74            }
 075            catch (Exception e)
 76            {
 077                scope.Failed(e);
 078                throw;
 79            }
 3480        }
 81
 82        /// <summary> Gets all subnets in a virtual network. </summary>
 83        /// <param name="resourceGroupName"> The name of the resource group. </param>
 84        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 85        /// <param name="cancellationToken"> The cancellation token to use. </param>
 86        public virtual AsyncPageable<Subnet> ListAsync(string resourceGroupName, string virtualNetworkName, Cancellation
 87        {
 488            if (resourceGroupName == null)
 89            {
 090                throw new ArgumentNullException(nameof(resourceGroupName));
 91            }
 492            if (virtualNetworkName == null)
 93            {
 094                throw new ArgumentNullException(nameof(virtualNetworkName));
 95            }
 96
 97            async Task<Page<Subnet>> FirstPageFunc(int? pageSizeHint)
 98            {
 499                using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.List");
 4100                scope.Start();
 101                try
 102                {
 4103                    var response = await RestClient.ListAsync(resourceGroupName, virtualNetworkName, cancellationToken).
 4104                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 105                }
 0106                catch (Exception e)
 107                {
 0108                    scope.Failed(e);
 0109                    throw;
 110                }
 4111            }
 112            async Task<Page<Subnet>> NextPageFunc(string nextLink, int? pageSizeHint)
 113            {
 0114                using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.List");
 0115                scope.Start();
 116                try
 117                {
 0118                    var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, virtualNetworkName, c
 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            }
 4127            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 128        }
 129
 130        /// <summary> Gets all subnets in a virtual network. </summary>
 131        /// <param name="resourceGroupName"> The name of the resource group. </param>
 132        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 133        /// <param name="cancellationToken"> The cancellation token to use. </param>
 134        public virtual Pageable<Subnet> List(string resourceGroupName, string virtualNetworkName, CancellationToken canc
 135        {
 4136            if (resourceGroupName == null)
 137            {
 0138                throw new ArgumentNullException(nameof(resourceGroupName));
 139            }
 4140            if (virtualNetworkName == null)
 141            {
 0142                throw new ArgumentNullException(nameof(virtualNetworkName));
 143            }
 144
 145            Page<Subnet> FirstPageFunc(int? pageSizeHint)
 146            {
 4147                using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.List");
 4148                scope.Start();
 149                try
 150                {
 4151                    var response = RestClient.List(resourceGroupName, virtualNetworkName, cancellationToken);
 4152                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 153                }
 0154                catch (Exception e)
 155                {
 0156                    scope.Failed(e);
 0157                    throw;
 158                }
 4159            }
 160            Page<Subnet> NextPageFunc(string nextLink, int? pageSizeHint)
 161            {
 0162                using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.List");
 0163                scope.Start();
 164                try
 165                {
 0166                    var response = RestClient.ListNextPage(nextLink, resourceGroupName, virtualNetworkName, cancellation
 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            }
 4175            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 176        }
 177
 178        /// <summary> Deletes the specified subnet. </summary>
 179        /// <param name="resourceGroupName"> The name of the resource group. </param>
 180        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 181        /// <param name="subnetName"> The name of the subnet. </param>
 182        /// <param name="cancellationToken"> The cancellation token to use. </param>
 183        public virtual async Task<SubnetsDeleteOperation> StartDeleteAsync(string resourceGroupName, string virtualNetwo
 184        {
 2185            if (resourceGroupName == null)
 186            {
 0187                throw new ArgumentNullException(nameof(resourceGroupName));
 188            }
 2189            if (virtualNetworkName == null)
 190            {
 0191                throw new ArgumentNullException(nameof(virtualNetworkName));
 192            }
 2193            if (subnetName == null)
 194            {
 0195                throw new ArgumentNullException(nameof(subnetName));
 196            }
 197
 2198            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.StartDelete");
 2199            scope.Start();
 200            try
 201            {
 2202                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, virtualNetworkName, subnetName, c
 2203                return new SubnetsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resource
 204            }
 0205            catch (Exception e)
 206            {
 0207                scope.Failed(e);
 0208                throw;
 209            }
 2210        }
 211
 212        /// <summary> Deletes the specified subnet. </summary>
 213        /// <param name="resourceGroupName"> The name of the resource group. </param>
 214        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 215        /// <param name="subnetName"> The name of the subnet. </param>
 216        /// <param name="cancellationToken"> The cancellation token to use. </param>
 217        public virtual SubnetsDeleteOperation StartDelete(string resourceGroupName, string virtualNetworkName, string su
 218        {
 2219            if (resourceGroupName == null)
 220            {
 0221                throw new ArgumentNullException(nameof(resourceGroupName));
 222            }
 2223            if (virtualNetworkName == null)
 224            {
 0225                throw new ArgumentNullException(nameof(virtualNetworkName));
 226            }
 2227            if (subnetName == null)
 228            {
 0229                throw new ArgumentNullException(nameof(subnetName));
 230            }
 231
 2232            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.StartDelete");
 2233            scope.Start();
 234            try
 235            {
 2236                var originalResponse = RestClient.Delete(resourceGroupName, virtualNetworkName, subnetName, cancellation
 2237                return new SubnetsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(resource
 238            }
 0239            catch (Exception e)
 240            {
 0241                scope.Failed(e);
 0242                throw;
 243            }
 2244        }
 245
 246        /// <summary> Creates or updates a subnet in the specified virtual network. </summary>
 247        /// <param name="resourceGroupName"> The name of the resource group. </param>
 248        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 249        /// <param name="subnetName"> The name of the subnet. </param>
 250        /// <param name="subnetParameters"> Parameters supplied to the create or update subnet operation. </param>
 251        /// <param name="cancellationToken"> The cancellation token to use. </param>
 252        public virtual async Task<SubnetsCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupName, str
 253        {
 2254            if (resourceGroupName == null)
 255            {
 0256                throw new ArgumentNullException(nameof(resourceGroupName));
 257            }
 2258            if (virtualNetworkName == null)
 259            {
 0260                throw new ArgumentNullException(nameof(virtualNetworkName));
 261            }
 2262            if (subnetName == null)
 263            {
 0264                throw new ArgumentNullException(nameof(subnetName));
 265            }
 2266            if (subnetParameters == null)
 267            {
 0268                throw new ArgumentNullException(nameof(subnetParameters));
 269            }
 270
 2271            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.StartCreateOrUpdate");
 2272            scope.Start();
 273            try
 274            {
 2275                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, virtualNetworkName, subne
 2276                return new SubnetsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdate
 277            }
 0278            catch (Exception e)
 279            {
 0280                scope.Failed(e);
 0281                throw;
 282            }
 2283        }
 284
 285        /// <summary> Creates or updates a subnet in the specified virtual network. </summary>
 286        /// <param name="resourceGroupName"> The name of the resource group. </param>
 287        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 288        /// <param name="subnetName"> The name of the subnet. </param>
 289        /// <param name="subnetParameters"> Parameters supplied to the create or update subnet operation. </param>
 290        /// <param name="cancellationToken"> The cancellation token to use. </param>
 291        public virtual SubnetsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string virtualNetwor
 292        {
 2293            if (resourceGroupName == null)
 294            {
 0295                throw new ArgumentNullException(nameof(resourceGroupName));
 296            }
 2297            if (virtualNetworkName == null)
 298            {
 0299                throw new ArgumentNullException(nameof(virtualNetworkName));
 300            }
 2301            if (subnetName == null)
 302            {
 0303                throw new ArgumentNullException(nameof(subnetName));
 304            }
 2305            if (subnetParameters == null)
 306            {
 0307                throw new ArgumentNullException(nameof(subnetParameters));
 308            }
 309
 2310            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.StartCreateOrUpdate");
 2311            scope.Start();
 312            try
 313            {
 2314                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, virtualNetworkName, subnetName, subn
 2315                return new SubnetsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdate
 316            }
 0317            catch (Exception e)
 318            {
 0319                scope.Failed(e);
 0320                throw;
 321            }
 2322        }
 323
 324        /// <summary> Prepares a subnet by applying network intent policies. </summary>
 325        /// <param name="resourceGroupName"> The name of the resource group. </param>
 326        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 327        /// <param name="subnetName"> The name of the subnet. </param>
 328        /// <param name="prepareNetworkPoliciesRequestParameters"> Parameters supplied to prepare subnet by applying net
 329        /// <param name="cancellationToken"> The cancellation token to use. </param>
 330        public virtual async Task<SubnetsPrepareNetworkPoliciesOperation> StartPrepareNetworkPoliciesAsync(string resour
 331        {
 0332            if (resourceGroupName == null)
 333            {
 0334                throw new ArgumentNullException(nameof(resourceGroupName));
 335            }
 0336            if (virtualNetworkName == null)
 337            {
 0338                throw new ArgumentNullException(nameof(virtualNetworkName));
 339            }
 0340            if (subnetName == null)
 341            {
 0342                throw new ArgumentNullException(nameof(subnetName));
 343            }
 0344            if (prepareNetworkPoliciesRequestParameters == null)
 345            {
 0346                throw new ArgumentNullException(nameof(prepareNetworkPoliciesRequestParameters));
 347            }
 348
 0349            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.StartPrepareNetworkPolicies");
 0350            scope.Start();
 351            try
 352            {
 0353                var originalResponse = await RestClient.PrepareNetworkPoliciesAsync(resourceGroupName, virtualNetworkNam
 0354                return new SubnetsPrepareNetworkPoliciesOperation(_clientDiagnostics, _pipeline, RestClient.CreatePrepar
 355            }
 0356            catch (Exception e)
 357            {
 0358                scope.Failed(e);
 0359                throw;
 360            }
 0361        }
 362
 363        /// <summary> Prepares a subnet by applying network intent policies. </summary>
 364        /// <param name="resourceGroupName"> The name of the resource group. </param>
 365        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 366        /// <param name="subnetName"> The name of the subnet. </param>
 367        /// <param name="prepareNetworkPoliciesRequestParameters"> Parameters supplied to prepare subnet by applying net
 368        /// <param name="cancellationToken"> The cancellation token to use. </param>
 369        public virtual SubnetsPrepareNetworkPoliciesOperation StartPrepareNetworkPolicies(string resourceGroupName, stri
 370        {
 0371            if (resourceGroupName == null)
 372            {
 0373                throw new ArgumentNullException(nameof(resourceGroupName));
 374            }
 0375            if (virtualNetworkName == null)
 376            {
 0377                throw new ArgumentNullException(nameof(virtualNetworkName));
 378            }
 0379            if (subnetName == null)
 380            {
 0381                throw new ArgumentNullException(nameof(subnetName));
 382            }
 0383            if (prepareNetworkPoliciesRequestParameters == null)
 384            {
 0385                throw new ArgumentNullException(nameof(prepareNetworkPoliciesRequestParameters));
 386            }
 387
 0388            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.StartPrepareNetworkPolicies");
 0389            scope.Start();
 390            try
 391            {
 0392                var originalResponse = RestClient.PrepareNetworkPolicies(resourceGroupName, virtualNetworkName, subnetNa
 0393                return new SubnetsPrepareNetworkPoliciesOperation(_clientDiagnostics, _pipeline, RestClient.CreatePrepar
 394            }
 0395            catch (Exception e)
 396            {
 0397                scope.Failed(e);
 0398                throw;
 399            }
 0400        }
 401
 402        /// <summary> Unprepares a subnet by removing network intent policies. </summary>
 403        /// <param name="resourceGroupName"> The name of the resource group. </param>
 404        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 405        /// <param name="subnetName"> The name of the subnet. </param>
 406        /// <param name="unprepareNetworkPoliciesRequestParameters"> Parameters supplied to unprepare subnet to remove n
 407        /// <param name="cancellationToken"> The cancellation token to use. </param>
 408        public virtual async Task<SubnetsUnprepareNetworkPoliciesOperation> StartUnprepareNetworkPoliciesAsync(string re
 409        {
 0410            if (resourceGroupName == null)
 411            {
 0412                throw new ArgumentNullException(nameof(resourceGroupName));
 413            }
 0414            if (virtualNetworkName == null)
 415            {
 0416                throw new ArgumentNullException(nameof(virtualNetworkName));
 417            }
 0418            if (subnetName == null)
 419            {
 0420                throw new ArgumentNullException(nameof(subnetName));
 421            }
 0422            if (unprepareNetworkPoliciesRequestParameters == null)
 423            {
 0424                throw new ArgumentNullException(nameof(unprepareNetworkPoliciesRequestParameters));
 425            }
 426
 0427            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.StartUnprepareNetworkPolicies");
 0428            scope.Start();
 429            try
 430            {
 0431                var originalResponse = await RestClient.UnprepareNetworkPoliciesAsync(resourceGroupName, virtualNetworkN
 0432                return new SubnetsUnprepareNetworkPoliciesOperation(_clientDiagnostics, _pipeline, RestClient.CreateUnpr
 433            }
 0434            catch (Exception e)
 435            {
 0436                scope.Failed(e);
 0437                throw;
 438            }
 0439        }
 440
 441        /// <summary> Unprepares a subnet by removing network intent policies. </summary>
 442        /// <param name="resourceGroupName"> The name of the resource group. </param>
 443        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 444        /// <param name="subnetName"> The name of the subnet. </param>
 445        /// <param name="unprepareNetworkPoliciesRequestParameters"> Parameters supplied to unprepare subnet to remove n
 446        /// <param name="cancellationToken"> The cancellation token to use. </param>
 447        public virtual SubnetsUnprepareNetworkPoliciesOperation StartUnprepareNetworkPolicies(string resourceGroupName, 
 448        {
 0449            if (resourceGroupName == null)
 450            {
 0451                throw new ArgumentNullException(nameof(resourceGroupName));
 452            }
 0453            if (virtualNetworkName == null)
 454            {
 0455                throw new ArgumentNullException(nameof(virtualNetworkName));
 456            }
 0457            if (subnetName == null)
 458            {
 0459                throw new ArgumentNullException(nameof(subnetName));
 460            }
 0461            if (unprepareNetworkPoliciesRequestParameters == null)
 462            {
 0463                throw new ArgumentNullException(nameof(unprepareNetworkPoliciesRequestParameters));
 464            }
 465
 0466            using var scope = _clientDiagnostics.CreateScope("SubnetsOperations.StartUnprepareNetworkPolicies");
 0467            scope.Start();
 468            try
 469            {
 0470                var originalResponse = RestClient.UnprepareNetworkPolicies(resourceGroupName, virtualNetworkName, subnet
 0471                return new SubnetsUnprepareNetworkPoliciesOperation(_clientDiagnostics, _pipeline, RestClient.CreateUnpr
 472            }
 0473            catch (Exception e)
 474            {
 0475                scope.Failed(e);
 0476                throw;
 477            }
 0478        }
 479    }
 480}