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