< Summary

Class:Azure.ResourceManager.Network.VpnGatewaysRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\VpnGatewaysRestOperations.cs
Covered lines:0
Uncovered lines:360
Coverable lines:360
Total lines:799
Line coverage:0% (0 of 360)
Covered branches:0
Total branches:140
Branch coverage:0% (0 of 140)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateUpdateTagsRequest(...)-0%100%
UpdateTagsAsync()-0%0%
UpdateTags(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateResetRequest(...)-0%100%
ResetAsync()-0%0%
Reset(...)-0%0%
CreateListByResourceGroupRequest(...)-0%100%
ListByResourceGroupAsync()-0%0%
ListByResourceGroup(...)-0%0%
CreateListRequest()-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateListByResourceGroupNextPageRequest(...)-0%100%
ListByResourceGroupNextPageAsync()-0%0%
ListByResourceGroupNextPage(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\VpnGatewaysRestOperations.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 VpnGatewaysRestOperations
 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 VpnGatewaysRestOperations. </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
 032        public VpnGatewaysRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription
 33        {
 034            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 038            endpoint ??= new Uri("https://management.azure.com");
 39
 040            this.subscriptionId = subscriptionId;
 041            this.endpoint = endpoint;
 042            _clientDiagnostics = clientDiagnostics;
 043            _pipeline = pipeline;
 044        }
 45
 46        internal HttpMessage CreateGetRequest(string resourceGroupName, string gatewayName)
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Get;
 051            var uri = new RawRequestUriBuilder();
 052            uri.Reset(endpoint);
 053            uri.AppendPath("/subscriptions/", false);
 054            uri.AppendPath(subscriptionId, true);
 055            uri.AppendPath("/resourceGroups/", false);
 056            uri.AppendPath(resourceGroupName, true);
 057            uri.AppendPath("/providers/Microsoft.Network/vpnGateways/", false);
 058            uri.AppendPath(gatewayName, true);
 059            uri.AppendQuery("api-version", "2020-04-01", true);
 060            request.Uri = uri;
 061            return message;
 62        }
 63
 64        /// <summary> Retrieves the details of a virtual wan vpn gateway. </summary>
 65        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 66        /// <param name="gatewayName"> The name of the gateway. </param>
 67        /// <param name="cancellationToken"> The cancellation token to use. </param>
 68        public async Task<Response<VpnGateway>> GetAsync(string resourceGroupName, string gatewayName, CancellationToken
 69        {
 070            if (resourceGroupName == null)
 71            {
 072                throw new ArgumentNullException(nameof(resourceGroupName));
 73            }
 074            if (gatewayName == null)
 75            {
 076                throw new ArgumentNullException(nameof(gatewayName));
 77            }
 78
 079            using var message = CreateGetRequest(resourceGroupName, gatewayName);
 080            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 081            switch (message.Response.Status)
 82            {
 83                case 200:
 84                    {
 085                        VpnGateway value = default;
 086                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 087                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 88                        {
 089                            value = null;
 90                        }
 91                        else
 92                        {
 093                            value = VpnGateway.DeserializeVpnGateway(document.RootElement);
 94                        }
 095                        return Response.FromValue(value, message.Response);
 96                    }
 97                default:
 098                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 99            }
 0100        }
 101
 102        /// <summary> Retrieves the details of a virtual wan vpn gateway. </summary>
 103        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 104        /// <param name="gatewayName"> The name of the gateway. </param>
 105        /// <param name="cancellationToken"> The cancellation token to use. </param>
 106        public Response<VpnGateway> Get(string resourceGroupName, string gatewayName, CancellationToken cancellationToke
 107        {
 0108            if (resourceGroupName == null)
 109            {
 0110                throw new ArgumentNullException(nameof(resourceGroupName));
 111            }
 0112            if (gatewayName == null)
 113            {
 0114                throw new ArgumentNullException(nameof(gatewayName));
 115            }
 116
 0117            using var message = CreateGetRequest(resourceGroupName, gatewayName);
 0118            _pipeline.Send(message, cancellationToken);
 0119            switch (message.Response.Status)
 120            {
 121                case 200:
 122                    {
 0123                        VpnGateway value = default;
 0124                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0125                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 126                        {
 0127                            value = null;
 128                        }
 129                        else
 130                        {
 0131                            value = VpnGateway.DeserializeVpnGateway(document.RootElement);
 132                        }
 0133                        return Response.FromValue(value, message.Response);
 134                    }
 135                default:
 0136                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 137            }
 0138        }
 139
 140        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string gatewayName, VpnGateway vpnGat
 141        {
 0142            var message = _pipeline.CreateMessage();
 0143            var request = message.Request;
 0144            request.Method = RequestMethod.Put;
 0145            var uri = new RawRequestUriBuilder();
 0146            uri.Reset(endpoint);
 0147            uri.AppendPath("/subscriptions/", false);
 0148            uri.AppendPath(subscriptionId, true);
 0149            uri.AppendPath("/resourceGroups/", false);
 0150            uri.AppendPath(resourceGroupName, true);
 0151            uri.AppendPath("/providers/Microsoft.Network/vpnGateways/", false);
 0152            uri.AppendPath(gatewayName, true);
 0153            uri.AppendQuery("api-version", "2020-04-01", true);
 0154            request.Uri = uri;
 0155            request.Headers.Add("Content-Type", "application/json");
 0156            var content = new Utf8JsonRequestContent();
 0157            content.JsonWriter.WriteObjectValue(vpnGatewayParameters);
 0158            request.Content = content;
 0159            return message;
 160        }
 161
 162        /// <summary> Creates a virtual wan vpn gateway if it doesn&apos;t exist else updates the existing gateway. </su
 163        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 164        /// <param name="gatewayName"> The name of the gateway. </param>
 165        /// <param name="vpnGatewayParameters"> Parameters supplied to create or Update a virtual wan vpn gateway. </par
 166        /// <param name="cancellationToken"> The cancellation token to use. </param>
 167        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string gatewayName, VpnGateway vpnGate
 168        {
 0169            if (resourceGroupName == null)
 170            {
 0171                throw new ArgumentNullException(nameof(resourceGroupName));
 172            }
 0173            if (gatewayName == null)
 174            {
 0175                throw new ArgumentNullException(nameof(gatewayName));
 176            }
 0177            if (vpnGatewayParameters == null)
 178            {
 0179                throw new ArgumentNullException(nameof(vpnGatewayParameters));
 180            }
 181
 0182            using var message = CreateCreateOrUpdateRequest(resourceGroupName, gatewayName, vpnGatewayParameters);
 0183            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0184            switch (message.Response.Status)
 185            {
 186                case 200:
 187                case 201:
 0188                    return message.Response;
 189                default:
 0190                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 191            }
 0192        }
 193
 194        /// <summary> Creates a virtual wan vpn gateway if it doesn&apos;t exist else updates the existing gateway. </su
 195        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 196        /// <param name="gatewayName"> The name of the gateway. </param>
 197        /// <param name="vpnGatewayParameters"> Parameters supplied to create or Update a virtual wan vpn gateway. </par
 198        /// <param name="cancellationToken"> The cancellation token to use. </param>
 199        public Response CreateOrUpdate(string resourceGroupName, string gatewayName, VpnGateway vpnGatewayParameters, Ca
 200        {
 0201            if (resourceGroupName == null)
 202            {
 0203                throw new ArgumentNullException(nameof(resourceGroupName));
 204            }
 0205            if (gatewayName == null)
 206            {
 0207                throw new ArgumentNullException(nameof(gatewayName));
 208            }
 0209            if (vpnGatewayParameters == null)
 210            {
 0211                throw new ArgumentNullException(nameof(vpnGatewayParameters));
 212            }
 213
 0214            using var message = CreateCreateOrUpdateRequest(resourceGroupName, gatewayName, vpnGatewayParameters);
 0215            _pipeline.Send(message, cancellationToken);
 0216            switch (message.Response.Status)
 217            {
 218                case 200:
 219                case 201:
 0220                    return message.Response;
 221                default:
 0222                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 223            }
 0224        }
 225
 226        internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string gatewayName, TagsObject vpnGateway
 227        {
 0228            var message = _pipeline.CreateMessage();
 0229            var request = message.Request;
 0230            request.Method = RequestMethod.Patch;
 0231            var uri = new RawRequestUriBuilder();
 0232            uri.Reset(endpoint);
 0233            uri.AppendPath("/subscriptions/", false);
 0234            uri.AppendPath(subscriptionId, true);
 0235            uri.AppendPath("/resourceGroups/", false);
 0236            uri.AppendPath(resourceGroupName, true);
 0237            uri.AppendPath("/providers/Microsoft.Network/vpnGateways/", false);
 0238            uri.AppendPath(gatewayName, true);
 0239            uri.AppendQuery("api-version", "2020-04-01", true);
 0240            request.Uri = uri;
 0241            request.Headers.Add("Content-Type", "application/json");
 0242            var content = new Utf8JsonRequestContent();
 0243            content.JsonWriter.WriteObjectValue(vpnGatewayParameters);
 0244            request.Content = content;
 0245            return message;
 246        }
 247
 248        /// <summary> Updates virtual wan vpn gateway tags. </summary>
 249        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 250        /// <param name="gatewayName"> The name of the gateway. </param>
 251        /// <param name="vpnGatewayParameters"> Parameters supplied to update a virtual wan vpn gateway tags. </param>
 252        /// <param name="cancellationToken"> The cancellation token to use. </param>
 253        public async Task<Response<VpnGateway>> UpdateTagsAsync(string resourceGroupName, string gatewayName, TagsObject
 254        {
 0255            if (resourceGroupName == null)
 256            {
 0257                throw new ArgumentNullException(nameof(resourceGroupName));
 258            }
 0259            if (gatewayName == null)
 260            {
 0261                throw new ArgumentNullException(nameof(gatewayName));
 262            }
 0263            if (vpnGatewayParameters == null)
 264            {
 0265                throw new ArgumentNullException(nameof(vpnGatewayParameters));
 266            }
 267
 0268            using var message = CreateUpdateTagsRequest(resourceGroupName, gatewayName, vpnGatewayParameters);
 0269            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0270            switch (message.Response.Status)
 271            {
 272                case 200:
 273                    {
 0274                        VpnGateway value = default;
 0275                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0276                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 277                        {
 0278                            value = null;
 279                        }
 280                        else
 281                        {
 0282                            value = VpnGateway.DeserializeVpnGateway(document.RootElement);
 283                        }
 0284                        return Response.FromValue(value, message.Response);
 285                    }
 286                default:
 0287                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 288            }
 0289        }
 290
 291        /// <summary> Updates virtual wan vpn gateway tags. </summary>
 292        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 293        /// <param name="gatewayName"> The name of the gateway. </param>
 294        /// <param name="vpnGatewayParameters"> Parameters supplied to update a virtual wan vpn gateway tags. </param>
 295        /// <param name="cancellationToken"> The cancellation token to use. </param>
 296        public Response<VpnGateway> UpdateTags(string resourceGroupName, string gatewayName, TagsObject vpnGatewayParame
 297        {
 0298            if (resourceGroupName == null)
 299            {
 0300                throw new ArgumentNullException(nameof(resourceGroupName));
 301            }
 0302            if (gatewayName == null)
 303            {
 0304                throw new ArgumentNullException(nameof(gatewayName));
 305            }
 0306            if (vpnGatewayParameters == null)
 307            {
 0308                throw new ArgumentNullException(nameof(vpnGatewayParameters));
 309            }
 310
 0311            using var message = CreateUpdateTagsRequest(resourceGroupName, gatewayName, vpnGatewayParameters);
 0312            _pipeline.Send(message, cancellationToken);
 0313            switch (message.Response.Status)
 314            {
 315                case 200:
 316                    {
 0317                        VpnGateway value = default;
 0318                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0319                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 320                        {
 0321                            value = null;
 322                        }
 323                        else
 324                        {
 0325                            value = VpnGateway.DeserializeVpnGateway(document.RootElement);
 326                        }
 0327                        return Response.FromValue(value, message.Response);
 328                    }
 329                default:
 0330                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 331            }
 0332        }
 333
 334        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string gatewayName)
 335        {
 0336            var message = _pipeline.CreateMessage();
 0337            var request = message.Request;
 0338            request.Method = RequestMethod.Delete;
 0339            var uri = new RawRequestUriBuilder();
 0340            uri.Reset(endpoint);
 0341            uri.AppendPath("/subscriptions/", false);
 0342            uri.AppendPath(subscriptionId, true);
 0343            uri.AppendPath("/resourceGroups/", false);
 0344            uri.AppendPath(resourceGroupName, true);
 0345            uri.AppendPath("/providers/Microsoft.Network/vpnGateways/", false);
 0346            uri.AppendPath(gatewayName, true);
 0347            uri.AppendQuery("api-version", "2020-04-01", true);
 0348            request.Uri = uri;
 0349            return message;
 350        }
 351
 352        /// <summary> Deletes a virtual wan vpn gateway. </summary>
 353        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 354        /// <param name="gatewayName"> The name of the gateway. </param>
 355        /// <param name="cancellationToken"> The cancellation token to use. </param>
 356        public async Task<Response> DeleteAsync(string resourceGroupName, string gatewayName, CancellationToken cancella
 357        {
 0358            if (resourceGroupName == null)
 359            {
 0360                throw new ArgumentNullException(nameof(resourceGroupName));
 361            }
 0362            if (gatewayName == null)
 363            {
 0364                throw new ArgumentNullException(nameof(gatewayName));
 365            }
 366
 0367            using var message = CreateDeleteRequest(resourceGroupName, gatewayName);
 0368            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0369            switch (message.Response.Status)
 370            {
 371                case 200:
 372                case 202:
 373                case 204:
 0374                    return message.Response;
 375                default:
 0376                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 377            }
 0378        }
 379
 380        /// <summary> Deletes a virtual wan vpn gateway. </summary>
 381        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 382        /// <param name="gatewayName"> The name of the gateway. </param>
 383        /// <param name="cancellationToken"> The cancellation token to use. </param>
 384        public Response Delete(string resourceGroupName, string gatewayName, CancellationToken cancellationToken = defau
 385        {
 0386            if (resourceGroupName == null)
 387            {
 0388                throw new ArgumentNullException(nameof(resourceGroupName));
 389            }
 0390            if (gatewayName == null)
 391            {
 0392                throw new ArgumentNullException(nameof(gatewayName));
 393            }
 394
 0395            using var message = CreateDeleteRequest(resourceGroupName, gatewayName);
 0396            _pipeline.Send(message, cancellationToken);
 0397            switch (message.Response.Status)
 398            {
 399                case 200:
 400                case 202:
 401                case 204:
 0402                    return message.Response;
 403                default:
 0404                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 405            }
 0406        }
 407
 408        internal HttpMessage CreateResetRequest(string resourceGroupName, string gatewayName)
 409        {
 0410            var message = _pipeline.CreateMessage();
 0411            var request = message.Request;
 0412            request.Method = RequestMethod.Post;
 0413            var uri = new RawRequestUriBuilder();
 0414            uri.Reset(endpoint);
 0415            uri.AppendPath("/subscriptions/", false);
 0416            uri.AppendPath(subscriptionId, true);
 0417            uri.AppendPath("/resourceGroups/", false);
 0418            uri.AppendPath(resourceGroupName, true);
 0419            uri.AppendPath("/providers/Microsoft.Network/vpnGateways/", false);
 0420            uri.AppendPath(gatewayName, true);
 0421            uri.AppendPath("/reset", false);
 0422            uri.AppendQuery("api-version", "2020-04-01", true);
 0423            request.Uri = uri;
 0424            return message;
 425        }
 426
 427        /// <summary> Resets the primary of the vpn gateway in the specified resource group. </summary>
 428        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 429        /// <param name="gatewayName"> The name of the gateway. </param>
 430        /// <param name="cancellationToken"> The cancellation token to use. </param>
 431        public async Task<Response> ResetAsync(string resourceGroupName, string gatewayName, CancellationToken cancellat
 432        {
 0433            if (resourceGroupName == null)
 434            {
 0435                throw new ArgumentNullException(nameof(resourceGroupName));
 436            }
 0437            if (gatewayName == null)
 438            {
 0439                throw new ArgumentNullException(nameof(gatewayName));
 440            }
 441
 0442            using var message = CreateResetRequest(resourceGroupName, gatewayName);
 0443            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0444            switch (message.Response.Status)
 445            {
 446                case 200:
 447                case 202:
 0448                    return message.Response;
 449                default:
 0450                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 451            }
 0452        }
 453
 454        /// <summary> Resets the primary of the vpn gateway in the specified resource group. </summary>
 455        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 456        /// <param name="gatewayName"> The name of the gateway. </param>
 457        /// <param name="cancellationToken"> The cancellation token to use. </param>
 458        public Response Reset(string resourceGroupName, string gatewayName, CancellationToken cancellationToken = defaul
 459        {
 0460            if (resourceGroupName == null)
 461            {
 0462                throw new ArgumentNullException(nameof(resourceGroupName));
 463            }
 0464            if (gatewayName == null)
 465            {
 0466                throw new ArgumentNullException(nameof(gatewayName));
 467            }
 468
 0469            using var message = CreateResetRequest(resourceGroupName, gatewayName);
 0470            _pipeline.Send(message, cancellationToken);
 0471            switch (message.Response.Status)
 472            {
 473                case 200:
 474                case 202:
 0475                    return message.Response;
 476                default:
 0477                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 478            }
 0479        }
 480
 481        internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName)
 482        {
 0483            var message = _pipeline.CreateMessage();
 0484            var request = message.Request;
 0485            request.Method = RequestMethod.Get;
 0486            var uri = new RawRequestUriBuilder();
 0487            uri.Reset(endpoint);
 0488            uri.AppendPath("/subscriptions/", false);
 0489            uri.AppendPath(subscriptionId, true);
 0490            uri.AppendPath("/resourceGroups/", false);
 0491            uri.AppendPath(resourceGroupName, true);
 0492            uri.AppendPath("/providers/Microsoft.Network/vpnGateways", false);
 0493            uri.AppendQuery("api-version", "2020-04-01", true);
 0494            request.Uri = uri;
 0495            return message;
 496        }
 497
 498        /// <summary> Lists all the VpnGateways in a resource group. </summary>
 499        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 500        /// <param name="cancellationToken"> The cancellation token to use. </param>
 501        public async Task<Response<ListVpnGatewaysResult>> ListByResourceGroupAsync(string resourceGroupName, Cancellati
 502        {
 0503            if (resourceGroupName == null)
 504            {
 0505                throw new ArgumentNullException(nameof(resourceGroupName));
 506            }
 507
 0508            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 0509            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0510            switch (message.Response.Status)
 511            {
 512                case 200:
 513                    {
 0514                        ListVpnGatewaysResult value = default;
 0515                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0516                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 517                        {
 0518                            value = null;
 519                        }
 520                        else
 521                        {
 0522                            value = ListVpnGatewaysResult.DeserializeListVpnGatewaysResult(document.RootElement);
 523                        }
 0524                        return Response.FromValue(value, message.Response);
 525                    }
 526                default:
 0527                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 528            }
 0529        }
 530
 531        /// <summary> Lists all the VpnGateways in a resource group. </summary>
 532        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 533        /// <param name="cancellationToken"> The cancellation token to use. </param>
 534        public Response<ListVpnGatewaysResult> ListByResourceGroup(string resourceGroupName, CancellationToken cancellat
 535        {
 0536            if (resourceGroupName == null)
 537            {
 0538                throw new ArgumentNullException(nameof(resourceGroupName));
 539            }
 540
 0541            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 0542            _pipeline.Send(message, cancellationToken);
 0543            switch (message.Response.Status)
 544            {
 545                case 200:
 546                    {
 0547                        ListVpnGatewaysResult value = default;
 0548                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0549                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 550                        {
 0551                            value = null;
 552                        }
 553                        else
 554                        {
 0555                            value = ListVpnGatewaysResult.DeserializeListVpnGatewaysResult(document.RootElement);
 556                        }
 0557                        return Response.FromValue(value, message.Response);
 558                    }
 559                default:
 0560                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 561            }
 0562        }
 563
 564        internal HttpMessage CreateListRequest()
 565        {
 0566            var message = _pipeline.CreateMessage();
 0567            var request = message.Request;
 0568            request.Method = RequestMethod.Get;
 0569            var uri = new RawRequestUriBuilder();
 0570            uri.Reset(endpoint);
 0571            uri.AppendPath("/subscriptions/", false);
 0572            uri.AppendPath(subscriptionId, true);
 0573            uri.AppendPath("/providers/Microsoft.Network/vpnGateways", false);
 0574            uri.AppendQuery("api-version", "2020-04-01", true);
 0575            request.Uri = uri;
 0576            return message;
 577        }
 578
 579        /// <summary> Lists all the VpnGateways in a subscription. </summary>
 580        /// <param name="cancellationToken"> The cancellation token to use. </param>
 581        public async Task<Response<ListVpnGatewaysResult>> ListAsync(CancellationToken cancellationToken = default)
 582        {
 0583            using var message = CreateListRequest();
 0584            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0585            switch (message.Response.Status)
 586            {
 587                case 200:
 588                    {
 0589                        ListVpnGatewaysResult value = default;
 0590                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0591                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 592                        {
 0593                            value = null;
 594                        }
 595                        else
 596                        {
 0597                            value = ListVpnGatewaysResult.DeserializeListVpnGatewaysResult(document.RootElement);
 598                        }
 0599                        return Response.FromValue(value, message.Response);
 600                    }
 601                default:
 0602                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 603            }
 0604        }
 605
 606        /// <summary> Lists all the VpnGateways in a subscription. </summary>
 607        /// <param name="cancellationToken"> The cancellation token to use. </param>
 608        public Response<ListVpnGatewaysResult> List(CancellationToken cancellationToken = default)
 609        {
 0610            using var message = CreateListRequest();
 0611            _pipeline.Send(message, cancellationToken);
 0612            switch (message.Response.Status)
 613            {
 614                case 200:
 615                    {
 0616                        ListVpnGatewaysResult value = default;
 0617                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0618                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 619                        {
 0620                            value = null;
 621                        }
 622                        else
 623                        {
 0624                            value = ListVpnGatewaysResult.DeserializeListVpnGatewaysResult(document.RootElement);
 625                        }
 0626                        return Response.FromValue(value, message.Response);
 627                    }
 628                default:
 0629                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 630            }
 0631        }
 632
 633        internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName)
 634        {
 0635            var message = _pipeline.CreateMessage();
 0636            var request = message.Request;
 0637            request.Method = RequestMethod.Get;
 0638            var uri = new RawRequestUriBuilder();
 0639            uri.Reset(endpoint);
 0640            uri.AppendRawNextLink(nextLink, false);
 0641            request.Uri = uri;
 0642            return message;
 643        }
 644
 645        /// <summary> Lists all the VpnGateways in a resource group. </summary>
 646        /// <param name="nextLink"> The URL to the next page of results. </param>
 647        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 648        /// <param name="cancellationToken"> The cancellation token to use. </param>
 649        public async Task<Response<ListVpnGatewaysResult>> ListByResourceGroupNextPageAsync(string nextLink, string reso
 650        {
 0651            if (nextLink == null)
 652            {
 0653                throw new ArgumentNullException(nameof(nextLink));
 654            }
 0655            if (resourceGroupName == null)
 656            {
 0657                throw new ArgumentNullException(nameof(resourceGroupName));
 658            }
 659
 0660            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0661            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0662            switch (message.Response.Status)
 663            {
 664                case 200:
 665                    {
 0666                        ListVpnGatewaysResult value = default;
 0667                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0668                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 669                        {
 0670                            value = null;
 671                        }
 672                        else
 673                        {
 0674                            value = ListVpnGatewaysResult.DeserializeListVpnGatewaysResult(document.RootElement);
 675                        }
 0676                        return Response.FromValue(value, message.Response);
 677                    }
 678                default:
 0679                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 680            }
 0681        }
 682
 683        /// <summary> Lists all the VpnGateways in a resource group. </summary>
 684        /// <param name="nextLink"> The URL to the next page of results. </param>
 685        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 686        /// <param name="cancellationToken"> The cancellation token to use. </param>
 687        public Response<ListVpnGatewaysResult> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, Ca
 688        {
 0689            if (nextLink == null)
 690            {
 0691                throw new ArgumentNullException(nameof(nextLink));
 692            }
 0693            if (resourceGroupName == null)
 694            {
 0695                throw new ArgumentNullException(nameof(resourceGroupName));
 696            }
 697
 0698            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0699            _pipeline.Send(message, cancellationToken);
 0700            switch (message.Response.Status)
 701            {
 702                case 200:
 703                    {
 0704                        ListVpnGatewaysResult value = default;
 0705                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0706                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 707                        {
 0708                            value = null;
 709                        }
 710                        else
 711                        {
 0712                            value = ListVpnGatewaysResult.DeserializeListVpnGatewaysResult(document.RootElement);
 713                        }
 0714                        return Response.FromValue(value, message.Response);
 715                    }
 716                default:
 0717                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 718            }
 0719        }
 720
 721        internal HttpMessage CreateListNextPageRequest(string nextLink)
 722        {
 0723            var message = _pipeline.CreateMessage();
 0724            var request = message.Request;
 0725            request.Method = RequestMethod.Get;
 0726            var uri = new RawRequestUriBuilder();
 0727            uri.Reset(endpoint);
 0728            uri.AppendRawNextLink(nextLink, false);
 0729            request.Uri = uri;
 0730            return message;
 731        }
 732
 733        /// <summary> Lists all the VpnGateways in a subscription. </summary>
 734        /// <param name="nextLink"> The URL to the next page of results. </param>
 735        /// <param name="cancellationToken"> The cancellation token to use. </param>
 736        public async Task<Response<ListVpnGatewaysResult>> ListNextPageAsync(string nextLink, CancellationToken cancella
 737        {
 0738            if (nextLink == null)
 739            {
 0740                throw new ArgumentNullException(nameof(nextLink));
 741            }
 742
 0743            using var message = CreateListNextPageRequest(nextLink);
 0744            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0745            switch (message.Response.Status)
 746            {
 747                case 200:
 748                    {
 0749                        ListVpnGatewaysResult value = default;
 0750                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0751                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 752                        {
 0753                            value = null;
 754                        }
 755                        else
 756                        {
 0757                            value = ListVpnGatewaysResult.DeserializeListVpnGatewaysResult(document.RootElement);
 758                        }
 0759                        return Response.FromValue(value, message.Response);
 760                    }
 761                default:
 0762                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 763            }
 0764        }
 765
 766        /// <summary> Lists all the VpnGateways in a subscription. </summary>
 767        /// <param name="nextLink"> The URL to the next page of results. </param>
 768        /// <param name="cancellationToken"> The cancellation token to use. </param>
 769        public Response<ListVpnGatewaysResult> ListNextPage(string nextLink, CancellationToken cancellationToken = defau
 770        {
 0771            if (nextLink == null)
 772            {
 0773                throw new ArgumentNullException(nameof(nextLink));
 774            }
 775
 0776            using var message = CreateListNextPageRequest(nextLink);
 0777            _pipeline.Send(message, cancellationToken);
 0778            switch (message.Response.Status)
 779            {
 780                case 200:
 781                    {
 0782                        ListVpnGatewaysResult value = default;
 0783                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0784                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 785                        {
 0786                            value = null;
 787                        }
 788                        else
 789                        {
 0790                            value = ListVpnGatewaysResult.DeserializeListVpnGatewaysResult(document.RootElement);
 791                        }
 0792                        return Response.FromValue(value, message.Response);
 793                    }
 794                default:
 0795                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 796            }
 0797        }
 798    }
 799}