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, 52 Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat.IPConfigurations", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { 53 return result, validation.NewError("network.VirtualNetworkGatewaysClient", "CreateOrUpdate", err.Error()) 54 } 55 56 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters) 57 if err != nil { 58 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") 59 return 60 } 61 62 result, err = client.CreateOrUpdateSender(req) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", result.Response(), "Failure sending request") 65 return 66 } 67 68 return 69} 70 71// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 72func (client VirtualNetworkGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway) (*http.Request, error) { 73 pathParameters := map[string]interface{}{ 74 "resourceGroupName": autorest.Encode("path", resourceGroupName), 75 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 76 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 77 } 78 79 const APIVersion = "2016-09-01" 80 queryParameters := map[string]interface{}{ 81 "api-version": APIVersion, 82 } 83 84 preparer := autorest.CreatePreparer( 85 autorest.AsContentType("application/json; charset=utf-8"), 86 autorest.AsPut(), 87 autorest.WithBaseURL(client.BaseURI), 88 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), 89 autorest.WithJSON(parameters), 90 autorest.WithQueryParameters(queryParameters)) 91 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 92} 93 94// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 95// http.Response Body if it receives an error. 96func (client VirtualNetworkGatewaysClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkGatewaysCreateOrUpdateFuture, err error) { 97 var resp *http.Response 98 resp, err = autorest.SendWithSender(client, req, 99 azure.DoRetryWithRegistration(client.Client)) 100 if err != nil { 101 return 102 } 103 err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated)) 104 if err != nil { 105 return 106 } 107 future.Future, err = azure.NewFutureFromResponse(resp) 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 client.ByInspecting(), 117 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 118 autorest.ByUnmarshallingJSON(&result), 119 autorest.ByClosing()) 120 result.Response = autorest.Response{Response: resp} 121 return 122} 123 124// Delete deletes the specified virtual network gateway. 125// Parameters: 126// resourceGroupName - the name of the resource group. 127// virtualNetworkGatewayName - the name of the virtual network gateway. 128func (client VirtualNetworkGatewaysClient) Delete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysDeleteFuture, err error) { 129 req, err := client.DeletePreparer(ctx, resourceGroupName, virtualNetworkGatewayName) 130 if err != nil { 131 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure preparing request") 132 return 133 } 134 135 result, err = client.DeleteSender(req) 136 if err != nil { 137 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", result.Response(), "Failure sending request") 138 return 139 } 140 141 return 142} 143 144// DeletePreparer prepares the Delete request. 145func (client VirtualNetworkGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { 146 pathParameters := map[string]interface{}{ 147 "resourceGroupName": autorest.Encode("path", resourceGroupName), 148 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 149 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 150 } 151 152 const APIVersion = "2016-09-01" 153 queryParameters := map[string]interface{}{ 154 "api-version": APIVersion, 155 } 156 157 preparer := autorest.CreatePreparer( 158 autorest.AsDelete(), 159 autorest.WithBaseURL(client.BaseURI), 160 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), 161 autorest.WithQueryParameters(queryParameters)) 162 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 163} 164 165// DeleteSender sends the Delete request. The method will close the 166// http.Response Body if it receives an error. 167func (client VirtualNetworkGatewaysClient) DeleteSender(req *http.Request) (future VirtualNetworkGatewaysDeleteFuture, err error) { 168 var resp *http.Response 169 resp, err = autorest.SendWithSender(client, req, 170 azure.DoRetryWithRegistration(client.Client)) 171 if err != nil { 172 return 173 } 174 err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) 175 if err != nil { 176 return 177 } 178 future.Future, err = azure.NewFutureFromResponse(resp) 179 return 180} 181 182// DeleteResponder handles the response to the Delete request. The method always 183// closes the http.Response Body. 184func (client VirtualNetworkGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 185 err = autorest.Respond( 186 resp, 187 client.ByInspecting(), 188 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 189 autorest.ByClosing()) 190 result.Response = resp 191 return 192} 193 194// Generatevpnclientpackage generates VPN client package for P2S client of the virtual network gateway in the specified 195// resource group. 196// Parameters: 197// resourceGroupName - the name of the resource group. 198// virtualNetworkGatewayName - the name of the virtual network gateway. 199// parameters - parameters supplied to the generate virtual network gateway VPN client package operation. 200func (client VirtualNetworkGatewaysClient) Generatevpnclientpackage(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result String, err error) { 201 req, err := client.GeneratevpnclientpackagePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters) 202 if err != nil { 203 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure preparing request") 204 return 205 } 206 207 resp, err := client.GeneratevpnclientpackageSender(req) 208 if err != nil { 209 result.Response = autorest.Response{Response: resp} 210 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", resp, "Failure sending request") 211 return 212 } 213 214 result, err = client.GeneratevpnclientpackageResponder(resp) 215 if err != nil { 216 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", resp, "Failure responding to request") 217 } 218 219 return 220} 221 222// GeneratevpnclientpackagePreparer prepares the Generatevpnclientpackage request. 223func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackagePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (*http.Request, error) { 224 pathParameters := map[string]interface{}{ 225 "resourceGroupName": autorest.Encode("path", resourceGroupName), 226 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 227 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 228 } 229 230 const APIVersion = "2016-09-01" 231 queryParameters := map[string]interface{}{ 232 "api-version": APIVersion, 233 } 234 235 preparer := autorest.CreatePreparer( 236 autorest.AsContentType("application/json; charset=utf-8"), 237 autorest.AsPost(), 238 autorest.WithBaseURL(client.BaseURI), 239 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnclientpackage", pathParameters), 240 autorest.WithJSON(parameters), 241 autorest.WithQueryParameters(queryParameters)) 242 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 243} 244 245// GeneratevpnclientpackageSender sends the Generatevpnclientpackage request. The method will close the 246// http.Response Body if it receives an error. 247func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageSender(req *http.Request) (*http.Response, error) { 248 return autorest.SendWithSender(client, req, 249 azure.DoRetryWithRegistration(client.Client)) 250} 251 252// GeneratevpnclientpackageResponder handles the response to the Generatevpnclientpackage request. The method always 253// closes the http.Response Body. 254func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageResponder(resp *http.Response) (result String, err error) { 255 err = autorest.Respond( 256 resp, 257 client.ByInspecting(), 258 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 259 autorest.ByUnmarshallingJSON(&result.Value), 260 autorest.ByClosing()) 261 result.Response = autorest.Response{Response: resp} 262 return 263} 264 265// Get gets the specified virtual network gateway by resource group. 266// Parameters: 267// resourceGroupName - the name of the resource group. 268// virtualNetworkGatewayName - the name of the virtual network gateway. 269func (client VirtualNetworkGatewaysClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGateway, err error) { 270 req, err := client.GetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName) 271 if err != nil { 272 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", nil, "Failure preparing request") 273 return 274 } 275 276 resp, err := client.GetSender(req) 277 if err != nil { 278 result.Response = autorest.Response{Response: resp} 279 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure sending request") 280 return 281 } 282 283 result, err = client.GetResponder(resp) 284 if err != nil { 285 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure responding to request") 286 } 287 288 return 289} 290 291// GetPreparer prepares the Get request. 292func (client VirtualNetworkGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { 293 pathParameters := map[string]interface{}{ 294 "resourceGroupName": autorest.Encode("path", resourceGroupName), 295 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 296 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 297 } 298 299 const APIVersion = "2016-09-01" 300 queryParameters := map[string]interface{}{ 301 "api-version": APIVersion, 302 } 303 304 preparer := autorest.CreatePreparer( 305 autorest.AsGet(), 306 autorest.WithBaseURL(client.BaseURI), 307 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), 308 autorest.WithQueryParameters(queryParameters)) 309 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 310} 311 312// GetSender sends the Get request. The method will close the 313// http.Response Body if it receives an error. 314func (client VirtualNetworkGatewaysClient) GetSender(req *http.Request) (*http.Response, error) { 315 return autorest.SendWithSender(client, req, 316 azure.DoRetryWithRegistration(client.Client)) 317} 318 319// GetResponder handles the response to the Get request. The method always 320// closes the http.Response Body. 321func (client VirtualNetworkGatewaysClient) GetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) { 322 err = autorest.Respond( 323 resp, 324 client.ByInspecting(), 325 azure.WithErrorUnlessStatusCode(http.StatusOK), 326 autorest.ByUnmarshallingJSON(&result), 327 autorest.ByClosing()) 328 result.Response = autorest.Response{Response: resp} 329 return 330} 331 332// GetAdvertisedRoutes this operation retrieves a list of routes the virtual network gateway is advertising to the 333// specified peer. 334// Parameters: 335// resourceGroupName - the name of the resource group. 336// virtualNetworkGatewayName - the name of the virtual network gateway. 337// peer - the IP address of the peer 338func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) { 339 req, err := client.GetAdvertisedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer) 340 if err != nil { 341 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure preparing request") 342 return 343 } 344 345 result, err = client.GetAdvertisedRoutesSender(req) 346 if err != nil { 347 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", result.Response(), "Failure sending request") 348 return 349 } 350 351 return 352} 353 354// GetAdvertisedRoutesPreparer prepares the GetAdvertisedRoutes request. 355func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) { 356 pathParameters := map[string]interface{}{ 357 "resourceGroupName": autorest.Encode("path", resourceGroupName), 358 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 359 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 360 } 361 362 const APIVersion = "2016-09-01" 363 queryParameters := map[string]interface{}{ 364 "api-version": APIVersion, 365 "peer": autorest.Encode("query", peer), 366 } 367 368 preparer := autorest.CreatePreparer( 369 autorest.AsPost(), 370 autorest.WithBaseURL(client.BaseURI), 371 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes", pathParameters), 372 autorest.WithQueryParameters(queryParameters)) 373 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 374} 375 376// GetAdvertisedRoutesSender sends the GetAdvertisedRoutes request. The method will close the 377// http.Response Body if it receives an error. 378func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) { 379 var resp *http.Response 380 resp, err = autorest.SendWithSender(client, req, 381 azure.DoRetryWithRegistration(client.Client)) 382 if err != nil { 383 return 384 } 385 err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) 386 if err != nil { 387 return 388 } 389 future.Future, err = azure.NewFutureFromResponse(resp) 390 return 391} 392 393// GetAdvertisedRoutesResponder handles the response to the GetAdvertisedRoutes request. The method always 394// closes the http.Response Body. 395func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) { 396 err = autorest.Respond( 397 resp, 398 client.ByInspecting(), 399 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 400 autorest.ByUnmarshallingJSON(&result), 401 autorest.ByClosing()) 402 result.Response = autorest.Response{Response: resp} 403 return 404} 405 406// GetBgpPeerStatus the GetBgpPeerStatus operation retrieves the status of all BGP peers. 407// Parameters: 408// resourceGroupName - the name of the resource group. 409// virtualNetworkGatewayName - the name of the virtual network gateway. 410// peer - the IP address of the peer to retrieve the status of. 411func (client VirtualNetworkGatewaysClient) GetBgpPeerStatus(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) { 412 req, err := client.GetBgpPeerStatusPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer) 413 if err != nil { 414 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure preparing request") 415 return 416 } 417 418 result, err = client.GetBgpPeerStatusSender(req) 419 if err != nil { 420 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", result.Response(), "Failure sending request") 421 return 422 } 423 424 return 425} 426 427// GetBgpPeerStatusPreparer prepares the GetBgpPeerStatus request. 428func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) { 429 pathParameters := map[string]interface{}{ 430 "resourceGroupName": autorest.Encode("path", resourceGroupName), 431 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 432 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 433 } 434 435 const APIVersion = "2016-09-01" 436 queryParameters := map[string]interface{}{ 437 "api-version": APIVersion, 438 } 439 if len(peer) > 0 { 440 queryParameters["peer"] = autorest.Encode("query", peer) 441 } 442 443 preparer := autorest.CreatePreparer( 444 autorest.AsPost(), 445 autorest.WithBaseURL(client.BaseURI), 446 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus", pathParameters), 447 autorest.WithQueryParameters(queryParameters)) 448 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 449} 450 451// GetBgpPeerStatusSender sends the GetBgpPeerStatus request. The method will close the 452// http.Response Body if it receives an error. 453func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusSender(req *http.Request) (future VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) { 454 var resp *http.Response 455 resp, err = autorest.SendWithSender(client, req, 456 azure.DoRetryWithRegistration(client.Client)) 457 if err != nil { 458 return 459 } 460 err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) 461 if err != nil { 462 return 463 } 464 future.Future, err = azure.NewFutureFromResponse(resp) 465 return 466} 467 468// GetBgpPeerStatusResponder handles the response to the GetBgpPeerStatus request. The method always 469// closes the http.Response Body. 470func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusResponder(resp *http.Response) (result BgpPeerStatusListResult, err error) { 471 err = autorest.Respond( 472 resp, 473 client.ByInspecting(), 474 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 475 autorest.ByUnmarshallingJSON(&result), 476 autorest.ByClosing()) 477 result.Response = autorest.Response{Response: resp} 478 return 479} 480 481// GetLearnedRoutes this operation retrieves a list of routes the virtual network gateway has learned, including routes 482// learned from BGP peers. 483// Parameters: 484// resourceGroupName - the name of the resource group. 485// virtualNetworkGatewayName - the name of the virtual network gateway. 486func (client VirtualNetworkGatewaysClient) GetLearnedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) { 487 req, err := client.GetLearnedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName) 488 if err != nil { 489 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure preparing request") 490 return 491 } 492 493 result, err = client.GetLearnedRoutesSender(req) 494 if err != nil { 495 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", result.Response(), "Failure sending request") 496 return 497 } 498 499 return 500} 501 502// GetLearnedRoutesPreparer prepares the GetLearnedRoutes request. 503func (client VirtualNetworkGatewaysClient) GetLearnedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { 504 pathParameters := map[string]interface{}{ 505 "resourceGroupName": autorest.Encode("path", resourceGroupName), 506 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 507 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 508 } 509 510 const APIVersion = "2016-09-01" 511 queryParameters := map[string]interface{}{ 512 "api-version": APIVersion, 513 } 514 515 preparer := autorest.CreatePreparer( 516 autorest.AsPost(), 517 autorest.WithBaseURL(client.BaseURI), 518 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes", pathParameters), 519 autorest.WithQueryParameters(queryParameters)) 520 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 521} 522 523// GetLearnedRoutesSender sends the GetLearnedRoutes request. The method will close the 524// http.Response Body if it receives an error. 525func (client VirtualNetworkGatewaysClient) GetLearnedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) { 526 var resp *http.Response 527 resp, err = autorest.SendWithSender(client, req, 528 azure.DoRetryWithRegistration(client.Client)) 529 if err != nil { 530 return 531 } 532 err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) 533 if err != nil { 534 return 535 } 536 future.Future, err = azure.NewFutureFromResponse(resp) 537 return 538} 539 540// GetLearnedRoutesResponder handles the response to the GetLearnedRoutes request. The method always 541// closes the http.Response Body. 542func (client VirtualNetworkGatewaysClient) GetLearnedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) { 543 err = autorest.Respond( 544 resp, 545 client.ByInspecting(), 546 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 547 autorest.ByUnmarshallingJSON(&result), 548 autorest.ByClosing()) 549 result.Response = autorest.Response{Response: resp} 550 return 551} 552 553// List gets all virtual network gateways by resource group. 554// Parameters: 555// resourceGroupName - the name of the resource group. 556func (client VirtualNetworkGatewaysClient) List(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultPage, err error) { 557 result.fn = client.listNextResults 558 req, err := client.ListPreparer(ctx, resourceGroupName) 559 if err != nil { 560 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request") 561 return 562 } 563 564 resp, err := client.ListSender(req) 565 if err != nil { 566 result.vnglr.Response = autorest.Response{Response: resp} 567 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request") 568 return 569 } 570 571 result.vnglr, err = client.ListResponder(resp) 572 if err != nil { 573 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure responding to request") 574 } 575 576 return 577} 578 579// ListPreparer prepares the List request. 580func (client VirtualNetworkGatewaysClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 581 pathParameters := map[string]interface{}{ 582 "resourceGroupName": autorest.Encode("path", resourceGroupName), 583 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 584 } 585 586 const APIVersion = "2016-09-01" 587 queryParameters := map[string]interface{}{ 588 "api-version": APIVersion, 589 } 590 591 preparer := autorest.CreatePreparer( 592 autorest.AsGet(), 593 autorest.WithBaseURL(client.BaseURI), 594 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways", pathParameters), 595 autorest.WithQueryParameters(queryParameters)) 596 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 597} 598 599// ListSender sends the List request. The method will close the 600// http.Response Body if it receives an error. 601func (client VirtualNetworkGatewaysClient) ListSender(req *http.Request) (*http.Response, error) { 602 return autorest.SendWithSender(client, req, 603 azure.DoRetryWithRegistration(client.Client)) 604} 605 606// ListResponder handles the response to the List request. The method always 607// closes the http.Response Body. 608func (client VirtualNetworkGatewaysClient) ListResponder(resp *http.Response) (result VirtualNetworkGatewayListResult, err error) { 609 err = autorest.Respond( 610 resp, 611 client.ByInspecting(), 612 azure.WithErrorUnlessStatusCode(http.StatusOK), 613 autorest.ByUnmarshallingJSON(&result), 614 autorest.ByClosing()) 615 result.Response = autorest.Response{Response: resp} 616 return 617} 618 619// listNextResults retrieves the next set of results, if any. 620func (client VirtualNetworkGatewaysClient) listNextResults(lastResults VirtualNetworkGatewayListResult) (result VirtualNetworkGatewayListResult, err error) { 621 req, err := lastResults.virtualNetworkGatewayListResultPreparer() 622 if err != nil { 623 return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", nil, "Failure preparing next results request") 624 } 625 if req == nil { 626 return 627 } 628 resp, err := client.ListSender(req) 629 if err != nil { 630 result.Response = autorest.Response{Response: resp} 631 return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure sending next results request") 632 } 633 result, err = client.ListResponder(resp) 634 if err != nil { 635 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure responding to next results request") 636 } 637 return 638} 639 640// ListComplete enumerates all values, automatically crossing page boundaries as required. 641func (client VirtualNetworkGatewaysClient) ListComplete(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultIterator, err error) { 642 result.page, err = client.List(ctx, resourceGroupName) 643 return 644} 645 646// Reset resets the primary of the virtual network gateway in the specified resource group. 647// Parameters: 648// resourceGroupName - the name of the resource group. 649// virtualNetworkGatewayName - the name of the virtual network gateway. 650// gatewayVip - virtual network gateway vip address supplied to the begin reset of the active-active feature 651// enabled gateway. 652func (client VirtualNetworkGatewaysClient) Reset(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (result VirtualNetworkGatewaysResetFuture, err error) { 653 req, err := client.ResetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, gatewayVip) 654 if err != nil { 655 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request") 656 return 657 } 658 659 result, err = client.ResetSender(req) 660 if err != nil { 661 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", result.Response(), "Failure sending request") 662 return 663 } 664 665 return 666} 667 668// ResetPreparer prepares the Reset request. 669func (client VirtualNetworkGatewaysClient) ResetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (*http.Request, error) { 670 pathParameters := map[string]interface{}{ 671 "resourceGroupName": autorest.Encode("path", resourceGroupName), 672 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 673 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 674 } 675 676 const APIVersion = "2016-09-01" 677 queryParameters := map[string]interface{}{ 678 "api-version": APIVersion, 679 } 680 if len(gatewayVip) > 0 { 681 queryParameters["gatewayVip"] = autorest.Encode("query", gatewayVip) 682 } 683 684 preparer := autorest.CreatePreparer( 685 autorest.AsPost(), 686 autorest.WithBaseURL(client.BaseURI), 687 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/reset", pathParameters), 688 autorest.WithQueryParameters(queryParameters)) 689 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 690} 691 692// ResetSender sends the Reset request. The method will close the 693// http.Response Body if it receives an error. 694func (client VirtualNetworkGatewaysClient) ResetSender(req *http.Request) (future VirtualNetworkGatewaysResetFuture, err error) { 695 var resp *http.Response 696 resp, err = autorest.SendWithSender(client, req, 697 azure.DoRetryWithRegistration(client.Client)) 698 if err != nil { 699 return 700 } 701 err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) 702 if err != nil { 703 return 704 } 705 future.Future, err = azure.NewFutureFromResponse(resp) 706 return 707} 708 709// ResetResponder handles the response to the Reset request. The method always 710// closes the http.Response Body. 711func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) { 712 err = autorest.Respond( 713 resp, 714 client.ByInspecting(), 715 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 716 autorest.ByUnmarshallingJSON(&result), 717 autorest.ByClosing()) 718 result.Response = autorest.Response{Response: resp} 719 return 720} 721