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/autorest/validation"
14	"github.com/Azure/go-autorest/tracing"
15	"net/http"
16)
17
18// VirtualNetworkGatewaysClient is the network Client
19type VirtualNetworkGatewaysClient struct {
20	BaseClient
21}
22
23// NewVirtualNetworkGatewaysClient creates an instance of the VirtualNetworkGatewaysClient client.
24func NewVirtualNetworkGatewaysClient(subscriptionID string) VirtualNetworkGatewaysClient {
25	return NewVirtualNetworkGatewaysClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewVirtualNetworkGatewaysClientWithBaseURI creates an instance of the VirtualNetworkGatewaysClient client using a
29// custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
30// Azure stack).
31func NewVirtualNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkGatewaysClient {
32	return VirtualNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)}
33}
34
35// CreateOrUpdate creates or updates a virtual network gateway in the specified resource group.
36// Parameters:
37// resourceGroupName - the name of the resource group.
38// virtualNetworkGatewayName - the name of the virtual network gateway.
39// parameters - parameters supplied to create or update virtual network gateway operation.
40func (client VirtualNetworkGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway) (result VirtualNetworkGatewaysCreateOrUpdateFuture, err error) {
41	if tracing.IsEnabled() {
42		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.CreateOrUpdate")
43		defer func() {
44			sc := -1
45			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
46				sc = result.FutureAPI.Response().StatusCode
47			}
48			tracing.EndSpan(ctx, sc, err)
49		}()
50	}
51	if err := validation.Validate([]validation.Validation{
52		{TargetValue: parameters,
53			Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
54		return result, validation.NewError("network.VirtualNetworkGatewaysClient", "CreateOrUpdate", err.Error())
55	}
56
57	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
58	if err != nil {
59		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
60		return
61	}
62
63	result, err = client.CreateOrUpdateSender(req)
64	if err != nil {
65		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure sending request")
66		return
67	}
68
69	return
70}
71
72// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
73func (client VirtualNetworkGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway) (*http.Request, error) {
74	pathParameters := map[string]interface{}{
75		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
76		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
77		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
78	}
79
80	const APIVersion = "2018-08-01"
81	queryParameters := map[string]interface{}{
82		"api-version": APIVersion,
83	}
84
85	preparer := autorest.CreatePreparer(
86		autorest.AsContentType("application/json; charset=utf-8"),
87		autorest.AsPut(),
88		autorest.WithBaseURL(client.BaseURI),
89		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
90		autorest.WithJSON(parameters),
91		autorest.WithQueryParameters(queryParameters))
92	return preparer.Prepare((&http.Request{}).WithContext(ctx))
93}
94
95// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
96// http.Response Body if it receives an error.
97func (client VirtualNetworkGatewaysClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkGatewaysCreateOrUpdateFuture, err error) {
98	var resp *http.Response
99	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
100	if err != nil {
101		return
102	}
103	var azf azure.Future
104	azf, err = azure.NewFutureFromResponse(resp)
105	future.FutureAPI = &azf
106	future.Result = future.result
107	return
108}
109
110// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
111// closes the http.Response Body.
112func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
113	err = autorest.Respond(
114		resp,
115		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
116		autorest.ByUnmarshallingJSON(&result),
117		autorest.ByClosing())
118	result.Response = autorest.Response{Response: resp}
119	return
120}
121
122// Delete deletes the specified virtual network gateway.
123// Parameters:
124// resourceGroupName - the name of the resource group.
125// virtualNetworkGatewayName - the name of the virtual network gateway.
126func (client VirtualNetworkGatewaysClient) Delete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysDeleteFuture, err error) {
127	if tracing.IsEnabled() {
128		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Delete")
129		defer func() {
130			sc := -1
131			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
132				sc = result.FutureAPI.Response().StatusCode
133			}
134			tracing.EndSpan(ctx, sc, err)
135		}()
136	}
137	req, err := client.DeletePreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
138	if err != nil {
139		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure preparing request")
140		return
141	}
142
143	result, err = client.DeleteSender(req)
144	if err != nil {
145		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure sending request")
146		return
147	}
148
149	return
150}
151
152// DeletePreparer prepares the Delete request.
153func (client VirtualNetworkGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
154	pathParameters := map[string]interface{}{
155		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
156		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
157		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
158	}
159
160	const APIVersion = "2018-08-01"
161	queryParameters := map[string]interface{}{
162		"api-version": APIVersion,
163	}
164
165	preparer := autorest.CreatePreparer(
166		autorest.AsDelete(),
167		autorest.WithBaseURL(client.BaseURI),
168		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
169		autorest.WithQueryParameters(queryParameters))
170	return preparer.Prepare((&http.Request{}).WithContext(ctx))
171}
172
173// DeleteSender sends the Delete request. The method will close the
174// http.Response Body if it receives an error.
175func (client VirtualNetworkGatewaysClient) DeleteSender(req *http.Request) (future VirtualNetworkGatewaysDeleteFuture, err error) {
176	var resp *http.Response
177	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
178	if err != nil {
179		return
180	}
181	var azf azure.Future
182	azf, err = azure.NewFutureFromResponse(resp)
183	future.FutureAPI = &azf
184	future.Result = future.result
185	return
186}
187
188// DeleteResponder handles the response to the Delete request. The method always
189// closes the http.Response Body.
190func (client VirtualNetworkGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
191	err = autorest.Respond(
192		resp,
193		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
194		autorest.ByClosing())
195	result.Response = resp
196	return
197}
198
199// Generatevpnclientpackage generates VPN client package for P2S client of the virtual network gateway in the specified
200// resource group.
201// Parameters:
202// resourceGroupName - the name of the resource group.
203// virtualNetworkGatewayName - the name of the virtual network gateway.
204// parameters - parameters supplied to the generate virtual network gateway VPN client package operation.
205func (client VirtualNetworkGatewaysClient) Generatevpnclientpackage(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result VirtualNetworkGatewaysGeneratevpnclientpackageFuture, err error) {
206	if tracing.IsEnabled() {
207		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Generatevpnclientpackage")
208		defer func() {
209			sc := -1
210			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
211				sc = result.FutureAPI.Response().StatusCode
212			}
213			tracing.EndSpan(ctx, sc, err)
214		}()
215	}
216	req, err := client.GeneratevpnclientpackagePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
217	if err != nil {
218		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure preparing request")
219		return
220	}
221
222	result, err = client.GeneratevpnclientpackageSender(req)
223	if err != nil {
224		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure sending request")
225		return
226	}
227
228	return
229}
230
231// GeneratevpnclientpackagePreparer prepares the Generatevpnclientpackage request.
232func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackagePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (*http.Request, error) {
233	pathParameters := map[string]interface{}{
234		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
235		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
236		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
237	}
238
239	const APIVersion = "2018-08-01"
240	queryParameters := map[string]interface{}{
241		"api-version": APIVersion,
242	}
243
244	preparer := autorest.CreatePreparer(
245		autorest.AsContentType("application/json; charset=utf-8"),
246		autorest.AsPost(),
247		autorest.WithBaseURL(client.BaseURI),
248		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnclientpackage", pathParameters),
249		autorest.WithJSON(parameters),
250		autorest.WithQueryParameters(queryParameters))
251	return preparer.Prepare((&http.Request{}).WithContext(ctx))
252}
253
254// GeneratevpnclientpackageSender sends the Generatevpnclientpackage request. The method will close the
255// http.Response Body if it receives an error.
256func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageSender(req *http.Request) (future VirtualNetworkGatewaysGeneratevpnclientpackageFuture, err error) {
257	var resp *http.Response
258	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
259	if err != nil {
260		return
261	}
262	var azf azure.Future
263	azf, err = azure.NewFutureFromResponse(resp)
264	future.FutureAPI = &azf
265	future.Result = future.result
266	return
267}
268
269// GeneratevpnclientpackageResponder handles the response to the Generatevpnclientpackage request. The method always
270// closes the http.Response Body.
271func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageResponder(resp *http.Response) (result String, err error) {
272	err = autorest.Respond(
273		resp,
274		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
275		autorest.ByUnmarshallingJSON(&result),
276		autorest.ByClosing())
277	result.Response = autorest.Response{Response: resp}
278	return
279}
280
281// GenerateVpnProfile generates VPN profile for P2S client of the virtual network gateway in the specified resource
282// group. Used for IKEV2 and radius based authentication.
283// Parameters:
284// resourceGroupName - the name of the resource group.
285// virtualNetworkGatewayName - the name of the virtual network gateway.
286// parameters - parameters supplied to the generate virtual network gateway VPN client package operation.
287func (client VirtualNetworkGatewaysClient) GenerateVpnProfile(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result VirtualNetworkGatewaysGenerateVpnProfileFuture, err error) {
288	if tracing.IsEnabled() {
289		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GenerateVpnProfile")
290		defer func() {
291			sc := -1
292			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
293				sc = result.FutureAPI.Response().StatusCode
294			}
295			tracing.EndSpan(ctx, sc, err)
296		}()
297	}
298	req, err := client.GenerateVpnProfilePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
299	if err != nil {
300		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GenerateVpnProfile", nil, "Failure preparing request")
301		return
302	}
303
304	result, err = client.GenerateVpnProfileSender(req)
305	if err != nil {
306		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GenerateVpnProfile", nil, "Failure sending request")
307		return
308	}
309
310	return
311}
312
313// GenerateVpnProfilePreparer prepares the GenerateVpnProfile request.
314func (client VirtualNetworkGatewaysClient) GenerateVpnProfilePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (*http.Request, error) {
315	pathParameters := map[string]interface{}{
316		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
317		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
318		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
319	}
320
321	const APIVersion = "2018-08-01"
322	queryParameters := map[string]interface{}{
323		"api-version": APIVersion,
324	}
325
326	preparer := autorest.CreatePreparer(
327		autorest.AsContentType("application/json; charset=utf-8"),
328		autorest.AsPost(),
329		autorest.WithBaseURL(client.BaseURI),
330		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnprofile", pathParameters),
331		autorest.WithJSON(parameters),
332		autorest.WithQueryParameters(queryParameters))
333	return preparer.Prepare((&http.Request{}).WithContext(ctx))
334}
335
336// GenerateVpnProfileSender sends the GenerateVpnProfile request. The method will close the
337// http.Response Body if it receives an error.
338func (client VirtualNetworkGatewaysClient) GenerateVpnProfileSender(req *http.Request) (future VirtualNetworkGatewaysGenerateVpnProfileFuture, err error) {
339	var resp *http.Response
340	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
341	if err != nil {
342		return
343	}
344	var azf azure.Future
345	azf, err = azure.NewFutureFromResponse(resp)
346	future.FutureAPI = &azf
347	future.Result = future.result
348	return
349}
350
351// GenerateVpnProfileResponder handles the response to the GenerateVpnProfile request. The method always
352// closes the http.Response Body.
353func (client VirtualNetworkGatewaysClient) GenerateVpnProfileResponder(resp *http.Response) (result String, err error) {
354	err = autorest.Respond(
355		resp,
356		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
357		autorest.ByUnmarshallingJSON(&result),
358		autorest.ByClosing())
359	result.Response = autorest.Response{Response: resp}
360	return
361}
362
363// Get gets the specified virtual network gateway by resource group.
364// Parameters:
365// resourceGroupName - the name of the resource group.
366// virtualNetworkGatewayName - the name of the virtual network gateway.
367func (client VirtualNetworkGatewaysClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGateway, err error) {
368	if tracing.IsEnabled() {
369		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Get")
370		defer func() {
371			sc := -1
372			if result.Response.Response != nil {
373				sc = result.Response.Response.StatusCode
374			}
375			tracing.EndSpan(ctx, sc, err)
376		}()
377	}
378	req, err := client.GetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
379	if err != nil {
380		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", nil, "Failure preparing request")
381		return
382	}
383
384	resp, err := client.GetSender(req)
385	if err != nil {
386		result.Response = autorest.Response{Response: resp}
387		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure sending request")
388		return
389	}
390
391	result, err = client.GetResponder(resp)
392	if err != nil {
393		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure responding to request")
394		return
395	}
396
397	return
398}
399
400// GetPreparer prepares the Get request.
401func (client VirtualNetworkGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
402	pathParameters := map[string]interface{}{
403		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
404		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
405		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
406	}
407
408	const APIVersion = "2018-08-01"
409	queryParameters := map[string]interface{}{
410		"api-version": APIVersion,
411	}
412
413	preparer := autorest.CreatePreparer(
414		autorest.AsGet(),
415		autorest.WithBaseURL(client.BaseURI),
416		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
417		autorest.WithQueryParameters(queryParameters))
418	return preparer.Prepare((&http.Request{}).WithContext(ctx))
419}
420
421// GetSender sends the Get request. The method will close the
422// http.Response Body if it receives an error.
423func (client VirtualNetworkGatewaysClient) GetSender(req *http.Request) (*http.Response, error) {
424	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
425}
426
427// GetResponder handles the response to the Get request. The method always
428// closes the http.Response Body.
429func (client VirtualNetworkGatewaysClient) GetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
430	err = autorest.Respond(
431		resp,
432		azure.WithErrorUnlessStatusCode(http.StatusOK),
433		autorest.ByUnmarshallingJSON(&result),
434		autorest.ByClosing())
435	result.Response = autorest.Response{Response: resp}
436	return
437}
438
439// GetAdvertisedRoutes this operation retrieves a list of routes the virtual network gateway is advertising to the
440// specified peer.
441// Parameters:
442// resourceGroupName - the name of the resource group.
443// virtualNetworkGatewayName - the name of the virtual network gateway.
444// peer - the IP address of the peer
445func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) {
446	if tracing.IsEnabled() {
447		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetAdvertisedRoutes")
448		defer func() {
449			sc := -1
450			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
451				sc = result.FutureAPI.Response().StatusCode
452			}
453			tracing.EndSpan(ctx, sc, err)
454		}()
455	}
456	req, err := client.GetAdvertisedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer)
457	if err != nil {
458		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure preparing request")
459		return
460	}
461
462	result, err = client.GetAdvertisedRoutesSender(req)
463	if err != nil {
464		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure sending request")
465		return
466	}
467
468	return
469}
470
471// GetAdvertisedRoutesPreparer prepares the GetAdvertisedRoutes request.
472func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) {
473	pathParameters := map[string]interface{}{
474		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
475		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
476		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
477	}
478
479	const APIVersion = "2018-08-01"
480	queryParameters := map[string]interface{}{
481		"api-version": APIVersion,
482		"peer":        autorest.Encode("query", peer),
483	}
484
485	preparer := autorest.CreatePreparer(
486		autorest.AsPost(),
487		autorest.WithBaseURL(client.BaseURI),
488		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes", pathParameters),
489		autorest.WithQueryParameters(queryParameters))
490	return preparer.Prepare((&http.Request{}).WithContext(ctx))
491}
492
493// GetAdvertisedRoutesSender sends the GetAdvertisedRoutes request. The method will close the
494// http.Response Body if it receives an error.
495func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) {
496	var resp *http.Response
497	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
498	if err != nil {
499		return
500	}
501	var azf azure.Future
502	azf, err = azure.NewFutureFromResponse(resp)
503	future.FutureAPI = &azf
504	future.Result = future.result
505	return
506}
507
508// GetAdvertisedRoutesResponder handles the response to the GetAdvertisedRoutes request. The method always
509// closes the http.Response Body.
510func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) {
511	err = autorest.Respond(
512		resp,
513		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
514		autorest.ByUnmarshallingJSON(&result),
515		autorest.ByClosing())
516	result.Response = autorest.Response{Response: resp}
517	return
518}
519
520// GetBgpPeerStatus the GetBgpPeerStatus operation retrieves the status of all BGP peers.
521// Parameters:
522// resourceGroupName - the name of the resource group.
523// virtualNetworkGatewayName - the name of the virtual network gateway.
524// peer - the IP address of the peer to retrieve the status of.
525func (client VirtualNetworkGatewaysClient) GetBgpPeerStatus(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) {
526	if tracing.IsEnabled() {
527		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetBgpPeerStatus")
528		defer func() {
529			sc := -1
530			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
531				sc = result.FutureAPI.Response().StatusCode
532			}
533			tracing.EndSpan(ctx, sc, err)
534		}()
535	}
536	req, err := client.GetBgpPeerStatusPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer)
537	if err != nil {
538		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure preparing request")
539		return
540	}
541
542	result, err = client.GetBgpPeerStatusSender(req)
543	if err != nil {
544		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure sending request")
545		return
546	}
547
548	return
549}
550
551// GetBgpPeerStatusPreparer prepares the GetBgpPeerStatus request.
552func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) {
553	pathParameters := map[string]interface{}{
554		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
555		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
556		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
557	}
558
559	const APIVersion = "2018-08-01"
560	queryParameters := map[string]interface{}{
561		"api-version": APIVersion,
562	}
563	if len(peer) > 0 {
564		queryParameters["peer"] = autorest.Encode("query", peer)
565	}
566
567	preparer := autorest.CreatePreparer(
568		autorest.AsPost(),
569		autorest.WithBaseURL(client.BaseURI),
570		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus", pathParameters),
571		autorest.WithQueryParameters(queryParameters))
572	return preparer.Prepare((&http.Request{}).WithContext(ctx))
573}
574
575// GetBgpPeerStatusSender sends the GetBgpPeerStatus request. The method will close the
576// http.Response Body if it receives an error.
577func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusSender(req *http.Request) (future VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) {
578	var resp *http.Response
579	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
580	if err != nil {
581		return
582	}
583	var azf azure.Future
584	azf, err = azure.NewFutureFromResponse(resp)
585	future.FutureAPI = &azf
586	future.Result = future.result
587	return
588}
589
590// GetBgpPeerStatusResponder handles the response to the GetBgpPeerStatus request. The method always
591// closes the http.Response Body.
592func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusResponder(resp *http.Response) (result BgpPeerStatusListResult, err error) {
593	err = autorest.Respond(
594		resp,
595		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
596		autorest.ByUnmarshallingJSON(&result),
597		autorest.ByClosing())
598	result.Response = autorest.Response{Response: resp}
599	return
600}
601
602// GetLearnedRoutes this operation retrieves a list of routes the virtual network gateway has learned, including routes
603// learned from BGP peers.
604// Parameters:
605// resourceGroupName - the name of the resource group.
606// virtualNetworkGatewayName - the name of the virtual network gateway.
607func (client VirtualNetworkGatewaysClient) GetLearnedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) {
608	if tracing.IsEnabled() {
609		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetLearnedRoutes")
610		defer func() {
611			sc := -1
612			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
613				sc = result.FutureAPI.Response().StatusCode
614			}
615			tracing.EndSpan(ctx, sc, err)
616		}()
617	}
618	req, err := client.GetLearnedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
619	if err != nil {
620		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure preparing request")
621		return
622	}
623
624	result, err = client.GetLearnedRoutesSender(req)
625	if err != nil {
626		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure sending request")
627		return
628	}
629
630	return
631}
632
633// GetLearnedRoutesPreparer prepares the GetLearnedRoutes request.
634func (client VirtualNetworkGatewaysClient) GetLearnedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
635	pathParameters := map[string]interface{}{
636		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
637		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
638		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
639	}
640
641	const APIVersion = "2018-08-01"
642	queryParameters := map[string]interface{}{
643		"api-version": APIVersion,
644	}
645
646	preparer := autorest.CreatePreparer(
647		autorest.AsPost(),
648		autorest.WithBaseURL(client.BaseURI),
649		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes", pathParameters),
650		autorest.WithQueryParameters(queryParameters))
651	return preparer.Prepare((&http.Request{}).WithContext(ctx))
652}
653
654// GetLearnedRoutesSender sends the GetLearnedRoutes request. The method will close the
655// http.Response Body if it receives an error.
656func (client VirtualNetworkGatewaysClient) GetLearnedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) {
657	var resp *http.Response
658	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
659	if err != nil {
660		return
661	}
662	var azf azure.Future
663	azf, err = azure.NewFutureFromResponse(resp)
664	future.FutureAPI = &azf
665	future.Result = future.result
666	return
667}
668
669// GetLearnedRoutesResponder handles the response to the GetLearnedRoutes request. The method always
670// closes the http.Response Body.
671func (client VirtualNetworkGatewaysClient) GetLearnedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) {
672	err = autorest.Respond(
673		resp,
674		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
675		autorest.ByUnmarshallingJSON(&result),
676		autorest.ByClosing())
677	result.Response = autorest.Response{Response: resp}
678	return
679}
680
681// GetVpnclientIpsecParameters the Get VpnclientIpsecParameters operation retrieves information about the vpnclient
682// ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource
683// provider.
684// Parameters:
685// resourceGroupName - the name of the resource group.
686// virtualNetworkGatewayName - the virtual network gateway name.
687func (client VirtualNetworkGatewaysClient) GetVpnclientIpsecParameters(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetVpnclientIpsecParametersFuture, err error) {
688	if tracing.IsEnabled() {
689		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetVpnclientIpsecParameters")
690		defer func() {
691			sc := -1
692			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
693				sc = result.FutureAPI.Response().StatusCode
694			}
695			tracing.EndSpan(ctx, sc, err)
696		}()
697	}
698	req, err := client.GetVpnclientIpsecParametersPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
699	if err != nil {
700		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnclientIpsecParameters", nil, "Failure preparing request")
701		return
702	}
703
704	result, err = client.GetVpnclientIpsecParametersSender(req)
705	if err != nil {
706		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnclientIpsecParameters", nil, "Failure sending request")
707		return
708	}
709
710	return
711}
712
713// GetVpnclientIpsecParametersPreparer prepares the GetVpnclientIpsecParameters request.
714func (client VirtualNetworkGatewaysClient) GetVpnclientIpsecParametersPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
715	pathParameters := map[string]interface{}{
716		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
717		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
718		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
719	}
720
721	const APIVersion = "2018-08-01"
722	queryParameters := map[string]interface{}{
723		"api-version": APIVersion,
724	}
725
726	preparer := autorest.CreatePreparer(
727		autorest.AsPost(),
728		autorest.WithBaseURL(client.BaseURI),
729		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getvpnclientipsecparameters", pathParameters),
730		autorest.WithQueryParameters(queryParameters))
731	return preparer.Prepare((&http.Request{}).WithContext(ctx))
732}
733
734// GetVpnclientIpsecParametersSender sends the GetVpnclientIpsecParameters request. The method will close the
735// http.Response Body if it receives an error.
736func (client VirtualNetworkGatewaysClient) GetVpnclientIpsecParametersSender(req *http.Request) (future VirtualNetworkGatewaysGetVpnclientIpsecParametersFuture, err error) {
737	var resp *http.Response
738	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
739	if err != nil {
740		return
741	}
742	var azf azure.Future
743	azf, err = azure.NewFutureFromResponse(resp)
744	future.FutureAPI = &azf
745	future.Result = future.result
746	return
747}
748
749// GetVpnclientIpsecParametersResponder handles the response to the GetVpnclientIpsecParameters request. The method always
750// closes the http.Response Body.
751func (client VirtualNetworkGatewaysClient) GetVpnclientIpsecParametersResponder(resp *http.Response) (result VpnClientIPsecParameters, err error) {
752	err = autorest.Respond(
753		resp,
754		azure.WithErrorUnlessStatusCode(http.StatusOK),
755		autorest.ByUnmarshallingJSON(&result),
756		autorest.ByClosing())
757	result.Response = autorest.Response{Response: resp}
758	return
759}
760
761// GetVpnProfilePackageURL gets pre-generated VPN profile for P2S client of the virtual network gateway in the
762// specified resource group. The profile needs to be generated first using generateVpnProfile.
763// Parameters:
764// resourceGroupName - the name of the resource group.
765// virtualNetworkGatewayName - the name of the virtual network gateway.
766func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURL(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetVpnProfilePackageURLFuture, err error) {
767	if tracing.IsEnabled() {
768		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetVpnProfilePackageURL")
769		defer func() {
770			sc := -1
771			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
772				sc = result.FutureAPI.Response().StatusCode
773			}
774			tracing.EndSpan(ctx, sc, err)
775		}()
776	}
777	req, err := client.GetVpnProfilePackageURLPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
778	if err != nil {
779		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnProfilePackageURL", nil, "Failure preparing request")
780		return
781	}
782
783	result, err = client.GetVpnProfilePackageURLSender(req)
784	if err != nil {
785		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnProfilePackageURL", nil, "Failure sending request")
786		return
787	}
788
789	return
790}
791
792// GetVpnProfilePackageURLPreparer prepares the GetVpnProfilePackageURL request.
793func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
794	pathParameters := map[string]interface{}{
795		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
796		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
797		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
798	}
799
800	const APIVersion = "2018-08-01"
801	queryParameters := map[string]interface{}{
802		"api-version": APIVersion,
803	}
804
805	preparer := autorest.CreatePreparer(
806		autorest.AsPost(),
807		autorest.WithBaseURL(client.BaseURI),
808		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getvpnprofilepackageurl", pathParameters),
809		autorest.WithQueryParameters(queryParameters))
810	return preparer.Prepare((&http.Request{}).WithContext(ctx))
811}
812
813// GetVpnProfilePackageURLSender sends the GetVpnProfilePackageURL request. The method will close the
814// http.Response Body if it receives an error.
815func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLSender(req *http.Request) (future VirtualNetworkGatewaysGetVpnProfilePackageURLFuture, err error) {
816	var resp *http.Response
817	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
818	if err != nil {
819		return
820	}
821	var azf azure.Future
822	azf, err = azure.NewFutureFromResponse(resp)
823	future.FutureAPI = &azf
824	future.Result = future.result
825	return
826}
827
828// GetVpnProfilePackageURLResponder handles the response to the GetVpnProfilePackageURL request. The method always
829// closes the http.Response Body.
830func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLResponder(resp *http.Response) (result String, err error) {
831	err = autorest.Respond(
832		resp,
833		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
834		autorest.ByUnmarshallingJSON(&result),
835		autorest.ByClosing())
836	result.Response = autorest.Response{Response: resp}
837	return
838}
839
840// List gets all virtual network gateways by resource group.
841// Parameters:
842// resourceGroupName - the name of the resource group.
843func (client VirtualNetworkGatewaysClient) List(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultPage, err error) {
844	if tracing.IsEnabled() {
845		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.List")
846		defer func() {
847			sc := -1
848			if result.vnglr.Response.Response != nil {
849				sc = result.vnglr.Response.Response.StatusCode
850			}
851			tracing.EndSpan(ctx, sc, err)
852		}()
853	}
854	result.fn = client.listNextResults
855	req, err := client.ListPreparer(ctx, resourceGroupName)
856	if err != nil {
857		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request")
858		return
859	}
860
861	resp, err := client.ListSender(req)
862	if err != nil {
863		result.vnglr.Response = autorest.Response{Response: resp}
864		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request")
865		return
866	}
867
868	result.vnglr, err = client.ListResponder(resp)
869	if err != nil {
870		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure responding to request")
871		return
872	}
873	if result.vnglr.hasNextLink() && result.vnglr.IsEmpty() {
874		err = result.NextWithContext(ctx)
875		return
876	}
877
878	return
879}
880
881// ListPreparer prepares the List request.
882func (client VirtualNetworkGatewaysClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
883	pathParameters := map[string]interface{}{
884		"resourceGroupName": autorest.Encode("path", resourceGroupName),
885		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
886	}
887
888	const APIVersion = "2018-08-01"
889	queryParameters := map[string]interface{}{
890		"api-version": APIVersion,
891	}
892
893	preparer := autorest.CreatePreparer(
894		autorest.AsGet(),
895		autorest.WithBaseURL(client.BaseURI),
896		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways", pathParameters),
897		autorest.WithQueryParameters(queryParameters))
898	return preparer.Prepare((&http.Request{}).WithContext(ctx))
899}
900
901// ListSender sends the List request. The method will close the
902// http.Response Body if it receives an error.
903func (client VirtualNetworkGatewaysClient) ListSender(req *http.Request) (*http.Response, error) {
904	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
905}
906
907// ListResponder handles the response to the List request. The method always
908// closes the http.Response Body.
909func (client VirtualNetworkGatewaysClient) ListResponder(resp *http.Response) (result VirtualNetworkGatewayListResult, err error) {
910	err = autorest.Respond(
911		resp,
912		azure.WithErrorUnlessStatusCode(http.StatusOK),
913		autorest.ByUnmarshallingJSON(&result),
914		autorest.ByClosing())
915	result.Response = autorest.Response{Response: resp}
916	return
917}
918
919// listNextResults retrieves the next set of results, if any.
920func (client VirtualNetworkGatewaysClient) listNextResults(ctx context.Context, lastResults VirtualNetworkGatewayListResult) (result VirtualNetworkGatewayListResult, err error) {
921	req, err := lastResults.virtualNetworkGatewayListResultPreparer(ctx)
922	if err != nil {
923		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", nil, "Failure preparing next results request")
924	}
925	if req == nil {
926		return
927	}
928	resp, err := client.ListSender(req)
929	if err != nil {
930		result.Response = autorest.Response{Response: resp}
931		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure sending next results request")
932	}
933	result, err = client.ListResponder(resp)
934	if err != nil {
935		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure responding to next results request")
936	}
937	return
938}
939
940// ListComplete enumerates all values, automatically crossing page boundaries as required.
941func (client VirtualNetworkGatewaysClient) ListComplete(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultIterator, err error) {
942	if tracing.IsEnabled() {
943		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.List")
944		defer func() {
945			sc := -1
946			if result.Response().Response.Response != nil {
947				sc = result.page.Response().Response.Response.StatusCode
948			}
949			tracing.EndSpan(ctx, sc, err)
950		}()
951	}
952	result.page, err = client.List(ctx, resourceGroupName)
953	return
954}
955
956// ListConnections gets all the connections in a virtual network gateway.
957// Parameters:
958// resourceGroupName - the name of the resource group.
959// virtualNetworkGatewayName - the name of the virtual network gateway.
960func (client VirtualNetworkGatewaysClient) ListConnections(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewayListConnectionsResultPage, err error) {
961	if tracing.IsEnabled() {
962		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.ListConnections")
963		defer func() {
964			sc := -1
965			if result.vnglcr.Response.Response != nil {
966				sc = result.vnglcr.Response.Response.StatusCode
967			}
968			tracing.EndSpan(ctx, sc, err)
969		}()
970	}
971	result.fn = client.listConnectionsNextResults
972	req, err := client.ListConnectionsPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
973	if err != nil {
974		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", nil, "Failure preparing request")
975		return
976	}
977
978	resp, err := client.ListConnectionsSender(req)
979	if err != nil {
980		result.vnglcr.Response = autorest.Response{Response: resp}
981		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", resp, "Failure sending request")
982		return
983	}
984
985	result.vnglcr, err = client.ListConnectionsResponder(resp)
986	if err != nil {
987		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", resp, "Failure responding to request")
988		return
989	}
990	if result.vnglcr.hasNextLink() && result.vnglcr.IsEmpty() {
991		err = result.NextWithContext(ctx)
992		return
993	}
994
995	return
996}
997
998// ListConnectionsPreparer prepares the ListConnections request.
999func (client VirtualNetworkGatewaysClient) ListConnectionsPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
1000	pathParameters := map[string]interface{}{
1001		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1002		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1003		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1004	}
1005
1006	const APIVersion = "2018-08-01"
1007	queryParameters := map[string]interface{}{
1008		"api-version": APIVersion,
1009	}
1010
1011	preparer := autorest.CreatePreparer(
1012		autorest.AsGet(),
1013		autorest.WithBaseURL(client.BaseURI),
1014		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/connections", pathParameters),
1015		autorest.WithQueryParameters(queryParameters))
1016	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1017}
1018
1019// ListConnectionsSender sends the ListConnections request. The method will close the
1020// http.Response Body if it receives an error.
1021func (client VirtualNetworkGatewaysClient) ListConnectionsSender(req *http.Request) (*http.Response, error) {
1022	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1023}
1024
1025// ListConnectionsResponder handles the response to the ListConnections request. The method always
1026// closes the http.Response Body.
1027func (client VirtualNetworkGatewaysClient) ListConnectionsResponder(resp *http.Response) (result VirtualNetworkGatewayListConnectionsResult, err error) {
1028	err = autorest.Respond(
1029		resp,
1030		azure.WithErrorUnlessStatusCode(http.StatusOK),
1031		autorest.ByUnmarshallingJSON(&result),
1032		autorest.ByClosing())
1033	result.Response = autorest.Response{Response: resp}
1034	return
1035}
1036
1037// listConnectionsNextResults retrieves the next set of results, if any.
1038func (client VirtualNetworkGatewaysClient) listConnectionsNextResults(ctx context.Context, lastResults VirtualNetworkGatewayListConnectionsResult) (result VirtualNetworkGatewayListConnectionsResult, err error) {
1039	req, err := lastResults.virtualNetworkGatewayListConnectionsResultPreparer(ctx)
1040	if err != nil {
1041		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", nil, "Failure preparing next results request")
1042	}
1043	if req == nil {
1044		return
1045	}
1046	resp, err := client.ListConnectionsSender(req)
1047	if err != nil {
1048		result.Response = autorest.Response{Response: resp}
1049		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", resp, "Failure sending next results request")
1050	}
1051	result, err = client.ListConnectionsResponder(resp)
1052	if err != nil {
1053		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", resp, "Failure responding to next results request")
1054	}
1055	return
1056}
1057
1058// ListConnectionsComplete enumerates all values, automatically crossing page boundaries as required.
1059func (client VirtualNetworkGatewaysClient) ListConnectionsComplete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewayListConnectionsResultIterator, err error) {
1060	if tracing.IsEnabled() {
1061		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.ListConnections")
1062		defer func() {
1063			sc := -1
1064			if result.Response().Response.Response != nil {
1065				sc = result.page.Response().Response.Response.StatusCode
1066			}
1067			tracing.EndSpan(ctx, sc, err)
1068		}()
1069	}
1070	result.page, err = client.ListConnections(ctx, resourceGroupName, virtualNetworkGatewayName)
1071	return
1072}
1073
1074// Reset resets the primary of the virtual network gateway in the specified resource group.
1075// Parameters:
1076// resourceGroupName - the name of the resource group.
1077// virtualNetworkGatewayName - the name of the virtual network gateway.
1078// gatewayVip - virtual network gateway vip address supplied to the begin reset of the active-active feature
1079// enabled gateway.
1080func (client VirtualNetworkGatewaysClient) Reset(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (result VirtualNetworkGatewaysResetFuture, err error) {
1081	if tracing.IsEnabled() {
1082		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Reset")
1083		defer func() {
1084			sc := -1
1085			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1086				sc = result.FutureAPI.Response().StatusCode
1087			}
1088			tracing.EndSpan(ctx, sc, err)
1089		}()
1090	}
1091	req, err := client.ResetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, gatewayVip)
1092	if err != nil {
1093		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request")
1094		return
1095	}
1096
1097	result, err = client.ResetSender(req)
1098	if err != nil {
1099		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure sending request")
1100		return
1101	}
1102
1103	return
1104}
1105
1106// ResetPreparer prepares the Reset request.
1107func (client VirtualNetworkGatewaysClient) ResetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (*http.Request, error) {
1108	pathParameters := map[string]interface{}{
1109		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1110		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1111		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1112	}
1113
1114	const APIVersion = "2018-08-01"
1115	queryParameters := map[string]interface{}{
1116		"api-version": APIVersion,
1117	}
1118	if len(gatewayVip) > 0 {
1119		queryParameters["gatewayVip"] = autorest.Encode("query", gatewayVip)
1120	}
1121
1122	preparer := autorest.CreatePreparer(
1123		autorest.AsPost(),
1124		autorest.WithBaseURL(client.BaseURI),
1125		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/reset", pathParameters),
1126		autorest.WithQueryParameters(queryParameters))
1127	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1128}
1129
1130// ResetSender sends the Reset request. The method will close the
1131// http.Response Body if it receives an error.
1132func (client VirtualNetworkGatewaysClient) ResetSender(req *http.Request) (future VirtualNetworkGatewaysResetFuture, err error) {
1133	var resp *http.Response
1134	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1135	if err != nil {
1136		return
1137	}
1138	var azf azure.Future
1139	azf, err = azure.NewFutureFromResponse(resp)
1140	future.FutureAPI = &azf
1141	future.Result = future.result
1142	return
1143}
1144
1145// ResetResponder handles the response to the Reset request. The method always
1146// closes the http.Response Body.
1147func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
1148	err = autorest.Respond(
1149		resp,
1150		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1151		autorest.ByUnmarshallingJSON(&result),
1152		autorest.ByClosing())
1153	result.Response = autorest.Response{Response: resp}
1154	return
1155}
1156
1157// ResetVpnClientSharedKey resets the VPN client shared key of the virtual network gateway in the specified resource
1158// group.
1159// Parameters:
1160// resourceGroupName - the name of the resource group.
1161// virtualNetworkGatewayName - the name of the virtual network gateway.
1162func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysResetVpnClientSharedKeyFuture, err error) {
1163	if tracing.IsEnabled() {
1164		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.ResetVpnClientSharedKey")
1165		defer func() {
1166			sc := -1
1167			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1168				sc = result.FutureAPI.Response().StatusCode
1169			}
1170			tracing.EndSpan(ctx, sc, err)
1171		}()
1172	}
1173	req, err := client.ResetVpnClientSharedKeyPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
1174	if err != nil {
1175		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ResetVpnClientSharedKey", nil, "Failure preparing request")
1176		return
1177	}
1178
1179	result, err = client.ResetVpnClientSharedKeySender(req)
1180	if err != nil {
1181		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ResetVpnClientSharedKey", nil, "Failure sending request")
1182		return
1183	}
1184
1185	return
1186}
1187
1188// ResetVpnClientSharedKeyPreparer prepares the ResetVpnClientSharedKey request.
1189func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKeyPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
1190	pathParameters := map[string]interface{}{
1191		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1192		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1193		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1194	}
1195
1196	const APIVersion = "2018-08-01"
1197	queryParameters := map[string]interface{}{
1198		"api-version": APIVersion,
1199	}
1200
1201	preparer := autorest.CreatePreparer(
1202		autorest.AsPost(),
1203		autorest.WithBaseURL(client.BaseURI),
1204		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/resetvpnclientsharedkey", pathParameters),
1205		autorest.WithQueryParameters(queryParameters))
1206	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1207}
1208
1209// ResetVpnClientSharedKeySender sends the ResetVpnClientSharedKey request. The method will close the
1210// http.Response Body if it receives an error.
1211func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKeySender(req *http.Request) (future VirtualNetworkGatewaysResetVpnClientSharedKeyFuture, err error) {
1212	var resp *http.Response
1213	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1214	if err != nil {
1215		return
1216	}
1217	var azf azure.Future
1218	azf, err = azure.NewFutureFromResponse(resp)
1219	future.FutureAPI = &azf
1220	future.Result = future.result
1221	return
1222}
1223
1224// ResetVpnClientSharedKeyResponder handles the response to the ResetVpnClientSharedKey request. The method always
1225// closes the http.Response Body.
1226func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKeyResponder(resp *http.Response) (result autorest.Response, err error) {
1227	err = autorest.Respond(
1228		resp,
1229		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1230		autorest.ByClosing())
1231	result.Response = resp
1232	return
1233}
1234
1235// SetVpnclientIpsecParameters the Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S
1236// client of virtual network gateway in the specified resource group through Network resource provider.
1237// Parameters:
1238// resourceGroupName - the name of the resource group.
1239// virtualNetworkGatewayName - the name of the virtual network gateway.
1240// vpnclientIpsecParams - parameters supplied to the Begin Set vpnclient ipsec parameters of Virtual Network
1241// Gateway P2S client operation through Network resource provider.
1242func (client VirtualNetworkGatewaysClient) SetVpnclientIpsecParameters(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, vpnclientIpsecParams VpnClientIPsecParameters) (result VirtualNetworkGatewaysSetVpnclientIpsecParametersFuture, err error) {
1243	if tracing.IsEnabled() {
1244		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.SetVpnclientIpsecParameters")
1245		defer func() {
1246			sc := -1
1247			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1248				sc = result.FutureAPI.Response().StatusCode
1249			}
1250			tracing.EndSpan(ctx, sc, err)
1251		}()
1252	}
1253	if err := validation.Validate([]validation.Validation{
1254		{TargetValue: vpnclientIpsecParams,
1255			Constraints: []validation.Constraint{{Target: "vpnclientIpsecParams.SaLifeTimeSeconds", Name: validation.Null, Rule: true, Chain: nil},
1256				{Target: "vpnclientIpsecParams.SaDataSizeKilobytes", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
1257		return result, validation.NewError("network.VirtualNetworkGatewaysClient", "SetVpnclientIpsecParameters", err.Error())
1258	}
1259
1260	req, err := client.SetVpnclientIpsecParametersPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams)
1261	if err != nil {
1262		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SetVpnclientIpsecParameters", nil, "Failure preparing request")
1263		return
1264	}
1265
1266	result, err = client.SetVpnclientIpsecParametersSender(req)
1267	if err != nil {
1268		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SetVpnclientIpsecParameters", nil, "Failure sending request")
1269		return
1270	}
1271
1272	return
1273}
1274
1275// SetVpnclientIpsecParametersPreparer prepares the SetVpnclientIpsecParameters request.
1276func (client VirtualNetworkGatewaysClient) SetVpnclientIpsecParametersPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, vpnclientIpsecParams VpnClientIPsecParameters) (*http.Request, error) {
1277	pathParameters := map[string]interface{}{
1278		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1279		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1280		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1281	}
1282
1283	const APIVersion = "2018-08-01"
1284	queryParameters := map[string]interface{}{
1285		"api-version": APIVersion,
1286	}
1287
1288	preparer := autorest.CreatePreparer(
1289		autorest.AsContentType("application/json; charset=utf-8"),
1290		autorest.AsPost(),
1291		autorest.WithBaseURL(client.BaseURI),
1292		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/setvpnclientipsecparameters", pathParameters),
1293		autorest.WithJSON(vpnclientIpsecParams),
1294		autorest.WithQueryParameters(queryParameters))
1295	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1296}
1297
1298// SetVpnclientIpsecParametersSender sends the SetVpnclientIpsecParameters request. The method will close the
1299// http.Response Body if it receives an error.
1300func (client VirtualNetworkGatewaysClient) SetVpnclientIpsecParametersSender(req *http.Request) (future VirtualNetworkGatewaysSetVpnclientIpsecParametersFuture, err error) {
1301	var resp *http.Response
1302	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1303	if err != nil {
1304		return
1305	}
1306	var azf azure.Future
1307	azf, err = azure.NewFutureFromResponse(resp)
1308	future.FutureAPI = &azf
1309	future.Result = future.result
1310	return
1311}
1312
1313// SetVpnclientIpsecParametersResponder handles the response to the SetVpnclientIpsecParameters request. The method always
1314// closes the http.Response Body.
1315func (client VirtualNetworkGatewaysClient) SetVpnclientIpsecParametersResponder(resp *http.Response) (result VpnClientIPsecParameters, err error) {
1316	err = autorest.Respond(
1317		resp,
1318		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1319		autorest.ByUnmarshallingJSON(&result),
1320		autorest.ByClosing())
1321	result.Response = autorest.Response{Response: resp}
1322	return
1323}
1324
1325// SupportedVpnDevices gets a xml format representation for supported vpn devices.
1326// Parameters:
1327// resourceGroupName - the name of the resource group.
1328// virtualNetworkGatewayName - the name of the virtual network gateway.
1329func (client VirtualNetworkGatewaysClient) SupportedVpnDevices(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result String, err error) {
1330	if tracing.IsEnabled() {
1331		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.SupportedVpnDevices")
1332		defer func() {
1333			sc := -1
1334			if result.Response.Response != nil {
1335				sc = result.Response.Response.StatusCode
1336			}
1337			tracing.EndSpan(ctx, sc, err)
1338		}()
1339	}
1340	req, err := client.SupportedVpnDevicesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
1341	if err != nil {
1342		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SupportedVpnDevices", nil, "Failure preparing request")
1343		return
1344	}
1345
1346	resp, err := client.SupportedVpnDevicesSender(req)
1347	if err != nil {
1348		result.Response = autorest.Response{Response: resp}
1349		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SupportedVpnDevices", resp, "Failure sending request")
1350		return
1351	}
1352
1353	result, err = client.SupportedVpnDevicesResponder(resp)
1354	if err != nil {
1355		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SupportedVpnDevices", resp, "Failure responding to request")
1356		return
1357	}
1358
1359	return
1360}
1361
1362// SupportedVpnDevicesPreparer prepares the SupportedVpnDevices request.
1363func (client VirtualNetworkGatewaysClient) SupportedVpnDevicesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
1364	pathParameters := map[string]interface{}{
1365		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1366		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1367		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1368	}
1369
1370	const APIVersion = "2018-08-01"
1371	queryParameters := map[string]interface{}{
1372		"api-version": APIVersion,
1373	}
1374
1375	preparer := autorest.CreatePreparer(
1376		autorest.AsPost(),
1377		autorest.WithBaseURL(client.BaseURI),
1378		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/supportedvpndevices", pathParameters),
1379		autorest.WithQueryParameters(queryParameters))
1380	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1381}
1382
1383// SupportedVpnDevicesSender sends the SupportedVpnDevices request. The method will close the
1384// http.Response Body if it receives an error.
1385func (client VirtualNetworkGatewaysClient) SupportedVpnDevicesSender(req *http.Request) (*http.Response, error) {
1386	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1387}
1388
1389// SupportedVpnDevicesResponder handles the response to the SupportedVpnDevices request. The method always
1390// closes the http.Response Body.
1391func (client VirtualNetworkGatewaysClient) SupportedVpnDevicesResponder(resp *http.Response) (result String, err error) {
1392	err = autorest.Respond(
1393		resp,
1394		azure.WithErrorUnlessStatusCode(http.StatusOK),
1395		autorest.ByUnmarshallingJSON(&result.Value),
1396		autorest.ByClosing())
1397	result.Response = autorest.Response{Response: resp}
1398	return
1399}
1400
1401// UpdateTags updates a virtual network gateway tags.
1402// Parameters:
1403// resourceGroupName - the name of the resource group.
1404// virtualNetworkGatewayName - the name of the virtual network gateway.
1405// parameters - parameters supplied to update virtual network gateway tags.
1406func (client VirtualNetworkGatewaysClient) UpdateTags(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters TagsObject) (result VirtualNetworkGatewaysUpdateTagsFuture, err error) {
1407	if tracing.IsEnabled() {
1408		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.UpdateTags")
1409		defer func() {
1410			sc := -1
1411			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1412				sc = result.FutureAPI.Response().StatusCode
1413			}
1414			tracing.EndSpan(ctx, sc, err)
1415		}()
1416	}
1417	req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
1418	if err != nil {
1419		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "UpdateTags", nil, "Failure preparing request")
1420		return
1421	}
1422
1423	result, err = client.UpdateTagsSender(req)
1424	if err != nil {
1425		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "UpdateTags", nil, "Failure sending request")
1426		return
1427	}
1428
1429	return
1430}
1431
1432// UpdateTagsPreparer prepares the UpdateTags request.
1433func (client VirtualNetworkGatewaysClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters TagsObject) (*http.Request, error) {
1434	pathParameters := map[string]interface{}{
1435		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1436		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1437		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1438	}
1439
1440	const APIVersion = "2018-08-01"
1441	queryParameters := map[string]interface{}{
1442		"api-version": APIVersion,
1443	}
1444
1445	preparer := autorest.CreatePreparer(
1446		autorest.AsContentType("application/json; charset=utf-8"),
1447		autorest.AsPatch(),
1448		autorest.WithBaseURL(client.BaseURI),
1449		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
1450		autorest.WithJSON(parameters),
1451		autorest.WithQueryParameters(queryParameters))
1452	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1453}
1454
1455// UpdateTagsSender sends the UpdateTags request. The method will close the
1456// http.Response Body if it receives an error.
1457func (client VirtualNetworkGatewaysClient) UpdateTagsSender(req *http.Request) (future VirtualNetworkGatewaysUpdateTagsFuture, err error) {
1458	var resp *http.Response
1459	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1460	if err != nil {
1461		return
1462	}
1463	var azf azure.Future
1464	azf, err = azure.NewFutureFromResponse(resp)
1465	future.FutureAPI = &azf
1466	future.Result = future.result
1467	return
1468}
1469
1470// UpdateTagsResponder handles the response to the UpdateTags request. The method always
1471// closes the http.Response Body.
1472func (client VirtualNetworkGatewaysClient) UpdateTagsResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
1473	err = autorest.Respond(
1474		resp,
1475		azure.WithErrorUnlessStatusCode(http.StatusOK),
1476		autorest.ByUnmarshallingJSON(&result),
1477		autorest.ByClosing())
1478	result.Response = autorest.Response{Response: resp}
1479	return
1480}
1481
1482// VpnDeviceConfigurationScript gets a xml format representation for vpn device configuration script.
1483// Parameters:
1484// resourceGroupName - the name of the resource group.
1485// virtualNetworkGatewayConnectionName - the name of the virtual network gateway connection for which the
1486// configuration script is generated.
1487// parameters - parameters supplied to the generate vpn device script operation.
1488func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScript(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VpnDeviceScriptParameters) (result String, err error) {
1489	if tracing.IsEnabled() {
1490		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.VpnDeviceConfigurationScript")
1491		defer func() {
1492			sc := -1
1493			if result.Response.Response != nil {
1494				sc = result.Response.Response.StatusCode
1495			}
1496			tracing.EndSpan(ctx, sc, err)
1497		}()
1498	}
1499	req, err := client.VpnDeviceConfigurationScriptPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters)
1500	if err != nil {
1501		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "VpnDeviceConfigurationScript", nil, "Failure preparing request")
1502		return
1503	}
1504
1505	resp, err := client.VpnDeviceConfigurationScriptSender(req)
1506	if err != nil {
1507		result.Response = autorest.Response{Response: resp}
1508		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "VpnDeviceConfigurationScript", resp, "Failure sending request")
1509		return
1510	}
1511
1512	result, err = client.VpnDeviceConfigurationScriptResponder(resp)
1513	if err != nil {
1514		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "VpnDeviceConfigurationScript", resp, "Failure responding to request")
1515		return
1516	}
1517
1518	return
1519}
1520
1521// VpnDeviceConfigurationScriptPreparer prepares the VpnDeviceConfigurationScript request.
1522func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScriptPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VpnDeviceScriptParameters) (*http.Request, error) {
1523	pathParameters := map[string]interface{}{
1524		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
1525		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
1526		"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
1527	}
1528
1529	const APIVersion = "2018-08-01"
1530	queryParameters := map[string]interface{}{
1531		"api-version": APIVersion,
1532	}
1533
1534	preparer := autorest.CreatePreparer(
1535		autorest.AsContentType("application/json; charset=utf-8"),
1536		autorest.AsPost(),
1537		autorest.WithBaseURL(client.BaseURI),
1538		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/vpndeviceconfigurationscript", pathParameters),
1539		autorest.WithJSON(parameters),
1540		autorest.WithQueryParameters(queryParameters))
1541	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1542}
1543
1544// VpnDeviceConfigurationScriptSender sends the VpnDeviceConfigurationScript request. The method will close the
1545// http.Response Body if it receives an error.
1546func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScriptSender(req *http.Request) (*http.Response, error) {
1547	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1548}
1549
1550// VpnDeviceConfigurationScriptResponder handles the response to the VpnDeviceConfigurationScript request. The method always
1551// closes the http.Response Body.
1552func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScriptResponder(resp *http.Response) (result String, err error) {
1553	err = autorest.Respond(
1554		resp,
1555		azure.WithErrorUnlessStatusCode(http.StatusOK),
1556		autorest.ByUnmarshallingJSON(&result.Value),
1557		autorest.ByClosing())
1558	result.Response = autorest.Response{Response: resp}
1559	return
1560}
1561