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	"net/http"
26)
27
28// VirtualNetworkGatewaysClient is the network Client
29type VirtualNetworkGatewaysClient struct {
30	BaseClient
31}
32
33// NewVirtualNetworkGatewaysClient creates an instance of the VirtualNetworkGatewaysClient client.
34func NewVirtualNetworkGatewaysClient(subscriptionID string) VirtualNetworkGatewaysClient {
35	return NewVirtualNetworkGatewaysClientWithBaseURI(DefaultBaseURI, subscriptionID)
36}
37
38// NewVirtualNetworkGatewaysClientWithBaseURI creates an instance of the VirtualNetworkGatewaysClient client.
39func NewVirtualNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkGatewaysClient {
40	return VirtualNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)}
41}
42
43// CreateOrUpdate creates or updates a virtual network gateway in the specified resource group.
44// Parameters:
45// resourceGroupName - the name of the resource group.
46// virtualNetworkGatewayName - the name of the virtual network gateway.
47// parameters - parameters supplied to create or update virtual network gateway operation.
48func (client VirtualNetworkGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway) (result VirtualNetworkGatewaysCreateOrUpdateFuture, err error) {
49	if err := validation.Validate([]validation.Validation{
50		{TargetValue: parameters,
51			Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
52		return result, validation.NewError("network.VirtualNetworkGatewaysClient", "CreateOrUpdate", err.Error())
53	}
54
55	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
56	if err != nil {
57		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
58		return
59	}
60
61	result, err = client.CreateOrUpdateSender(req)
62	if err != nil {
63		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", result.Response(), "Failure sending request")
64		return
65	}
66
67	return
68}
69
70// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
71func (client VirtualNetworkGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway) (*http.Request, error) {
72	pathParameters := map[string]interface{}{
73		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
74		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
75		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
76	}
77
78	const APIVersion = "2017-08-01"
79	queryParameters := map[string]interface{}{
80		"api-version": APIVersion,
81	}
82
83	preparer := autorest.CreatePreparer(
84		autorest.AsContentType("application/json; charset=utf-8"),
85		autorest.AsPut(),
86		autorest.WithBaseURL(client.BaseURI),
87		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
88		autorest.WithJSON(parameters),
89		autorest.WithQueryParameters(queryParameters))
90	return preparer.Prepare((&http.Request{}).WithContext(ctx))
91}
92
93// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
94// http.Response Body if it receives an error.
95func (client VirtualNetworkGatewaysClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkGatewaysCreateOrUpdateFuture, err error) {
96	var resp *http.Response
97	resp, err = autorest.SendWithSender(client, req,
98		azure.DoRetryWithRegistration(client.Client))
99	if err != nil {
100		return
101	}
102	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated))
103	if err != nil {
104		return
105	}
106	future.Future, err = azure.NewFutureFromResponse(resp)
107	return
108}
109
110// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
111// closes the http.Response Body.
112func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
113	err = autorest.Respond(
114		resp,
115		client.ByInspecting(),
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	req, err := client.DeletePreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
129	if err != nil {
130		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure preparing request")
131		return
132	}
133
134	result, err = client.DeleteSender(req)
135	if err != nil {
136		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", result.Response(), "Failure sending request")
137		return
138	}
139
140	return
141}
142
143// DeletePreparer prepares the Delete request.
144func (client VirtualNetworkGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
145	pathParameters := map[string]interface{}{
146		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
147		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
148		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
149	}
150
151	const APIVersion = "2017-08-01"
152	queryParameters := map[string]interface{}{
153		"api-version": APIVersion,
154	}
155
156	preparer := autorest.CreatePreparer(
157		autorest.AsDelete(),
158		autorest.WithBaseURL(client.BaseURI),
159		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
160		autorest.WithQueryParameters(queryParameters))
161	return preparer.Prepare((&http.Request{}).WithContext(ctx))
162}
163
164// DeleteSender sends the Delete request. The method will close the
165// http.Response Body if it receives an error.
166func (client VirtualNetworkGatewaysClient) DeleteSender(req *http.Request) (future VirtualNetworkGatewaysDeleteFuture, err error) {
167	var resp *http.Response
168	resp, err = autorest.SendWithSender(client, req,
169		azure.DoRetryWithRegistration(client.Client))
170	if err != nil {
171		return
172	}
173	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent))
174	if err != nil {
175		return
176	}
177	future.Future, err = azure.NewFutureFromResponse(resp)
178	return
179}
180
181// DeleteResponder handles the response to the Delete request. The method always
182// closes the http.Response Body.
183func (client VirtualNetworkGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
184	err = autorest.Respond(
185		resp,
186		client.ByInspecting(),
187		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
188		autorest.ByClosing())
189	result.Response = resp
190	return
191}
192
193// Generatevpnclientpackage generates VPN client package for P2S client of the virtual network gateway in the specified
194// resource group.
195// Parameters:
196// resourceGroupName - the name of the resource group.
197// virtualNetworkGatewayName - the name of the virtual network gateway.
198// parameters - parameters supplied to the generate virtual network gateway VPN client package operation.
199func (client VirtualNetworkGatewaysClient) Generatevpnclientpackage(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result VirtualNetworkGatewaysGeneratevpnclientpackageFuture, err error) {
200	req, err := client.GeneratevpnclientpackagePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
201	if err != nil {
202		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure preparing request")
203		return
204	}
205
206	result, err = client.GeneratevpnclientpackageSender(req)
207	if err != nil {
208		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", result.Response(), "Failure sending request")
209		return
210	}
211
212	return
213}
214
215// GeneratevpnclientpackagePreparer prepares the Generatevpnclientpackage request.
216func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackagePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (*http.Request, error) {
217	pathParameters := map[string]interface{}{
218		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
219		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
220		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
221	}
222
223	const APIVersion = "2017-08-01"
224	queryParameters := map[string]interface{}{
225		"api-version": APIVersion,
226	}
227
228	preparer := autorest.CreatePreparer(
229		autorest.AsContentType("application/json; charset=utf-8"),
230		autorest.AsPost(),
231		autorest.WithBaseURL(client.BaseURI),
232		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnclientpackage", pathParameters),
233		autorest.WithJSON(parameters),
234		autorest.WithQueryParameters(queryParameters))
235	return preparer.Prepare((&http.Request{}).WithContext(ctx))
236}
237
238// GeneratevpnclientpackageSender sends the Generatevpnclientpackage request. The method will close the
239// http.Response Body if it receives an error.
240func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageSender(req *http.Request) (future VirtualNetworkGatewaysGeneratevpnclientpackageFuture, err error) {
241	var resp *http.Response
242	resp, err = autorest.SendWithSender(client, req,
243		azure.DoRetryWithRegistration(client.Client))
244	if err != nil {
245		return
246	}
247	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK))
248	if err != nil {
249		return
250	}
251	future.Future, err = azure.NewFutureFromResponse(resp)
252	return
253}
254
255// GeneratevpnclientpackageResponder handles the response to the Generatevpnclientpackage request. The method always
256// closes the http.Response Body.
257func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageResponder(resp *http.Response) (result String, err error) {
258	err = autorest.Respond(
259		resp,
260		client.ByInspecting(),
261		azure.WithErrorUnlessStatusCode(http.StatusOK),
262		autorest.ByUnmarshallingJSON(&result),
263		autorest.ByClosing())
264	result.Response = autorest.Response{Response: resp}
265	return
266}
267
268// GenerateVpnProfile generates VPN profile for P2S client of the virtual network gateway in the specified resource
269// group. Used for IKEV2 and radius based authentication.
270// Parameters:
271// resourceGroupName - the name of the resource group.
272// virtualNetworkGatewayName - the name of the virtual network gateway.
273// parameters - parameters supplied to the generate virtual network gateway VPN client package operation.
274func (client VirtualNetworkGatewaysClient) GenerateVpnProfile(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result VirtualNetworkGatewaysGenerateVpnProfileFuture, err error) {
275	req, err := client.GenerateVpnProfilePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters)
276	if err != nil {
277		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GenerateVpnProfile", nil, "Failure preparing request")
278		return
279	}
280
281	result, err = client.GenerateVpnProfileSender(req)
282	if err != nil {
283		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GenerateVpnProfile", result.Response(), "Failure sending request")
284		return
285	}
286
287	return
288}
289
290// GenerateVpnProfilePreparer prepares the GenerateVpnProfile request.
291func (client VirtualNetworkGatewaysClient) GenerateVpnProfilePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (*http.Request, error) {
292	pathParameters := map[string]interface{}{
293		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
294		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
295		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
296	}
297
298	const APIVersion = "2017-08-01"
299	queryParameters := map[string]interface{}{
300		"api-version": APIVersion,
301	}
302
303	preparer := autorest.CreatePreparer(
304		autorest.AsContentType("application/json; charset=utf-8"),
305		autorest.AsPost(),
306		autorest.WithBaseURL(client.BaseURI),
307		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnprofile", pathParameters),
308		autorest.WithJSON(parameters),
309		autorest.WithQueryParameters(queryParameters))
310	return preparer.Prepare((&http.Request{}).WithContext(ctx))
311}
312
313// GenerateVpnProfileSender sends the GenerateVpnProfile request. The method will close the
314// http.Response Body if it receives an error.
315func (client VirtualNetworkGatewaysClient) GenerateVpnProfileSender(req *http.Request) (future VirtualNetworkGatewaysGenerateVpnProfileFuture, err error) {
316	var resp *http.Response
317	resp, err = autorest.SendWithSender(client, req,
318		azure.DoRetryWithRegistration(client.Client))
319	if err != nil {
320		return
321	}
322	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
323	if err != nil {
324		return
325	}
326	future.Future, err = azure.NewFutureFromResponse(resp)
327	return
328}
329
330// GenerateVpnProfileResponder handles the response to the GenerateVpnProfile request. The method always
331// closes the http.Response Body.
332func (client VirtualNetworkGatewaysClient) GenerateVpnProfileResponder(resp *http.Response) (result String, err error) {
333	err = autorest.Respond(
334		resp,
335		client.ByInspecting(),
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// Get gets the specified virtual network gateway by resource group.
344// Parameters:
345// resourceGroupName - the name of the resource group.
346// virtualNetworkGatewayName - the name of the virtual network gateway.
347func (client VirtualNetworkGatewaysClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGateway, err error) {
348	req, err := client.GetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
349	if err != nil {
350		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", nil, "Failure preparing request")
351		return
352	}
353
354	resp, err := client.GetSender(req)
355	if err != nil {
356		result.Response = autorest.Response{Response: resp}
357		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure sending request")
358		return
359	}
360
361	result, err = client.GetResponder(resp)
362	if err != nil {
363		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure responding to request")
364	}
365
366	return
367}
368
369// GetPreparer prepares the Get request.
370func (client VirtualNetworkGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
371	pathParameters := map[string]interface{}{
372		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
373		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
374		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
375	}
376
377	const APIVersion = "2017-08-01"
378	queryParameters := map[string]interface{}{
379		"api-version": APIVersion,
380	}
381
382	preparer := autorest.CreatePreparer(
383		autorest.AsGet(),
384		autorest.WithBaseURL(client.BaseURI),
385		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters),
386		autorest.WithQueryParameters(queryParameters))
387	return preparer.Prepare((&http.Request{}).WithContext(ctx))
388}
389
390// GetSender sends the Get request. The method will close the
391// http.Response Body if it receives an error.
392func (client VirtualNetworkGatewaysClient) GetSender(req *http.Request) (*http.Response, error) {
393	return autorest.SendWithSender(client, req,
394		azure.DoRetryWithRegistration(client.Client))
395}
396
397// GetResponder handles the response to the Get request. The method always
398// closes the http.Response Body.
399func (client VirtualNetworkGatewaysClient) GetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
400	err = autorest.Respond(
401		resp,
402		client.ByInspecting(),
403		azure.WithErrorUnlessStatusCode(http.StatusOK),
404		autorest.ByUnmarshallingJSON(&result),
405		autorest.ByClosing())
406	result.Response = autorest.Response{Response: resp}
407	return
408}
409
410// GetAdvertisedRoutes this operation retrieves a list of routes the virtual network gateway is advertising to the
411// specified peer.
412// Parameters:
413// resourceGroupName - the name of the resource group.
414// virtualNetworkGatewayName - the name of the virtual network gateway.
415// peer - the IP address of the peer
416func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) {
417	req, err := client.GetAdvertisedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer)
418	if err != nil {
419		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure preparing request")
420		return
421	}
422
423	result, err = client.GetAdvertisedRoutesSender(req)
424	if err != nil {
425		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", result.Response(), "Failure sending request")
426		return
427	}
428
429	return
430}
431
432// GetAdvertisedRoutesPreparer prepares the GetAdvertisedRoutes request.
433func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) {
434	pathParameters := map[string]interface{}{
435		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
436		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
437		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
438	}
439
440	const APIVersion = "2017-08-01"
441	queryParameters := map[string]interface{}{
442		"api-version": APIVersion,
443		"peer":        autorest.Encode("query", peer),
444	}
445
446	preparer := autorest.CreatePreparer(
447		autorest.AsPost(),
448		autorest.WithBaseURL(client.BaseURI),
449		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes", pathParameters),
450		autorest.WithQueryParameters(queryParameters))
451	return preparer.Prepare((&http.Request{}).WithContext(ctx))
452}
453
454// GetAdvertisedRoutesSender sends the GetAdvertisedRoutes request. The method will close the
455// http.Response Body if it receives an error.
456func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) {
457	var resp *http.Response
458	resp, err = autorest.SendWithSender(client, req,
459		azure.DoRetryWithRegistration(client.Client))
460	if err != nil {
461		return
462	}
463	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
464	if err != nil {
465		return
466	}
467	future.Future, err = azure.NewFutureFromResponse(resp)
468	return
469}
470
471// GetAdvertisedRoutesResponder handles the response to the GetAdvertisedRoutes request. The method always
472// closes the http.Response Body.
473func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) {
474	err = autorest.Respond(
475		resp,
476		client.ByInspecting(),
477		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
478		autorest.ByUnmarshallingJSON(&result),
479		autorest.ByClosing())
480	result.Response = autorest.Response{Response: resp}
481	return
482}
483
484// GetBgpPeerStatus the GetBgpPeerStatus operation retrieves the status of all BGP peers.
485// Parameters:
486// resourceGroupName - the name of the resource group.
487// virtualNetworkGatewayName - the name of the virtual network gateway.
488// peer - the IP address of the peer to retrieve the status of.
489func (client VirtualNetworkGatewaysClient) GetBgpPeerStatus(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) {
490	req, err := client.GetBgpPeerStatusPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer)
491	if err != nil {
492		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure preparing request")
493		return
494	}
495
496	result, err = client.GetBgpPeerStatusSender(req)
497	if err != nil {
498		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", result.Response(), "Failure sending request")
499		return
500	}
501
502	return
503}
504
505// GetBgpPeerStatusPreparer prepares the GetBgpPeerStatus request.
506func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) {
507	pathParameters := map[string]interface{}{
508		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
509		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
510		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
511	}
512
513	const APIVersion = "2017-08-01"
514	queryParameters := map[string]interface{}{
515		"api-version": APIVersion,
516	}
517	if len(peer) > 0 {
518		queryParameters["peer"] = autorest.Encode("query", peer)
519	}
520
521	preparer := autorest.CreatePreparer(
522		autorest.AsPost(),
523		autorest.WithBaseURL(client.BaseURI),
524		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus", pathParameters),
525		autorest.WithQueryParameters(queryParameters))
526	return preparer.Prepare((&http.Request{}).WithContext(ctx))
527}
528
529// GetBgpPeerStatusSender sends the GetBgpPeerStatus request. The method will close the
530// http.Response Body if it receives an error.
531func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusSender(req *http.Request) (future VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) {
532	var resp *http.Response
533	resp, err = autorest.SendWithSender(client, req,
534		azure.DoRetryWithRegistration(client.Client))
535	if err != nil {
536		return
537	}
538	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
539	if err != nil {
540		return
541	}
542	future.Future, err = azure.NewFutureFromResponse(resp)
543	return
544}
545
546// GetBgpPeerStatusResponder handles the response to the GetBgpPeerStatus request. The method always
547// closes the http.Response Body.
548func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusResponder(resp *http.Response) (result BgpPeerStatusListResult, err error) {
549	err = autorest.Respond(
550		resp,
551		client.ByInspecting(),
552		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
553		autorest.ByUnmarshallingJSON(&result),
554		autorest.ByClosing())
555	result.Response = autorest.Response{Response: resp}
556	return
557}
558
559// GetLearnedRoutes this operation retrieves a list of routes the virtual network gateway has learned, including routes
560// learned from BGP peers.
561// Parameters:
562// resourceGroupName - the name of the resource group.
563// virtualNetworkGatewayName - the name of the virtual network gateway.
564func (client VirtualNetworkGatewaysClient) GetLearnedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) {
565	req, err := client.GetLearnedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
566	if err != nil {
567		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure preparing request")
568		return
569	}
570
571	result, err = client.GetLearnedRoutesSender(req)
572	if err != nil {
573		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", result.Response(), "Failure sending request")
574		return
575	}
576
577	return
578}
579
580// GetLearnedRoutesPreparer prepares the GetLearnedRoutes request.
581func (client VirtualNetworkGatewaysClient) GetLearnedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
582	pathParameters := map[string]interface{}{
583		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
584		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
585		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
586	}
587
588	const APIVersion = "2017-08-01"
589	queryParameters := map[string]interface{}{
590		"api-version": APIVersion,
591	}
592
593	preparer := autorest.CreatePreparer(
594		autorest.AsPost(),
595		autorest.WithBaseURL(client.BaseURI),
596		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes", pathParameters),
597		autorest.WithQueryParameters(queryParameters))
598	return preparer.Prepare((&http.Request{}).WithContext(ctx))
599}
600
601// GetLearnedRoutesSender sends the GetLearnedRoutes request. The method will close the
602// http.Response Body if it receives an error.
603func (client VirtualNetworkGatewaysClient) GetLearnedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) {
604	var resp *http.Response
605	resp, err = autorest.SendWithSender(client, req,
606		azure.DoRetryWithRegistration(client.Client))
607	if err != nil {
608		return
609	}
610	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
611	if err != nil {
612		return
613	}
614	future.Future, err = azure.NewFutureFromResponse(resp)
615	return
616}
617
618// GetLearnedRoutesResponder handles the response to the GetLearnedRoutes request. The method always
619// closes the http.Response Body.
620func (client VirtualNetworkGatewaysClient) GetLearnedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) {
621	err = autorest.Respond(
622		resp,
623		client.ByInspecting(),
624		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
625		autorest.ByUnmarshallingJSON(&result),
626		autorest.ByClosing())
627	result.Response = autorest.Response{Response: resp}
628	return
629}
630
631// GetVpnProfilePackageURL gets pre-generated VPN profile for P2S client of the virtual network gateway in the
632// specified resource group. The profile needs to be generated first using generateVpnProfile.
633// Parameters:
634// resourceGroupName - the name of the resource group.
635// virtualNetworkGatewayName - the name of the virtual network gateway.
636func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURL(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetVpnProfilePackageURLFuture, err error) {
637	req, err := client.GetVpnProfilePackageURLPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
638	if err != nil {
639		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnProfilePackageURL", nil, "Failure preparing request")
640		return
641	}
642
643	result, err = client.GetVpnProfilePackageURLSender(req)
644	if err != nil {
645		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnProfilePackageURL", result.Response(), "Failure sending request")
646		return
647	}
648
649	return
650}
651
652// GetVpnProfilePackageURLPreparer prepares the GetVpnProfilePackageURL request.
653func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
654	pathParameters := map[string]interface{}{
655		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
656		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
657		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
658	}
659
660	const APIVersion = "2017-08-01"
661	queryParameters := map[string]interface{}{
662		"api-version": APIVersion,
663	}
664
665	preparer := autorest.CreatePreparer(
666		autorest.AsPost(),
667		autorest.WithBaseURL(client.BaseURI),
668		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getvpnprofilepackageurl", pathParameters),
669		autorest.WithQueryParameters(queryParameters))
670	return preparer.Prepare((&http.Request{}).WithContext(ctx))
671}
672
673// GetVpnProfilePackageURLSender sends the GetVpnProfilePackageURL request. The method will close the
674// http.Response Body if it receives an error.
675func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLSender(req *http.Request) (future VirtualNetworkGatewaysGetVpnProfilePackageURLFuture, err error) {
676	var resp *http.Response
677	resp, err = autorest.SendWithSender(client, req,
678		azure.DoRetryWithRegistration(client.Client))
679	if err != nil {
680		return
681	}
682	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
683	if err != nil {
684		return
685	}
686	future.Future, err = azure.NewFutureFromResponse(resp)
687	return
688}
689
690// GetVpnProfilePackageURLResponder handles the response to the GetVpnProfilePackageURL request. The method always
691// closes the http.Response Body.
692func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLResponder(resp *http.Response) (result String, err error) {
693	err = autorest.Respond(
694		resp,
695		client.ByInspecting(),
696		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
697		autorest.ByUnmarshallingJSON(&result),
698		autorest.ByClosing())
699	result.Response = autorest.Response{Response: resp}
700	return
701}
702
703// List gets all virtual network gateways by resource group.
704// Parameters:
705// resourceGroupName - the name of the resource group.
706func (client VirtualNetworkGatewaysClient) List(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultPage, err error) {
707	result.fn = client.listNextResults
708	req, err := client.ListPreparer(ctx, resourceGroupName)
709	if err != nil {
710		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request")
711		return
712	}
713
714	resp, err := client.ListSender(req)
715	if err != nil {
716		result.vnglr.Response = autorest.Response{Response: resp}
717		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request")
718		return
719	}
720
721	result.vnglr, err = client.ListResponder(resp)
722	if err != nil {
723		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure responding to request")
724	}
725
726	return
727}
728
729// ListPreparer prepares the List request.
730func (client VirtualNetworkGatewaysClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
731	pathParameters := map[string]interface{}{
732		"resourceGroupName": autorest.Encode("path", resourceGroupName),
733		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
734	}
735
736	const APIVersion = "2017-08-01"
737	queryParameters := map[string]interface{}{
738		"api-version": APIVersion,
739	}
740
741	preparer := autorest.CreatePreparer(
742		autorest.AsGet(),
743		autorest.WithBaseURL(client.BaseURI),
744		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways", pathParameters),
745		autorest.WithQueryParameters(queryParameters))
746	return preparer.Prepare((&http.Request{}).WithContext(ctx))
747}
748
749// ListSender sends the List request. The method will close the
750// http.Response Body if it receives an error.
751func (client VirtualNetworkGatewaysClient) ListSender(req *http.Request) (*http.Response, error) {
752	return autorest.SendWithSender(client, req,
753		azure.DoRetryWithRegistration(client.Client))
754}
755
756// ListResponder handles the response to the List request. The method always
757// closes the http.Response Body.
758func (client VirtualNetworkGatewaysClient) ListResponder(resp *http.Response) (result VirtualNetworkGatewayListResult, err error) {
759	err = autorest.Respond(
760		resp,
761		client.ByInspecting(),
762		azure.WithErrorUnlessStatusCode(http.StatusOK),
763		autorest.ByUnmarshallingJSON(&result),
764		autorest.ByClosing())
765	result.Response = autorest.Response{Response: resp}
766	return
767}
768
769// listNextResults retrieves the next set of results, if any.
770func (client VirtualNetworkGatewaysClient) listNextResults(lastResults VirtualNetworkGatewayListResult) (result VirtualNetworkGatewayListResult, err error) {
771	req, err := lastResults.virtualNetworkGatewayListResultPreparer()
772	if err != nil {
773		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", nil, "Failure preparing next results request")
774	}
775	if req == nil {
776		return
777	}
778	resp, err := client.ListSender(req)
779	if err != nil {
780		result.Response = autorest.Response{Response: resp}
781		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure sending next results request")
782	}
783	result, err = client.ListResponder(resp)
784	if err != nil {
785		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure responding to next results request")
786	}
787	return
788}
789
790// ListComplete enumerates all values, automatically crossing page boundaries as required.
791func (client VirtualNetworkGatewaysClient) ListComplete(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultIterator, err error) {
792	result.page, err = client.List(ctx, resourceGroupName)
793	return
794}
795
796// ListConnections gets all the connections in a virtual network gateway.
797// Parameters:
798// resourceGroupName - the name of the resource group.
799// virtualNetworkGatewayName - the name of the virtual network gateway.
800func (client VirtualNetworkGatewaysClient) ListConnections(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewayListConnectionsResultPage, err error) {
801	result.fn = client.listConnectionsNextResults
802	req, err := client.ListConnectionsPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
803	if err != nil {
804		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", nil, "Failure preparing request")
805		return
806	}
807
808	resp, err := client.ListConnectionsSender(req)
809	if err != nil {
810		result.vnglcr.Response = autorest.Response{Response: resp}
811		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", resp, "Failure sending request")
812		return
813	}
814
815	result.vnglcr, err = client.ListConnectionsResponder(resp)
816	if err != nil {
817		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", resp, "Failure responding to request")
818	}
819
820	return
821}
822
823// ListConnectionsPreparer prepares the ListConnections request.
824func (client VirtualNetworkGatewaysClient) ListConnectionsPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
825	pathParameters := map[string]interface{}{
826		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
827		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
828		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
829	}
830
831	const APIVersion = "2017-08-01"
832	queryParameters := map[string]interface{}{
833		"api-version": APIVersion,
834	}
835
836	preparer := autorest.CreatePreparer(
837		autorest.AsGet(),
838		autorest.WithBaseURL(client.BaseURI),
839		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/connections", pathParameters),
840		autorest.WithQueryParameters(queryParameters))
841	return preparer.Prepare((&http.Request{}).WithContext(ctx))
842}
843
844// ListConnectionsSender sends the ListConnections request. The method will close the
845// http.Response Body if it receives an error.
846func (client VirtualNetworkGatewaysClient) ListConnectionsSender(req *http.Request) (*http.Response, error) {
847	return autorest.SendWithSender(client, req,
848		azure.DoRetryWithRegistration(client.Client))
849}
850
851// ListConnectionsResponder handles the response to the ListConnections request. The method always
852// closes the http.Response Body.
853func (client VirtualNetworkGatewaysClient) ListConnectionsResponder(resp *http.Response) (result VirtualNetworkGatewayListConnectionsResult, err error) {
854	err = autorest.Respond(
855		resp,
856		client.ByInspecting(),
857		azure.WithErrorUnlessStatusCode(http.StatusOK),
858		autorest.ByUnmarshallingJSON(&result),
859		autorest.ByClosing())
860	result.Response = autorest.Response{Response: resp}
861	return
862}
863
864// listConnectionsNextResults retrieves the next set of results, if any.
865func (client VirtualNetworkGatewaysClient) listConnectionsNextResults(lastResults VirtualNetworkGatewayListConnectionsResult) (result VirtualNetworkGatewayListConnectionsResult, err error) {
866	req, err := lastResults.virtualNetworkGatewayListConnectionsResultPreparer()
867	if err != nil {
868		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", nil, "Failure preparing next results request")
869	}
870	if req == nil {
871		return
872	}
873	resp, err := client.ListConnectionsSender(req)
874	if err != nil {
875		result.Response = autorest.Response{Response: resp}
876		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", resp, "Failure sending next results request")
877	}
878	result, err = client.ListConnectionsResponder(resp)
879	if err != nil {
880		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", resp, "Failure responding to next results request")
881	}
882	return
883}
884
885// ListConnectionsComplete enumerates all values, automatically crossing page boundaries as required.
886func (client VirtualNetworkGatewaysClient) ListConnectionsComplete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewayListConnectionsResultIterator, err error) {
887	result.page, err = client.ListConnections(ctx, resourceGroupName, virtualNetworkGatewayName)
888	return
889}
890
891// Reset resets the primary of the virtual network gateway in the specified resource group.
892// Parameters:
893// resourceGroupName - the name of the resource group.
894// virtualNetworkGatewayName - the name of the virtual network gateway.
895// gatewayVip - virtual network gateway vip address supplied to the begin reset of the active-active feature
896// enabled gateway.
897func (client VirtualNetworkGatewaysClient) Reset(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (result VirtualNetworkGatewaysResetFuture, err error) {
898	req, err := client.ResetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, gatewayVip)
899	if err != nil {
900		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request")
901		return
902	}
903
904	result, err = client.ResetSender(req)
905	if err != nil {
906		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", result.Response(), "Failure sending request")
907		return
908	}
909
910	return
911}
912
913// ResetPreparer prepares the Reset request.
914func (client VirtualNetworkGatewaysClient) ResetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (*http.Request, error) {
915	pathParameters := map[string]interface{}{
916		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
917		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
918		"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
919	}
920
921	const APIVersion = "2017-08-01"
922	queryParameters := map[string]interface{}{
923		"api-version": APIVersion,
924	}
925	if len(gatewayVip) > 0 {
926		queryParameters["gatewayVip"] = autorest.Encode("query", gatewayVip)
927	}
928
929	preparer := autorest.CreatePreparer(
930		autorest.AsPost(),
931		autorest.WithBaseURL(client.BaseURI),
932		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/reset", pathParameters),
933		autorest.WithQueryParameters(queryParameters))
934	return preparer.Prepare((&http.Request{}).WithContext(ctx))
935}
936
937// ResetSender sends the Reset request. The method will close the
938// http.Response Body if it receives an error.
939func (client VirtualNetworkGatewaysClient) ResetSender(req *http.Request) (future VirtualNetworkGatewaysResetFuture, err error) {
940	var resp *http.Response
941	resp, err = autorest.SendWithSender(client, req,
942		azure.DoRetryWithRegistration(client.Client))
943	if err != nil {
944		return
945	}
946	err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
947	if err != nil {
948		return
949	}
950	future.Future, err = azure.NewFutureFromResponse(resp)
951	return
952}
953
954// ResetResponder handles the response to the Reset request. The method always
955// closes the http.Response Body.
956func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
957	err = autorest.Respond(
958		resp,
959		client.ByInspecting(),
960		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
961		autorest.ByUnmarshallingJSON(&result),
962		autorest.ByClosing())
963	result.Response = autorest.Response{Response: resp}
964	return
965}
966