< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\VpnSiteLinkConnectionsRestOperations.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 VpnSiteLinkConnectionsRestOperations
 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 VpnSiteLinkConnectionsRestOperations. </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 VpnSiteLinkConnectionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string s
 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, strin
 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.AppendPath("/vpnLinkConnections/", false);
 062            uri.AppendPath(linkConnectionName, true);
 063            uri.AppendQuery("api-version", "2020-04-01", true);
 064            request.Uri = uri;
 065            return message;
 66        }
 67
 68        /// <summary> Retrieves the details of a vpn site link connection. </summary>
 69        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 70        /// <param name="gatewayName"> The name of the gateway. </param>
 71        /// <param name="connectionName"> The name of the vpn connection. </param>
 72        /// <param name="linkConnectionName"> The name of the vpn connection. </param>
 73        /// <param name="cancellationToken"> The cancellation token to use. </param>
 74        public async Task<Response<VpnSiteLinkConnection>> GetAsync(string resourceGroupName, string gatewayName, string
 75        {
 076            if (resourceGroupName == null)
 77            {
 078                throw new ArgumentNullException(nameof(resourceGroupName));
 79            }
 080            if (gatewayName == null)
 81            {
 082                throw new ArgumentNullException(nameof(gatewayName));
 83            }
 084            if (connectionName == null)
 85            {
 086                throw new ArgumentNullException(nameof(connectionName));
 87            }
 088            if (linkConnectionName == null)
 89            {
 090                throw new ArgumentNullException(nameof(linkConnectionName));
 91            }
 92
 093            using var message = CreateGetRequest(resourceGroupName, gatewayName, connectionName, linkConnectionName);
 094            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 095            switch (message.Response.Status)
 96            {
 97                case 200:
 98                    {
 099                        VpnSiteLinkConnection value = default;
 0100                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0101                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 102                        {
 0103                            value = null;
 104                        }
 105                        else
 106                        {
 0107                            value = VpnSiteLinkConnection.DeserializeVpnSiteLinkConnection(document.RootElement);
 108                        }
 0109                        return Response.FromValue(value, message.Response);
 110                    }
 111                default:
 0112                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 113            }
 0114        }
 115
 116        /// <summary> Retrieves the details of a vpn site link connection. </summary>
 117        /// <param name="resourceGroupName"> The resource group name of the VpnGateway. </param>
 118        /// <param name="gatewayName"> The name of the gateway. </param>
 119        /// <param name="connectionName"> The name of the vpn connection. </param>
 120        /// <param name="linkConnectionName"> The name of the vpn connection. </param>
 121        /// <param name="cancellationToken"> The cancellation token to use. </param>
 122        public Response<VpnSiteLinkConnection> Get(string resourceGroupName, string gatewayName, string connectionName, 
 123        {
 0124            if (resourceGroupName == null)
 125            {
 0126                throw new ArgumentNullException(nameof(resourceGroupName));
 127            }
 0128            if (gatewayName == null)
 129            {
 0130                throw new ArgumentNullException(nameof(gatewayName));
 131            }
 0132            if (connectionName == null)
 133            {
 0134                throw new ArgumentNullException(nameof(connectionName));
 135            }
 0136            if (linkConnectionName == null)
 137            {
 0138                throw new ArgumentNullException(nameof(linkConnectionName));
 139            }
 140
 0141            using var message = CreateGetRequest(resourceGroupName, gatewayName, connectionName, linkConnectionName);
 0142            _pipeline.Send(message, cancellationToken);
 0143            switch (message.Response.Status)
 144            {
 145                case 200:
 146                    {
 0147                        VpnSiteLinkConnection value = default;
 0148                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0149                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 150                        {
 0151                            value = null;
 152                        }
 153                        else
 154                        {
 0155                            value = VpnSiteLinkConnection.DeserializeVpnSiteLinkConnection(document.RootElement);
 156                        }
 0157                        return Response.FromValue(value, message.Response);
 158                    }
 159                default:
 0160                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 161            }
 0162        }
 163    }
 164}