< Summary

Class:Azure.ResourceManager.Network.SubnetsRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\SubnetsRestOperations.cs
Covered lines:157
Uncovered lines:177
Coverable lines:334
Total lines:733
Line coverage:47% (157 of 334)
Covered branches:44
Total branches:154
Branch coverage:28.5% (44 of 154)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-66.67%50%
Delete(...)-66.67%50%
CreateGetRequest(...)-100%100%
GetAsync()-70.59%50%
Get(...)-70.59%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-64.29%50%
CreateOrUpdate(...)-64.29%50%
CreatePrepareNetworkPoliciesRequest(...)-0%100%
PrepareNetworkPoliciesAsync()-0%0%
PrepareNetworkPolicies(...)-0%0%
CreateUnprepareNetworkPoliciesRequest(...)-0%100%
UnprepareNetworkPoliciesAsync()-0%0%
UnprepareNetworkPolicies(...)-0%0%
CreateListRequest(...)-100%100%
ListAsync()-73.33%50%
List(...)-73.33%50%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\SubnetsRestOperations.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.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Core;
 14using Azure.Core.Pipeline;
 15using Azure.ResourceManager.Network.Models;
 16
 17namespace Azure.ResourceManager.Network
 18{
 19    internal partial class SubnetsRestOperations
 20    {
 21        private string subscriptionId;
 22        private Uri endpoint;
 23        private ClientDiagnostics _clientDiagnostics;
 24        private HttpPipeline _pipeline;
 25
 26        /// <summary> Initializes a new instance of SubnetsRestOperations. </summary>
 27        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 28        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 29        /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 8432        public SubnetsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, 
 33        {
 8434            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 8438            endpoint ??= new Uri("https://management.azure.com");
 39
 8440            this.subscriptionId = subscriptionId;
 8441            this.endpoint = endpoint;
 8442            _clientDiagnostics = clientDiagnostics;
 8443            _pipeline = pipeline;
 8444        }
 45
 46        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string virtualNetworkName, string subnetName)
 47        {
 848            var message = _pipeline.CreateMessage();
 849            var request = message.Request;
 850            request.Method = RequestMethod.Delete;
 851            var uri = new RawRequestUriBuilder();
 852            uri.Reset(endpoint);
 853            uri.AppendPath("/subscriptions/", false);
 854            uri.AppendPath(subscriptionId, true);
 855            uri.AppendPath("/resourceGroups/", false);
 856            uri.AppendPath(resourceGroupName, true);
 857            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 858            uri.AppendPath(virtualNetworkName, true);
 859            uri.AppendPath("/subnets/", false);
 860            uri.AppendPath(subnetName, true);
 861            uri.AppendQuery("api-version", "2020-04-01", true);
 862            request.Uri = uri;
 863            return message;
 64        }
 65
 66        /// <summary> Deletes the specified subnet. </summary>
 67        /// <param name="resourceGroupName"> The name of the resource group. </param>
 68        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 69        /// <param name="subnetName"> The name of the subnet. </param>
 70        /// <param name="cancellationToken"> The cancellation token to use. </param>
 71        public async Task<Response> DeleteAsync(string resourceGroupName, string virtualNetworkName, string subnetName, 
 72        {
 273            if (resourceGroupName == null)
 74            {
 075                throw new ArgumentNullException(nameof(resourceGroupName));
 76            }
 277            if (virtualNetworkName == null)
 78            {
 079                throw new ArgumentNullException(nameof(virtualNetworkName));
 80            }
 281            if (subnetName == null)
 82            {
 083                throw new ArgumentNullException(nameof(subnetName));
 84            }
 85
 286            using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkName, subnetName);
 287            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 288            switch (message.Response.Status)
 89            {
 90                case 200:
 91                case 202:
 92                case 204:
 293                    return message.Response;
 94                default:
 095                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 96            }
 297        }
 98
 99        /// <summary> Deletes the specified subnet. </summary>
 100        /// <param name="resourceGroupName"> The name of the resource group. </param>
 101        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 102        /// <param name="subnetName"> The name of the subnet. </param>
 103        /// <param name="cancellationToken"> The cancellation token to use. </param>
 104        public Response Delete(string resourceGroupName, string virtualNetworkName, string subnetName, CancellationToken
 105        {
 2106            if (resourceGroupName == null)
 107            {
 0108                throw new ArgumentNullException(nameof(resourceGroupName));
 109            }
 2110            if (virtualNetworkName == null)
 111            {
 0112                throw new ArgumentNullException(nameof(virtualNetworkName));
 113            }
 2114            if (subnetName == null)
 115            {
 0116                throw new ArgumentNullException(nameof(subnetName));
 117            }
 118
 2119            using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkName, subnetName);
 2120            _pipeline.Send(message, cancellationToken);
 2121            switch (message.Response.Status)
 122            {
 123                case 200:
 124                case 202:
 125                case 204:
 2126                    return message.Response;
 127                default:
 0128                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 129            }
 2130        }
 131
 132        internal HttpMessage CreateGetRequest(string resourceGroupName, string virtualNetworkName, string subnetName, st
 133        {
 68134            var message = _pipeline.CreateMessage();
 68135            var request = message.Request;
 68136            request.Method = RequestMethod.Get;
 68137            var uri = new RawRequestUriBuilder();
 68138            uri.Reset(endpoint);
 68139            uri.AppendPath("/subscriptions/", false);
 68140            uri.AppendPath(subscriptionId, true);
 68141            uri.AppendPath("/resourceGroups/", false);
 68142            uri.AppendPath(resourceGroupName, true);
 68143            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 68144            uri.AppendPath(virtualNetworkName, true);
 68145            uri.AppendPath("/subnets/", false);
 68146            uri.AppendPath(subnetName, true);
 68147            uri.AppendQuery("api-version", "2020-04-01", true);
 68148            if (expand != null)
 149            {
 4150                uri.AppendQuery("$expand", expand, true);
 151            }
 68152            request.Uri = uri;
 68153            return message;
 154        }
 155
 156        /// <summary> Gets the specified subnet by virtual network and resource group. </summary>
 157        /// <param name="resourceGroupName"> The name of the resource group. </param>
 158        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 159        /// <param name="subnetName"> The name of the subnet. </param>
 160        /// <param name="expand"> Expands referenced resources. </param>
 161        /// <param name="cancellationToken"> The cancellation token to use. </param>
 162        public async Task<Response<Subnet>> GetAsync(string resourceGroupName, string virtualNetworkName, string subnetN
 163        {
 34164            if (resourceGroupName == null)
 165            {
 0166                throw new ArgumentNullException(nameof(resourceGroupName));
 167            }
 34168            if (virtualNetworkName == null)
 169            {
 0170                throw new ArgumentNullException(nameof(virtualNetworkName));
 171            }
 34172            if (subnetName == null)
 173            {
 0174                throw new ArgumentNullException(nameof(subnetName));
 175            }
 176
 34177            using var message = CreateGetRequest(resourceGroupName, virtualNetworkName, subnetName, expand);
 34178            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 34179            switch (message.Response.Status)
 180            {
 181                case 200:
 182                    {
 34183                        Subnet value = default;
 34184                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 34185                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 186                        {
 0187                            value = null;
 188                        }
 189                        else
 190                        {
 34191                            value = Subnet.DeserializeSubnet(document.RootElement);
 192                        }
 34193                        return Response.FromValue(value, message.Response);
 194                    }
 195                default:
 0196                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 197            }
 34198        }
 199
 200        /// <summary> Gets the specified subnet by virtual network and resource group. </summary>
 201        /// <param name="resourceGroupName"> The name of the resource group. </param>
 202        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 203        /// <param name="subnetName"> The name of the subnet. </param>
 204        /// <param name="expand"> Expands referenced resources. </param>
 205        /// <param name="cancellationToken"> The cancellation token to use. </param>
 206        public Response<Subnet> Get(string resourceGroupName, string virtualNetworkName, string subnetName, string expan
 207        {
 34208            if (resourceGroupName == null)
 209            {
 0210                throw new ArgumentNullException(nameof(resourceGroupName));
 211            }
 34212            if (virtualNetworkName == null)
 213            {
 0214                throw new ArgumentNullException(nameof(virtualNetworkName));
 215            }
 34216            if (subnetName == null)
 217            {
 0218                throw new ArgumentNullException(nameof(subnetName));
 219            }
 220
 34221            using var message = CreateGetRequest(resourceGroupName, virtualNetworkName, subnetName, expand);
 34222            _pipeline.Send(message, cancellationToken);
 34223            switch (message.Response.Status)
 224            {
 225                case 200:
 226                    {
 34227                        Subnet value = default;
 34228                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 34229                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 230                        {
 0231                            value = null;
 232                        }
 233                        else
 234                        {
 34235                            value = Subnet.DeserializeSubnet(document.RootElement);
 236                        }
 34237                        return Response.FromValue(value, message.Response);
 238                    }
 239                default:
 0240                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 241            }
 34242        }
 243
 244        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string virtualNetworkName, string sub
 245        {
 8246            var message = _pipeline.CreateMessage();
 8247            var request = message.Request;
 8248            request.Method = RequestMethod.Put;
 8249            var uri = new RawRequestUriBuilder();
 8250            uri.Reset(endpoint);
 8251            uri.AppendPath("/subscriptions/", false);
 8252            uri.AppendPath(subscriptionId, true);
 8253            uri.AppendPath("/resourceGroups/", false);
 8254            uri.AppendPath(resourceGroupName, true);
 8255            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 8256            uri.AppendPath(virtualNetworkName, true);
 8257            uri.AppendPath("/subnets/", false);
 8258            uri.AppendPath(subnetName, true);
 8259            uri.AppendQuery("api-version", "2020-04-01", true);
 8260            request.Uri = uri;
 8261            request.Headers.Add("Content-Type", "application/json");
 8262            var content = new Utf8JsonRequestContent();
 8263            content.JsonWriter.WriteObjectValue(subnetParameters);
 8264            request.Content = content;
 8265            return message;
 266        }
 267
 268        /// <summary> Creates or updates a subnet in the specified virtual network. </summary>
 269        /// <param name="resourceGroupName"> The name of the resource group. </param>
 270        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 271        /// <param name="subnetName"> The name of the subnet. </param>
 272        /// <param name="subnetParameters"> Parameters supplied to the create or update subnet operation. </param>
 273        /// <param name="cancellationToken"> The cancellation token to use. </param>
 274        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string virtualNetworkName, string subn
 275        {
 2276            if (resourceGroupName == null)
 277            {
 0278                throw new ArgumentNullException(nameof(resourceGroupName));
 279            }
 2280            if (virtualNetworkName == null)
 281            {
 0282                throw new ArgumentNullException(nameof(virtualNetworkName));
 283            }
 2284            if (subnetName == null)
 285            {
 0286                throw new ArgumentNullException(nameof(subnetName));
 287            }
 2288            if (subnetParameters == null)
 289            {
 0290                throw new ArgumentNullException(nameof(subnetParameters));
 291            }
 292
 2293            using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkName, subnetName, subnetPar
 2294            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2295            switch (message.Response.Status)
 296            {
 297                case 200:
 298                case 201:
 2299                    return message.Response;
 300                default:
 0301                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 302            }
 2303        }
 304
 305        /// <summary> Creates or updates a subnet in the specified virtual network. </summary>
 306        /// <param name="resourceGroupName"> The name of the resource group. </param>
 307        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 308        /// <param name="subnetName"> The name of the subnet. </param>
 309        /// <param name="subnetParameters"> Parameters supplied to the create or update subnet operation. </param>
 310        /// <param name="cancellationToken"> The cancellation token to use. </param>
 311        public Response CreateOrUpdate(string resourceGroupName, string virtualNetworkName, string subnetName, Subnet su
 312        {
 2313            if (resourceGroupName == null)
 314            {
 0315                throw new ArgumentNullException(nameof(resourceGroupName));
 316            }
 2317            if (virtualNetworkName == null)
 318            {
 0319                throw new ArgumentNullException(nameof(virtualNetworkName));
 320            }
 2321            if (subnetName == null)
 322            {
 0323                throw new ArgumentNullException(nameof(subnetName));
 324            }
 2325            if (subnetParameters == null)
 326            {
 0327                throw new ArgumentNullException(nameof(subnetParameters));
 328            }
 329
 2330            using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkName, subnetName, subnetPar
 2331            _pipeline.Send(message, cancellationToken);
 2332            switch (message.Response.Status)
 333            {
 334                case 200:
 335                case 201:
 2336                    return message.Response;
 337                default:
 0338                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 339            }
 2340        }
 341
 342        internal HttpMessage CreatePrepareNetworkPoliciesRequest(string resourceGroupName, string virtualNetworkName, st
 343        {
 0344            var message = _pipeline.CreateMessage();
 0345            var request = message.Request;
 0346            request.Method = RequestMethod.Post;
 0347            var uri = new RawRequestUriBuilder();
 0348            uri.Reset(endpoint);
 0349            uri.AppendPath("/subscriptions/", false);
 0350            uri.AppendPath(subscriptionId, true);
 0351            uri.AppendPath("/resourceGroups/", false);
 0352            uri.AppendPath(resourceGroupName, true);
 0353            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 0354            uri.AppendPath(virtualNetworkName, true);
 0355            uri.AppendPath("/subnets/", false);
 0356            uri.AppendPath(subnetName, true);
 0357            uri.AppendPath("/PrepareNetworkPolicies", false);
 0358            uri.AppendQuery("api-version", "2020-04-01", true);
 0359            request.Uri = uri;
 0360            request.Headers.Add("Content-Type", "application/json");
 0361            var content = new Utf8JsonRequestContent();
 0362            content.JsonWriter.WriteObjectValue(prepareNetworkPoliciesRequestParameters);
 0363            request.Content = content;
 0364            return message;
 365        }
 366
 367        /// <summary> Prepares a subnet by applying network intent policies. </summary>
 368        /// <param name="resourceGroupName"> The name of the resource group. </param>
 369        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 370        /// <param name="subnetName"> The name of the subnet. </param>
 371        /// <param name="prepareNetworkPoliciesRequestParameters"> Parameters supplied to prepare subnet by applying net
 372        /// <param name="cancellationToken"> The cancellation token to use. </param>
 373        public async Task<Response> PrepareNetworkPoliciesAsync(string resourceGroupName, string virtualNetworkName, str
 374        {
 0375            if (resourceGroupName == null)
 376            {
 0377                throw new ArgumentNullException(nameof(resourceGroupName));
 378            }
 0379            if (virtualNetworkName == null)
 380            {
 0381                throw new ArgumentNullException(nameof(virtualNetworkName));
 382            }
 0383            if (subnetName == null)
 384            {
 0385                throw new ArgumentNullException(nameof(subnetName));
 386            }
 0387            if (prepareNetworkPoliciesRequestParameters == null)
 388            {
 0389                throw new ArgumentNullException(nameof(prepareNetworkPoliciesRequestParameters));
 390            }
 391
 0392            using var message = CreatePrepareNetworkPoliciesRequest(resourceGroupName, virtualNetworkName, subnetName, p
 0393            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0394            switch (message.Response.Status)
 395            {
 396                case 200:
 397                case 202:
 0398                    return message.Response;
 399                default:
 0400                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 401            }
 0402        }
 403
 404        /// <summary> Prepares a subnet by applying network intent policies. </summary>
 405        /// <param name="resourceGroupName"> The name of the resource group. </param>
 406        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 407        /// <param name="subnetName"> The name of the subnet. </param>
 408        /// <param name="prepareNetworkPoliciesRequestParameters"> Parameters supplied to prepare subnet by applying net
 409        /// <param name="cancellationToken"> The cancellation token to use. </param>
 410        public Response PrepareNetworkPolicies(string resourceGroupName, string virtualNetworkName, string subnetName, P
 411        {
 0412            if (resourceGroupName == null)
 413            {
 0414                throw new ArgumentNullException(nameof(resourceGroupName));
 415            }
 0416            if (virtualNetworkName == null)
 417            {
 0418                throw new ArgumentNullException(nameof(virtualNetworkName));
 419            }
 0420            if (subnetName == null)
 421            {
 0422                throw new ArgumentNullException(nameof(subnetName));
 423            }
 0424            if (prepareNetworkPoliciesRequestParameters == null)
 425            {
 0426                throw new ArgumentNullException(nameof(prepareNetworkPoliciesRequestParameters));
 427            }
 428
 0429            using var message = CreatePrepareNetworkPoliciesRequest(resourceGroupName, virtualNetworkName, subnetName, p
 0430            _pipeline.Send(message, cancellationToken);
 0431            switch (message.Response.Status)
 432            {
 433                case 200:
 434                case 202:
 0435                    return message.Response;
 436                default:
 0437                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 438            }
 0439        }
 440
 441        internal HttpMessage CreateUnprepareNetworkPoliciesRequest(string resourceGroupName, string virtualNetworkName, 
 442        {
 0443            var message = _pipeline.CreateMessage();
 0444            var request = message.Request;
 0445            request.Method = RequestMethod.Post;
 0446            var uri = new RawRequestUriBuilder();
 0447            uri.Reset(endpoint);
 0448            uri.AppendPath("/subscriptions/", false);
 0449            uri.AppendPath(subscriptionId, true);
 0450            uri.AppendPath("/resourceGroups/", false);
 0451            uri.AppendPath(resourceGroupName, true);
 0452            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 0453            uri.AppendPath(virtualNetworkName, true);
 0454            uri.AppendPath("/subnets/", false);
 0455            uri.AppendPath(subnetName, true);
 0456            uri.AppendPath("/UnprepareNetworkPolicies", false);
 0457            uri.AppendQuery("api-version", "2020-04-01", true);
 0458            request.Uri = uri;
 0459            request.Headers.Add("Content-Type", "application/json");
 0460            var content = new Utf8JsonRequestContent();
 0461            content.JsonWriter.WriteObjectValue(unprepareNetworkPoliciesRequestParameters);
 0462            request.Content = content;
 0463            return message;
 464        }
 465
 466        /// <summary> Unprepares a subnet by removing network intent policies. </summary>
 467        /// <param name="resourceGroupName"> The name of the resource group. </param>
 468        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 469        /// <param name="subnetName"> The name of the subnet. </param>
 470        /// <param name="unprepareNetworkPoliciesRequestParameters"> Parameters supplied to unprepare subnet to remove n
 471        /// <param name="cancellationToken"> The cancellation token to use. </param>
 472        public async Task<Response> UnprepareNetworkPoliciesAsync(string resourceGroupName, string virtualNetworkName, s
 473        {
 0474            if (resourceGroupName == null)
 475            {
 0476                throw new ArgumentNullException(nameof(resourceGroupName));
 477            }
 0478            if (virtualNetworkName == null)
 479            {
 0480                throw new ArgumentNullException(nameof(virtualNetworkName));
 481            }
 0482            if (subnetName == null)
 483            {
 0484                throw new ArgumentNullException(nameof(subnetName));
 485            }
 0486            if (unprepareNetworkPoliciesRequestParameters == null)
 487            {
 0488                throw new ArgumentNullException(nameof(unprepareNetworkPoliciesRequestParameters));
 489            }
 490
 0491            using var message = CreateUnprepareNetworkPoliciesRequest(resourceGroupName, virtualNetworkName, subnetName,
 0492            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0493            switch (message.Response.Status)
 494            {
 495                case 200:
 496                case 202:
 0497                    return message.Response;
 498                default:
 0499                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 500            }
 0501        }
 502
 503        /// <summary> Unprepares a subnet by removing network intent policies. </summary>
 504        /// <param name="resourceGroupName"> The name of the resource group. </param>
 505        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 506        /// <param name="subnetName"> The name of the subnet. </param>
 507        /// <param name="unprepareNetworkPoliciesRequestParameters"> Parameters supplied to unprepare subnet to remove n
 508        /// <param name="cancellationToken"> The cancellation token to use. </param>
 509        public Response UnprepareNetworkPolicies(string resourceGroupName, string virtualNetworkName, string subnetName,
 510        {
 0511            if (resourceGroupName == null)
 512            {
 0513                throw new ArgumentNullException(nameof(resourceGroupName));
 514            }
 0515            if (virtualNetworkName == null)
 516            {
 0517                throw new ArgumentNullException(nameof(virtualNetworkName));
 518            }
 0519            if (subnetName == null)
 520            {
 0521                throw new ArgumentNullException(nameof(subnetName));
 522            }
 0523            if (unprepareNetworkPoliciesRequestParameters == null)
 524            {
 0525                throw new ArgumentNullException(nameof(unprepareNetworkPoliciesRequestParameters));
 526            }
 527
 0528            using var message = CreateUnprepareNetworkPoliciesRequest(resourceGroupName, virtualNetworkName, subnetName,
 0529            _pipeline.Send(message, cancellationToken);
 0530            switch (message.Response.Status)
 531            {
 532                case 200:
 533                case 202:
 0534                    return message.Response;
 535                default:
 0536                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 537            }
 0538        }
 539
 540        internal HttpMessage CreateListRequest(string resourceGroupName, string virtualNetworkName)
 541        {
 8542            var message = _pipeline.CreateMessage();
 8543            var request = message.Request;
 8544            request.Method = RequestMethod.Get;
 8545            var uri = new RawRequestUriBuilder();
 8546            uri.Reset(endpoint);
 8547            uri.AppendPath("/subscriptions/", false);
 8548            uri.AppendPath(subscriptionId, true);
 8549            uri.AppendPath("/resourceGroups/", false);
 8550            uri.AppendPath(resourceGroupName, true);
 8551            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 8552            uri.AppendPath(virtualNetworkName, true);
 8553            uri.AppendPath("/subnets", false);
 8554            uri.AppendQuery("api-version", "2020-04-01", true);
 8555            request.Uri = uri;
 8556            return message;
 557        }
 558
 559        /// <summary> Gets all subnets in a virtual network. </summary>
 560        /// <param name="resourceGroupName"> The name of the resource group. </param>
 561        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 562        /// <param name="cancellationToken"> The cancellation token to use. </param>
 563        public async Task<Response<SubnetListResult>> ListAsync(string resourceGroupName, string virtualNetworkName, Can
 564        {
 4565            if (resourceGroupName == null)
 566            {
 0567                throw new ArgumentNullException(nameof(resourceGroupName));
 568            }
 4569            if (virtualNetworkName == null)
 570            {
 0571                throw new ArgumentNullException(nameof(virtualNetworkName));
 572            }
 573
 4574            using var message = CreateListRequest(resourceGroupName, virtualNetworkName);
 4575            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4576            switch (message.Response.Status)
 577            {
 578                case 200:
 579                    {
 4580                        SubnetListResult value = default;
 4581                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4582                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 583                        {
 0584                            value = null;
 585                        }
 586                        else
 587                        {
 4588                            value = SubnetListResult.DeserializeSubnetListResult(document.RootElement);
 589                        }
 4590                        return Response.FromValue(value, message.Response);
 591                    }
 592                default:
 0593                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 594            }
 4595        }
 596
 597        /// <summary> Gets all subnets in a virtual network. </summary>
 598        /// <param name="resourceGroupName"> The name of the resource group. </param>
 599        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 600        /// <param name="cancellationToken"> The cancellation token to use. </param>
 601        public Response<SubnetListResult> List(string resourceGroupName, string virtualNetworkName, CancellationToken ca
 602        {
 4603            if (resourceGroupName == null)
 604            {
 0605                throw new ArgumentNullException(nameof(resourceGroupName));
 606            }
 4607            if (virtualNetworkName == null)
 608            {
 0609                throw new ArgumentNullException(nameof(virtualNetworkName));
 610            }
 611
 4612            using var message = CreateListRequest(resourceGroupName, virtualNetworkName);
 4613            _pipeline.Send(message, cancellationToken);
 4614            switch (message.Response.Status)
 615            {
 616                case 200:
 617                    {
 4618                        SubnetListResult value = default;
 4619                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4620                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 621                        {
 0622                            value = null;
 623                        }
 624                        else
 625                        {
 4626                            value = SubnetListResult.DeserializeSubnetListResult(document.RootElement);
 627                        }
 4628                        return Response.FromValue(value, message.Response);
 629                    }
 630                default:
 0631                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 632            }
 4633        }
 634
 635        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string virtualNetworkN
 636        {
 0637            var message = _pipeline.CreateMessage();
 0638            var request = message.Request;
 0639            request.Method = RequestMethod.Get;
 0640            var uri = new RawRequestUriBuilder();
 0641            uri.Reset(endpoint);
 0642            uri.AppendRawNextLink(nextLink, false);
 0643            request.Uri = uri;
 0644            return message;
 645        }
 646
 647        /// <summary> Gets all subnets in a virtual network. </summary>
 648        /// <param name="nextLink"> The URL to the next page of results. </param>
 649        /// <param name="resourceGroupName"> The name of the resource group. </param>
 650        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 651        /// <param name="cancellationToken"> The cancellation token to use. </param>
 652        public async Task<Response<SubnetListResult>> ListNextPageAsync(string nextLink, string resourceGroupName, strin
 653        {
 0654            if (nextLink == null)
 655            {
 0656                throw new ArgumentNullException(nameof(nextLink));
 657            }
 0658            if (resourceGroupName == null)
 659            {
 0660                throw new ArgumentNullException(nameof(resourceGroupName));
 661            }
 0662            if (virtualNetworkName == null)
 663            {
 0664                throw new ArgumentNullException(nameof(virtualNetworkName));
 665            }
 666
 0667            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualNetworkName);
 0668            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0669            switch (message.Response.Status)
 670            {
 671                case 200:
 672                    {
 0673                        SubnetListResult value = default;
 0674                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0675                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 676                        {
 0677                            value = null;
 678                        }
 679                        else
 680                        {
 0681                            value = SubnetListResult.DeserializeSubnetListResult(document.RootElement);
 682                        }
 0683                        return Response.FromValue(value, message.Response);
 684                    }
 685                default:
 0686                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 687            }
 0688        }
 689
 690        /// <summary> Gets all subnets in a virtual network. </summary>
 691        /// <param name="nextLink"> The URL to the next page of results. </param>
 692        /// <param name="resourceGroupName"> The name of the resource group. </param>
 693        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 694        /// <param name="cancellationToken"> The cancellation token to use. </param>
 695        public Response<SubnetListResult> ListNextPage(string nextLink, string resourceGroupName, string virtualNetworkN
 696        {
 0697            if (nextLink == null)
 698            {
 0699                throw new ArgumentNullException(nameof(nextLink));
 700            }
 0701            if (resourceGroupName == null)
 702            {
 0703                throw new ArgumentNullException(nameof(resourceGroupName));
 704            }
 0705            if (virtualNetworkName == null)
 706            {
 0707                throw new ArgumentNullException(nameof(virtualNetworkName));
 708            }
 709
 0710            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualNetworkName);
 0711            _pipeline.Send(message, cancellationToken);
 0712            switch (message.Response.Status)
 713            {
 714                case 200:
 715                    {
 0716                        SubnetListResult value = default;
 0717                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0718                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 719                        {
 0720                            value = null;
 721                        }
 722                        else
 723                        {
 0724                            value = SubnetListResult.DeserializeSubnetListResult(document.RootElement);
 725                        }
 0726                        return Response.FromValue(value, message.Response);
 727                    }
 728                default:
 0729                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 730            }
 0731        }
 732    }
 733}