| | 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.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Core; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | | using Azure.ResourceManager.Network.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Network |
| | 17 | | { |
| | 18 | | internal partial class VpnSitesConfigurationRestOperations |
| | 19 | | { |
| | 20 | | private string subscriptionId; |
| | 21 | | private Uri endpoint; |
| | 22 | | private ClientDiagnostics _clientDiagnostics; |
| | 23 | | private HttpPipeline _pipeline; |
| | 24 | |
|
| | 25 | | /// <summary> Initializes a new instance of VpnSitesConfigurationRestOperations. </summary> |
| | 26 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 27 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 28 | | /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc |
| | 29 | | /// <param name="endpoint"> server parameter. </param> |
| | 30 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 0 | 31 | | public VpnSitesConfigurationRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string su |
| | 32 | | { |
| 0 | 33 | | if (subscriptionId == null) |
| | 34 | | { |
| 0 | 35 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 36 | | } |
| 0 | 37 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 38 | |
|
| 0 | 39 | | this.subscriptionId = subscriptionId; |
| 0 | 40 | | this.endpoint = endpoint; |
| 0 | 41 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 42 | | _pipeline = pipeline; |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | internal HttpMessage CreateDownloadRequest(string resourceGroupName, string virtualWANName, GetVpnSitesConfigura |
| | 46 | | { |
| 0 | 47 | | var message = _pipeline.CreateMessage(); |
| 0 | 48 | | var request0 = message.Request; |
| 0 | 49 | | request0.Method = RequestMethod.Post; |
| 0 | 50 | | var uri = new RawRequestUriBuilder(); |
| 0 | 51 | | uri.Reset(endpoint); |
| 0 | 52 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 53 | | uri.AppendPath(subscriptionId, true); |
| 0 | 54 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 55 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 56 | | uri.AppendPath("/providers/Microsoft.Network/virtualWans/", false); |
| 0 | 57 | | uri.AppendPath(virtualWANName, true); |
| 0 | 58 | | uri.AppendPath("/vpnConfiguration", false); |
| 0 | 59 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 60 | | request0.Uri = uri; |
| 0 | 61 | | request0.Headers.Add("Content-Type", "application/json"); |
| 0 | 62 | | var content = new Utf8JsonRequestContent(); |
| 0 | 63 | | content.JsonWriter.WriteObjectValue(request); |
| 0 | 64 | | request0.Content = content; |
| 0 | 65 | | return message; |
| | 66 | | } |
| | 67 | |
|
| | 68 | | /// <summary> Gives the sas-url to download the configurations for vpn-sites in a resource group. </summary> |
| | 69 | | /// <param name="resourceGroupName"> The resource group name. </param> |
| | 70 | | /// <param name="virtualWANName"> The name of the VirtualWAN for which configuration of all vpn-sites is needed. |
| | 71 | | /// <param name="request"> Parameters supplied to download vpn-sites configuration. </param> |
| | 72 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 73 | | public async Task<Response> DownloadAsync(string resourceGroupName, string virtualWANName, GetVpnSitesConfigurat |
| | 74 | | { |
| 0 | 75 | | if (resourceGroupName == null) |
| | 76 | | { |
| 0 | 77 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 78 | | } |
| 0 | 79 | | if (virtualWANName == null) |
| | 80 | | { |
| 0 | 81 | | throw new ArgumentNullException(nameof(virtualWANName)); |
| | 82 | | } |
| 0 | 83 | | if (request == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(request)); |
| | 86 | | } |
| | 87 | |
|
| 0 | 88 | | using var message = CreateDownloadRequest(resourceGroupName, virtualWANName, request); |
| 0 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | case 202: |
| 0 | 94 | | return message.Response; |
| | 95 | | default: |
| 0 | 96 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 97 | | } |
| 0 | 98 | | } |
| | 99 | |
|
| | 100 | | /// <summary> Gives the sas-url to download the configurations for vpn-sites in a resource group. </summary> |
| | 101 | | /// <param name="resourceGroupName"> The resource group name. </param> |
| | 102 | | /// <param name="virtualWANName"> The name of the VirtualWAN for which configuration of all vpn-sites is needed. |
| | 103 | | /// <param name="request"> Parameters supplied to download vpn-sites configuration. </param> |
| | 104 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 105 | | public Response Download(string resourceGroupName, string virtualWANName, GetVpnSitesConfigurationRequest reques |
| | 106 | | { |
| 0 | 107 | | if (resourceGroupName == null) |
| | 108 | | { |
| 0 | 109 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 110 | | } |
| 0 | 111 | | if (virtualWANName == null) |
| | 112 | | { |
| 0 | 113 | | throw new ArgumentNullException(nameof(virtualWANName)); |
| | 114 | | } |
| 0 | 115 | | if (request == null) |
| | 116 | | { |
| 0 | 117 | | throw new ArgumentNullException(nameof(request)); |
| | 118 | | } |
| | 119 | |
|
| 0 | 120 | | using var message = CreateDownloadRequest(resourceGroupName, virtualWANName, request); |
| 0 | 121 | | _pipeline.Send(message, cancellationToken); |
| 0 | 122 | | switch (message.Response.Status) |
| | 123 | | { |
| | 124 | | case 200: |
| | 125 | | case 202: |
| 0 | 126 | | return message.Response; |
| | 127 | | default: |
| 0 | 128 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 129 | | } |
| 0 | 130 | | } |
| | 131 | | } |
| | 132 | | } |