< Summary

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

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%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateListByVpnGatewayRequest(...)-0%100%
ListByVpnGatewayAsync()-0%0%
ListByVpnGateway(...)-0%0%
CreateListByVpnGatewayNextPageRequest(...)-0%100%
ListByVpnGatewayNextPageAsync()-0%0%
ListByVpnGatewayNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\VpnConnectionsRestOperations.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 VpnConnectionsRestOperations
 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 VpnConnectionsRestOperations. </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 VpnConnectionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript
 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, string connectionName)
 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.AppendPath("/vpnConnections/", false);
 060            uri.AppendPath(connectionName, true);
 061            uri.AppendQuery("api-version", "2020-04-01", true);
 062            request.Uri = uri;
 063            return message;
 64        }
 65
 66        /// <summary> Retrieves the details of a vpn connection. </summary>
 67        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 68        /// <param name="gatewayName"> The name of the gateway. </param>
 69        /// <param name="connectionName"> The name of the vpn connection. </param>
 70        /// <param name="cancellationToken"> The cancellation token to use. </param>
 71        public async Task<Response<VpnConnection>> GetAsync(string resourceGroupName, string gatewayName, string connect
 72        {
 073            if (resourceGroupName == null)
 74            {
 075                throw new ArgumentNullException(nameof(resourceGroupName));
 76            }
 077            if (gatewayName == null)
 78            {
 079                throw new ArgumentNullException(nameof(gatewayName));
 80            }
 081            if (connectionName == null)
 82            {
 083                throw new ArgumentNullException(nameof(connectionName));
 84            }
 85
 086            using var message = CreateGetRequest(resourceGroupName, gatewayName, connectionName);
 087            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 088            switch (message.Response.Status)
 89            {
 90                case 200:
 91                    {
 092                        VpnConnection value = default;
 093                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 094                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 95                        {
 096                            value = null;
 97                        }
 98                        else
 99                        {
 0100                            value = VpnConnection.DeserializeVpnConnection(document.RootElement);
 101                        }
 0102                        return Response.FromValue(value, message.Response);
 103                    }
 104                default:
 0105                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 106            }
 0107        }
 108
 109        /// <summary> Retrieves the details of a vpn connection. </summary>
 110        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 111        /// <param name="gatewayName"> The name of the gateway. </param>
 112        /// <param name="connectionName"> The name of the vpn connection. </param>
 113        /// <param name="cancellationToken"> The cancellation token to use. </param>
 114        public Response<VpnConnection> Get(string resourceGroupName, string gatewayName, string connectionName, Cancella
 115        {
 0116            if (resourceGroupName == null)
 117            {
 0118                throw new ArgumentNullException(nameof(resourceGroupName));
 119            }
 0120            if (gatewayName == null)
 121            {
 0122                throw new ArgumentNullException(nameof(gatewayName));
 123            }
 0124            if (connectionName == null)
 125            {
 0126                throw new ArgumentNullException(nameof(connectionName));
 127            }
 128
 0129            using var message = CreateGetRequest(resourceGroupName, gatewayName, connectionName);
 0130            _pipeline.Send(message, cancellationToken);
 0131            switch (message.Response.Status)
 132            {
 133                case 200:
 134                    {
 0135                        VpnConnection value = default;
 0136                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0137                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 138                        {
 0139                            value = null;
 140                        }
 141                        else
 142                        {
 0143                            value = VpnConnection.DeserializeVpnConnection(document.RootElement);
 144                        }
 0145                        return Response.FromValue(value, message.Response);
 146                    }
 147                default:
 0148                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 149            }
 0150        }
 151
 152        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string gatewayName, string connection
 153        {
 0154            var message = _pipeline.CreateMessage();
 0155            var request = message.Request;
 0156            request.Method = RequestMethod.Put;
 0157            var uri = new RawRequestUriBuilder();
 0158            uri.Reset(endpoint);
 0159            uri.AppendPath("/subscriptions/", false);
 0160            uri.AppendPath(subscriptionId, true);
 0161            uri.AppendPath("/resourceGroups/", false);
 0162            uri.AppendPath(resourceGroupName, true);
 0163            uri.AppendPath("/providers/Microsoft.Network/vpnGateways/", false);
 0164            uri.AppendPath(gatewayName, true);
 0165            uri.AppendPath("/vpnConnections/", false);
 0166            uri.AppendPath(connectionName, true);
 0167            uri.AppendQuery("api-version", "2020-04-01", true);
 0168            request.Uri = uri;
 0169            request.Headers.Add("Content-Type", "application/json");
 0170            var content = new Utf8JsonRequestContent();
 0171            content.JsonWriter.WriteObjectValue(vpnConnectionParameters);
 0172            request.Content = content;
 0173            return message;
 174        }
 175
 176        /// <summary> Creates a vpn connection to a scalable vpn gateway if it doesn&apos;t exist else updates the exist
 177        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 178        /// <param name="gatewayName"> The name of the gateway. </param>
 179        /// <param name="connectionName"> The name of the connection. </param>
 180        /// <param name="vpnConnectionParameters"> Parameters supplied to create or Update a VPN Connection. </param>
 181        /// <param name="cancellationToken"> The cancellation token to use. </param>
 182        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string gatewayName, string connectionN
 183        {
 0184            if (resourceGroupName == null)
 185            {
 0186                throw new ArgumentNullException(nameof(resourceGroupName));
 187            }
 0188            if (gatewayName == null)
 189            {
 0190                throw new ArgumentNullException(nameof(gatewayName));
 191            }
 0192            if (connectionName == null)
 193            {
 0194                throw new ArgumentNullException(nameof(connectionName));
 195            }
 0196            if (vpnConnectionParameters == null)
 197            {
 0198                throw new ArgumentNullException(nameof(vpnConnectionParameters));
 199            }
 200
 0201            using var message = CreateCreateOrUpdateRequest(resourceGroupName, gatewayName, connectionName, vpnConnectio
 0202            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0203            switch (message.Response.Status)
 204            {
 205                case 200:
 206                case 201:
 0207                    return message.Response;
 208                default:
 0209                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 210            }
 0211        }
 212
 213        /// <summary> Creates a vpn connection to a scalable vpn gateway if it doesn&apos;t exist else updates the exist
 214        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 215        /// <param name="gatewayName"> The name of the gateway. </param>
 216        /// <param name="connectionName"> The name of the connection. </param>
 217        /// <param name="vpnConnectionParameters"> Parameters supplied to create or Update a VPN Connection. </param>
 218        /// <param name="cancellationToken"> The cancellation token to use. </param>
 219        public Response CreateOrUpdate(string resourceGroupName, string gatewayName, string connectionName, VpnConnectio
 220        {
 0221            if (resourceGroupName == null)
 222            {
 0223                throw new ArgumentNullException(nameof(resourceGroupName));
 224            }
 0225            if (gatewayName == null)
 226            {
 0227                throw new ArgumentNullException(nameof(gatewayName));
 228            }
 0229            if (connectionName == null)
 230            {
 0231                throw new ArgumentNullException(nameof(connectionName));
 232            }
 0233            if (vpnConnectionParameters == null)
 234            {
 0235                throw new ArgumentNullException(nameof(vpnConnectionParameters));
 236            }
 237
 0238            using var message = CreateCreateOrUpdateRequest(resourceGroupName, gatewayName, connectionName, vpnConnectio
 0239            _pipeline.Send(message, cancellationToken);
 0240            switch (message.Response.Status)
 241            {
 242                case 200:
 243                case 201:
 0244                    return message.Response;
 245                default:
 0246                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 247            }
 0248        }
 249
 250        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string gatewayName, string connectionName)
 251        {
 0252            var message = _pipeline.CreateMessage();
 0253            var request = message.Request;
 0254            request.Method = RequestMethod.Delete;
 0255            var uri = new RawRequestUriBuilder();
 0256            uri.Reset(endpoint);
 0257            uri.AppendPath("/subscriptions/", false);
 0258            uri.AppendPath(subscriptionId, true);
 0259            uri.AppendPath("/resourceGroups/", false);
 0260            uri.AppendPath(resourceGroupName, true);
 0261            uri.AppendPath("/providers/Microsoft.Network/vpnGateways/", false);
 0262            uri.AppendPath(gatewayName, true);
 0263            uri.AppendPath("/vpnConnections/", false);
 0264            uri.AppendPath(connectionName, true);
 0265            uri.AppendQuery("api-version", "2020-04-01", true);
 0266            request.Uri = uri;
 0267            return message;
 268        }
 269
 270        /// <summary> Deletes a vpn connection. </summary>
 271        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 272        /// <param name="gatewayName"> The name of the gateway. </param>
 273        /// <param name="connectionName"> The name of the connection. </param>
 274        /// <param name="cancellationToken"> The cancellation token to use. </param>
 275        public async Task<Response> DeleteAsync(string resourceGroupName, string gatewayName, string connectionName, Can
 276        {
 0277            if (resourceGroupName == null)
 278            {
 0279                throw new ArgumentNullException(nameof(resourceGroupName));
 280            }
 0281            if (gatewayName == null)
 282            {
 0283                throw new ArgumentNullException(nameof(gatewayName));
 284            }
 0285            if (connectionName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(connectionName));
 288            }
 289
 0290            using var message = CreateDeleteRequest(resourceGroupName, gatewayName, connectionName);
 0291            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0292            switch (message.Response.Status)
 293            {
 294                case 200:
 295                case 202:
 296                case 204:
 0297                    return message.Response;
 298                default:
 0299                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 300            }
 0301        }
 302
 303        /// <summary> Deletes a vpn connection. </summary>
 304        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 305        /// <param name="gatewayName"> The name of the gateway. </param>
 306        /// <param name="connectionName"> The name of the connection. </param>
 307        /// <param name="cancellationToken"> The cancellation token to use. </param>
 308        public Response Delete(string resourceGroupName, string gatewayName, string connectionName, CancellationToken ca
 309        {
 0310            if (resourceGroupName == null)
 311            {
 0312                throw new ArgumentNullException(nameof(resourceGroupName));
 313            }
 0314            if (gatewayName == null)
 315            {
 0316                throw new ArgumentNullException(nameof(gatewayName));
 317            }
 0318            if (connectionName == null)
 319            {
 0320                throw new ArgumentNullException(nameof(connectionName));
 321            }
 322
 0323            using var message = CreateDeleteRequest(resourceGroupName, gatewayName, connectionName);
 0324            _pipeline.Send(message, cancellationToken);
 0325            switch (message.Response.Status)
 326            {
 327                case 200:
 328                case 202:
 329                case 204:
 0330                    return message.Response;
 331                default:
 0332                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 333            }
 0334        }
 335
 336        internal HttpMessage CreateListByVpnGatewayRequest(string resourceGroupName, string gatewayName)
 337        {
 0338            var message = _pipeline.CreateMessage();
 0339            var request = message.Request;
 0340            request.Method = RequestMethod.Get;
 0341            var uri = new RawRequestUriBuilder();
 0342            uri.Reset(endpoint);
 0343            uri.AppendPath("/subscriptions/", false);
 0344            uri.AppendPath(subscriptionId, true);
 0345            uri.AppendPath("/resourceGroups/", false);
 0346            uri.AppendPath(resourceGroupName, true);
 0347            uri.AppendPath("/providers/Microsoft.Network/vpnGateways/", false);
 0348            uri.AppendPath(gatewayName, true);
 0349            uri.AppendPath("/vpnConnections", false);
 0350            uri.AppendQuery("api-version", "2020-04-01", true);
 0351            request.Uri = uri;
 0352            return message;
 353        }
 354
 355        /// <summary> Retrieves all vpn connections for a particular virtual wan vpn gateway. </summary>
 356        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 357        /// <param name="gatewayName"> The name of the gateway. </param>
 358        /// <param name="cancellationToken"> The cancellation token to use. </param>
 359        public async Task<Response<ListVpnConnectionsResult>> ListByVpnGatewayAsync(string resourceGroupName, string gat
 360        {
 0361            if (resourceGroupName == null)
 362            {
 0363                throw new ArgumentNullException(nameof(resourceGroupName));
 364            }
 0365            if (gatewayName == null)
 366            {
 0367                throw new ArgumentNullException(nameof(gatewayName));
 368            }
 369
 0370            using var message = CreateListByVpnGatewayRequest(resourceGroupName, gatewayName);
 0371            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0372            switch (message.Response.Status)
 373            {
 374                case 200:
 375                    {
 0376                        ListVpnConnectionsResult value = default;
 0377                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0378                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 379                        {
 0380                            value = null;
 381                        }
 382                        else
 383                        {
 0384                            value = ListVpnConnectionsResult.DeserializeListVpnConnectionsResult(document.RootElement);
 385                        }
 0386                        return Response.FromValue(value, message.Response);
 387                    }
 388                default:
 0389                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 390            }
 0391        }
 392
 393        /// <summary> Retrieves all vpn connections for a particular virtual wan vpn gateway. </summary>
 394        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 395        /// <param name="gatewayName"> The name of the gateway. </param>
 396        /// <param name="cancellationToken"> The cancellation token to use. </param>
 397        public Response<ListVpnConnectionsResult> ListByVpnGateway(string resourceGroupName, string gatewayName, Cancell
 398        {
 0399            if (resourceGroupName == null)
 400            {
 0401                throw new ArgumentNullException(nameof(resourceGroupName));
 402            }
 0403            if (gatewayName == null)
 404            {
 0405                throw new ArgumentNullException(nameof(gatewayName));
 406            }
 407
 0408            using var message = CreateListByVpnGatewayRequest(resourceGroupName, gatewayName);
 0409            _pipeline.Send(message, cancellationToken);
 0410            switch (message.Response.Status)
 411            {
 412                case 200:
 413                    {
 0414                        ListVpnConnectionsResult value = default;
 0415                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0416                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 417                        {
 0418                            value = null;
 419                        }
 420                        else
 421                        {
 0422                            value = ListVpnConnectionsResult.DeserializeListVpnConnectionsResult(document.RootElement);
 423                        }
 0424                        return Response.FromValue(value, message.Response);
 425                    }
 426                default:
 0427                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 428            }
 0429        }
 430
 431        internal HttpMessage CreateListByVpnGatewayNextPageRequest(string nextLink, string resourceGroupName, string gat
 432        {
 0433            var message = _pipeline.CreateMessage();
 0434            var request = message.Request;
 0435            request.Method = RequestMethod.Get;
 0436            var uri = new RawRequestUriBuilder();
 0437            uri.Reset(endpoint);
 0438            uri.AppendRawNextLink(nextLink, false);
 0439            request.Uri = uri;
 0440            return message;
 441        }
 442
 443        /// <summary> Retrieves all vpn connections for a particular virtual wan vpn gateway. </summary>
 444        /// <param name="nextLink"> The URL to the next page of results. </param>
 445        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 446        /// <param name="gatewayName"> The name of the gateway. </param>
 447        /// <param name="cancellationToken"> The cancellation token to use. </param>
 448        public async Task<Response<ListVpnConnectionsResult>> ListByVpnGatewayNextPageAsync(string nextLink, string reso
 449        {
 0450            if (nextLink == null)
 451            {
 0452                throw new ArgumentNullException(nameof(nextLink));
 453            }
 0454            if (resourceGroupName == null)
 455            {
 0456                throw new ArgumentNullException(nameof(resourceGroupName));
 457            }
 0458            if (gatewayName == null)
 459            {
 0460                throw new ArgumentNullException(nameof(gatewayName));
 461            }
 462
 0463            using var message = CreateListByVpnGatewayNextPageRequest(nextLink, resourceGroupName, gatewayName);
 0464            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0465            switch (message.Response.Status)
 466            {
 467                case 200:
 468                    {
 0469                        ListVpnConnectionsResult value = default;
 0470                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0471                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 472                        {
 0473                            value = null;
 474                        }
 475                        else
 476                        {
 0477                            value = ListVpnConnectionsResult.DeserializeListVpnConnectionsResult(document.RootElement);
 478                        }
 0479                        return Response.FromValue(value, message.Response);
 480                    }
 481                default:
 0482                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 483            }
 0484        }
 485
 486        /// <summary> Retrieves all vpn connections for a particular virtual wan vpn gateway. </summary>
 487        /// <param name="nextLink"> The URL to the next page of results. </param>
 488        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 489        /// <param name="gatewayName"> The name of the gateway. </param>
 490        /// <param name="cancellationToken"> The cancellation token to use. </param>
 491        public Response<ListVpnConnectionsResult> ListByVpnGatewayNextPage(string nextLink, string resourceGroupName, st
 492        {
 0493            if (nextLink == null)
 494            {
 0495                throw new ArgumentNullException(nameof(nextLink));
 496            }
 0497            if (resourceGroupName == null)
 498            {
 0499                throw new ArgumentNullException(nameof(resourceGroupName));
 500            }
 0501            if (gatewayName == null)
 502            {
 0503                throw new ArgumentNullException(nameof(gatewayName));
 504            }
 505
 0506            using var message = CreateListByVpnGatewayNextPageRequest(nextLink, resourceGroupName, gatewayName);
 0507            _pipeline.Send(message, cancellationToken);
 0508            switch (message.Response.Status)
 509            {
 510                case 200:
 511                    {
 0512                        ListVpnConnectionsResult value = default;
 0513                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0514                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 515                        {
 0516                            value = null;
 517                        }
 518                        else
 519                        {
 0520                            value = ListVpnConnectionsResult.DeserializeListVpnConnectionsResult(document.RootElement);
 521                        }
 0522                        return Response.FromValue(value, message.Response);
 523                    }
 524                default:
 0525                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 526            }
 0527        }
 528    }
 529}