< Summary

Class:Azure.ResourceManager.Network.VirtualNetworkGatewayConnectionsRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\VirtualNetworkGatewayConnectionsRestOperations.cs
Covered lines:139
Uncovered lines:323
Coverable lines:462
Total lines:995
Line coverage:30% (139 of 462)
Covered branches:34
Total branches:194
Branch coverage:17.5% (34 of 194)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-66.67%50%
CreateOrUpdate(...)-66.67%50%
CreateGetRequest(...)-100%100%
GetAsync()-73.33%50%
Get(...)-73.33%50%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-70%50%
Delete(...)-70%50%
CreateUpdateTagsRequest(...)-0%100%
UpdateTagsAsync()-0%0%
UpdateTags(...)-0%0%
CreateSetSharedKeyRequest(...)-0%100%
SetSharedKeyAsync()-0%0%
SetSharedKey(...)-0%0%
CreateGetSharedKeyRequest(...)-0%100%
GetSharedKeyAsync()-0%0%
GetSharedKey(...)-0%0%
CreateListRequest(...)-100%100%
ListAsync()-76.92%50%
List(...)-76.92%50%
CreateResetSharedKeyRequest(...)-0%100%
ResetSharedKeyAsync()-0%0%
ResetSharedKey(...)-0%0%
CreateStartPacketCaptureRequest(...)-0%0%
StartPacketCaptureAsync()-0%0%
StartPacketCapture(...)-0%0%
CreateStopPacketCaptureRequest(...)-0%100%
StopPacketCaptureAsync()-0%0%
StopPacketCapture(...)-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\VirtualNetworkGatewayConnectionsRestOperations.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 VirtualNetworkGatewayConnectionsRestOperations
 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 VirtualNetworkGatewayConnectionsRestOperations. </summary>
 27        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 28        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 29        /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 8432        public VirtualNetworkGatewayConnectionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline
 33        {
 8434            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 8438            endpoint ??= new Uri("https://management.azure.com");
 39
 8440            this.subscriptionId = subscriptionId;
 8441            this.endpoint = endpoint;
 8442            _clientDiagnostics = clientDiagnostics;
 8443            _pipeline = pipeline;
 8444        }
 45
 46        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string virtualNetworkGatewayConnectio
 47        {
 4848            var message = _pipeline.CreateMessage();
 4849            var request = message.Request;
 4850            request.Method = RequestMethod.Put;
 4851            var uri = new RawRequestUriBuilder();
 4852            uri.Reset(endpoint);
 4853            uri.AppendPath("/subscriptions/", false);
 4854            uri.AppendPath(subscriptionId, true);
 4855            uri.AppendPath("/resourceGroups/", false);
 4856            uri.AppendPath(resourceGroupName, true);
 4857            uri.AppendPath("/providers/Microsoft.Network/connections/", false);
 4858            uri.AppendPath(virtualNetworkGatewayConnectionName, true);
 4859            uri.AppendQuery("api-version", "2020-04-01", true);
 4860            request.Uri = uri;
 4861            request.Headers.Add("Content-Type", "application/json");
 4862            var content = new Utf8JsonRequestContent();
 4863            content.JsonWriter.WriteObjectValue(parameters);
 4864            request.Content = content;
 4865            return message;
 66        }
 67
 68        /// <summary> Creates or updates a virtual network gateway connection in the specified resource group. </summary
 69        /// <param name="resourceGroupName"> The name of the resource group. </param>
 70        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 71        /// <param name="parameters"> Parameters supplied to the create or update virtual network gateway connection ope
 72        /// <param name="cancellationToken"> The cancellation token to use. </param>
 73        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string virtualNetworkGatewayConnection
 74        {
 1275            if (resourceGroupName == null)
 76            {
 077                throw new ArgumentNullException(nameof(resourceGroupName));
 78            }
 1279            if (virtualNetworkGatewayConnectionName == null)
 80            {
 081                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 82            }
 1283            if (parameters == null)
 84            {
 085                throw new ArgumentNullException(nameof(parameters));
 86            }
 87
 1288            using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkGatewayConnectionName, para
 1289            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 1290            switch (message.Response.Status)
 91            {
 92                case 200:
 93                case 201:
 1294                    return message.Response;
 95                default:
 096                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 97            }
 1298        }
 99
 100        /// <summary> Creates or updates a virtual network gateway connection in the specified resource group. </summary
 101        /// <param name="resourceGroupName"> The name of the resource group. </param>
 102        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 103        /// <param name="parameters"> Parameters supplied to the create or update virtual network gateway connection ope
 104        /// <param name="cancellationToken"> The cancellation token to use. </param>
 105        public Response CreateOrUpdate(string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetw
 106        {
 12107            if (resourceGroupName == null)
 108            {
 0109                throw new ArgumentNullException(nameof(resourceGroupName));
 110            }
 12111            if (virtualNetworkGatewayConnectionName == null)
 112            {
 0113                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 114            }
 12115            if (parameters == null)
 116            {
 0117                throw new ArgumentNullException(nameof(parameters));
 118            }
 119
 12120            using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkGatewayConnectionName, para
 12121            _pipeline.Send(message, cancellationToken);
 12122            switch (message.Response.Status)
 123            {
 124                case 200:
 125                case 201:
 12126                    return message.Response;
 127                default:
 0128                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 129            }
 12130        }
 131
 132        internal HttpMessage CreateGetRequest(string resourceGroupName, string virtualNetworkGatewayConnectionName)
 133        {
 24134            var message = _pipeline.CreateMessage();
 24135            var request = message.Request;
 24136            request.Method = RequestMethod.Get;
 24137            var uri = new RawRequestUriBuilder();
 24138            uri.Reset(endpoint);
 24139            uri.AppendPath("/subscriptions/", false);
 24140            uri.AppendPath(subscriptionId, true);
 24141            uri.AppendPath("/resourceGroups/", false);
 24142            uri.AppendPath(resourceGroupName, true);
 24143            uri.AppendPath("/providers/Microsoft.Network/connections/", false);
 24144            uri.AppendPath(virtualNetworkGatewayConnectionName, true);
 24145            uri.AppendQuery("api-version", "2020-04-01", true);
 24146            request.Uri = uri;
 24147            return message;
 148        }
 149
 150        /// <summary> Gets the specified virtual network gateway connection by resource group. </summary>
 151        /// <param name="resourceGroupName"> The name of the resource group. </param>
 152        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 153        /// <param name="cancellationToken"> The cancellation token to use. </param>
 154        public async Task<Response<VirtualNetworkGatewayConnection>> GetAsync(string resourceGroupName, string virtualNe
 155        {
 12156            if (resourceGroupName == null)
 157            {
 0158                throw new ArgumentNullException(nameof(resourceGroupName));
 159            }
 12160            if (virtualNetworkGatewayConnectionName == null)
 161            {
 0162                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 163            }
 164
 12165            using var message = CreateGetRequest(resourceGroupName, virtualNetworkGatewayConnectionName);
 12166            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 12167            switch (message.Response.Status)
 168            {
 169                case 200:
 170                    {
 12171                        VirtualNetworkGatewayConnection value = default;
 12172                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 12173                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 174                        {
 0175                            value = null;
 176                        }
 177                        else
 178                        {
 12179                            value = VirtualNetworkGatewayConnection.DeserializeVirtualNetworkGatewayConnection(document.
 180                        }
 12181                        return Response.FromValue(value, message.Response);
 182                    }
 183                default:
 0184                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 185            }
 12186        }
 187
 188        /// <summary> Gets the specified virtual network gateway connection by resource group. </summary>
 189        /// <param name="resourceGroupName"> The name of the resource group. </param>
 190        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 191        /// <param name="cancellationToken"> The cancellation token to use. </param>
 192        public Response<VirtualNetworkGatewayConnection> Get(string resourceGroupName, string virtualNetworkGatewayConne
 193        {
 12194            if (resourceGroupName == null)
 195            {
 0196                throw new ArgumentNullException(nameof(resourceGroupName));
 197            }
 12198            if (virtualNetworkGatewayConnectionName == null)
 199            {
 0200                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 201            }
 202
 12203            using var message = CreateGetRequest(resourceGroupName, virtualNetworkGatewayConnectionName);
 12204            _pipeline.Send(message, cancellationToken);
 12205            switch (message.Response.Status)
 206            {
 207                case 200:
 208                    {
 12209                        VirtualNetworkGatewayConnection value = default;
 12210                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 12211                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 212                        {
 0213                            value = null;
 214                        }
 215                        else
 216                        {
 12217                            value = VirtualNetworkGatewayConnection.DeserializeVirtualNetworkGatewayConnection(document.
 218                        }
 12219                        return Response.FromValue(value, message.Response);
 220                    }
 221                default:
 0222                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 223            }
 12224        }
 225
 226        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string virtualNetworkGatewayConnectionName)
 227        {
 24228            var message = _pipeline.CreateMessage();
 24229            var request = message.Request;
 24230            request.Method = RequestMethod.Delete;
 24231            var uri = new RawRequestUriBuilder();
 24232            uri.Reset(endpoint);
 24233            uri.AppendPath("/subscriptions/", false);
 24234            uri.AppendPath(subscriptionId, true);
 24235            uri.AppendPath("/resourceGroups/", false);
 24236            uri.AppendPath(resourceGroupName, true);
 24237            uri.AppendPath("/providers/Microsoft.Network/connections/", false);
 24238            uri.AppendPath(virtualNetworkGatewayConnectionName, true);
 24239            uri.AppendQuery("api-version", "2020-04-01", true);
 24240            request.Uri = uri;
 24241            return message;
 242        }
 243
 244        /// <summary> Deletes the specified virtual network Gateway connection. </summary>
 245        /// <param name="resourceGroupName"> The name of the resource group. </param>
 246        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 247        /// <param name="cancellationToken"> The cancellation token to use. </param>
 248        public async Task<Response> DeleteAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Ca
 249        {
 6250            if (resourceGroupName == null)
 251            {
 0252                throw new ArgumentNullException(nameof(resourceGroupName));
 253            }
 6254            if (virtualNetworkGatewayConnectionName == null)
 255            {
 0256                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 257            }
 258
 6259            using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkGatewayConnectionName);
 6260            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 6261            switch (message.Response.Status)
 262            {
 263                case 200:
 264                case 202:
 265                case 204:
 6266                    return message.Response;
 267                default:
 0268                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 269            }
 6270        }
 271
 272        /// <summary> Deletes the specified virtual network Gateway connection. </summary>
 273        /// <param name="resourceGroupName"> The name of the resource group. </param>
 274        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 275        /// <param name="cancellationToken"> The cancellation token to use. </param>
 276        public Response Delete(string resourceGroupName, string virtualNetworkGatewayConnectionName, CancellationToken c
 277        {
 6278            if (resourceGroupName == null)
 279            {
 0280                throw new ArgumentNullException(nameof(resourceGroupName));
 281            }
 6282            if (virtualNetworkGatewayConnectionName == null)
 283            {
 0284                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 285            }
 286
 6287            using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkGatewayConnectionName);
 6288            _pipeline.Send(message, cancellationToken);
 6289            switch (message.Response.Status)
 290            {
 291                case 200:
 292                case 202:
 293                case 204:
 6294                    return message.Response;
 295                default:
 0296                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 297            }
 6298        }
 299
 300        internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string virtualNetworkGatewayConnectionNam
 301        {
 0302            var message = _pipeline.CreateMessage();
 0303            var request = message.Request;
 0304            request.Method = RequestMethod.Patch;
 0305            var uri = new RawRequestUriBuilder();
 0306            uri.Reset(endpoint);
 0307            uri.AppendPath("/subscriptions/", false);
 0308            uri.AppendPath(subscriptionId, true);
 0309            uri.AppendPath("/resourceGroups/", false);
 0310            uri.AppendPath(resourceGroupName, true);
 0311            uri.AppendPath("/providers/Microsoft.Network/connections/", false);
 0312            uri.AppendPath(virtualNetworkGatewayConnectionName, true);
 0313            uri.AppendQuery("api-version", "2020-04-01", true);
 0314            request.Uri = uri;
 0315            request.Headers.Add("Content-Type", "application/json");
 0316            var content = new Utf8JsonRequestContent();
 0317            content.JsonWriter.WriteObjectValue(parameters);
 0318            request.Content = content;
 0319            return message;
 320        }
 321
 322        /// <summary> Updates a virtual network gateway connection tags. </summary>
 323        /// <param name="resourceGroupName"> The name of the resource group. </param>
 324        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 325        /// <param name="parameters"> Parameters supplied to update virtual network gateway connection tags. </param>
 326        /// <param name="cancellationToken"> The cancellation token to use. </param>
 327        public async Task<Response> UpdateTagsAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName
 328        {
 0329            if (resourceGroupName == null)
 330            {
 0331                throw new ArgumentNullException(nameof(resourceGroupName));
 332            }
 0333            if (virtualNetworkGatewayConnectionName == null)
 334            {
 0335                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 336            }
 0337            if (parameters == null)
 338            {
 0339                throw new ArgumentNullException(nameof(parameters));
 340            }
 341
 0342            using var message = CreateUpdateTagsRequest(resourceGroupName, virtualNetworkGatewayConnectionName, paramete
 0343            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0344            switch (message.Response.Status)
 345            {
 346                case 200:
 347                case 202:
 0348                    return message.Response;
 349                default:
 0350                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 351            }
 0352        }
 353
 354        /// <summary> Updates a virtual network gateway connection tags. </summary>
 355        /// <param name="resourceGroupName"> The name of the resource group. </param>
 356        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 357        /// <param name="parameters"> Parameters supplied to update virtual network gateway connection tags. </param>
 358        /// <param name="cancellationToken"> The cancellation token to use. </param>
 359        public Response UpdateTags(string resourceGroupName, string virtualNetworkGatewayConnectionName, TagsObject para
 360        {
 0361            if (resourceGroupName == null)
 362            {
 0363                throw new ArgumentNullException(nameof(resourceGroupName));
 364            }
 0365            if (virtualNetworkGatewayConnectionName == null)
 366            {
 0367                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 368            }
 0369            if (parameters == null)
 370            {
 0371                throw new ArgumentNullException(nameof(parameters));
 372            }
 373
 0374            using var message = CreateUpdateTagsRequest(resourceGroupName, virtualNetworkGatewayConnectionName, paramete
 0375            _pipeline.Send(message, cancellationToken);
 0376            switch (message.Response.Status)
 377            {
 378                case 200:
 379                case 202:
 0380                    return message.Response;
 381                default:
 0382                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 383            }
 0384        }
 385
 386        internal HttpMessage CreateSetSharedKeyRequest(string resourceGroupName, string virtualNetworkGatewayConnectionN
 387        {
 0388            var message = _pipeline.CreateMessage();
 0389            var request = message.Request;
 0390            request.Method = RequestMethod.Put;
 0391            var uri = new RawRequestUriBuilder();
 0392            uri.Reset(endpoint);
 0393            uri.AppendPath("/subscriptions/", false);
 0394            uri.AppendPath(subscriptionId, true);
 0395            uri.AppendPath("/resourceGroups/", false);
 0396            uri.AppendPath(resourceGroupName, true);
 0397            uri.AppendPath("/providers/Microsoft.Network/connections/", false);
 0398            uri.AppendPath(virtualNetworkGatewayConnectionName, true);
 0399            uri.AppendPath("/sharedkey", false);
 0400            uri.AppendQuery("api-version", "2020-04-01", true);
 0401            request.Uri = uri;
 0402            request.Headers.Add("Content-Type", "application/json");
 0403            var content = new Utf8JsonRequestContent();
 0404            content.JsonWriter.WriteObjectValue(parameters);
 0405            request.Content = content;
 0406            return message;
 407        }
 408
 409        /// <summary> The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connec
 410        /// <param name="resourceGroupName"> The name of the resource group. </param>
 411        /// <param name="virtualNetworkGatewayConnectionName"> The virtual network gateway connection name. </param>
 412        /// <param name="parameters"> Parameters supplied to the Begin Set Virtual Network Gateway connection Shared key
 413        /// <param name="cancellationToken"> The cancellation token to use. </param>
 414        public async Task<Response> SetSharedKeyAsync(string resourceGroupName, string virtualNetworkGatewayConnectionNa
 415        {
 0416            if (resourceGroupName == null)
 417            {
 0418                throw new ArgumentNullException(nameof(resourceGroupName));
 419            }
 0420            if (virtualNetworkGatewayConnectionName == null)
 421            {
 0422                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 423            }
 0424            if (parameters == null)
 425            {
 0426                throw new ArgumentNullException(nameof(parameters));
 427            }
 428
 0429            using var message = CreateSetSharedKeyRequest(resourceGroupName, virtualNetworkGatewayConnectionName, parame
 0430            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0431            switch (message.Response.Status)
 432            {
 433                case 200:
 434                case 201:
 0435                    return message.Response;
 436                default:
 0437                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 438            }
 0439        }
 440
 441        /// <summary> The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connec
 442        /// <param name="resourceGroupName"> The name of the resource group. </param>
 443        /// <param name="virtualNetworkGatewayConnectionName"> The virtual network gateway connection name. </param>
 444        /// <param name="parameters"> Parameters supplied to the Begin Set Virtual Network Gateway connection Shared key
 445        /// <param name="cancellationToken"> The cancellation token to use. </param>
 446        public Response SetSharedKey(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSha
 447        {
 0448            if (resourceGroupName == null)
 449            {
 0450                throw new ArgumentNullException(nameof(resourceGroupName));
 451            }
 0452            if (virtualNetworkGatewayConnectionName == null)
 453            {
 0454                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 455            }
 0456            if (parameters == null)
 457            {
 0458                throw new ArgumentNullException(nameof(parameters));
 459            }
 460
 0461            using var message = CreateSetSharedKeyRequest(resourceGroupName, virtualNetworkGatewayConnectionName, parame
 0462            _pipeline.Send(message, cancellationToken);
 0463            switch (message.Response.Status)
 464            {
 465                case 200:
 466                case 201:
 0467                    return message.Response;
 468                default:
 0469                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 470            }
 0471        }
 472
 473        internal HttpMessage CreateGetSharedKeyRequest(string resourceGroupName, string virtualNetworkGatewayConnectionN
 474        {
 0475            var message = _pipeline.CreateMessage();
 0476            var request = message.Request;
 0477            request.Method = RequestMethod.Get;
 0478            var uri = new RawRequestUriBuilder();
 0479            uri.Reset(endpoint);
 0480            uri.AppendPath("/subscriptions/", false);
 0481            uri.AppendPath(subscriptionId, true);
 0482            uri.AppendPath("/resourceGroups/", false);
 0483            uri.AppendPath(resourceGroupName, true);
 0484            uri.AppendPath("/providers/Microsoft.Network/connections/", false);
 0485            uri.AppendPath(virtualNetworkGatewayConnectionName, true);
 0486            uri.AppendPath("/sharedkey", false);
 0487            uri.AppendQuery("api-version", "2020-04-01", true);
 0488            request.Uri = uri;
 0489            return message;
 490        }
 491
 492        /// <summary> The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specifi
 493        /// <param name="resourceGroupName"> The name of the resource group. </param>
 494        /// <param name="virtualNetworkGatewayConnectionName"> The virtual network gateway connection shared key name. <
 495        /// <param name="cancellationToken"> The cancellation token to use. </param>
 496        public async Task<Response<ConnectionSharedKey>> GetSharedKeyAsync(string resourceGroupName, string virtualNetwo
 497        {
 0498            if (resourceGroupName == null)
 499            {
 0500                throw new ArgumentNullException(nameof(resourceGroupName));
 501            }
 0502            if (virtualNetworkGatewayConnectionName == null)
 503            {
 0504                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 505            }
 506
 0507            using var message = CreateGetSharedKeyRequest(resourceGroupName, virtualNetworkGatewayConnectionName);
 0508            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0509            switch (message.Response.Status)
 510            {
 511                case 200:
 512                    {
 0513                        ConnectionSharedKey value = default;
 0514                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0515                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 516                        {
 0517                            value = null;
 518                        }
 519                        else
 520                        {
 0521                            value = ConnectionSharedKey.DeserializeConnectionSharedKey(document.RootElement);
 522                        }
 0523                        return Response.FromValue(value, message.Response);
 524                    }
 525                default:
 0526                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 527            }
 0528        }
 529
 530        /// <summary> The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specifi
 531        /// <param name="resourceGroupName"> The name of the resource group. </param>
 532        /// <param name="virtualNetworkGatewayConnectionName"> The virtual network gateway connection shared key name. <
 533        /// <param name="cancellationToken"> The cancellation token to use. </param>
 534        public Response<ConnectionSharedKey> GetSharedKey(string resourceGroupName, string virtualNetworkGatewayConnecti
 535        {
 0536            if (resourceGroupName == null)
 537            {
 0538                throw new ArgumentNullException(nameof(resourceGroupName));
 539            }
 0540            if (virtualNetworkGatewayConnectionName == null)
 541            {
 0542                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 543            }
 544
 0545            using var message = CreateGetSharedKeyRequest(resourceGroupName, virtualNetworkGatewayConnectionName);
 0546            _pipeline.Send(message, cancellationToken);
 0547            switch (message.Response.Status)
 548            {
 549                case 200:
 550                    {
 0551                        ConnectionSharedKey value = default;
 0552                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0553                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 554                        {
 0555                            value = null;
 556                        }
 557                        else
 558                        {
 0559                            value = ConnectionSharedKey.DeserializeConnectionSharedKey(document.RootElement);
 560                        }
 0561                        return Response.FromValue(value, message.Response);
 562                    }
 563                default:
 0564                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 565            }
 0566        }
 567
 568        internal HttpMessage CreateListRequest(string resourceGroupName)
 569        {
 24570            var message = _pipeline.CreateMessage();
 24571            var request = message.Request;
 24572            request.Method = RequestMethod.Get;
 24573            var uri = new RawRequestUriBuilder();
 24574            uri.Reset(endpoint);
 24575            uri.AppendPath("/subscriptions/", false);
 24576            uri.AppendPath(subscriptionId, true);
 24577            uri.AppendPath("/resourceGroups/", false);
 24578            uri.AppendPath(resourceGroupName, true);
 24579            uri.AppendPath("/providers/Microsoft.Network/connections", false);
 24580            uri.AppendQuery("api-version", "2020-04-01", true);
 24581            request.Uri = uri;
 24582            return message;
 583        }
 584
 585        /// <summary> The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways con
 586        /// <param name="resourceGroupName"> The name of the resource group. </param>
 587        /// <param name="cancellationToken"> The cancellation token to use. </param>
 588        public async Task<Response<VirtualNetworkGatewayConnectionListResult>> ListAsync(string resourceGroupName, Cance
 589        {
 12590            if (resourceGroupName == null)
 591            {
 0592                throw new ArgumentNullException(nameof(resourceGroupName));
 593            }
 594
 12595            using var message = CreateListRequest(resourceGroupName);
 12596            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 12597            switch (message.Response.Status)
 598            {
 599                case 200:
 600                    {
 12601                        VirtualNetworkGatewayConnectionListResult value = default;
 12602                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 12603                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 604                        {
 0605                            value = null;
 606                        }
 607                        else
 608                        {
 12609                            value = VirtualNetworkGatewayConnectionListResult.DeserializeVirtualNetworkGatewayConnection
 610                        }
 12611                        return Response.FromValue(value, message.Response);
 612                    }
 613                default:
 0614                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 615            }
 12616        }
 617
 618        /// <summary> The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways con
 619        /// <param name="resourceGroupName"> The name of the resource group. </param>
 620        /// <param name="cancellationToken"> The cancellation token to use. </param>
 621        public Response<VirtualNetworkGatewayConnectionListResult> List(string resourceGroupName, CancellationToken canc
 622        {
 12623            if (resourceGroupName == null)
 624            {
 0625                throw new ArgumentNullException(nameof(resourceGroupName));
 626            }
 627
 12628            using var message = CreateListRequest(resourceGroupName);
 12629            _pipeline.Send(message, cancellationToken);
 12630            switch (message.Response.Status)
 631            {
 632                case 200:
 633                    {
 12634                        VirtualNetworkGatewayConnectionListResult value = default;
 12635                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 12636                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 637                        {
 0638                            value = null;
 639                        }
 640                        else
 641                        {
 12642                            value = VirtualNetworkGatewayConnectionListResult.DeserializeVirtualNetworkGatewayConnection
 643                        }
 12644                        return Response.FromValue(value, message.Response);
 645                    }
 646                default:
 0647                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 648            }
 12649        }
 650
 651        internal HttpMessage CreateResetSharedKeyRequest(string resourceGroupName, string virtualNetworkGatewayConnectio
 652        {
 0653            var message = _pipeline.CreateMessage();
 0654            var request = message.Request;
 0655            request.Method = RequestMethod.Post;
 0656            var uri = new RawRequestUriBuilder();
 0657            uri.Reset(endpoint);
 0658            uri.AppendPath("/subscriptions/", false);
 0659            uri.AppendPath(subscriptionId, true);
 0660            uri.AppendPath("/resourceGroups/", false);
 0661            uri.AppendPath(resourceGroupName, true);
 0662            uri.AppendPath("/providers/Microsoft.Network/connections/", false);
 0663            uri.AppendPath(virtualNetworkGatewayConnectionName, true);
 0664            uri.AppendPath("/sharedkey/reset", false);
 0665            uri.AppendQuery("api-version", "2020-04-01", true);
 0666            request.Uri = uri;
 0667            request.Headers.Add("Content-Type", "application/json");
 0668            var content = new Utf8JsonRequestContent();
 0669            content.JsonWriter.WriteObjectValue(parameters);
 0670            request.Content = content;
 0671            return message;
 672        }
 673
 674        /// <summary> The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway con
 675        /// <param name="resourceGroupName"> The name of the resource group. </param>
 676        /// <param name="virtualNetworkGatewayConnectionName"> The virtual network gateway connection reset shared key N
 677        /// <param name="parameters"> Parameters supplied to the begin reset virtual network gateway connection shared k
 678        /// <param name="cancellationToken"> The cancellation token to use. </param>
 679        public async Task<Response> ResetSharedKeyAsync(string resourceGroupName, string virtualNetworkGatewayConnection
 680        {
 0681            if (resourceGroupName == null)
 682            {
 0683                throw new ArgumentNullException(nameof(resourceGroupName));
 684            }
 0685            if (virtualNetworkGatewayConnectionName == null)
 686            {
 0687                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 688            }
 0689            if (parameters == null)
 690            {
 0691                throw new ArgumentNullException(nameof(parameters));
 692            }
 693
 0694            using var message = CreateResetSharedKeyRequest(resourceGroupName, virtualNetworkGatewayConnectionName, para
 0695            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0696            switch (message.Response.Status)
 697            {
 698                case 200:
 699                case 202:
 0700                    return message.Response;
 701                default:
 0702                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 703            }
 0704        }
 705
 706        /// <summary> The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway con
 707        /// <param name="resourceGroupName"> The name of the resource group. </param>
 708        /// <param name="virtualNetworkGatewayConnectionName"> The virtual network gateway connection reset shared key N
 709        /// <param name="parameters"> Parameters supplied to the begin reset virtual network gateway connection shared k
 710        /// <param name="cancellationToken"> The cancellation token to use. </param>
 711        public Response ResetSharedKey(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionR
 712        {
 0713            if (resourceGroupName == null)
 714            {
 0715                throw new ArgumentNullException(nameof(resourceGroupName));
 716            }
 0717            if (virtualNetworkGatewayConnectionName == null)
 718            {
 0719                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 720            }
 0721            if (parameters == null)
 722            {
 0723                throw new ArgumentNullException(nameof(parameters));
 724            }
 725
 0726            using var message = CreateResetSharedKeyRequest(resourceGroupName, virtualNetworkGatewayConnectionName, para
 0727            _pipeline.Send(message, cancellationToken);
 0728            switch (message.Response.Status)
 729            {
 730                case 200:
 731                case 202:
 0732                    return message.Response;
 733                default:
 0734                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 735            }
 0736        }
 737
 738        internal HttpMessage CreateStartPacketCaptureRequest(string resourceGroupName, string virtualNetworkGatewayConne
 739        {
 0740            var message = _pipeline.CreateMessage();
 0741            var request = message.Request;
 0742            request.Method = RequestMethod.Post;
 0743            var uri = new RawRequestUriBuilder();
 0744            uri.Reset(endpoint);
 0745            uri.AppendPath("/subscriptions/", false);
 0746            uri.AppendPath(subscriptionId, true);
 0747            uri.AppendPath("/resourceGroups/", false);
 0748            uri.AppendPath(resourceGroupName, true);
 0749            uri.AppendPath("/providers/Microsoft.Network/connections/", false);
 0750            uri.AppendPath(virtualNetworkGatewayConnectionName, true);
 0751            uri.AppendPath("/startPacketCapture", false);
 0752            uri.AppendQuery("api-version", "2020-04-01", true);
 0753            request.Uri = uri;
 0754            request.Headers.Add("Content-Type", "application/json");
 0755            if (parameters != null)
 756            {
 0757                var content = new Utf8JsonRequestContent();
 0758                content.JsonWriter.WriteObjectValue(parameters);
 0759                request.Content = content;
 760            }
 0761            return message;
 762        }
 763
 764        /// <summary> Starts packet capture on virtual network gateway connection in the specified resource group. </sum
 765        /// <param name="resourceGroupName"> The name of the resource group. </param>
 766        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 767        /// <param name="parameters"> Virtual network gateway packet capture parameters supplied to start packet capture
 768        /// <param name="cancellationToken"> The cancellation token to use. </param>
 769        public async Task<Response> StartPacketCaptureAsync(string resourceGroupName, string virtualNetworkGatewayConnec
 770        {
 0771            if (resourceGroupName == null)
 772            {
 0773                throw new ArgumentNullException(nameof(resourceGroupName));
 774            }
 0775            if (virtualNetworkGatewayConnectionName == null)
 776            {
 0777                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 778            }
 779
 0780            using var message = CreateStartPacketCaptureRequest(resourceGroupName, virtualNetworkGatewayConnectionName, 
 0781            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0782            switch (message.Response.Status)
 783            {
 784                case 200:
 785                case 202:
 0786                    return message.Response;
 787                default:
 0788                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 789            }
 0790        }
 791
 792        /// <summary> Starts packet capture on virtual network gateway connection in the specified resource group. </sum
 793        /// <param name="resourceGroupName"> The name of the resource group. </param>
 794        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway connection. </par
 795        /// <param name="parameters"> Virtual network gateway packet capture parameters supplied to start packet capture
 796        /// <param name="cancellationToken"> The cancellation token to use. </param>
 797        public Response StartPacketCapture(string resourceGroupName, string virtualNetworkGatewayConnectionName, VpnPack
 798        {
 0799            if (resourceGroupName == null)
 800            {
 0801                throw new ArgumentNullException(nameof(resourceGroupName));
 802            }
 0803            if (virtualNetworkGatewayConnectionName == null)
 804            {
 0805                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 806            }
 807
 0808            using var message = CreateStartPacketCaptureRequest(resourceGroupName, virtualNetworkGatewayConnectionName, 
 0809            _pipeline.Send(message, cancellationToken);
 0810            switch (message.Response.Status)
 811            {
 812                case 200:
 813                case 202:
 0814                    return message.Response;
 815                default:
 0816                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 817            }
 0818        }
 819
 820        internal HttpMessage CreateStopPacketCaptureRequest(string resourceGroupName, string virtualNetworkGatewayConnec
 821        {
 0822            var message = _pipeline.CreateMessage();
 0823            var request = message.Request;
 0824            request.Method = RequestMethod.Post;
 0825            var uri = new RawRequestUriBuilder();
 0826            uri.Reset(endpoint);
 0827            uri.AppendPath("/subscriptions/", false);
 0828            uri.AppendPath(subscriptionId, true);
 0829            uri.AppendPath("/resourceGroups/", false);
 0830            uri.AppendPath(resourceGroupName, true);
 0831            uri.AppendPath("/providers/Microsoft.Network/connections/", false);
 0832            uri.AppendPath(virtualNetworkGatewayConnectionName, true);
 0833            uri.AppendPath("/stopPacketCapture", false);
 0834            uri.AppendQuery("api-version", "2020-04-01", true);
 0835            request.Uri = uri;
 0836            request.Headers.Add("Content-Type", "application/json");
 0837            var content = new Utf8JsonRequestContent();
 0838            content.JsonWriter.WriteObjectValue(parameters);
 0839            request.Content = content;
 0840            return message;
 841        }
 842
 843        /// <summary> Stops packet capture on virtual network gateway connection in the specified resource group. </summ
 844        /// <param name="resourceGroupName"> The name of the resource group. </param>
 845        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway Connection. </par
 846        /// <param name="parameters"> Virtual network gateway packet capture parameters supplied to stop packet capture 
 847        /// <param name="cancellationToken"> The cancellation token to use. </param>
 848        public async Task<Response> StopPacketCaptureAsync(string resourceGroupName, string virtualNetworkGatewayConnect
 849        {
 0850            if (resourceGroupName == null)
 851            {
 0852                throw new ArgumentNullException(nameof(resourceGroupName));
 853            }
 0854            if (virtualNetworkGatewayConnectionName == null)
 855            {
 0856                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 857            }
 0858            if (parameters == null)
 859            {
 0860                throw new ArgumentNullException(nameof(parameters));
 861            }
 862
 0863            using var message = CreateStopPacketCaptureRequest(resourceGroupName, virtualNetworkGatewayConnectionName, p
 0864            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0865            switch (message.Response.Status)
 866            {
 867                case 200:
 868                case 202:
 0869                    return message.Response;
 870                default:
 0871                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 872            }
 0873        }
 874
 875        /// <summary> Stops packet capture on virtual network gateway connection in the specified resource group. </summ
 876        /// <param name="resourceGroupName"> The name of the resource group. </param>
 877        /// <param name="virtualNetworkGatewayConnectionName"> The name of the virtual network gateway Connection. </par
 878        /// <param name="parameters"> Virtual network gateway packet capture parameters supplied to stop packet capture 
 879        /// <param name="cancellationToken"> The cancellation token to use. </param>
 880        public Response StopPacketCapture(string resourceGroupName, string virtualNetworkGatewayConnectionName, VpnPacke
 881        {
 0882            if (resourceGroupName == null)
 883            {
 0884                throw new ArgumentNullException(nameof(resourceGroupName));
 885            }
 0886            if (virtualNetworkGatewayConnectionName == null)
 887            {
 0888                throw new ArgumentNullException(nameof(virtualNetworkGatewayConnectionName));
 889            }
 0890            if (parameters == null)
 891            {
 0892                throw new ArgumentNullException(nameof(parameters));
 893            }
 894
 0895            using var message = CreateStopPacketCaptureRequest(resourceGroupName, virtualNetworkGatewayConnectionName, p
 0896            _pipeline.Send(message, cancellationToken);
 0897            switch (message.Response.Status)
 898            {
 899                case 200:
 900                case 202:
 0901                    return message.Response;
 902                default:
 0903                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 904            }
 0905        }
 906
 907        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName)
 908        {
 0909            var message = _pipeline.CreateMessage();
 0910            var request = message.Request;
 0911            request.Method = RequestMethod.Get;
 0912            var uri = new RawRequestUriBuilder();
 0913            uri.Reset(endpoint);
 0914            uri.AppendRawNextLink(nextLink, false);
 0915            request.Uri = uri;
 0916            return message;
 917        }
 918
 919        /// <summary> The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways con
 920        /// <param name="nextLink"> The URL to the next page of results. </param>
 921        /// <param name="resourceGroupName"> The name of the resource group. </param>
 922        /// <param name="cancellationToken"> The cancellation token to use. </param>
 923        public async Task<Response<VirtualNetworkGatewayConnectionListResult>> ListNextPageAsync(string nextLink, string
 924        {
 0925            if (nextLink == null)
 926            {
 0927                throw new ArgumentNullException(nameof(nextLink));
 928            }
 0929            if (resourceGroupName == null)
 930            {
 0931                throw new ArgumentNullException(nameof(resourceGroupName));
 932            }
 933
 0934            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 0935            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0936            switch (message.Response.Status)
 937            {
 938                case 200:
 939                    {
 0940                        VirtualNetworkGatewayConnectionListResult value = default;
 0941                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0942                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 943                        {
 0944                            value = null;
 945                        }
 946                        else
 947                        {
 0948                            value = VirtualNetworkGatewayConnectionListResult.DeserializeVirtualNetworkGatewayConnection
 949                        }
 0950                        return Response.FromValue(value, message.Response);
 951                    }
 952                default:
 0953                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 954            }
 0955        }
 956
 957        /// <summary> The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways con
 958        /// <param name="nextLink"> The URL to the next page of results. </param>
 959        /// <param name="resourceGroupName"> The name of the resource group. </param>
 960        /// <param name="cancellationToken"> The cancellation token to use. </param>
 961        public Response<VirtualNetworkGatewayConnectionListResult> ListNextPage(string nextLink, string resourceGroupNam
 962        {
 0963            if (nextLink == null)
 964            {
 0965                throw new ArgumentNullException(nameof(nextLink));
 966            }
 0967            if (resourceGroupName == null)
 968            {
 0969                throw new ArgumentNullException(nameof(resourceGroupName));
 970            }
 971
 0972            using var message = CreateListNextPageRequest(nextLink, resourceGroupName);
 0973            _pipeline.Send(message, cancellationToken);
 0974            switch (message.Response.Status)
 975            {
 976                case 200:
 977                    {
 0978                        VirtualNetworkGatewayConnectionListResult value = default;
 0979                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0980                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 981                        {
 0982                            value = null;
 983                        }
 984                        else
 985                        {
 0986                            value = VirtualNetworkGatewayConnectionListResult.DeserializeVirtualNetworkGatewayConnection
 987                        }
 0988                        return Response.FromValue(value, message.Response);
 989                    }
 990                default:
 0991                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 992            }
 0993        }
 994    }
 995}