|
Packit Service |
4d2de5 |
package network
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
// Copyright (c) Microsoft and contributors. All rights reserved.
|
|
Packit Service |
4d2de5 |
//
|
|
Packit Service |
4d2de5 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit Service |
4d2de5 |
// you may not use this file except in compliance with the License.
|
|
Packit Service |
4d2de5 |
// You may obtain a copy of the License at
|
|
Packit Service |
4d2de5 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit Service |
4d2de5 |
//
|
|
Packit Service |
4d2de5 |
// Unless required by applicable law or agreed to in writing, software
|
|
Packit Service |
4d2de5 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit Service |
4d2de5 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit Service |
4d2de5 |
//
|
|
Packit Service |
4d2de5 |
// See the License for the specific language governing permissions and
|
|
Packit Service |
4d2de5 |
// limitations under the License.
|
|
Packit Service |
4d2de5 |
//
|
|
Packit Service |
4d2de5 |
// Code generated by Microsoft (R) AutoRest Code Generator.
|
|
Packit Service |
4d2de5 |
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
import (
|
|
Packit Service |
4d2de5 |
"context"
|
|
Packit Service |
4d2de5 |
"github.com/Azure/go-autorest/autorest"
|
|
Packit Service |
4d2de5 |
"github.com/Azure/go-autorest/autorest/azure"
|
|
Packit Service |
4d2de5 |
"github.com/Azure/go-autorest/autorest/validation"
|
|
Packit Service |
4d2de5 |
"github.com/Azure/go-autorest/tracing"
|
|
Packit Service |
4d2de5 |
"net/http"
|
|
Packit Service |
4d2de5 |
)
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
// VpnSitesConfigurationClient is the network Client
|
|
Packit Service |
4d2de5 |
type VpnSitesConfigurationClient struct {
|
|
Packit Service |
4d2de5 |
BaseClient
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
// NewVpnSitesConfigurationClient creates an instance of the VpnSitesConfigurationClient client.
|
|
Packit Service |
4d2de5 |
func NewVpnSitesConfigurationClient(subscriptionID string) VpnSitesConfigurationClient {
|
|
Packit Service |
4d2de5 |
return NewVpnSitesConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
// NewVpnSitesConfigurationClientWithBaseURI creates an instance of the VpnSitesConfigurationClient client using a
|
|
Packit Service |
4d2de5 |
// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
|
|
Packit Service |
4d2de5 |
// Azure stack).
|
|
Packit Service |
4d2de5 |
func NewVpnSitesConfigurationClientWithBaseURI(baseURI string, subscriptionID string) VpnSitesConfigurationClient {
|
|
Packit Service |
4d2de5 |
return VpnSitesConfigurationClient{NewWithBaseURI(baseURI, subscriptionID)}
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
// Download gives the sas-url to download the configurations for vpn-sites in a resource group.
|
|
Packit Service |
4d2de5 |
// Parameters:
|
|
Packit Service |
4d2de5 |
// resourceGroupName - the resource group name.
|
|
Packit Service |
4d2de5 |
// virtualWANName - the name of the VirtualWAN for which configuration of all vpn-sites is needed.
|
|
Packit Service |
4d2de5 |
// request - parameters supplied to download vpn-sites configuration.
|
|
Packit Service |
4d2de5 |
func (client VpnSitesConfigurationClient) Download(ctx context.Context, resourceGroupName string, virtualWANName string, request GetVpnSitesConfigurationRequest) (result VpnSitesConfigurationDownloadFuture, err error) {
|
|
Packit Service |
4d2de5 |
if tracing.IsEnabled() {
|
|
Packit Service |
4d2de5 |
ctx = tracing.StartSpan(ctx, fqdn+"/VpnSitesConfigurationClient.Download")
|
|
Packit Service |
4d2de5 |
defer func() {
|
|
Packit Service |
4d2de5 |
sc := -1
|
|
Packit Service |
4d2de5 |
if result.Response() != nil {
|
|
Packit Service |
4d2de5 |
sc = result.Response().StatusCode
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
tracing.EndSpan(ctx, sc, err)
|
|
Packit Service |
4d2de5 |
}()
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
if err := validation.Validate([]validation.Validation{
|
|
Packit Service |
4d2de5 |
{TargetValue: request,
|
|
Packit Service |
4d2de5 |
Constraints: []validation.Constraint{{Target: "request.OutputBlobSasURL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
|
Packit Service |
4d2de5 |
return result, validation.NewError("network.VpnSitesConfigurationClient", "Download", err.Error())
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
req, err := client.DownloadPreparer(ctx, resourceGroupName, virtualWANName, request)
|
|
Packit Service |
4d2de5 |
if err != nil {
|
|
Packit Service |
4d2de5 |
err = autorest.NewErrorWithError(err, "network.VpnSitesConfigurationClient", "Download", nil, "Failure preparing request")
|
|
Packit Service |
4d2de5 |
return
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
result, err = client.DownloadSender(req)
|
|
Packit Service |
4d2de5 |
if err != nil {
|
|
Packit Service |
4d2de5 |
err = autorest.NewErrorWithError(err, "network.VpnSitesConfigurationClient", "Download", result.Response(), "Failure sending request")
|
|
Packit Service |
4d2de5 |
return
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
return
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
// DownloadPreparer prepares the Download request.
|
|
Packit Service |
4d2de5 |
func (client VpnSitesConfigurationClient) DownloadPreparer(ctx context.Context, resourceGroupName string, virtualWANName string, request GetVpnSitesConfigurationRequest) (*http.Request, error) {
|
|
Packit Service |
4d2de5 |
pathParameters := map[string]interface{}{
|
|
Packit Service |
4d2de5 |
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
Packit Service |
4d2de5 |
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
Packit Service |
4d2de5 |
"virtualWANName": autorest.Encode("path", virtualWANName),
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
const APIVersion = "2019-09-01"
|
|
Packit Service |
4d2de5 |
queryParameters := map[string]interface{}{
|
|
Packit Service |
4d2de5 |
"api-version": APIVersion,
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
preparer := autorest.CreatePreparer(
|
|
Packit Service |
4d2de5 |
autorest.AsContentType("application/json; charset=utf-8"),
|
|
Packit Service |
4d2de5 |
autorest.AsPost(),
|
|
Packit Service |
4d2de5 |
autorest.WithBaseURL(client.BaseURI),
|
|
Packit Service |
4d2de5 |
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/vpnConfiguration", pathParameters),
|
|
Packit Service |
4d2de5 |
autorest.WithJSON(request),
|
|
Packit Service |
4d2de5 |
autorest.WithQueryParameters(queryParameters))
|
|
Packit Service |
4d2de5 |
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
// DownloadSender sends the Download request. The method will close the
|
|
Packit Service |
4d2de5 |
// http.Response Body if it receives an error.
|
|
Packit Service |
4d2de5 |
func (client VpnSitesConfigurationClient) DownloadSender(req *http.Request) (future VpnSitesConfigurationDownloadFuture, err error) {
|
|
Packit Service |
4d2de5 |
var resp *http.Response
|
|
Packit Service |
4d2de5 |
resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
|
|
Packit Service |
4d2de5 |
if err != nil {
|
|
Packit Service |
4d2de5 |
return
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
future.Future, err = azure.NewFutureFromResponse(resp)
|
|
Packit Service |
4d2de5 |
return
|
|
Packit Service |
4d2de5 |
}
|
|
Packit Service |
4d2de5 |
|
|
Packit Service |
4d2de5 |
// DownloadResponder handles the response to the Download request. The method always
|
|
Packit Service |
4d2de5 |
// closes the http.Response Body.
|
|
Packit Service |
4d2de5 |
func (client VpnSitesConfigurationClient) DownloadResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
Packit Service |
4d2de5 |
err = autorest.Respond(
|
|
Packit Service |
4d2de5 |
resp,
|
|
Packit Service |
4d2de5 |
client.ByInspecting(),
|
|
Packit Service |
4d2de5 |
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
|
Packit Service |
4d2de5 |
autorest.ByClosing())
|
|
Packit Service |
4d2de5 |
result.Response = resp
|
|
Packit Service |
4d2de5 |
return
|
|
Packit Service |
4d2de5 |
}
|