1package network 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/tracing" 14 "net/http" 15) 16 17// VpnSitesConfigurationClient is the network Client 18type VpnSitesConfigurationClient struct { 19 BaseClient 20} 21 22// NewVpnSitesConfigurationClient creates an instance of the VpnSitesConfigurationClient client. 23func NewVpnSitesConfigurationClient(subscriptionID string) VpnSitesConfigurationClient { 24 return NewVpnSitesConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewVpnSitesConfigurationClientWithBaseURI creates an instance of the VpnSitesConfigurationClient client using a 28// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, 29// Azure stack). 30func NewVpnSitesConfigurationClientWithBaseURI(baseURI string, subscriptionID string) VpnSitesConfigurationClient { 31 return VpnSitesConfigurationClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Download gives the sas-url to download the configurations for vpn-sites in a resource group. 35// Parameters: 36// resourceGroupName - the resource group name. 37// virtualWANName - the name of the VirtualWAN for which configuration of all vpn-sites is needed. 38// request - parameters supplied to download vpn-sites configuration. 39func (client VpnSitesConfigurationClient) Download(ctx context.Context, resourceGroupName string, virtualWANName string, request GetVpnSitesConfigurationRequest) (result VpnSitesConfigurationDownloadFuture, err error) { 40 if tracing.IsEnabled() { 41 ctx = tracing.StartSpan(ctx, fqdn+"/VpnSitesConfigurationClient.Download") 42 defer func() { 43 sc := -1 44 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 45 sc = result.FutureAPI.Response().StatusCode 46 } 47 tracing.EndSpan(ctx, sc, err) 48 }() 49 } 50 req, err := client.DownloadPreparer(ctx, resourceGroupName, virtualWANName, request) 51 if err != nil { 52 err = autorest.NewErrorWithError(err, "network.VpnSitesConfigurationClient", "Download", nil, "Failure preparing request") 53 return 54 } 55 56 result, err = client.DownloadSender(req) 57 if err != nil { 58 err = autorest.NewErrorWithError(err, "network.VpnSitesConfigurationClient", "Download", nil, "Failure sending request") 59 return 60 } 61 62 return 63} 64 65// DownloadPreparer prepares the Download request. 66func (client VpnSitesConfigurationClient) DownloadPreparer(ctx context.Context, resourceGroupName string, virtualWANName string, request GetVpnSitesConfigurationRequest) (*http.Request, error) { 67 pathParameters := map[string]interface{}{ 68 "resourceGroupName": autorest.Encode("path", resourceGroupName), 69 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 70 "virtualWANName": autorest.Encode("path", virtualWANName), 71 } 72 73 const APIVersion = "2018-08-01" 74 queryParameters := map[string]interface{}{ 75 "api-version": APIVersion, 76 } 77 78 preparer := autorest.CreatePreparer( 79 autorest.AsContentType("application/json; charset=utf-8"), 80 autorest.AsPost(), 81 autorest.WithBaseURL(client.BaseURI), 82 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/vpnConfiguration", pathParameters), 83 autorest.WithJSON(request), 84 autorest.WithQueryParameters(queryParameters)) 85 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 86} 87 88// DownloadSender sends the Download request. The method will close the 89// http.Response Body if it receives an error. 90func (client VpnSitesConfigurationClient) DownloadSender(req *http.Request) (future VpnSitesConfigurationDownloadFuture, err error) { 91 var resp *http.Response 92 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 93 if err != nil { 94 return 95 } 96 var azf azure.Future 97 azf, err = azure.NewFutureFromResponse(resp) 98 future.FutureAPI = &azf 99 future.Result = future.result 100 return 101} 102 103// DownloadResponder handles the response to the Download request. The method always 104// closes the http.Response Body. 105func (client VpnSitesConfigurationClient) DownloadResponder(resp *http.Response) (result autorest.Response, err error) { 106 err = autorest.Respond( 107 resp, 108 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 109 autorest.ByClosing()) 110 result.Response = resp 111 return 112} 113