| | | 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 VpnSiteLinksRestOperations |
| | | 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 VpnSiteLinksRestOperations. </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 VpnSiteLinksRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio |
| | | 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 vpnSiteName, string vpnSiteLinkName) |
| | | 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/vpnSites/", false); |
| | 0 | 58 | | uri.AppendPath(vpnSiteName, true); |
| | 0 | 59 | | uri.AppendPath("/vpnSiteLinks/", false); |
| | 0 | 60 | | uri.AppendPath(vpnSiteLinkName, true); |
| | 0 | 61 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| | 0 | 62 | | request.Uri = uri; |
| | 0 | 63 | | return message; |
| | | 64 | | } |
| | | 65 | | |
| | | 66 | | /// <summary> Retrieves the details of a VPN site link. </summary> |
| | | 67 | | /// <param name="resourceGroupName"> The resource group name of the VpnSite. </param> |
| | | 68 | | /// <param name="vpnSiteName"> The name of the VpnSite. </param> |
| | | 69 | | /// <param name="vpnSiteLinkName"> The name of the VpnSiteLink being retrieved. </param> |
| | | 70 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 71 | | public async Task<Response<VpnSiteLink>> GetAsync(string resourceGroupName, string vpnSiteName, string vpnSiteLi |
| | | 72 | | { |
| | 0 | 73 | | if (resourceGroupName == null) |
| | | 74 | | { |
| | 0 | 75 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 76 | | } |
| | 0 | 77 | | if (vpnSiteName == null) |
| | | 78 | | { |
| | 0 | 79 | | throw new ArgumentNullException(nameof(vpnSiteName)); |
| | | 80 | | } |
| | 0 | 81 | | if (vpnSiteLinkName == null) |
| | | 82 | | { |
| | 0 | 83 | | throw new ArgumentNullException(nameof(vpnSiteLinkName)); |
| | | 84 | | } |
| | | 85 | | |
| | 0 | 86 | | using var message = CreateGetRequest(resourceGroupName, vpnSiteName, vpnSiteLinkName); |
| | 0 | 87 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 88 | | switch (message.Response.Status) |
| | | 89 | | { |
| | | 90 | | case 200: |
| | | 91 | | { |
| | 0 | 92 | | VpnSiteLink value = default; |
| | 0 | 93 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 94 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 95 | | { |
| | 0 | 96 | | value = null; |
| | | 97 | | } |
| | | 98 | | else |
| | | 99 | | { |
| | 0 | 100 | | value = VpnSiteLink.DeserializeVpnSiteLink(document.RootElement); |
| | | 101 | | } |
| | 0 | 102 | | return Response.FromValue(value, message.Response); |
| | | 103 | | } |
| | | 104 | | default: |
| | 0 | 105 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 106 | | } |
| | 0 | 107 | | } |
| | | 108 | | |
| | | 109 | | /// <summary> Retrieves the details of a VPN site link. </summary> |
| | | 110 | | /// <param name="resourceGroupName"> The resource group name of the VpnSite. </param> |
| | | 111 | | /// <param name="vpnSiteName"> The name of the VpnSite. </param> |
| | | 112 | | /// <param name="vpnSiteLinkName"> The name of the VpnSiteLink being retrieved. </param> |
| | | 113 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 114 | | public Response<VpnSiteLink> Get(string resourceGroupName, string vpnSiteName, string vpnSiteLinkName, Cancellat |
| | | 115 | | { |
| | 0 | 116 | | if (resourceGroupName == null) |
| | | 117 | | { |
| | 0 | 118 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 119 | | } |
| | 0 | 120 | | if (vpnSiteName == null) |
| | | 121 | | { |
| | 0 | 122 | | throw new ArgumentNullException(nameof(vpnSiteName)); |
| | | 123 | | } |
| | 0 | 124 | | if (vpnSiteLinkName == null) |
| | | 125 | | { |
| | 0 | 126 | | throw new ArgumentNullException(nameof(vpnSiteLinkName)); |
| | | 127 | | } |
| | | 128 | | |
| | 0 | 129 | | using var message = CreateGetRequest(resourceGroupName, vpnSiteName, vpnSiteLinkName); |
| | 0 | 130 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 131 | | switch (message.Response.Status) |
| | | 132 | | { |
| | | 133 | | case 200: |
| | | 134 | | { |
| | 0 | 135 | | VpnSiteLink value = default; |
| | 0 | 136 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 137 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 138 | | { |
| | 0 | 139 | | value = null; |
| | | 140 | | } |
| | | 141 | | else |
| | | 142 | | { |
| | 0 | 143 | | value = VpnSiteLink.DeserializeVpnSiteLink(document.RootElement); |
| | | 144 | | } |
| | 0 | 145 | | return Response.FromValue(value, message.Response); |
| | | 146 | | } |
| | | 147 | | default: |
| | 0 | 148 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 149 | | } |
| | 0 | 150 | | } |
| | | 151 | | |
| | | 152 | | internal HttpMessage CreateListByVpnSiteRequest(string resourceGroupName, string vpnSiteName) |
| | | 153 | | { |
| | 0 | 154 | | var message = _pipeline.CreateMessage(); |
| | 0 | 155 | | var request = message.Request; |
| | 0 | 156 | | request.Method = RequestMethod.Get; |
| | 0 | 157 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 158 | | uri.Reset(endpoint); |
| | 0 | 159 | | uri.AppendPath("/subscriptions/", false); |
| | 0 | 160 | | uri.AppendPath(subscriptionId, true); |
| | 0 | 161 | | uri.AppendPath("/resourceGroups/", false); |
| | 0 | 162 | | uri.AppendPath(resourceGroupName, true); |
| | 0 | 163 | | uri.AppendPath("/providers/Microsoft.Network/vpnSites/", false); |
| | 0 | 164 | | uri.AppendPath(vpnSiteName, true); |
| | 0 | 165 | | uri.AppendPath("/vpnSiteLinks", false); |
| | 0 | 166 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| | 0 | 167 | | request.Uri = uri; |
| | 0 | 168 | | return message; |
| | | 169 | | } |
| | | 170 | | |
| | | 171 | | /// <summary> Lists all the vpnSiteLinks in a resource group for a vpn site. </summary> |
| | | 172 | | /// <param name="resourceGroupName"> The resource group name of the VpnSite. </param> |
| | | 173 | | /// <param name="vpnSiteName"> The name of the VpnSite. </param> |
| | | 174 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 175 | | public async Task<Response<ListVpnSiteLinksResult>> ListByVpnSiteAsync(string resourceGroupName, string vpnSiteN |
| | | 176 | | { |
| | 0 | 177 | | if (resourceGroupName == null) |
| | | 178 | | { |
| | 0 | 179 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 180 | | } |
| | 0 | 181 | | if (vpnSiteName == null) |
| | | 182 | | { |
| | 0 | 183 | | throw new ArgumentNullException(nameof(vpnSiteName)); |
| | | 184 | | } |
| | | 185 | | |
| | 0 | 186 | | using var message = CreateListByVpnSiteRequest(resourceGroupName, vpnSiteName); |
| | 0 | 187 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 188 | | switch (message.Response.Status) |
| | | 189 | | { |
| | | 190 | | case 200: |
| | | 191 | | { |
| | 0 | 192 | | ListVpnSiteLinksResult value = default; |
| | 0 | 193 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 194 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 195 | | { |
| | 0 | 196 | | value = null; |
| | | 197 | | } |
| | | 198 | | else |
| | | 199 | | { |
| | 0 | 200 | | value = ListVpnSiteLinksResult.DeserializeListVpnSiteLinksResult(document.RootElement); |
| | | 201 | | } |
| | 0 | 202 | | return Response.FromValue(value, message.Response); |
| | | 203 | | } |
| | | 204 | | default: |
| | 0 | 205 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 206 | | } |
| | 0 | 207 | | } |
| | | 208 | | |
| | | 209 | | /// <summary> Lists all the vpnSiteLinks in a resource group for a vpn site. </summary> |
| | | 210 | | /// <param name="resourceGroupName"> The resource group name of the VpnSite. </param> |
| | | 211 | | /// <param name="vpnSiteName"> The name of the VpnSite. </param> |
| | | 212 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 213 | | public Response<ListVpnSiteLinksResult> ListByVpnSite(string resourceGroupName, string vpnSiteName, Cancellation |
| | | 214 | | { |
| | 0 | 215 | | if (resourceGroupName == null) |
| | | 216 | | { |
| | 0 | 217 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 218 | | } |
| | 0 | 219 | | if (vpnSiteName == null) |
| | | 220 | | { |
| | 0 | 221 | | throw new ArgumentNullException(nameof(vpnSiteName)); |
| | | 222 | | } |
| | | 223 | | |
| | 0 | 224 | | using var message = CreateListByVpnSiteRequest(resourceGroupName, vpnSiteName); |
| | 0 | 225 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 226 | | switch (message.Response.Status) |
| | | 227 | | { |
| | | 228 | | case 200: |
| | | 229 | | { |
| | 0 | 230 | | ListVpnSiteLinksResult value = default; |
| | 0 | 231 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 232 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 233 | | { |
| | 0 | 234 | | value = null; |
| | | 235 | | } |
| | | 236 | | else |
| | | 237 | | { |
| | 0 | 238 | | value = ListVpnSiteLinksResult.DeserializeListVpnSiteLinksResult(document.RootElement); |
| | | 239 | | } |
| | 0 | 240 | | return Response.FromValue(value, message.Response); |
| | | 241 | | } |
| | | 242 | | default: |
| | 0 | 243 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 244 | | } |
| | 0 | 245 | | } |
| | | 246 | | |
| | | 247 | | internal HttpMessage CreateListByVpnSiteNextPageRequest(string nextLink, string resourceGroupName, string vpnSit |
| | | 248 | | { |
| | 0 | 249 | | var message = _pipeline.CreateMessage(); |
| | 0 | 250 | | var request = message.Request; |
| | 0 | 251 | | request.Method = RequestMethod.Get; |
| | 0 | 252 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 253 | | uri.Reset(endpoint); |
| | 0 | 254 | | uri.AppendRawNextLink(nextLink, false); |
| | 0 | 255 | | request.Uri = uri; |
| | 0 | 256 | | return message; |
| | | 257 | | } |
| | | 258 | | |
| | | 259 | | /// <summary> Lists all the vpnSiteLinks in a resource group for a vpn site. </summary> |
| | | 260 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 261 | | /// <param name="resourceGroupName"> The resource group name of the VpnSite. </param> |
| | | 262 | | /// <param name="vpnSiteName"> The name of the VpnSite. </param> |
| | | 263 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 264 | | public async Task<Response<ListVpnSiteLinksResult>> ListByVpnSiteNextPageAsync(string nextLink, string resourceG |
| | | 265 | | { |
| | 0 | 266 | | if (nextLink == null) |
| | | 267 | | { |
| | 0 | 268 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 269 | | } |
| | 0 | 270 | | if (resourceGroupName == null) |
| | | 271 | | { |
| | 0 | 272 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 273 | | } |
| | 0 | 274 | | if (vpnSiteName == null) |
| | | 275 | | { |
| | 0 | 276 | | throw new ArgumentNullException(nameof(vpnSiteName)); |
| | | 277 | | } |
| | | 278 | | |
| | 0 | 279 | | using var message = CreateListByVpnSiteNextPageRequest(nextLink, resourceGroupName, vpnSiteName); |
| | 0 | 280 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 281 | | switch (message.Response.Status) |
| | | 282 | | { |
| | | 283 | | case 200: |
| | | 284 | | { |
| | 0 | 285 | | ListVpnSiteLinksResult value = default; |
| | 0 | 286 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 287 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 288 | | { |
| | 0 | 289 | | value = null; |
| | | 290 | | } |
| | | 291 | | else |
| | | 292 | | { |
| | 0 | 293 | | value = ListVpnSiteLinksResult.DeserializeListVpnSiteLinksResult(document.RootElement); |
| | | 294 | | } |
| | 0 | 295 | | return Response.FromValue(value, message.Response); |
| | | 296 | | } |
| | | 297 | | default: |
| | 0 | 298 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 299 | | } |
| | 0 | 300 | | } |
| | | 301 | | |
| | | 302 | | /// <summary> Lists all the vpnSiteLinks in a resource group for a vpn site. </summary> |
| | | 303 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 304 | | /// <param name="resourceGroupName"> The resource group name of the VpnSite. </param> |
| | | 305 | | /// <param name="vpnSiteName"> The name of the VpnSite. </param> |
| | | 306 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 307 | | public Response<ListVpnSiteLinksResult> ListByVpnSiteNextPage(string nextLink, string resourceGroupName, string |
| | | 308 | | { |
| | 0 | 309 | | if (nextLink == null) |
| | | 310 | | { |
| | 0 | 311 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 312 | | } |
| | 0 | 313 | | if (resourceGroupName == null) |
| | | 314 | | { |
| | 0 | 315 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 316 | | } |
| | 0 | 317 | | if (vpnSiteName == null) |
| | | 318 | | { |
| | 0 | 319 | | throw new ArgumentNullException(nameof(vpnSiteName)); |
| | | 320 | | } |
| | | 321 | | |
| | 0 | 322 | | using var message = CreateListByVpnSiteNextPageRequest(nextLink, resourceGroupName, vpnSiteName); |
| | 0 | 323 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 324 | | switch (message.Response.Status) |
| | | 325 | | { |
| | | 326 | | case 200: |
| | | 327 | | { |
| | 0 | 328 | | ListVpnSiteLinksResult value = default; |
| | 0 | 329 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 330 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 331 | | { |
| | 0 | 332 | | value = null; |
| | | 333 | | } |
| | | 334 | | else |
| | | 335 | | { |
| | 0 | 336 | | value = ListVpnSiteLinksResult.DeserializeListVpnSiteLinksResult(document.RootElement); |
| | | 337 | | } |
| | 0 | 338 | | return Response.FromValue(value, message.Response); |
| | | 339 | | } |
| | | 340 | | default: |
| | 0 | 341 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 342 | | } |
| | 0 | 343 | | } |
| | | 344 | | } |
| | | 345 | | } |