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