| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Network.Models; |
| | 16 | |
|
| | 17 | | namespace 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 |
| 0 | 32 | | public VpnSiteLinkConnectionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string s |
| | 33 | | { |
| 0 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 0 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 0 | 40 | | this.subscriptionId = subscriptionId; |
| 0 | 41 | | this.endpoint = endpoint; |
| 0 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 43 | | _pipeline = pipeline; |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string gatewayName, string connectionName, strin |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Get; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 54 | | uri.AppendPath(subscriptionId, true); |
| 0 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 57 | | uri.AppendPath("/providers/Microsoft.Network/vpnGateways/", false); |
| 0 | 58 | | uri.AppendPath(gatewayName, true); |
| 0 | 59 | | uri.AppendPath("/vpnConnections/", false); |
| 0 | 60 | | uri.AppendPath(connectionName, true); |
| 0 | 61 | | uri.AppendPath("/vpnLinkConnections/", false); |
| 0 | 62 | | uri.AppendPath(linkConnectionName, true); |
| 0 | 63 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 64 | | request.Uri = uri; |
| 0 | 65 | | 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 | | { |
| 0 | 76 | | if (resourceGroupName == null) |
| | 77 | | { |
| 0 | 78 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 79 | | } |
| 0 | 80 | | if (gatewayName == null) |
| | 81 | | { |
| 0 | 82 | | throw new ArgumentNullException(nameof(gatewayName)); |
| | 83 | | } |
| 0 | 84 | | if (connectionName == null) |
| | 85 | | { |
| 0 | 86 | | throw new ArgumentNullException(nameof(connectionName)); |
| | 87 | | } |
| 0 | 88 | | if (linkConnectionName == null) |
| | 89 | | { |
| 0 | 90 | | throw new ArgumentNullException(nameof(linkConnectionName)); |
| | 91 | | } |
| | 92 | |
|
| 0 | 93 | | using var message = CreateGetRequest(resourceGroupName, gatewayName, connectionName, linkConnectionName); |
| 0 | 94 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 95 | | switch (message.Response.Status) |
| | 96 | | { |
| | 97 | | case 200: |
| | 98 | | { |
| 0 | 99 | | VpnSiteLinkConnection value = default; |
| 0 | 100 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 101 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 102 | | { |
| 0 | 103 | | value = null; |
| | 104 | | } |
| | 105 | | else |
| | 106 | | { |
| 0 | 107 | | value = VpnSiteLinkConnection.DeserializeVpnSiteLinkConnection(document.RootElement); |
| | 108 | | } |
| 0 | 109 | | return Response.FromValue(value, message.Response); |
| | 110 | | } |
| | 111 | | default: |
| 0 | 112 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 113 | | } |
| 0 | 114 | | } |
| | 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 | | { |
| 0 | 124 | | if (resourceGroupName == null) |
| | 125 | | { |
| 0 | 126 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 127 | | } |
| 0 | 128 | | if (gatewayName == null) |
| | 129 | | { |
| 0 | 130 | | throw new ArgumentNullException(nameof(gatewayName)); |
| | 131 | | } |
| 0 | 132 | | if (connectionName == null) |
| | 133 | | { |
| 0 | 134 | | throw new ArgumentNullException(nameof(connectionName)); |
| | 135 | | } |
| 0 | 136 | | if (linkConnectionName == null) |
| | 137 | | { |
| 0 | 138 | | throw new ArgumentNullException(nameof(linkConnectionName)); |
| | 139 | | } |
| | 140 | |
|
| 0 | 141 | | using var message = CreateGetRequest(resourceGroupName, gatewayName, connectionName, linkConnectionName); |
| 0 | 142 | | _pipeline.Send(message, cancellationToken); |
| 0 | 143 | | switch (message.Response.Status) |
| | 144 | | { |
| | 145 | | case 200: |
| | 146 | | { |
| 0 | 147 | | VpnSiteLinkConnection value = default; |
| 0 | 148 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 149 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 150 | | { |
| 0 | 151 | | value = null; |
| | 152 | | } |
| | 153 | | else |
| | 154 | | { |
| 0 | 155 | | value = VpnSiteLinkConnection.DeserializeVpnSiteLinkConnection(document.RootElement); |
| | 156 | | } |
| 0 | 157 | | return Response.FromValue(value, message.Response); |
| | 158 | | } |
| | 159 | | default: |
| 0 | 160 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 161 | | } |
| 0 | 162 | | } |
| | 163 | | } |
| | 164 | | } |