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-01-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-01-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-01-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-01-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-01-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-01-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-01-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-01-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// GetVpnProfilePackageURL gets pre-generated VPN profile for P2S client of the virtual network gateway in the
820// specified resource group. The profile needs to be generated first using generateVpnProfile.
821// Parameters:
822// resourceGroupName - the name of the resource group.
823// virtualNetworkGatewayName - the name of the virtual network gateway.
824func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURL(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetVpnProfilePackageURLFuture, err error) {
825	if tracing.IsEnabled() {
826		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetVpnProfilePackageURL")
827		defer func() {
828			sc := -1
829			if result.Response() != nil {
830				sc = result.Response().StatusCode
831			}
832			tracing.EndSpan(ctx, sc, err)
833		}()
834	}
835	req, err := client.GetVpnProfilePackageURLPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
836	if err != nil {
837		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnProfilePackageURL", nil, "Failure preparing request")
838		return
839	}
840
841	result, err = client.GetVpnProfilePackageURLSender(req)
842	if err != nil {
843		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnProfilePackageURL", nil, "Failure sending request")
844		return
845	}
846
847	return
848}
849
850// GetVpnProfilePackageURLPreparer prepares the GetVpnProfilePackageURL request.
851func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
852	pathParameters := map[string]interface{}{
853		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
854		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
855		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
856	}
857
858	const APIVersion = "2018-01-01"
859	queryParameters := map[string]interface{}{
860		"api-version": APIVersion,
861	}
862
863	preparer := autorest.CreatePreparer(
864		autorest.AsPost(),
865		autorest.WithBaseURL(client.BaseURI),
866		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getvpnprofilepackageurl", pathParameters),
867		autorest.WithQueryParameters(queryParameters))
868	return preparer.Prepare((&http.Request{}).WithContext(ctx))
869}
870
871// GetVpnProfilePackageURLSender sends the GetVpnProfilePackageURL request. The method will close the
872// http.Response Body if it receives an error.
873func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLSender(req *http.Request) (future VirtualNetworkGatewaysGetVpnProfilePackageURLFuture, err error) {
874	var resp *http.Response
875	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
876	if err != nil {
877		return
878	}
879	var azf azure.Future
880	azf, err = azure.NewFutureFromResponse(resp)
881	future.FutureAPI = &azf
882	future.Result = func(client VirtualNetworkGatewaysClient) (s String, err error) {
883		var done bool
884		done, err = future.DoneWithContext(context.Background(), client)
885		if err != nil {
886			err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetVpnProfilePackageURLFuture", "Result", future.Response(), "Polling failure")
887			return
888		}
889		if !done {
890			err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysGetVpnProfilePackageURLFuture")
891			return
892		}
893		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
894		if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent {
895			s, err = client.GetVpnProfilePackageURLResponder(s.Response.Response)
896			if err != nil {
897				err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetVpnProfilePackageURLFuture", "Result", s.Response.Response, "Failure responding to request")
898			}
899		}
900		return
901	}
902	return
903}
904
905// GetVpnProfilePackageURLResponder handles the response to the GetVpnProfilePackageURL request. The method always
906// closes the http.Response Body.
907func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLResponder(resp *http.Response) (result String, err error) {
908	err = autorest.Respond(
909		resp,
910		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
911		autorest.ByUnmarshallingJSON(&result),
912		autorest.ByClosing())
913	result.Response = autorest.Response{Response: resp}
914	return
915}
916
917// List gets all virtual network gateways by resource group.
918// Parameters:
919// resourceGroupName - the name of the resource group.
920func (client VirtualNetworkGatewaysClient) List(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultPage, err error) {
921	if tracing.IsEnabled() {
922		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.List")
923		defer func() {
924			sc := -1
925			if result.vnglr.Response.Response != nil {
926				sc = result.vnglr.Response.Response.StatusCode
927			}
928			tracing.EndSpan(ctx, sc, err)
929		}()
930	}
931	result.fn = client.listNextResults
932	req, err := client.ListPreparer(ctx, resourceGroupName)
933	if err != nil {
934		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request")
935		return
936	}
937
938	resp, err := client.ListSender(req)
939	if err != nil {
940		result.vnglr.Response = autorest.Response{Response: resp}
941		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request")
942		return
943	}
944
945	result.vnglr, err = client.ListResponder(resp)
946	if err != nil {
947		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure responding to request")
948		return
949	}
950	if result.vnglr.hasNextLink() && result.vnglr.IsEmpty() {
951		err = result.NextWithContext(ctx)
952		return
953	}
954
955	return
956}
957
958// ListPreparer prepares the List request.
959func (client VirtualNetworkGatewaysClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
960	pathParameters := map[string]interface{}{
961		"resourceGroupName": autorest.Encode("path", resourceGroupName),
962		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
963	}
964
965	const APIVersion = "2018-01-01"
966	queryParameters := map[string]interface{}{
967		"api-version": APIVersion,
968	}
969
970	preparer := autorest.CreatePreparer(
971		autorest.AsGet(),
972		autorest.WithBaseURL(client.BaseURI),
973		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways", pathParameters),
974		autorest.WithQueryParameters(queryParameters))
975	return preparer.Prepare((&http.Request{}).WithContext(ctx))
976}
977
978// ListSender sends the List request. The method will close the
979// http.Response Body if it receives an error.
980func (client VirtualNetworkGatewaysClient) ListSender(req *http.Request) (*http.Response, error) {
981	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
982}
983
984// ListResponder handles the response to the List request. The method always
985// closes the http.Response Body.
986func (client VirtualNetworkGatewaysClient) ListResponder(resp *http.Response) (result VirtualNetworkGatewayListResult, err error) {
987	err = autorest.Respond(
988		resp,
989		azure.WithErrorUnlessStatusCode(http.StatusOK),
990		autorest.ByUnmarshallingJSON(&result),
991		autorest.ByClosing())
992	result.Response = autorest.Response{Response: resp}
993	return
994}
995
996// listNextResults retrieves the next set of results, if any.
997func (client VirtualNetworkGatewaysClient) listNextResults(ctx context.Context, lastResults VirtualNetworkGatewayListResult) (result VirtualNetworkGatewayListResult, err error) {
998	req, err := lastResults.virtualNetworkGatewayListResultPreparer(ctx)
999	if err != nil {
1000		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", nil, "Failure preparing next results request")
1001	}
1002	if req == nil {
1003		return
1004	}
1005	resp, err := client.ListSender(req)
1006	if err != nil {
1007		result.Response = autorest.Response{Response: resp}
1008		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure sending next results request")
1009	}
1010	result, err = client.ListResponder(resp)
1011	if err != nil {
1012		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure responding to next results request")
1013	}
1014	return
1015}
1016
1017// ListComplete enumerates all values, automatically crossing page boundaries as required.
1018func (client VirtualNetworkGatewaysClient) ListComplete(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultIterator, err error) {
1019	if tracing.IsEnabled() {
1020		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.List")
1021		defer func() {
1022			sc := -1
1023			if result.Response().Response.Response != nil {
1024				sc = result.page.Response().Response.Response.StatusCode
1025			}
1026			tracing.EndSpan(ctx, sc, err)
1027		}()
1028	}
1029	result.page, err = client.List(ctx, resourceGroupName)
1030	return
1031}
1032
1033// ListConnections gets all the connections in a virtual network gateway.
1034// Parameters:
1035// resourceGroupName - the name of the resource group.
1036// virtualNetworkGatewayName - the name of the virtual network gateway.
1037func (client VirtualNetworkGatewaysClient) ListConnections(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewayListConnectionsResultPage, err error) {
1038	if tracing.IsEnabled() {
1039		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.ListConnections")
1040		defer func() {
1041			sc := -1
1042			if result.vnglcr.Response.Response != nil {
1043				sc = result.vnglcr.Response.Response.StatusCode
1044			}
1045			tracing.EndSpan(ctx, sc, err)
1046		}()
1047	}
1048	result.fn = client.listConnectionsNextResults
1049	req, err := client.ListConnectionsPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
1050	if err != nil {
1051		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", nil, "Failure preparing request")
1052		return
1053	}
1054
1055	resp, err := client.ListConnectionsSender(req)
1056	if err != nil {
1057		result.vnglcr.Response = autorest.Response{Response: resp}
1058		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", resp, "Failure sending request")
1059		return
1060	}
1061
1062	result.vnglcr, err = client.ListConnectionsResponder(resp)
1063	if err != nil {
1064		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", resp, "Failure responding to request")
1065		return
1066	}
1067	if result.vnglcr.hasNextLink() && result.vnglcr.IsEmpty() {
1068		err = result.NextWithContext(ctx)
1069		return
1070	}
1071
1072	return
1073}
1074
1075// ListConnectionsPreparer prepares the ListConnections request.
1076func (client VirtualNetworkGatewaysClient) ListConnectionsPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
1077	pathParameters := map[string]interface{}{
1078		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1079		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1080		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1081	}
1082
1083	const APIVersion = "2018-01-01"
1084	queryParameters := map[string]interface{}{
1085		"api-version": APIVersion,
1086	}
1087
1088	preparer := autorest.CreatePreparer(
1089		autorest.AsGet(),
1090		autorest.WithBaseURL(client.BaseURI),
1091		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/connections", pathParameters),
1092		autorest.WithQueryParameters(queryParameters))
1093	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1094}
1095
1096// ListConnectionsSender sends the ListConnections request. The method will close the
1097// http.Response Body if it receives an error.
1098func (client VirtualNetworkGatewaysClient) ListConnectionsSender(req *http.Request) (*http.Response, error) {
1099	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1100}
1101
1102// ListConnectionsResponder handles the response to the ListConnections request. The method always
1103// closes the http.Response Body.
1104func (client VirtualNetworkGatewaysClient) ListConnectionsResponder(resp *http.Response) (result VirtualNetworkGatewayListConnectionsResult, err error) {
1105	err = autorest.Respond(
1106		resp,
1107		azure.WithErrorUnlessStatusCode(http.StatusOK),
1108		autorest.ByUnmarshallingJSON(&result),
1109		autorest.ByClosing())
1110	result.Response = autorest.Response{Response: resp}
1111	return
1112}
1113
1114// listConnectionsNextResults retrieves the next set of results, if any.
1115func (client VirtualNetworkGatewaysClient) listConnectionsNextResults(ctx context.Context, lastResults VirtualNetworkGatewayListConnectionsResult) (result VirtualNetworkGatewayListConnectionsResult, err error) {
1116	req, err := lastResults.virtualNetworkGatewayListConnectionsResultPreparer(ctx)
1117	if err != nil {
1118		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", nil, "Failure preparing next results request")
1119	}
1120	if req == nil {
1121		return
1122	}
1123	resp, err := client.ListConnectionsSender(req)
1124	if err != nil {
1125		result.Response = autorest.Response{Response: resp}
1126		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", resp, "Failure sending next results request")
1127	}
1128	result, err = client.ListConnectionsResponder(resp)
1129	if err != nil {
1130		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", resp, "Failure responding to next results request")
1131	}
1132	return
1133}
1134
1135// ListConnectionsComplete enumerates all values, automatically crossing page boundaries as required.
1136func (client VirtualNetworkGatewaysClient) ListConnectionsComplete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewayListConnectionsResultIterator, err error) {
1137	if tracing.IsEnabled() {
1138		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.ListConnections")
1139		defer func() {
1140			sc := -1
1141			if result.Response().Response.Response != nil {
1142				sc = result.page.Response().Response.Response.StatusCode
1143			}
1144			tracing.EndSpan(ctx, sc, err)
1145		}()
1146	}
1147	result.page, err = client.ListConnections(ctx, resourceGroupName, virtualNetworkGatewayName)
1148	return
1149}
1150
1151// Reset resets the primary of the virtual network gateway in the specified resource group.
1152// Parameters:
1153// resourceGroupName - the name of the resource group.
1154// virtualNetworkGatewayName - the name of the virtual network gateway.
1155// gatewayVip - virtual network gateway vip address supplied to the begin reset of the active-active feature
1156// enabled gateway.
1157func (client VirtualNetworkGatewaysClient) Reset(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (result VirtualNetworkGatewaysResetFuture, err error) {
1158	if tracing.IsEnabled() {
1159		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Reset")
1160		defer func() {
1161			sc := -1
1162			if result.Response() != nil {
1163				sc = result.Response().StatusCode
1164			}
1165			tracing.EndSpan(ctx, sc, err)
1166		}()
1167	}
1168	req, err := client.ResetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, gatewayVip)
1169	if err != nil {
1170		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request")
1171		return
1172	}
1173
1174	result, err = client.ResetSender(req)
1175	if err != nil {
1176		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure sending request")
1177		return
1178	}
1179
1180	return
1181}
1182
1183// ResetPreparer prepares the Reset request.
1184func (client VirtualNetworkGatewaysClient) ResetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (*http.Request, error) {
1185	pathParameters := map[string]interface{}{
1186		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1187		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1188		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1189	}
1190
1191	const APIVersion = "2018-01-01"
1192	queryParameters := map[string]interface{}{
1193		"api-version": APIVersion,
1194	}
1195	if len(gatewayVip) > 0 {
1196		queryParameters["gatewayVip"] = autorest.Encode("query", gatewayVip)
1197	}
1198
1199	preparer := autorest.CreatePreparer(
1200		autorest.AsPost(),
1201		autorest.WithBaseURL(client.BaseURI),
1202		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/reset", pathParameters),
1203		autorest.WithQueryParameters(queryParameters))
1204	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1205}
1206
1207// ResetSender sends the Reset request. The method will close the
1208// http.Response Body if it receives an error.
1209func (client VirtualNetworkGatewaysClient) ResetSender(req *http.Request) (future VirtualNetworkGatewaysResetFuture, err error) {
1210	var resp *http.Response
1211	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1212	if err != nil {
1213		return
1214	}
1215	var azf azure.Future
1216	azf, err = azure.NewFutureFromResponse(resp)
1217	future.FutureAPI = &azf
1218	future.Result = func(client VirtualNetworkGatewaysClient) (vng VirtualNetworkGateway, err error) {
1219		var done bool
1220		done, err = future.DoneWithContext(context.Background(), client)
1221		if err != nil {
1222			err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysResetFuture", "Result", future.Response(), "Polling failure")
1223			return
1224		}
1225		if !done {
1226			err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysResetFuture")
1227			return
1228		}
1229		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1230		if vng.Response.Response, err = future.GetResult(sender); err == nil && vng.Response.Response.StatusCode != http.StatusNoContent {
1231			vng, err = client.ResetResponder(vng.Response.Response)
1232			if err != nil {
1233				err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysResetFuture", "Result", vng.Response.Response, "Failure responding to request")
1234			}
1235		}
1236		return
1237	}
1238	return
1239}
1240
1241// ResetResponder handles the response to the Reset request. The method always
1242// closes the http.Response Body.
1243func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
1244	err = autorest.Respond(
1245		resp,
1246		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1247		autorest.ByUnmarshallingJSON(&result),
1248		autorest.ByClosing())
1249	result.Response = autorest.Response{Response: resp}
1250	return
1251}
1252
1253// SupportedVpnDevices gets a xml format representation for supported vpn devices.
1254// Parameters:
1255// resourceGroupName - the name of the resource group.
1256// virtualNetworkGatewayName - the name of the virtual network gateway.
1257func (client VirtualNetworkGatewaysClient) SupportedVpnDevices(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result String, err error) {
1258	if tracing.IsEnabled() {
1259		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.SupportedVpnDevices")
1260		defer func() {
1261			sc := -1
1262			if result.Response.Response != nil {
1263				sc = result.Response.Response.StatusCode
1264			}
1265			tracing.EndSpan(ctx, sc, err)
1266		}()
1267	}
1268	req, err := client.SupportedVpnDevicesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
1269	if err != nil {
1270		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SupportedVpnDevices", nil, "Failure preparing request")
1271		return
1272	}
1273
1274	resp, err := client.SupportedVpnDevicesSender(req)
1275	if err != nil {
1276		result.Response = autorest.Response{Response: resp}
1277		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SupportedVpnDevices", resp, "Failure sending request")
1278		return
1279	}
1280
1281	result, err = client.SupportedVpnDevicesResponder(resp)
1282	if err != nil {
1283		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SupportedVpnDevices", resp, "Failure responding to request")
1284		return
1285	}
1286
1287	return
1288}
1289
1290// SupportedVpnDevicesPreparer prepares the SupportedVpnDevices request.
1291func (client VirtualNetworkGatewaysClient) SupportedVpnDevicesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
1292	pathParameters := map[string]interface{}{
1293		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1294		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1295		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1296	}
1297
1298	const APIVersion = "2018-01-01"
1299	queryParameters := map[string]interface{}{
1300		"api-version": APIVersion,
1301	}
1302
1303	preparer := autorest.CreatePreparer(
1304		autorest.AsPost(),
1305		autorest.WithBaseURL(client.BaseURI),
1306		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/supportedvpndevices", pathParameters),
1307		autorest.WithQueryParameters(queryParameters))
1308	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1309}
1310
1311// SupportedVpnDevicesSender sends the SupportedVpnDevices request. The method will close the
1312// http.Response Body if it receives an error.
1313func (client VirtualNetworkGatewaysClient) SupportedVpnDevicesSender(req *http.Request) (*http.Response, error) {
1314	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1315}
1316
1317// SupportedVpnDevicesResponder handles the response to the SupportedVpnDevices request. The method always
1318// closes the http.Response Body.
1319func (client VirtualNetworkGatewaysClient) SupportedVpnDevicesResponder(resp *http.Response) (result String, err error) {
1320	err = autorest.Respond(
1321		resp,
1322		azure.WithErrorUnlessStatusCode(http.StatusOK),
1323		autorest.ByUnmarshallingJSON(&result.Value),
1324		autorest.ByClosing())
1325	result.Response = autorest.Response{Response: resp}
1326	return
1327}
1328
1329// UpdateTags updates a virtual network gateway tags.
1330// Parameters:
1331// resourceGroupName - the name of the resource group.
1332// virtualNetworkGatewayName - the name of the virtual network gateway.
1333// parameters - parameters supplied to update virtual network gateway tags.
1334func (client VirtualNetworkGatewaysClient) UpdateTags(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters TagsObject) (result VirtualNetworkGatewaysUpdateTagsFuture, err error) {
1335	if tracing.IsEnabled() {
1336		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.UpdateTags")
1337		defer func() {
1338			sc := -1
1339			if result.Response() != nil {
1340				sc = result.Response().StatusCode
1341			}
1342			tracing.EndSpan(ctx, sc, err)
1343		}()
1344	}
1345	req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
1346	if err != nil {
1347		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "UpdateTags", nil, "Failure preparing request")
1348		return
1349	}
1350
1351	result, err = client.UpdateTagsSender(req)
1352	if err != nil {
1353		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "UpdateTags", nil, "Failure sending request")
1354		return
1355	}
1356
1357	return
1358}
1359
1360// UpdateTagsPreparer prepares the UpdateTags request.
1361func (client VirtualNetworkGatewaysClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters TagsObject) (*http.Request, error) {
1362	pathParameters := map[string]interface{}{
1363		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1364		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1365		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
1366	}
1367
1368	const APIVersion = "2018-01-01"
1369	queryParameters := map[string]interface{}{
1370		"api-version": APIVersion,
1371	}
1372
1373	preparer := autorest.CreatePreparer(
1374		autorest.AsContentType("application/json; charset=utf-8"),
1375		autorest.AsPatch(),
1376		autorest.WithBaseURL(client.BaseURI),
1377		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
1378		autorest.WithJSON(parameters),
1379		autorest.WithQueryParameters(queryParameters))
1380	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1381}
1382
1383// UpdateTagsSender sends the UpdateTags request. The method will close the
1384// http.Response Body if it receives an error.
1385func (client VirtualNetworkGatewaysClient) UpdateTagsSender(req *http.Request) (future VirtualNetworkGatewaysUpdateTagsFuture, err error) {
1386	var resp *http.Response
1387	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1388	if err != nil {
1389		return
1390	}
1391	var azf azure.Future
1392	azf, err = azure.NewFutureFromResponse(resp)
1393	future.FutureAPI = &azf
1394	future.Result = func(client VirtualNetworkGatewaysClient) (vng VirtualNetworkGateway, err error) {
1395		var done bool
1396		done, err = future.DoneWithContext(context.Background(), client)
1397		if err != nil {
1398			err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysUpdateTagsFuture", "Result", future.Response(), "Polling failure")
1399			return
1400		}
1401		if !done {
1402			err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysUpdateTagsFuture")
1403			return
1404		}
1405		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1406		if vng.Response.Response, err = future.GetResult(sender); err == nil && vng.Response.Response.StatusCode != http.StatusNoContent {
1407			vng, err = client.UpdateTagsResponder(vng.Response.Response)
1408			if err != nil {
1409				err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysUpdateTagsFuture", "Result", vng.Response.Response, "Failure responding to request")
1410			}
1411		}
1412		return
1413	}
1414	return
1415}
1416
1417// UpdateTagsResponder handles the response to the UpdateTags request. The method always
1418// closes the http.Response Body.
1419func (client VirtualNetworkGatewaysClient) UpdateTagsResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
1420	err = autorest.Respond(
1421		resp,
1422		azure.WithErrorUnlessStatusCode(http.StatusOK),
1423		autorest.ByUnmarshallingJSON(&result),
1424		autorest.ByClosing())
1425	result.Response = autorest.Response{Response: resp}
1426	return
1427}
1428
1429// VpnDeviceConfigurationScript gets a xml format representation for vpn device configuration script.
1430// Parameters:
1431// resourceGroupName - the name of the resource group.
1432// virtualNetworkGatewayConnectionName - the name of the virtual network gateway connection for which the
1433// configuration script is generated.
1434// parameters - parameters supplied to the generate vpn device script operation.
1435func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScript(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VpnDeviceScriptParameters) (result String, err error) {
1436	if tracing.IsEnabled() {
1437		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.VpnDeviceConfigurationScript")
1438		defer func() {
1439			sc := -1
1440			if result.Response.Response != nil {
1441				sc = result.Response.Response.StatusCode
1442			}
1443			tracing.EndSpan(ctx, sc, err)
1444		}()
1445	}
1446	req, err := client.VpnDeviceConfigurationScriptPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters)
1447	if err != nil {
1448		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "VpnDeviceConfigurationScript", nil, "Failure preparing request")
1449		return
1450	}
1451
1452	resp, err := client.VpnDeviceConfigurationScriptSender(req)
1453	if err != nil {
1454		result.Response = autorest.Response{Response: resp}
1455		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "VpnDeviceConfigurationScript", resp, "Failure sending request")
1456		return
1457	}
1458
1459	result, err = client.VpnDeviceConfigurationScriptResponder(resp)
1460	if err != nil {
1461		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "VpnDeviceConfigurationScript", resp, "Failure responding to request")
1462		return
1463	}
1464
1465	return
1466}
1467
1468// VpnDeviceConfigurationScriptPreparer prepares the VpnDeviceConfigurationScript request.
1469func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScriptPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VpnDeviceScriptParameters) (*http.Request, error) {
1470	pathParameters := map[string]interface{}{
1471		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
1472		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
1473		"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
1474	}
1475
1476	const APIVersion = "2018-01-01"
1477	queryParameters := map[string]interface{}{
1478		"api-version": APIVersion,
1479	}
1480
1481	preparer := autorest.CreatePreparer(
1482		autorest.AsContentType("application/json; charset=utf-8"),
1483		autorest.AsPost(),
1484		autorest.WithBaseURL(client.BaseURI),
1485		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/vpndeviceconfigurationscript", pathParameters),
1486		autorest.WithJSON(parameters),
1487		autorest.WithQueryParameters(queryParameters))
1488	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1489}
1490
1491// VpnDeviceConfigurationScriptSender sends the VpnDeviceConfigurationScript request. The method will close the
1492// http.Response Body if it receives an error.
1493func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScriptSender(req *http.Request) (*http.Response, error) {
1494	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1495}
1496
1497// VpnDeviceConfigurationScriptResponder handles the response to the VpnDeviceConfigurationScript request. The method always
1498// closes the http.Response Body.
1499func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScriptResponder(resp *http.Response) (result String, err error) {
1500	err = autorest.Respond(
1501		resp,
1502		azure.WithErrorUnlessStatusCode(http.StatusOK),
1503		autorest.ByUnmarshallingJSON(&result.Value),
1504		autorest.ByClosing())
1505	result.Response = autorest.Response{Response: resp}
1506	return
1507}
1508