< Summary

Class:Azure.ResourceManager.Network.VirtualNetworksRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\VirtualNetworksRestOperations.cs
Covered lines:246
Uncovered lines:218
Coverable lines:464
Total lines:1031
Line coverage:53% (246 of 464)
Covered branches:57
Total branches:182
Branch coverage:31.3% (57 of 182)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-70%50%
Delete(...)-70%50%
CreateGetRequest(...)-93.75%50%
GetAsync()-73.33%50%
Get(...)-73.33%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-66.67%50%
CreateOrUpdate(...)-66.67%50%
CreateUpdateTagsRequest(...)-0%100%
UpdateTagsAsync()-0%0%
UpdateTags(...)-0%0%
CreateListAllRequest()-100%100%
ListAllAsync()-81.82%50%
ListAll(...)-81.82%50%
CreateListRequest(...)-100%100%
ListAsync()-76.92%50%
List(...)-76.92%50%
CreateCheckIPAddressAvailabilityRequest(...)-100%100%
CheckIPAddressAvailabilityAsync()-70.59%50%
CheckIPAddressAvailability(...)-70.59%50%
CreateListUsageRequest(...)-100%100%
ListUsageAsync()-73.33%50%
ListUsage(...)-73.33%50%
CreateListAllNextPageRequest(...)-0%100%
ListAllNextPageAsync()-0%0%
ListAllNextPage(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%
CreateListUsageNextPageRequest(...)-0%100%
ListUsageNextPageAsync()-0%0%
ListUsageNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\VirtualNetworksRestOperations.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 VirtualNetworksRestOperations
 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 VirtualNetworksRestOperations. </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
 28032        public VirtualNetworksRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscrip
 33        {
 28034            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 28038            endpoint ??= new Uri("https://management.azure.com");
 39
 28040            this.subscriptionId = subscriptionId;
 28041            this.endpoint = endpoint;
 28042            _clientDiagnostics = clientDiagnostics;
 28043            _pipeline = pipeline;
 28044        }
 45
 46        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string virtualNetworkName)
 47        {
 15248            var message = _pipeline.CreateMessage();
 15249            var request = message.Request;
 15250            request.Method = RequestMethod.Delete;
 15251            var uri = new RawRequestUriBuilder();
 15252            uri.Reset(endpoint);
 15253            uri.AppendPath("/subscriptions/", false);
 15254            uri.AppendPath(subscriptionId, true);
 15255            uri.AppendPath("/resourceGroups/", false);
 15256            uri.AppendPath(resourceGroupName, true);
 15257            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 15258            uri.AppendPath(virtualNetworkName, true);
 15259            uri.AppendQuery("api-version", "2020-04-01", true);
 15260            request.Uri = uri;
 15261            return message;
 62        }
 63
 64        /// <summary> Deletes the specified virtual network. </summary>
 65        /// <param name="resourceGroupName"> The name of the resource group. </param>
 66        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 67        /// <param name="cancellationToken"> The cancellation token to use. </param>
 68        public async Task<Response> DeleteAsync(string resourceGroupName, string virtualNetworkName, CancellationToken c
 69        {
 3870            if (resourceGroupName == null)
 71            {
 072                throw new ArgumentNullException(nameof(resourceGroupName));
 73            }
 3874            if (virtualNetworkName == null)
 75            {
 076                throw new ArgumentNullException(nameof(virtualNetworkName));
 77            }
 78
 3879            using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkName);
 3880            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 3881            switch (message.Response.Status)
 82            {
 83                case 200:
 84                case 202:
 85                case 204:
 3886                    return message.Response;
 87                default:
 088                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 89            }
 3890        }
 91
 92        /// <summary> Deletes the specified virtual network. </summary>
 93        /// <param name="resourceGroupName"> The name of the resource group. </param>
 94        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 95        /// <param name="cancellationToken"> The cancellation token to use. </param>
 96        public Response Delete(string resourceGroupName, string virtualNetworkName, CancellationToken cancellationToken 
 97        {
 3898            if (resourceGroupName == null)
 99            {
 0100                throw new ArgumentNullException(nameof(resourceGroupName));
 101            }
 38102            if (virtualNetworkName == null)
 103            {
 0104                throw new ArgumentNullException(nameof(virtualNetworkName));
 105            }
 106
 38107            using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkName);
 38108            _pipeline.Send(message, cancellationToken);
 38109            switch (message.Response.Status)
 110            {
 111                case 200:
 112                case 202:
 113                case 204:
 38114                    return message.Response;
 115                default:
 0116                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 117            }
 38118        }
 119
 120        internal HttpMessage CreateGetRequest(string resourceGroupName, string virtualNetworkName, string expand)
 121        {
 60122            var message = _pipeline.CreateMessage();
 60123            var request = message.Request;
 60124            request.Method = RequestMethod.Get;
 60125            var uri = new RawRequestUriBuilder();
 60126            uri.Reset(endpoint);
 60127            uri.AppendPath("/subscriptions/", false);
 60128            uri.AppendPath(subscriptionId, true);
 60129            uri.AppendPath("/resourceGroups/", false);
 60130            uri.AppendPath(resourceGroupName, true);
 60131            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 60132            uri.AppendPath(virtualNetworkName, true);
 60133            uri.AppendQuery("api-version", "2020-04-01", true);
 60134            if (expand != null)
 135            {
 0136                uri.AppendQuery("$expand", expand, true);
 137            }
 60138            request.Uri = uri;
 60139            return message;
 140        }
 141
 142        /// <summary> Gets the specified virtual network by resource group. </summary>
 143        /// <param name="resourceGroupName"> The name of the resource group. </param>
 144        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 145        /// <param name="expand"> Expands referenced resources. </param>
 146        /// <param name="cancellationToken"> The cancellation token to use. </param>
 147        public async Task<Response<VirtualNetwork>> GetAsync(string resourceGroupName, string virtualNetworkName, string
 148        {
 30149            if (resourceGroupName == null)
 150            {
 0151                throw new ArgumentNullException(nameof(resourceGroupName));
 152            }
 30153            if (virtualNetworkName == null)
 154            {
 0155                throw new ArgumentNullException(nameof(virtualNetworkName));
 156            }
 157
 30158            using var message = CreateGetRequest(resourceGroupName, virtualNetworkName, expand);
 30159            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 30160            switch (message.Response.Status)
 161            {
 162                case 200:
 163                    {
 30164                        VirtualNetwork value = default;
 30165                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 30166                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 167                        {
 0168                            value = null;
 169                        }
 170                        else
 171                        {
 30172                            value = VirtualNetwork.DeserializeVirtualNetwork(document.RootElement);
 173                        }
 30174                        return Response.FromValue(value, message.Response);
 175                    }
 176                default:
 0177                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 178            }
 30179        }
 180
 181        /// <summary> Gets the specified virtual network by resource group. </summary>
 182        /// <param name="resourceGroupName"> The name of the resource group. </param>
 183        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 184        /// <param name="expand"> Expands referenced resources. </param>
 185        /// <param name="cancellationToken"> The cancellation token to use. </param>
 186        public Response<VirtualNetwork> Get(string resourceGroupName, string virtualNetworkName, string expand = null, C
 187        {
 30188            if (resourceGroupName == null)
 189            {
 0190                throw new ArgumentNullException(nameof(resourceGroupName));
 191            }
 30192            if (virtualNetworkName == null)
 193            {
 0194                throw new ArgumentNullException(nameof(virtualNetworkName));
 195            }
 196
 30197            using var message = CreateGetRequest(resourceGroupName, virtualNetworkName, expand);
 30198            _pipeline.Send(message, cancellationToken);
 30199            switch (message.Response.Status)
 200            {
 201                case 200:
 202                    {
 30203                        VirtualNetwork value = default;
 30204                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 30205                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 206                        {
 0207                            value = null;
 208                        }
 209                        else
 210                        {
 30211                            value = VirtualNetwork.DeserializeVirtualNetwork(document.RootElement);
 212                        }
 30213                        return Response.FromValue(value, message.Response);
 214                    }
 215                default:
 0216                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 217            }
 30218        }
 219
 220        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string virtualNetworkName, VirtualNet
 221        {
 216222            var message = _pipeline.CreateMessage();
 216223            var request = message.Request;
 216224            request.Method = RequestMethod.Put;
 216225            var uri = new RawRequestUriBuilder();
 216226            uri.Reset(endpoint);
 216227            uri.AppendPath("/subscriptions/", false);
 216228            uri.AppendPath(subscriptionId, true);
 216229            uri.AppendPath("/resourceGroups/", false);
 216230            uri.AppendPath(resourceGroupName, true);
 216231            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 216232            uri.AppendPath(virtualNetworkName, true);
 216233            uri.AppendQuery("api-version", "2020-04-01", true);
 216234            request.Uri = uri;
 216235            request.Headers.Add("Content-Type", "application/json");
 216236            var content = new Utf8JsonRequestContent();
 216237            content.JsonWriter.WriteObjectValue(parameters);
 216238            request.Content = content;
 216239            return message;
 240        }
 241
 242        /// <summary> Creates or updates a virtual network in the specified resource group. </summary>
 243        /// <param name="resourceGroupName"> The name of the resource group. </param>
 244        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 245        /// <param name="parameters"> Parameters supplied to the create or update virtual network operation. </param>
 246        /// <param name="cancellationToken"> The cancellation token to use. </param>
 247        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string virtualNetworkName, VirtualNetw
 248        {
 54249            if (resourceGroupName == null)
 250            {
 0251                throw new ArgumentNullException(nameof(resourceGroupName));
 252            }
 54253            if (virtualNetworkName == null)
 254            {
 0255                throw new ArgumentNullException(nameof(virtualNetworkName));
 256            }
 54257            if (parameters == null)
 258            {
 0259                throw new ArgumentNullException(nameof(parameters));
 260            }
 261
 54262            using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkName, parameters);
 54263            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 54264            switch (message.Response.Status)
 265            {
 266                case 200:
 267                case 201:
 54268                    return message.Response;
 269                default:
 0270                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 271            }
 54272        }
 273
 274        /// <summary> Creates or updates a virtual network in the specified resource group. </summary>
 275        /// <param name="resourceGroupName"> The name of the resource group. </param>
 276        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 277        /// <param name="parameters"> Parameters supplied to the create or update virtual network operation. </param>
 278        /// <param name="cancellationToken"> The cancellation token to use. </param>
 279        public Response CreateOrUpdate(string resourceGroupName, string virtualNetworkName, VirtualNetwork parameters, C
 280        {
 54281            if (resourceGroupName == null)
 282            {
 0283                throw new ArgumentNullException(nameof(resourceGroupName));
 284            }
 54285            if (virtualNetworkName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(virtualNetworkName));
 288            }
 54289            if (parameters == null)
 290            {
 0291                throw new ArgumentNullException(nameof(parameters));
 292            }
 293
 54294            using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkName, parameters);
 54295            _pipeline.Send(message, cancellationToken);
 54296            switch (message.Response.Status)
 297            {
 298                case 200:
 299                case 201:
 54300                    return message.Response;
 301                default:
 0302                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 303            }
 54304        }
 305
 306        internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string virtualNetworkName, TagsObject par
 307        {
 0308            var message = _pipeline.CreateMessage();
 0309            var request = message.Request;
 0310            request.Method = RequestMethod.Patch;
 0311            var uri = new RawRequestUriBuilder();
 0312            uri.Reset(endpoint);
 0313            uri.AppendPath("/subscriptions/", false);
 0314            uri.AppendPath(subscriptionId, true);
 0315            uri.AppendPath("/resourceGroups/", false);
 0316            uri.AppendPath(resourceGroupName, true);
 0317            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 0318            uri.AppendPath(virtualNetworkName, true);
 0319            uri.AppendQuery("api-version", "2020-04-01", true);
 0320            request.Uri = uri;
 0321            request.Headers.Add("Content-Type", "application/json");
 0322            var content = new Utf8JsonRequestContent();
 0323            content.JsonWriter.WriteObjectValue(parameters);
 0324            request.Content = content;
 0325            return message;
 326        }
 327
 328        /// <summary> Updates a virtual network tags. </summary>
 329        /// <param name="resourceGroupName"> The name of the resource group. </param>
 330        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 331        /// <param name="parameters"> Parameters supplied to update virtual network tags. </param>
 332        /// <param name="cancellationToken"> The cancellation token to use. </param>
 333        public async Task<Response<VirtualNetwork>> UpdateTagsAsync(string resourceGroupName, string virtualNetworkName,
 334        {
 0335            if (resourceGroupName == null)
 336            {
 0337                throw new ArgumentNullException(nameof(resourceGroupName));
 338            }
 0339            if (virtualNetworkName == null)
 340            {
 0341                throw new ArgumentNullException(nameof(virtualNetworkName));
 342            }
 0343            if (parameters == null)
 344            {
 0345                throw new ArgumentNullException(nameof(parameters));
 346            }
 347
 0348            using var message = CreateUpdateTagsRequest(resourceGroupName, virtualNetworkName, parameters);
 0349            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0350            switch (message.Response.Status)
 351            {
 352                case 200:
 353                    {
 0354                        VirtualNetwork value = default;
 0355                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0356                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 357                        {
 0358                            value = null;
 359                        }
 360                        else
 361                        {
 0362                            value = VirtualNetwork.DeserializeVirtualNetwork(document.RootElement);
 363                        }
 0364                        return Response.FromValue(value, message.Response);
 365                    }
 366                default:
 0367                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 368            }
 0369        }
 370
 371        /// <summary> Updates a virtual network tags. </summary>
 372        /// <param name="resourceGroupName"> The name of the resource group. </param>
 373        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 374        /// <param name="parameters"> Parameters supplied to update virtual network tags. </param>
 375        /// <param name="cancellationToken"> The cancellation token to use. </param>
 376        public Response<VirtualNetwork> UpdateTags(string resourceGroupName, string virtualNetworkName, TagsObject param
 377        {
 0378            if (resourceGroupName == null)
 379            {
 0380                throw new ArgumentNullException(nameof(resourceGroupName));
 381            }
 0382            if (virtualNetworkName == null)
 383            {
 0384                throw new ArgumentNullException(nameof(virtualNetworkName));
 385            }
 0386            if (parameters == null)
 387            {
 0388                throw new ArgumentNullException(nameof(parameters));
 389            }
 390
 0391            using var message = CreateUpdateTagsRequest(resourceGroupName, virtualNetworkName, parameters);
 0392            _pipeline.Send(message, cancellationToken);
 0393            switch (message.Response.Status)
 394            {
 395                case 200:
 396                    {
 0397                        VirtualNetwork value = default;
 0398                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0399                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 400                        {
 0401                            value = null;
 402                        }
 403                        else
 404                        {
 0405                            value = VirtualNetwork.DeserializeVirtualNetwork(document.RootElement);
 406                        }
 0407                        return Response.FromValue(value, message.Response);
 408                    }
 409                default:
 0410                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 411            }
 0412        }
 413
 414        internal HttpMessage CreateListAllRequest()
 415        {
 4416            var message = _pipeline.CreateMessage();
 4417            var request = message.Request;
 4418            request.Method = RequestMethod.Get;
 4419            var uri = new RawRequestUriBuilder();
 4420            uri.Reset(endpoint);
 4421            uri.AppendPath("/subscriptions/", false);
 4422            uri.AppendPath(subscriptionId, true);
 4423            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks", false);
 4424            uri.AppendQuery("api-version", "2020-04-01", true);
 4425            request.Uri = uri;
 4426            return message;
 427        }
 428
 429        /// <summary> Gets all virtual networks in a subscription. </summary>
 430        /// <param name="cancellationToken"> The cancellation token to use. </param>
 431        public async Task<Response<VirtualNetworkListResult>> ListAllAsync(CancellationToken cancellationToken = default
 432        {
 2433            using var message = CreateListAllRequest();
 2434            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2435            switch (message.Response.Status)
 436            {
 437                case 200:
 438                    {
 2439                        VirtualNetworkListResult value = default;
 2440                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2441                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 442                        {
 0443                            value = null;
 444                        }
 445                        else
 446                        {
 2447                            value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement);
 448                        }
 2449                        return Response.FromValue(value, message.Response);
 450                    }
 451                default:
 0452                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 453            }
 2454        }
 455
 456        /// <summary> Gets all virtual networks in a subscription. </summary>
 457        /// <param name="cancellationToken"> The cancellation token to use. </param>
 458        public Response<VirtualNetworkListResult> ListAll(CancellationToken cancellationToken = default)
 459        {
 2460            using var message = CreateListAllRequest();
 2461            _pipeline.Send(message, cancellationToken);
 2462            switch (message.Response.Status)
 463            {
 464                case 200:
 465                    {
 2466                        VirtualNetworkListResult value = default;
 2467                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2468                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 469                        {
 0470                            value = null;
 471                        }
 472                        else
 473                        {
 2474                            value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement);
 475                        }
 2476                        return Response.FromValue(value, message.Response);
 477                    }
 478                default:
 0479                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 480            }
 2481        }
 482
 483        internal HttpMessage CreateListRequest(string resourceGroupName)
 484        {
 16485            var message = _pipeline.CreateMessage();
 16486            var request = message.Request;
 16487            request.Method = RequestMethod.Get;
 16488            var uri = new RawRequestUriBuilder();
 16489            uri.Reset(endpoint);
 16490            uri.AppendPath("/subscriptions/", false);
 16491            uri.AppendPath(subscriptionId, true);
 16492            uri.AppendPath("/resourceGroups/", false);
 16493            uri.AppendPath(resourceGroupName, true);
 16494            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks", false);
 16495            uri.AppendQuery("api-version", "2020-04-01", true);
 16496            request.Uri = uri;
 16497            return message;
 498        }
 499
 500        /// <summary> Gets all virtual networks in a resource group. </summary>
 501        /// <param name="resourceGroupName"> The name of the resource group. </param>
 502        /// <param name="cancellationToken"> The cancellation token to use. </param>
 503        public async Task<Response<VirtualNetworkListResult>> ListAsync(string resourceGroupName, CancellationToken canc
 504        {
 8505            if (resourceGroupName == null)
 506            {
 0507                throw new ArgumentNullException(nameof(resourceGroupName));
 508            }
 509
 8510            using var message = CreateListRequest(resourceGroupName);
 8511            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 8512            switch (message.Response.Status)
 513            {
 514                case 200:
 515                    {
 8516                        VirtualNetworkListResult value = default;
 8517                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 8518                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 519                        {
 0520                            value = null;
 521                        }
 522                        else
 523                        {
 8524                            value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement);
 525                        }
 8526                        return Response.FromValue(value, message.Response);
 527                    }
 528                default:
 0529                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 530            }
 8531        }
 532
 533        /// <summary> Gets all virtual networks in a resource group. </summary>
 534        /// <param name="resourceGroupName"> The name of the resource group. </param>
 535        /// <param name="cancellationToken"> The cancellation token to use. </param>
 536        public Response<VirtualNetworkListResult> List(string resourceGroupName, CancellationToken cancellationToken = d
 537        {
 8538            if (resourceGroupName == null)
 539            {
 0540                throw new ArgumentNullException(nameof(resourceGroupName));
 541            }
 542
 8543            using var message = CreateListRequest(resourceGroupName);
 8544            _pipeline.Send(message, cancellationToken);
 8545            switch (message.Response.Status)
 546            {
 547                case 200:
 548                    {
 8549                        VirtualNetworkListResult value = default;
 8550                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 8551                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 552                        {
 0553                            value = null;
 554                        }
 555                        else
 556                        {
 8557                            value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement);
 558                        }
 8559                        return Response.FromValue(value, message.Response);
 560                    }
 561                default:
 0562                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 563            }
 8564        }
 565
 566        internal HttpMessage CreateCheckIPAddressAvailabilityRequest(string resourceGroupName, string virtualNetworkName
 567        {
 8568            var message = _pipeline.CreateMessage();
 8569            var request = message.Request;
 8570            request.Method = RequestMethod.Get;
 8571            var uri = new RawRequestUriBuilder();
 8572            uri.Reset(endpoint);
 8573            uri.AppendPath("/subscriptions/", false);
 8574            uri.AppendPath(subscriptionId, true);
 8575            uri.AppendPath("/resourceGroups/", false);
 8576            uri.AppendPath(resourceGroupName, true);
 8577            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 8578            uri.AppendPath(virtualNetworkName, true);
 8579            uri.AppendPath("/CheckIPAddressAvailability", false);
 8580            uri.AppendQuery("ipAddress", ipAddress, true);
 8581            uri.AppendQuery("api-version", "2020-04-01", true);
 8582            request.Uri = uri;
 8583            return message;
 584        }
 585
 586        /// <summary> Checks whether a private IP address is available for use. </summary>
 587        /// <param name="resourceGroupName"> The name of the resource group. </param>
 588        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 589        /// <param name="ipAddress"> The private IP address to be verified. </param>
 590        /// <param name="cancellationToken"> The cancellation token to use. </param>
 591        public async Task<Response<IPAddressAvailabilityResult>> CheckIPAddressAvailabilityAsync(string resourceGroupNam
 592        {
 4593            if (resourceGroupName == null)
 594            {
 0595                throw new ArgumentNullException(nameof(resourceGroupName));
 596            }
 4597            if (virtualNetworkName == null)
 598            {
 0599                throw new ArgumentNullException(nameof(virtualNetworkName));
 600            }
 4601            if (ipAddress == null)
 602            {
 0603                throw new ArgumentNullException(nameof(ipAddress));
 604            }
 605
 4606            using var message = CreateCheckIPAddressAvailabilityRequest(resourceGroupName, virtualNetworkName, ipAddress
 4607            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4608            switch (message.Response.Status)
 609            {
 610                case 200:
 611                    {
 4612                        IPAddressAvailabilityResult value = default;
 4613                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4614                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 615                        {
 0616                            value = null;
 617                        }
 618                        else
 619                        {
 4620                            value = IPAddressAvailabilityResult.DeserializeIPAddressAvailabilityResult(document.RootElem
 621                        }
 4622                        return Response.FromValue(value, message.Response);
 623                    }
 624                default:
 0625                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 626            }
 4627        }
 628
 629        /// <summary> Checks whether a private IP address is available for use. </summary>
 630        /// <param name="resourceGroupName"> The name of the resource group. </param>
 631        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 632        /// <param name="ipAddress"> The private IP address to be verified. </param>
 633        /// <param name="cancellationToken"> The cancellation token to use. </param>
 634        public Response<IPAddressAvailabilityResult> CheckIPAddressAvailability(string resourceGroupName, string virtual
 635        {
 4636            if (resourceGroupName == null)
 637            {
 0638                throw new ArgumentNullException(nameof(resourceGroupName));
 639            }
 4640            if (virtualNetworkName == null)
 641            {
 0642                throw new ArgumentNullException(nameof(virtualNetworkName));
 643            }
 4644            if (ipAddress == null)
 645            {
 0646                throw new ArgumentNullException(nameof(ipAddress));
 647            }
 648
 4649            using var message = CreateCheckIPAddressAvailabilityRequest(resourceGroupName, virtualNetworkName, ipAddress
 4650            _pipeline.Send(message, cancellationToken);
 4651            switch (message.Response.Status)
 652            {
 653                case 200:
 654                    {
 4655                        IPAddressAvailabilityResult value = default;
 4656                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4657                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 658                        {
 0659                            value = null;
 660                        }
 661                        else
 662                        {
 4663                            value = IPAddressAvailabilityResult.DeserializeIPAddressAvailabilityResult(document.RootElem
 664                        }
 4665                        return Response.FromValue(value, message.Response);
 666                    }
 667                default:
 0668                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 669            }
 4670        }
 671
 672        internal HttpMessage CreateListUsageRequest(string resourceGroupName, string virtualNetworkName)
 673        {
 8674            var message = _pipeline.CreateMessage();
 8675            var request = message.Request;
 8676            request.Method = RequestMethod.Get;
 8677            var uri = new RawRequestUriBuilder();
 8678            uri.Reset(endpoint);
 8679            uri.AppendPath("/subscriptions/", false);
 8680            uri.AppendPath(subscriptionId, true);
 8681            uri.AppendPath("/resourceGroups/", false);
 8682            uri.AppendPath(resourceGroupName, true);
 8683            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 8684            uri.AppendPath(virtualNetworkName, true);
 8685            uri.AppendPath("/usages", false);
 8686            uri.AppendQuery("api-version", "2020-04-01", true);
 8687            request.Uri = uri;
 8688            return message;
 689        }
 690
 691        /// <summary> Lists usage stats. </summary>
 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 async Task<Response<VirtualNetworkListUsageResult>> ListUsageAsync(string resourceGroupName, string virtu
 696        {
 4697            if (resourceGroupName == null)
 698            {
 0699                throw new ArgumentNullException(nameof(resourceGroupName));
 700            }
 4701            if (virtualNetworkName == null)
 702            {
 0703                throw new ArgumentNullException(nameof(virtualNetworkName));
 704            }
 705
 4706            using var message = CreateListUsageRequest(resourceGroupName, virtualNetworkName);
 4707            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4708            switch (message.Response.Status)
 709            {
 710                case 200:
 711                    {
 4712                        VirtualNetworkListUsageResult value = default;
 4713                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4714                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 715                        {
 0716                            value = null;
 717                        }
 718                        else
 719                        {
 4720                            value = VirtualNetworkListUsageResult.DeserializeVirtualNetworkListUsageResult(document.Root
 721                        }
 4722                        return Response.FromValue(value, message.Response);
 723                    }
 724                default:
 0725                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 726            }
 4727        }
 728
 729        /// <summary> Lists usage stats. </summary>
 730        /// <param name="resourceGroupName"> The name of the resource group. </param>
 731        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 732        /// <param name="cancellationToken"> The cancellation token to use. </param>
 733        public Response<VirtualNetworkListUsageResult> ListUsage(string resourceGroupName, string virtualNetworkName, Ca
 734        {
 4735            if (resourceGroupName == null)
 736            {
 0737                throw new ArgumentNullException(nameof(resourceGroupName));
 738            }
 4739            if (virtualNetworkName == null)
 740            {
 0741                throw new ArgumentNullException(nameof(virtualNetworkName));
 742            }
 743
 4744            using var message = CreateListUsageRequest(resourceGroupName, virtualNetworkName);
 4745            _pipeline.Send(message, cancellationToken);
 4746            switch (message.Response.Status)
 747            {
 748                case 200:
 749                    {
 4750                        VirtualNetworkListUsageResult value = default;
 4751                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4752                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 753                        {
 0754                            value = null;
 755                        }
 756                        else
 757                        {
 4758                            value = VirtualNetworkListUsageResult.DeserializeVirtualNetworkListUsageResult(document.Root
 759                        }
 4760                        return Response.FromValue(value, message.Response);
 761                    }
 762                default:
 0763                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 764            }
 4765        }
 766
 767        internal HttpMessage CreateListAllNextPageRequest(string nextLink)
 768        {
 0769            var message = _pipeline.CreateMessage();
 0770            var request = message.Request;
 0771            request.Method = RequestMethod.Get;
 0772            var uri = new RawRequestUriBuilder();
 0773            uri.Reset(endpoint);
 0774            uri.AppendRawNextLink(nextLink, false);
 0775            request.Uri = uri;
 0776            return message;
 777        }
 778
 779        /// <summary> Gets all virtual networks in a subscription. </summary>
 780        /// <param name="nextLink"> The URL to the next page of results. </param>
 781        /// <param name="cancellationToken"> The cancellation token to use. </param>
 782        public async Task<Response<VirtualNetworkListResult>> ListAllNextPageAsync(string nextLink, CancellationToken ca
 783        {
 0784            if (nextLink == null)
 785            {
 0786                throw new ArgumentNullException(nameof(nextLink));
 787            }
 788
 0789            using var message = CreateListAllNextPageRequest(nextLink);
 0790            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0791            switch (message.Response.Status)
 792            {
 793                case 200:
 794                    {
 0795                        VirtualNetworkListResult value = default;
 0796                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0797                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 798                        {
 0799                            value = null;
 800                        }
 801                        else
 802                        {
 0803                            value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement);
 804                        }
 0805                        return Response.FromValue(value, message.Response);
 806                    }
 807                default:
 0808                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 809            }
 0810        }
 811
 812        /// <summary> Gets all virtual networks in a subscription. </summary>
 813        /// <param name="nextLink"> The URL to the next page of results. </param>
 814        /// <param name="cancellationToken"> The cancellation token to use. </param>
 815        public Response<VirtualNetworkListResult> ListAllNextPage(string nextLink, CancellationToken cancellationToken =
 816        {
 0817            if (nextLink == null)
 818            {
 0819                throw new ArgumentNullException(nameof(nextLink));
 820            }
 821
 0822            using var message = CreateListAllNextPageRequest(nextLink);
 0823            _pipeline.Send(message, cancellationToken);
 0824            switch (message.Response.Status)
 825            {
 826                case 200:
 827                    {
 0828                        VirtualNetworkListResult value = default;
 0829                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0830                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 831                        {
 0832                            value = null;
 833                        }
 834                        else
 835                        {
 0836                            value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement);
 837                        }
 0838                        return Response.FromValue(value, message.Response);
 839                    }
 840                default:
 0841                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 842            }
 0843        }
 844
 845        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName)
 846        {
 0847            var message = _pipeline.CreateMessage();
 0848            var request = message.Request;
 0849            request.Method = RequestMethod.Get;
 0850            var uri = new RawRequestUriBuilder();
 0851            uri.Reset(endpoint);
 0852            uri.AppendRawNextLink(nextLink, false);
 0853            request.Uri = uri;
 0854            return message;
 855        }
 856
 857        /// <summary> Gets all virtual networks in a resource group. </summary>
 858        /// <param name="nextLink"> The URL to the next page of results. </param>
 859        /// <param name="resourceGroupName"> The name of the resource group. </param>
 860        /// <param name="cancellationToken"> The cancellation token to use. </param>
 861        public async Task<Response<VirtualNetworkListResult>> ListNextPageAsync(string nextLink, string resourceGroupNam
 862        {
 0863            if (nextLink == null)
 864            {
 0865                throw new ArgumentNullException(nameof(nextLink));
 866            }
 0867            if (resourceGroupName == null)
 868            {
 0869                throw new ArgumentNullException(nameof(resourceGroupName));
 870            }
 871
 0872            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 0873            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0874            switch (message.Response.Status)
 875            {
 876                case 200:
 877                    {
 0878                        VirtualNetworkListResult value = default;
 0879                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0880                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 881                        {
 0882                            value = null;
 883                        }
 884                        else
 885                        {
 0886                            value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement);
 887                        }
 0888                        return Response.FromValue(value, message.Response);
 889                    }
 890                default:
 0891                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 892            }
 0893        }
 894
 895        /// <summary> Gets all virtual networks in a resource group. </summary>
 896        /// <param name="nextLink"> The URL to the next page of results. </param>
 897        /// <param name="resourceGroupName"> The name of the resource group. </param>
 898        /// <param name="cancellationToken"> The cancellation token to use. </param>
 899        public Response<VirtualNetworkListResult> ListNextPage(string nextLink, string resourceGroupName, CancellationTo
 900        {
 0901            if (nextLink == null)
 902            {
 0903                throw new ArgumentNullException(nameof(nextLink));
 904            }
 0905            if (resourceGroupName == null)
 906            {
 0907                throw new ArgumentNullException(nameof(resourceGroupName));
 908            }
 909
 0910            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 0911            _pipeline.Send(message, cancellationToken);
 0912            switch (message.Response.Status)
 913            {
 914                case 200:
 915                    {
 0916                        VirtualNetworkListResult value = default;
 0917                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0918                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 919                        {
 0920                            value = null;
 921                        }
 922                        else
 923                        {
 0924                            value = VirtualNetworkListResult.DeserializeVirtualNetworkListResult(document.RootElement);
 925                        }
 0926                        return Response.FromValue(value, message.Response);
 927                    }
 928                default:
 0929                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 930            }
 0931        }
 932
 933        internal HttpMessage CreateListUsageNextPageRequest(string nextLink, string resourceGroupName, string virtualNet
 934        {
 0935            var message = _pipeline.CreateMessage();
 0936            var request = message.Request;
 0937            request.Method = RequestMethod.Get;
 0938            var uri = new RawRequestUriBuilder();
 0939            uri.Reset(endpoint);
 0940            uri.AppendRawNextLink(nextLink, false);
 0941            request.Uri = uri;
 0942            return message;
 943        }
 944
 945        /// <summary> Lists usage stats. </summary>
 946        /// <param name="nextLink"> The URL to the next page of results. </param>
 947        /// <param name="resourceGroupName"> The name of the resource group. </param>
 948        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 949        /// <param name="cancellationToken"> The cancellation token to use. </param>
 950        public async Task<Response<VirtualNetworkListUsageResult>> ListUsageNextPageAsync(string nextLink, string resour
 951        {
 0952            if (nextLink == null)
 953            {
 0954                throw new ArgumentNullException(nameof(nextLink));
 955            }
 0956            if (resourceGroupName == null)
 957            {
 0958                throw new ArgumentNullException(nameof(resourceGroupName));
 959            }
 0960            if (virtualNetworkName == null)
 961            {
 0962                throw new ArgumentNullException(nameof(virtualNetworkName));
 963            }
 964
 0965            using var message = CreateListUsageNextPageRequest(nextLink, resourceGroupName, virtualNetworkName);
 0966            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0967            switch (message.Response.Status)
 968            {
 969                case 200:
 970                    {
 0971                        VirtualNetworkListUsageResult value = default;
 0972                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0973                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 974                        {
 0975                            value = null;
 976                        }
 977                        else
 978                        {
 0979                            value = VirtualNetworkListUsageResult.DeserializeVirtualNetworkListUsageResult(document.Root
 980                        }
 0981                        return Response.FromValue(value, message.Response);
 982                    }
 983                default:
 0984                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 985            }
 0986        }
 987
 988        /// <summary> Lists usage stats. </summary>
 989        /// <param name="nextLink"> The URL to the next page of results. </param>
 990        /// <param name="resourceGroupName"> The name of the resource group. </param>
 991        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 992        /// <param name="cancellationToken"> The cancellation token to use. </param>
 993        public Response<VirtualNetworkListUsageResult> ListUsageNextPage(string nextLink, string resourceGroupName, stri
 994        {
 0995            if (nextLink == null)
 996            {
 0997                throw new ArgumentNullException(nameof(nextLink));
 998            }
 0999            if (resourceGroupName == null)
 1000            {
 01001                throw new ArgumentNullException(nameof(resourceGroupName));
 1002            }
 01003            if (virtualNetworkName == null)
 1004            {
 01005                throw new ArgumentNullException(nameof(virtualNetworkName));
 1006            }
 1007
 01008            using var message = CreateListUsageNextPageRequest(nextLink, resourceGroupName, virtualNetworkName);
 01009            _pipeline.Send(message, cancellationToken);
 01010            switch (message.Response.Status)
 1011            {
 1012                case 200:
 1013                    {
 01014                        VirtualNetworkListUsageResult value = default;
 01015                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 01016                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 1017                        {
 01018                            value = null;
 1019                        }
 1020                        else
 1021                        {
 01022                            value = VirtualNetworkListUsageResult.DeserializeVirtualNetworkListUsageResult(document.Root
 1023                        }
 01024                        return Response.FromValue(value, message.Response);
 1025                    }
 1026                default:
 01027                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 1028            }
 01029        }
 1030    }
 1031}