1package network
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
10	"context"
11	"github.com/Azure/go-autorest/autorest"
12	"github.com/Azure/go-autorest/autorest/azure"
13	"github.com/Azure/go-autorest/autorest/validation"
14	"github.com/Azure/go-autorest/tracing"
15	"net/http"
16)
17
18// VirtualNetworkGatewaysClient is the network Client
19type VirtualNetworkGatewaysClient struct {
20	BaseClient
21}
22
23// NewVirtualNetworkGatewaysClient creates an instance of the VirtualNetworkGatewaysClient client.
24func NewVirtualNetworkGatewaysClient(subscriptionID string) VirtualNetworkGatewaysClient {
25	return NewVirtualNetworkGatewaysClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewVirtualNetworkGatewaysClientWithBaseURI creates an instance of the VirtualNetworkGatewaysClient client using a
29// custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
30// Azure stack).
31func NewVirtualNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkGatewaysClient {
32	return VirtualNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)}
33}
34
35// CreateOrUpdate creates or updates a virtual network gateway in the specified resource group.
36// Parameters:
37// resourceGroupName - the name of the resource group.
38// virtualNetworkGatewayName - the name of the virtual network gateway.
39// parameters - parameters supplied to create or update virtual network gateway operation.
40func (client VirtualNetworkGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway) (result VirtualNetworkGatewaysCreateOrUpdateFuture, err error) {
41	if tracing.IsEnabled() {
42		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.CreateOrUpdate")
43		defer func() {
44			sc := -1
45			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
46				sc = result.FutureAPI.Response().StatusCode
47			}
48			tracing.EndSpan(ctx, sc, err)
49		}()
50	}
51	if err := validation.Validate([]validation.Validation{
52		{TargetValue: parameters,
53			Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true,
54				Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat.IPConfigurations", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
55		return result, validation.NewError("network.VirtualNetworkGatewaysClient", "CreateOrUpdate", err.Error())
56	}
57
58	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
59	if err != nil {
60		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
61		return
62	}
63
64	result, err = client.CreateOrUpdateSender(req)
65	if err != nil {
66		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure sending request")
67		return
68	}
69
70	return
71}
72
73// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
74func (client VirtualNetworkGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway) (*http.Request, error) {
75	pathParameters := map[string]interface{}{
76		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
77		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
78		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
79	}
80
81	const APIVersion = "2016-09-01"
82	queryParameters := map[string]interface{}{
83		"api-version": APIVersion,
84	}
85
86	preparer := autorest.CreatePreparer(
87		autorest.AsContentType("application/json; charset=utf-8"),
88		autorest.AsPut(),
89		autorest.WithBaseURL(client.BaseURI),
90		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
91		autorest.WithJSON(parameters),
92		autorest.WithQueryParameters(queryParameters))
93	return preparer.Prepare((&http.Request{}).WithContext(ctx))
94}
95
96// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
97// http.Response Body if it receives an error.
98func (client VirtualNetworkGatewaysClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkGatewaysCreateOrUpdateFuture, err error) {
99	var resp *http.Response
100	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
101	if err != nil {
102		return
103	}
104	var azf azure.Future
105	azf, err = azure.NewFutureFromResponse(resp)
106	future.FutureAPI = &azf
107	future.Result = future.result
108	return
109}
110
111// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
112// closes the http.Response Body.
113func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
114	err = autorest.Respond(
115		resp,
116		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
117		autorest.ByUnmarshallingJSON(&result),
118		autorest.ByClosing())
119	result.Response = autorest.Response{Response: resp}
120	return
121}
122
123// Delete deletes the specified virtual network gateway.
124// Parameters:
125// resourceGroupName - the name of the resource group.
126// virtualNetworkGatewayName - the name of the virtual network gateway.
127func (client VirtualNetworkGatewaysClient) Delete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysDeleteFuture, err error) {
128	if tracing.IsEnabled() {
129		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Delete")
130		defer func() {
131			sc := -1
132			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
133				sc = result.FutureAPI.Response().StatusCode
134			}
135			tracing.EndSpan(ctx, sc, err)
136		}()
137	}
138	req, err := client.DeletePreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
139	if err != nil {
140		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure preparing request")
141		return
142	}
143
144	result, err = client.DeleteSender(req)
145	if err != nil {
146		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure sending request")
147		return
148	}
149
150	return
151}
152
153// DeletePreparer prepares the Delete request.
154func (client VirtualNetworkGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
155	pathParameters := map[string]interface{}{
156		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
157		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
158		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
159	}
160
161	const APIVersion = "2016-09-01"
162	queryParameters := map[string]interface{}{
163		"api-version": APIVersion,
164	}
165
166	preparer := autorest.CreatePreparer(
167		autorest.AsDelete(),
168		autorest.WithBaseURL(client.BaseURI),
169		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
170		autorest.WithQueryParameters(queryParameters))
171	return preparer.Prepare((&http.Request{}).WithContext(ctx))
172}
173
174// DeleteSender sends the Delete request. The method will close the
175// http.Response Body if it receives an error.
176func (client VirtualNetworkGatewaysClient) DeleteSender(req *http.Request) (future VirtualNetworkGatewaysDeleteFuture, err error) {
177	var resp *http.Response
178	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
179	if err != nil {
180		return
181	}
182	var azf azure.Future
183	azf, err = azure.NewFutureFromResponse(resp)
184	future.FutureAPI = &azf
185	future.Result = future.result
186	return
187}
188
189// DeleteResponder handles the response to the Delete request. The method always
190// closes the http.Response Body.
191func (client VirtualNetworkGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
192	err = autorest.Respond(
193		resp,
194		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
195		autorest.ByClosing())
196	result.Response = resp
197	return
198}
199
200// Generatevpnclientpackage generates VPN client package for P2S client of the virtual network gateway in the specified
201// resource group.
202// Parameters:
203// resourceGroupName - the name of the resource group.
204// virtualNetworkGatewayName - the name of the virtual network gateway.
205// parameters - parameters supplied to the generate virtual network gateway VPN client package operation.
206func (client VirtualNetworkGatewaysClient) Generatevpnclientpackage(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result VirtualNetworkGatewaysGeneratevpnclientpackageFuture, err error) {
207	if tracing.IsEnabled() {
208		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Generatevpnclientpackage")
209		defer func() {
210			sc := -1
211			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
212				sc = result.FutureAPI.Response().StatusCode
213			}
214			tracing.EndSpan(ctx, sc, err)
215		}()
216	}
217	req, err := client.GeneratevpnclientpackagePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
218	if err != nil {
219		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure preparing request")
220		return
221	}
222
223	result, err = client.GeneratevpnclientpackageSender(req)
224	if err != nil {
225		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure sending request")
226		return
227	}
228
229	return
230}
231
232// GeneratevpnclientpackagePreparer prepares the Generatevpnclientpackage request.
233func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackagePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (*http.Request, error) {
234	pathParameters := map[string]interface{}{
235		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
236		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
237		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
238	}
239
240	const APIVersion = "2016-09-01"
241	queryParameters := map[string]interface{}{
242		"api-version": APIVersion,
243	}
244
245	preparer := autorest.CreatePreparer(
246		autorest.AsContentType("application/json; charset=utf-8"),
247		autorest.AsPost(),
248		autorest.WithBaseURL(client.BaseURI),
249		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnclientpackage", pathParameters),
250		autorest.WithJSON(parameters),
251		autorest.WithQueryParameters(queryParameters))
252	return preparer.Prepare((&http.Request{}).WithContext(ctx))
253}
254
255// GeneratevpnclientpackageSender sends the Generatevpnclientpackage request. The method will close the
256// http.Response Body if it receives an error.
257func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageSender(req *http.Request) (future VirtualNetworkGatewaysGeneratevpnclientpackageFuture, err error) {
258	var resp *http.Response
259	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
260	if err != nil {
261		return
262	}
263	var azf azure.Future
264	azf, err = azure.NewFutureFromResponse(resp)
265	future.FutureAPI = &azf
266	future.Result = future.result
267	return
268}
269
270// GeneratevpnclientpackageResponder handles the response to the Generatevpnclientpackage request. The method always
271// closes the http.Response Body.
272func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageResponder(resp *http.Response) (result String, err error) {
273	err = autorest.Respond(
274		resp,
275		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
276		autorest.ByUnmarshallingJSON(&result),
277		autorest.ByClosing())
278	result.Response = autorest.Response{Response: resp}
279	return
280}
281
282// Get gets the specified virtual network gateway by resource group.
283// Parameters:
284// resourceGroupName - the name of the resource group.
285// virtualNetworkGatewayName - the name of the virtual network gateway.
286func (client VirtualNetworkGatewaysClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGateway, err error) {
287	if tracing.IsEnabled() {
288		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Get")
289		defer func() {
290			sc := -1
291			if result.Response.Response != nil {
292				sc = result.Response.Response.StatusCode
293			}
294			tracing.EndSpan(ctx, sc, err)
295		}()
296	}
297	req, err := client.GetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
298	if err != nil {
299		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", nil, "Failure preparing request")
300		return
301	}
302
303	resp, err := client.GetSender(req)
304	if err != nil {
305		result.Response = autorest.Response{Response: resp}
306		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure sending request")
307		return
308	}
309
310	result, err = client.GetResponder(resp)
311	if err != nil {
312		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure responding to request")
313		return
314	}
315
316	return
317}
318
319// GetPreparer prepares the Get request.
320func (client VirtualNetworkGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
321	pathParameters := map[string]interface{}{
322		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
323		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
324		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
325	}
326
327	const APIVersion = "2016-09-01"
328	queryParameters := map[string]interface{}{
329		"api-version": APIVersion,
330	}
331
332	preparer := autorest.CreatePreparer(
333		autorest.AsGet(),
334		autorest.WithBaseURL(client.BaseURI),
335		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
336		autorest.WithQueryParameters(queryParameters))
337	return preparer.Prepare((&http.Request{}).WithContext(ctx))
338}
339
340// GetSender sends the Get request. The method will close the
341// http.Response Body if it receives an error.
342func (client VirtualNetworkGatewaysClient) GetSender(req *http.Request) (*http.Response, error) {
343	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
344}
345
346// GetResponder handles the response to the Get request. The method always
347// closes the http.Response Body.
348func (client VirtualNetworkGatewaysClient) GetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
349	err = autorest.Respond(
350		resp,
351		azure.WithErrorUnlessStatusCode(http.StatusOK),
352		autorest.ByUnmarshallingJSON(&result),
353		autorest.ByClosing())
354	result.Response = autorest.Response{Response: resp}
355	return
356}
357
358// GetAdvertisedRoutes this operation retrieves a list of routes the virtual network gateway is advertising to the
359// specified peer.
360// Parameters:
361// resourceGroupName - the name of the resource group.
362// virtualNetworkGatewayName - the name of the virtual network gateway.
363// peer - the IP address of the peer
364func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) {
365	if tracing.IsEnabled() {
366		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetAdvertisedRoutes")
367		defer func() {
368			sc := -1
369			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
370				sc = result.FutureAPI.Response().StatusCode
371			}
372			tracing.EndSpan(ctx, sc, err)
373		}()
374	}
375	req, err := client.GetAdvertisedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer)
376	if err != nil {
377		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure preparing request")
378		return
379	}
380
381	result, err = client.GetAdvertisedRoutesSender(req)
382	if err != nil {
383		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure sending request")
384		return
385	}
386
387	return
388}
389
390// GetAdvertisedRoutesPreparer prepares the GetAdvertisedRoutes request.
391func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) {
392	pathParameters := map[string]interface{}{
393		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
394		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
395		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
396	}
397
398	const APIVersion = "2016-09-01"
399	queryParameters := map[string]interface{}{
400		"api-version": APIVersion,
401		"peer":        autorest.Encode("query", peer),
402	}
403
404	preparer := autorest.CreatePreparer(
405		autorest.AsPost(),
406		autorest.WithBaseURL(client.BaseURI),
407		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes", pathParameters),
408		autorest.WithQueryParameters(queryParameters))
409	return preparer.Prepare((&http.Request{}).WithContext(ctx))
410}
411
412// GetAdvertisedRoutesSender sends the GetAdvertisedRoutes request. The method will close the
413// http.Response Body if it receives an error.
414func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) {
415	var resp *http.Response
416	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
417	if err != nil {
418		return
419	}
420	var azf azure.Future
421	azf, err = azure.NewFutureFromResponse(resp)
422	future.FutureAPI = &azf
423	future.Result = future.result
424	return
425}
426
427// GetAdvertisedRoutesResponder handles the response to the GetAdvertisedRoutes request. The method always
428// closes the http.Response Body.
429func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) {
430	err = autorest.Respond(
431		resp,
432		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
433		autorest.ByUnmarshallingJSON(&result),
434		autorest.ByClosing())
435	result.Response = autorest.Response{Response: resp}
436	return
437}
438
439// GetBgpPeerStatus the GetBgpPeerStatus operation retrieves the status of all BGP peers.
440// Parameters:
441// resourceGroupName - the name of the resource group.
442// virtualNetworkGatewayName - the name of the virtual network gateway.
443// peer - the IP address of the peer to retrieve the status of.
444func (client VirtualNetworkGatewaysClient) GetBgpPeerStatus(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) {
445	if tracing.IsEnabled() {
446		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetBgpPeerStatus")
447		defer func() {
448			sc := -1
449			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
450				sc = result.FutureAPI.Response().StatusCode
451			}
452			tracing.EndSpan(ctx, sc, err)
453		}()
454	}
455	req, err := client.GetBgpPeerStatusPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer)
456	if err != nil {
457		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure preparing request")
458		return
459	}
460
461	result, err = client.GetBgpPeerStatusSender(req)
462	if err != nil {
463		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure sending request")
464		return
465	}
466
467	return
468}
469
470// GetBgpPeerStatusPreparer prepares the GetBgpPeerStatus request.
471func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) {
472	pathParameters := map[string]interface{}{
473		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
474		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
475		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
476	}
477
478	const APIVersion = "2016-09-01"
479	queryParameters := map[string]interface{}{
480		"api-version": APIVersion,
481	}
482	if len(peer) > 0 {
483		queryParameters["peer"] = autorest.Encode("query", peer)
484	}
485
486	preparer := autorest.CreatePreparer(
487		autorest.AsPost(),
488		autorest.WithBaseURL(client.BaseURI),
489		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus", pathParameters),
490		autorest.WithQueryParameters(queryParameters))
491	return preparer.Prepare((&http.Request{}).WithContext(ctx))
492}
493
494// GetBgpPeerStatusSender sends the GetBgpPeerStatus request. The method will close the
495// http.Response Body if it receives an error.
496func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusSender(req *http.Request) (future VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) {
497	var resp *http.Response
498	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
499	if err != nil {
500		return
501	}
502	var azf azure.Future
503	azf, err = azure.NewFutureFromResponse(resp)
504	future.FutureAPI = &azf
505	future.Result = future.result
506	return
507}
508
509// GetBgpPeerStatusResponder handles the response to the GetBgpPeerStatus request. The method always
510// closes the http.Response Body.
511func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusResponder(resp *http.Response) (result BgpPeerStatusListResult, err error) {
512	err = autorest.Respond(
513		resp,
514		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
515		autorest.ByUnmarshallingJSON(&result),
516		autorest.ByClosing())
517	result.Response = autorest.Response{Response: resp}
518	return
519}
520
521// GetLearnedRoutes this operation retrieves a list of routes the virtual network gateway has learned, including routes
522// learned from BGP peers.
523// Parameters:
524// resourceGroupName - the name of the resource group.
525// virtualNetworkGatewayName - the name of the virtual network gateway.
526func (client VirtualNetworkGatewaysClient) GetLearnedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) {
527	if tracing.IsEnabled() {
528		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetLearnedRoutes")
529		defer func() {
530			sc := -1
531			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
532				sc = result.FutureAPI.Response().StatusCode
533			}
534			tracing.EndSpan(ctx, sc, err)
535		}()
536	}
537	req, err := client.GetLearnedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
538	if err != nil {
539		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure preparing request")
540		return
541	}
542
543	result, err = client.GetLearnedRoutesSender(req)
544	if err != nil {
545		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure sending request")
546		return
547	}
548
549	return
550}
551
552// GetLearnedRoutesPreparer prepares the GetLearnedRoutes request.
553func (client VirtualNetworkGatewaysClient) GetLearnedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName 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 = "2016-09-01"
561	queryParameters := map[string]interface{}{
562		"api-version": APIVersion,
563	}
564
565	preparer := autorest.CreatePreparer(
566		autorest.AsPost(),
567		autorest.WithBaseURL(client.BaseURI),
568		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes", pathParameters),
569		autorest.WithQueryParameters(queryParameters))
570	return preparer.Prepare((&http.Request{}).WithContext(ctx))
571}
572
573// GetLearnedRoutesSender sends the GetLearnedRoutes request. The method will close the
574// http.Response Body if it receives an error.
575func (client VirtualNetworkGatewaysClient) GetLearnedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) {
576	var resp *http.Response
577	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
578	if err != nil {
579		return
580	}
581	var azf azure.Future
582	azf, err = azure.NewFutureFromResponse(resp)
583	future.FutureAPI = &azf
584	future.Result = future.result
585	return
586}
587
588// GetLearnedRoutesResponder handles the response to the GetLearnedRoutes request. The method always
589// closes the http.Response Body.
590func (client VirtualNetworkGatewaysClient) GetLearnedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) {
591	err = autorest.Respond(
592		resp,
593		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
594		autorest.ByUnmarshallingJSON(&result),
595		autorest.ByClosing())
596	result.Response = autorest.Response{Response: resp}
597	return
598}
599
600// List gets all virtual network gateways by resource group.
601// Parameters:
602// resourceGroupName - the name of the resource group.
603func (client VirtualNetworkGatewaysClient) List(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultPage, err error) {
604	if tracing.IsEnabled() {
605		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.List")
606		defer func() {
607			sc := -1
608			if result.vnglr.Response.Response != nil {
609				sc = result.vnglr.Response.Response.StatusCode
610			}
611			tracing.EndSpan(ctx, sc, err)
612		}()
613	}
614	result.fn = client.listNextResults
615	req, err := client.ListPreparer(ctx, resourceGroupName)
616	if err != nil {
617		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request")
618		return
619	}
620
621	resp, err := client.ListSender(req)
622	if err != nil {
623		result.vnglr.Response = autorest.Response{Response: resp}
624		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request")
625		return
626	}
627
628	result.vnglr, err = client.ListResponder(resp)
629	if err != nil {
630		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure responding to request")
631		return
632	}
633	if result.vnglr.hasNextLink() && result.vnglr.IsEmpty() {
634		err = result.NextWithContext(ctx)
635		return
636	}
637
638	return
639}
640
641// ListPreparer prepares the List request.
642func (client VirtualNetworkGatewaysClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
643	pathParameters := map[string]interface{}{
644		"resourceGroupName": autorest.Encode("path", resourceGroupName),
645		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
646	}
647
648	const APIVersion = "2016-09-01"
649	queryParameters := map[string]interface{}{
650		"api-version": APIVersion,
651	}
652
653	preparer := autorest.CreatePreparer(
654		autorest.AsGet(),
655		autorest.WithBaseURL(client.BaseURI),
656		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways", pathParameters),
657		autorest.WithQueryParameters(queryParameters))
658	return preparer.Prepare((&http.Request{}).WithContext(ctx))
659}
660
661// ListSender sends the List request. The method will close the
662// http.Response Body if it receives an error.
663func (client VirtualNetworkGatewaysClient) ListSender(req *http.Request) (*http.Response, error) {
664	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
665}
666
667// ListResponder handles the response to the List request. The method always
668// closes the http.Response Body.
669func (client VirtualNetworkGatewaysClient) ListResponder(resp *http.Response) (result VirtualNetworkGatewayListResult, err error) {
670	err = autorest.Respond(
671		resp,
672		azure.WithErrorUnlessStatusCode(http.StatusOK),
673		autorest.ByUnmarshallingJSON(&result),
674		autorest.ByClosing())
675	result.Response = autorest.Response{Response: resp}
676	return
677}
678
679// listNextResults retrieves the next set of results, if any.
680func (client VirtualNetworkGatewaysClient) listNextResults(ctx context.Context, lastResults VirtualNetworkGatewayListResult) (result VirtualNetworkGatewayListResult, err error) {
681	req, err := lastResults.virtualNetworkGatewayListResultPreparer(ctx)
682	if err != nil {
683		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", nil, "Failure preparing next results request")
684	}
685	if req == nil {
686		return
687	}
688	resp, err := client.ListSender(req)
689	if err != nil {
690		result.Response = autorest.Response{Response: resp}
691		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure sending next results request")
692	}
693	result, err = client.ListResponder(resp)
694	if err != nil {
695		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure responding to next results request")
696	}
697	return
698}
699
700// ListComplete enumerates all values, automatically crossing page boundaries as required.
701func (client VirtualNetworkGatewaysClient) ListComplete(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultIterator, err error) {
702	if tracing.IsEnabled() {
703		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.List")
704		defer func() {
705			sc := -1
706			if result.Response().Response.Response != nil {
707				sc = result.page.Response().Response.Response.StatusCode
708			}
709			tracing.EndSpan(ctx, sc, err)
710		}()
711	}
712	result.page, err = client.List(ctx, resourceGroupName)
713	return
714}
715
716// Reset resets the primary of the virtual network gateway in the specified resource group.
717// Parameters:
718// resourceGroupName - the name of the resource group.
719// virtualNetworkGatewayName - the name of the virtual network gateway.
720// gatewayVip - virtual network gateway vip address supplied to the begin reset of the active-active feature
721// enabled gateway.
722func (client VirtualNetworkGatewaysClient) Reset(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (result VirtualNetworkGatewaysResetFuture, err error) {
723	if tracing.IsEnabled() {
724		ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Reset")
725		defer func() {
726			sc := -1
727			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
728				sc = result.FutureAPI.Response().StatusCode
729			}
730			tracing.EndSpan(ctx, sc, err)
731		}()
732	}
733	req, err := client.ResetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, gatewayVip)
734	if err != nil {
735		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request")
736		return
737	}
738
739	result, err = client.ResetSender(req)
740	if err != nil {
741		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure sending request")
742		return
743	}
744
745	return
746}
747
748// ResetPreparer prepares the Reset request.
749func (client VirtualNetworkGatewaysClient) ResetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (*http.Request, error) {
750	pathParameters := map[string]interface{}{
751		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
752		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
753		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
754	}
755
756	const APIVersion = "2016-09-01"
757	queryParameters := map[string]interface{}{
758		"api-version": APIVersion,
759	}
760	if len(gatewayVip) > 0 {
761		queryParameters["gatewayVip"] = autorest.Encode("query", gatewayVip)
762	}
763
764	preparer := autorest.CreatePreparer(
765		autorest.AsPost(),
766		autorest.WithBaseURL(client.BaseURI),
767		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/reset", pathParameters),
768		autorest.WithQueryParameters(queryParameters))
769	return preparer.Prepare((&http.Request{}).WithContext(ctx))
770}
771
772// ResetSender sends the Reset request. The method will close the
773// http.Response Body if it receives an error.
774func (client VirtualNetworkGatewaysClient) ResetSender(req *http.Request) (future VirtualNetworkGatewaysResetFuture, err error) {
775	var resp *http.Response
776	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
777	if err != nil {
778		return
779	}
780	var azf azure.Future
781	azf, err = azure.NewFutureFromResponse(resp)
782	future.FutureAPI = &azf
783	future.Result = future.result
784	return
785}
786
787// ResetResponder handles the response to the Reset request. The method always
788// closes the http.Response Body.
789func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
790	err = autorest.Respond(
791		resp,
792		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
793		autorest.ByUnmarshallingJSON(&result),
794		autorest.ByClosing())
795	result.Response = autorest.Response{Response: resp}
796	return
797}
798