1package network 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/validation" 25 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// VirtualNetworkGatewaysClient is the network Client 30type VirtualNetworkGatewaysClient struct { 31 BaseClient 32} 33 34// NewVirtualNetworkGatewaysClient creates an instance of the VirtualNetworkGatewaysClient client. 35func NewVirtualNetworkGatewaysClient(subscriptionID string) VirtualNetworkGatewaysClient { 36 return NewVirtualNetworkGatewaysClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewVirtualNetworkGatewaysClientWithBaseURI creates an instance of the VirtualNetworkGatewaysClient client using a 40// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, 41// Azure stack). 42func NewVirtualNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkGatewaysClient { 43 return VirtualNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// CreateOrUpdate creates or updates a virtual network gateway in the specified resource group. 47// Parameters: 48// resourceGroupName - the name of the resource group. 49// virtualNetworkGatewayName - the name of the virtual network gateway. 50// parameters - parameters supplied to create or update virtual network gateway operation. 51func (client VirtualNetworkGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway) (result VirtualNetworkGatewaysCreateOrUpdateFuture, err error) { 52 if tracing.IsEnabled() { 53 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.CreateOrUpdate") 54 defer func() { 55 sc := -1 56 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 57 sc = result.FutureAPI.Response().StatusCode 58 } 59 tracing.EndSpan(ctx, sc, err) 60 }() 61 } 62 if err := validation.Validate([]validation.Validation{ 63 {TargetValue: parameters, 64 Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 65 return result, validation.NewError("network.VirtualNetworkGatewaysClient", "CreateOrUpdate", err.Error()) 66 } 67 68 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters) 69 if err != nil { 70 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") 71 return 72 } 73 74 result, err = client.CreateOrUpdateSender(req) 75 if err != nil { 76 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure sending request") 77 return 78 } 79 80 return 81} 82 83// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 84func (client VirtualNetworkGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway) (*http.Request, error) { 85 pathParameters := map[string]interface{}{ 86 "resourceGroupName": autorest.Encode("path", resourceGroupName), 87 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 88 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 89 } 90 91 const APIVersion = "2017-11-01" 92 queryParameters := map[string]interface{}{ 93 "api-version": APIVersion, 94 } 95 96 preparer := autorest.CreatePreparer( 97 autorest.AsContentType("application/json; charset=utf-8"), 98 autorest.AsPut(), 99 autorest.WithBaseURL(client.BaseURI), 100 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), 101 autorest.WithJSON(parameters), 102 autorest.WithQueryParameters(queryParameters)) 103 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 104} 105 106// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 107// http.Response Body if it receives an error. 108func (client VirtualNetworkGatewaysClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkGatewaysCreateOrUpdateFuture, err error) { 109 var resp *http.Response 110 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 111 if err != nil { 112 return 113 } 114 var azf azure.Future 115 azf, err = azure.NewFutureFromResponse(resp) 116 future.FutureAPI = &azf 117 future.Result = func(client VirtualNetworkGatewaysClient) (vng VirtualNetworkGateway, err error) { 118 var done bool 119 done, err = future.DoneWithContext(context.Background(), client) 120 if err != nil { 121 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") 122 return 123 } 124 if !done { 125 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysCreateOrUpdateFuture") 126 return 127 } 128 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 129 vng.Response.Response, err = future.GetResult(sender) 130 if vng.Response.Response == nil && err == nil { 131 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysCreateOrUpdateFuture", "Result", nil, "received nil response and error") 132 } 133 if err == nil && vng.Response.Response.StatusCode != http.StatusNoContent { 134 vng, err = client.CreateOrUpdateResponder(vng.Response.Response) 135 if err != nil { 136 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysCreateOrUpdateFuture", "Result", vng.Response.Response, "Failure responding to request") 137 } 138 } 139 return 140 } 141 return 142} 143 144// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 145// closes the http.Response Body. 146func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGateway, err error) { 147 err = autorest.Respond( 148 resp, 149 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 150 autorest.ByUnmarshallingJSON(&result), 151 autorest.ByClosing()) 152 result.Response = autorest.Response{Response: resp} 153 return 154} 155 156// Delete deletes the specified virtual network gateway. 157// Parameters: 158// resourceGroupName - the name of the resource group. 159// virtualNetworkGatewayName - the name of the virtual network gateway. 160func (client VirtualNetworkGatewaysClient) Delete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysDeleteFuture, err error) { 161 if tracing.IsEnabled() { 162 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Delete") 163 defer func() { 164 sc := -1 165 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 166 sc = result.FutureAPI.Response().StatusCode 167 } 168 tracing.EndSpan(ctx, sc, err) 169 }() 170 } 171 req, err := client.DeletePreparer(ctx, resourceGroupName, virtualNetworkGatewayName) 172 if err != nil { 173 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure preparing request") 174 return 175 } 176 177 result, err = client.DeleteSender(req) 178 if err != nil { 179 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure sending request") 180 return 181 } 182 183 return 184} 185 186// DeletePreparer prepares the Delete request. 187func (client VirtualNetworkGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { 188 pathParameters := map[string]interface{}{ 189 "resourceGroupName": autorest.Encode("path", resourceGroupName), 190 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 191 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 192 } 193 194 const APIVersion = "2017-11-01" 195 queryParameters := map[string]interface{}{ 196 "api-version": APIVersion, 197 } 198 199 preparer := autorest.CreatePreparer( 200 autorest.AsDelete(), 201 autorest.WithBaseURL(client.BaseURI), 202 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), 203 autorest.WithQueryParameters(queryParameters)) 204 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 205} 206 207// DeleteSender sends the Delete request. The method will close the 208// http.Response Body if it receives an error. 209func (client VirtualNetworkGatewaysClient) DeleteSender(req *http.Request) (future VirtualNetworkGatewaysDeleteFuture, err error) { 210 var resp *http.Response 211 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 212 if err != nil { 213 return 214 } 215 var azf azure.Future 216 azf, err = azure.NewFutureFromResponse(resp) 217 future.FutureAPI = &azf 218 future.Result = func(client VirtualNetworkGatewaysClient) (ar autorest.Response, err error) { 219 var done bool 220 done, err = future.DoneWithContext(context.Background(), client) 221 if err != nil { 222 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysDeleteFuture", "Result", future.Response(), "Polling failure") 223 return 224 } 225 if !done { 226 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysDeleteFuture") 227 return 228 } 229 ar.Response = future.Response() 230 return 231 } 232 return 233} 234 235// DeleteResponder handles the response to the Delete request. The method always 236// closes the http.Response Body. 237func (client VirtualNetworkGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 238 err = autorest.Respond( 239 resp, 240 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 241 autorest.ByClosing()) 242 result.Response = resp 243 return 244} 245 246// Generatevpnclientpackage generates VPN client package for P2S client of the virtual network gateway in the specified 247// resource group. 248// Parameters: 249// resourceGroupName - the name of the resource group. 250// virtualNetworkGatewayName - the name of the virtual network gateway. 251// parameters - parameters supplied to the generate virtual network gateway VPN client package operation. 252func (client VirtualNetworkGatewaysClient) Generatevpnclientpackage(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result VirtualNetworkGatewaysGeneratevpnclientpackageFuture, err error) { 253 if tracing.IsEnabled() { 254 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Generatevpnclientpackage") 255 defer func() { 256 sc := -1 257 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 258 sc = result.FutureAPI.Response().StatusCode 259 } 260 tracing.EndSpan(ctx, sc, err) 261 }() 262 } 263 req, err := client.GeneratevpnclientpackagePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters) 264 if err != nil { 265 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure preparing request") 266 return 267 } 268 269 result, err = client.GeneratevpnclientpackageSender(req) 270 if err != nil { 271 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure sending request") 272 return 273 } 274 275 return 276} 277 278// GeneratevpnclientpackagePreparer prepares the Generatevpnclientpackage request. 279func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackagePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (*http.Request, error) { 280 pathParameters := map[string]interface{}{ 281 "resourceGroupName": autorest.Encode("path", resourceGroupName), 282 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 283 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 284 } 285 286 const APIVersion = "2017-11-01" 287 queryParameters := map[string]interface{}{ 288 "api-version": APIVersion, 289 } 290 291 preparer := autorest.CreatePreparer( 292 autorest.AsContentType("application/json; charset=utf-8"), 293 autorest.AsPost(), 294 autorest.WithBaseURL(client.BaseURI), 295 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnclientpackage", pathParameters), 296 autorest.WithJSON(parameters), 297 autorest.WithQueryParameters(queryParameters)) 298 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 299} 300 301// GeneratevpnclientpackageSender sends the Generatevpnclientpackage request. The method will close the 302// http.Response Body if it receives an error. 303func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageSender(req *http.Request) (future VirtualNetworkGatewaysGeneratevpnclientpackageFuture, err error) { 304 var resp *http.Response 305 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 306 if err != nil { 307 return 308 } 309 var azf azure.Future 310 azf, err = azure.NewFutureFromResponse(resp) 311 future.FutureAPI = &azf 312 future.Result = func(client VirtualNetworkGatewaysClient) (s String, err error) { 313 var done bool 314 done, err = future.DoneWithContext(context.Background(), client) 315 if err != nil { 316 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGeneratevpnclientpackageFuture", "Result", future.Response(), "Polling failure") 317 return 318 } 319 if !done { 320 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysGeneratevpnclientpackageFuture") 321 return 322 } 323 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 324 s.Response.Response, err = future.GetResult(sender) 325 if s.Response.Response == nil && err == nil { 326 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGeneratevpnclientpackageFuture", "Result", nil, "received nil response and error") 327 } 328 if err == nil && s.Response.Response.StatusCode != http.StatusNoContent { 329 s, err = client.GeneratevpnclientpackageResponder(s.Response.Response) 330 if err != nil { 331 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGeneratevpnclientpackageFuture", "Result", s.Response.Response, "Failure responding to request") 332 } 333 } 334 return 335 } 336 return 337} 338 339// GeneratevpnclientpackageResponder handles the response to the Generatevpnclientpackage request. The method always 340// closes the http.Response Body. 341func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageResponder(resp *http.Response) (result String, err error) { 342 err = autorest.Respond( 343 resp, 344 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 345 autorest.ByUnmarshallingJSON(&result), 346 autorest.ByClosing()) 347 result.Response = autorest.Response{Response: resp} 348 return 349} 350 351// GenerateVpnProfile generates VPN profile for P2S client of the virtual network gateway in the specified resource 352// group. Used for IKEV2 and radius based authentication. 353// Parameters: 354// resourceGroupName - the name of the resource group. 355// virtualNetworkGatewayName - the name of the virtual network gateway. 356// parameters - parameters supplied to the generate virtual network gateway VPN client package operation. 357func (client VirtualNetworkGatewaysClient) GenerateVpnProfile(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result VirtualNetworkGatewaysGenerateVpnProfileFuture, err error) { 358 if tracing.IsEnabled() { 359 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GenerateVpnProfile") 360 defer func() { 361 sc := -1 362 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 363 sc = result.FutureAPI.Response().StatusCode 364 } 365 tracing.EndSpan(ctx, sc, err) 366 }() 367 } 368 req, err := client.GenerateVpnProfilePreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters) 369 if err != nil { 370 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GenerateVpnProfile", nil, "Failure preparing request") 371 return 372 } 373 374 result, err = client.GenerateVpnProfileSender(req) 375 if err != nil { 376 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GenerateVpnProfile", nil, "Failure sending request") 377 return 378 } 379 380 return 381} 382 383// GenerateVpnProfilePreparer prepares the GenerateVpnProfile request. 384func (client VirtualNetworkGatewaysClient) GenerateVpnProfilePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (*http.Request, error) { 385 pathParameters := map[string]interface{}{ 386 "resourceGroupName": autorest.Encode("path", resourceGroupName), 387 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 388 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 389 } 390 391 const APIVersion = "2017-11-01" 392 queryParameters := map[string]interface{}{ 393 "api-version": APIVersion, 394 } 395 396 preparer := autorest.CreatePreparer( 397 autorest.AsContentType("application/json; charset=utf-8"), 398 autorest.AsPost(), 399 autorest.WithBaseURL(client.BaseURI), 400 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnprofile", pathParameters), 401 autorest.WithJSON(parameters), 402 autorest.WithQueryParameters(queryParameters)) 403 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 404} 405 406// GenerateVpnProfileSender sends the GenerateVpnProfile request. The method will close the 407// http.Response Body if it receives an error. 408func (client VirtualNetworkGatewaysClient) GenerateVpnProfileSender(req *http.Request) (future VirtualNetworkGatewaysGenerateVpnProfileFuture, err error) { 409 var resp *http.Response 410 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 411 if err != nil { 412 return 413 } 414 var azf azure.Future 415 azf, err = azure.NewFutureFromResponse(resp) 416 future.FutureAPI = &azf 417 future.Result = func(client VirtualNetworkGatewaysClient) (s String, err error) { 418 var done bool 419 done, err = future.DoneWithContext(context.Background(), client) 420 if err != nil { 421 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGenerateVpnProfileFuture", "Result", future.Response(), "Polling failure") 422 return 423 } 424 if !done { 425 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysGenerateVpnProfileFuture") 426 return 427 } 428 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 429 s.Response.Response, err = future.GetResult(sender) 430 if s.Response.Response == nil && err == nil { 431 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGenerateVpnProfileFuture", "Result", nil, "received nil response and error") 432 } 433 if err == nil && s.Response.Response.StatusCode != http.StatusNoContent { 434 s, err = client.GenerateVpnProfileResponder(s.Response.Response) 435 if err != nil { 436 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGenerateVpnProfileFuture", "Result", s.Response.Response, "Failure responding to request") 437 } 438 } 439 return 440 } 441 return 442} 443 444// GenerateVpnProfileResponder handles the response to the GenerateVpnProfile request. The method always 445// closes the http.Response Body. 446func (client VirtualNetworkGatewaysClient) GenerateVpnProfileResponder(resp *http.Response) (result String, err error) { 447 err = autorest.Respond( 448 resp, 449 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 450 autorest.ByUnmarshallingJSON(&result), 451 autorest.ByClosing()) 452 result.Response = autorest.Response{Response: resp} 453 return 454} 455 456// Get gets the specified virtual network gateway by resource group. 457// Parameters: 458// resourceGroupName - the name of the resource group. 459// virtualNetworkGatewayName - the name of the virtual network gateway. 460func (client VirtualNetworkGatewaysClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGateway, err error) { 461 if tracing.IsEnabled() { 462 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Get") 463 defer func() { 464 sc := -1 465 if result.Response.Response != nil { 466 sc = result.Response.Response.StatusCode 467 } 468 tracing.EndSpan(ctx, sc, err) 469 }() 470 } 471 req, err := client.GetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName) 472 if err != nil { 473 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", nil, "Failure preparing request") 474 return 475 } 476 477 resp, err := client.GetSender(req) 478 if err != nil { 479 result.Response = autorest.Response{Response: resp} 480 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure sending request") 481 return 482 } 483 484 result, err = client.GetResponder(resp) 485 if err != nil { 486 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure responding to request") 487 return 488 } 489 490 return 491} 492 493// GetPreparer prepares the Get request. 494func (client VirtualNetworkGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { 495 pathParameters := map[string]interface{}{ 496 "resourceGroupName": autorest.Encode("path", resourceGroupName), 497 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 498 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 499 } 500 501 const APIVersion = "2017-11-01" 502 queryParameters := map[string]interface{}{ 503 "api-version": APIVersion, 504 } 505 506 preparer := autorest.CreatePreparer( 507 autorest.AsGet(), 508 autorest.WithBaseURL(client.BaseURI), 509 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), 510 autorest.WithQueryParameters(queryParameters)) 511 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 512} 513 514// GetSender sends the Get request. The method will close the 515// http.Response Body if it receives an error. 516func (client VirtualNetworkGatewaysClient) GetSender(req *http.Request) (*http.Response, error) { 517 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 518} 519 520// GetResponder handles the response to the Get request. The method always 521// closes the http.Response Body. 522func (client VirtualNetworkGatewaysClient) GetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) { 523 err = autorest.Respond( 524 resp, 525 azure.WithErrorUnlessStatusCode(http.StatusOK), 526 autorest.ByUnmarshallingJSON(&result), 527 autorest.ByClosing()) 528 result.Response = autorest.Response{Response: resp} 529 return 530} 531 532// GetAdvertisedRoutes this operation retrieves a list of routes the virtual network gateway is advertising to the 533// specified peer. 534// Parameters: 535// resourceGroupName - the name of the resource group. 536// virtualNetworkGatewayName - the name of the virtual network gateway. 537// peer - the IP address of the peer 538func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) { 539 if tracing.IsEnabled() { 540 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetAdvertisedRoutes") 541 defer func() { 542 sc := -1 543 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 544 sc = result.FutureAPI.Response().StatusCode 545 } 546 tracing.EndSpan(ctx, sc, err) 547 }() 548 } 549 req, err := client.GetAdvertisedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer) 550 if err != nil { 551 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure preparing request") 552 return 553 } 554 555 result, err = client.GetAdvertisedRoutesSender(req) 556 if err != nil { 557 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure sending request") 558 return 559 } 560 561 return 562} 563 564// GetAdvertisedRoutesPreparer prepares the GetAdvertisedRoutes request. 565func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) { 566 pathParameters := map[string]interface{}{ 567 "resourceGroupName": autorest.Encode("path", resourceGroupName), 568 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 569 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 570 } 571 572 const APIVersion = "2017-11-01" 573 queryParameters := map[string]interface{}{ 574 "api-version": APIVersion, 575 "peer": autorest.Encode("query", peer), 576 } 577 578 preparer := autorest.CreatePreparer( 579 autorest.AsPost(), 580 autorest.WithBaseURL(client.BaseURI), 581 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes", pathParameters), 582 autorest.WithQueryParameters(queryParameters)) 583 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 584} 585 586// GetAdvertisedRoutesSender sends the GetAdvertisedRoutes request. The method will close the 587// http.Response Body if it receives an error. 588func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetAdvertisedRoutesFuture, err error) { 589 var resp *http.Response 590 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 591 if err != nil { 592 return 593 } 594 var azf azure.Future 595 azf, err = azure.NewFutureFromResponse(resp) 596 future.FutureAPI = &azf 597 future.Result = func(client VirtualNetworkGatewaysClient) (grlr GatewayRouteListResult, err error) { 598 var done bool 599 done, err = future.DoneWithContext(context.Background(), client) 600 if err != nil { 601 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetAdvertisedRoutesFuture", "Result", future.Response(), "Polling failure") 602 return 603 } 604 if !done { 605 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysGetAdvertisedRoutesFuture") 606 return 607 } 608 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 609 grlr.Response.Response, err = future.GetResult(sender) 610 if grlr.Response.Response == nil && err == nil { 611 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetAdvertisedRoutesFuture", "Result", nil, "received nil response and error") 612 } 613 if err == nil && grlr.Response.Response.StatusCode != http.StatusNoContent { 614 grlr, err = client.GetAdvertisedRoutesResponder(grlr.Response.Response) 615 if err != nil { 616 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetAdvertisedRoutesFuture", "Result", grlr.Response.Response, "Failure responding to request") 617 } 618 } 619 return 620 } 621 return 622} 623 624// GetAdvertisedRoutesResponder handles the response to the GetAdvertisedRoutes request. The method always 625// closes the http.Response Body. 626func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) { 627 err = autorest.Respond( 628 resp, 629 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 630 autorest.ByUnmarshallingJSON(&result), 631 autorest.ByClosing()) 632 result.Response = autorest.Response{Response: resp} 633 return 634} 635 636// GetBgpPeerStatus the GetBgpPeerStatus operation retrieves the status of all BGP peers. 637// Parameters: 638// resourceGroupName - the name of the resource group. 639// virtualNetworkGatewayName - the name of the virtual network gateway. 640// peer - the IP address of the peer to retrieve the status of. 641func (client VirtualNetworkGatewaysClient) GetBgpPeerStatus(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (result VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) { 642 if tracing.IsEnabled() { 643 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetBgpPeerStatus") 644 defer func() { 645 sc := -1 646 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 647 sc = result.FutureAPI.Response().StatusCode 648 } 649 tracing.EndSpan(ctx, sc, err) 650 }() 651 } 652 req, err := client.GetBgpPeerStatusPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, peer) 653 if err != nil { 654 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure preparing request") 655 return 656 } 657 658 result, err = client.GetBgpPeerStatusSender(req) 659 if err != nil { 660 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure sending request") 661 return 662 } 663 664 return 665} 666 667// GetBgpPeerStatusPreparer prepares the GetBgpPeerStatus request. 668func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, peer string) (*http.Request, error) { 669 pathParameters := map[string]interface{}{ 670 "resourceGroupName": autorest.Encode("path", resourceGroupName), 671 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 672 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 673 } 674 675 const APIVersion = "2017-11-01" 676 queryParameters := map[string]interface{}{ 677 "api-version": APIVersion, 678 } 679 if len(peer) > 0 { 680 queryParameters["peer"] = autorest.Encode("query", peer) 681 } 682 683 preparer := autorest.CreatePreparer( 684 autorest.AsPost(), 685 autorest.WithBaseURL(client.BaseURI), 686 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus", pathParameters), 687 autorest.WithQueryParameters(queryParameters)) 688 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 689} 690 691// GetBgpPeerStatusSender sends the GetBgpPeerStatus request. The method will close the 692// http.Response Body if it receives an error. 693func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusSender(req *http.Request) (future VirtualNetworkGatewaysGetBgpPeerStatusFuture, err error) { 694 var resp *http.Response 695 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 696 if err != nil { 697 return 698 } 699 var azf azure.Future 700 azf, err = azure.NewFutureFromResponse(resp) 701 future.FutureAPI = &azf 702 future.Result = func(client VirtualNetworkGatewaysClient) (bpslr BgpPeerStatusListResult, err error) { 703 var done bool 704 done, err = future.DoneWithContext(context.Background(), client) 705 if err != nil { 706 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetBgpPeerStatusFuture", "Result", future.Response(), "Polling failure") 707 return 708 } 709 if !done { 710 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysGetBgpPeerStatusFuture") 711 return 712 } 713 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 714 bpslr.Response.Response, err = future.GetResult(sender) 715 if bpslr.Response.Response == nil && err == nil { 716 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetBgpPeerStatusFuture", "Result", nil, "received nil response and error") 717 } 718 if err == nil && bpslr.Response.Response.StatusCode != http.StatusNoContent { 719 bpslr, err = client.GetBgpPeerStatusResponder(bpslr.Response.Response) 720 if err != nil { 721 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetBgpPeerStatusFuture", "Result", bpslr.Response.Response, "Failure responding to request") 722 } 723 } 724 return 725 } 726 return 727} 728 729// GetBgpPeerStatusResponder handles the response to the GetBgpPeerStatus request. The method always 730// closes the http.Response Body. 731func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusResponder(resp *http.Response) (result BgpPeerStatusListResult, err error) { 732 err = autorest.Respond( 733 resp, 734 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 735 autorest.ByUnmarshallingJSON(&result), 736 autorest.ByClosing()) 737 result.Response = autorest.Response{Response: resp} 738 return 739} 740 741// GetLearnedRoutes this operation retrieves a list of routes the virtual network gateway has learned, including routes 742// learned from BGP peers. 743// Parameters: 744// resourceGroupName - the name of the resource group. 745// virtualNetworkGatewayName - the name of the virtual network gateway. 746func (client VirtualNetworkGatewaysClient) GetLearnedRoutes(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) { 747 if tracing.IsEnabled() { 748 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetLearnedRoutes") 749 defer func() { 750 sc := -1 751 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 752 sc = result.FutureAPI.Response().StatusCode 753 } 754 tracing.EndSpan(ctx, sc, err) 755 }() 756 } 757 req, err := client.GetLearnedRoutesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName) 758 if err != nil { 759 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure preparing request") 760 return 761 } 762 763 result, err = client.GetLearnedRoutesSender(req) 764 if err != nil { 765 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure sending request") 766 return 767 } 768 769 return 770} 771 772// GetLearnedRoutesPreparer prepares the GetLearnedRoutes request. 773func (client VirtualNetworkGatewaysClient) GetLearnedRoutesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { 774 pathParameters := map[string]interface{}{ 775 "resourceGroupName": autorest.Encode("path", resourceGroupName), 776 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 777 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 778 } 779 780 const APIVersion = "2017-11-01" 781 queryParameters := map[string]interface{}{ 782 "api-version": APIVersion, 783 } 784 785 preparer := autorest.CreatePreparer( 786 autorest.AsPost(), 787 autorest.WithBaseURL(client.BaseURI), 788 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes", pathParameters), 789 autorest.WithQueryParameters(queryParameters)) 790 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 791} 792 793// GetLearnedRoutesSender sends the GetLearnedRoutes request. The method will close the 794// http.Response Body if it receives an error. 795func (client VirtualNetworkGatewaysClient) GetLearnedRoutesSender(req *http.Request) (future VirtualNetworkGatewaysGetLearnedRoutesFuture, err error) { 796 var resp *http.Response 797 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 798 if err != nil { 799 return 800 } 801 var azf azure.Future 802 azf, err = azure.NewFutureFromResponse(resp) 803 future.FutureAPI = &azf 804 future.Result = func(client VirtualNetworkGatewaysClient) (grlr GatewayRouteListResult, err error) { 805 var done bool 806 done, err = future.DoneWithContext(context.Background(), client) 807 if err != nil { 808 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetLearnedRoutesFuture", "Result", future.Response(), "Polling failure") 809 return 810 } 811 if !done { 812 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysGetLearnedRoutesFuture") 813 return 814 } 815 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 816 grlr.Response.Response, err = future.GetResult(sender) 817 if grlr.Response.Response == nil && err == nil { 818 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetLearnedRoutesFuture", "Result", nil, "received nil response and error") 819 } 820 if err == nil && grlr.Response.Response.StatusCode != http.StatusNoContent { 821 grlr, err = client.GetLearnedRoutesResponder(grlr.Response.Response) 822 if err != nil { 823 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetLearnedRoutesFuture", "Result", grlr.Response.Response, "Failure responding to request") 824 } 825 } 826 return 827 } 828 return 829} 830 831// GetLearnedRoutesResponder handles the response to the GetLearnedRoutes request. The method always 832// closes the http.Response Body. 833func (client VirtualNetworkGatewaysClient) GetLearnedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, err error) { 834 err = autorest.Respond( 835 resp, 836 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 837 autorest.ByUnmarshallingJSON(&result), 838 autorest.ByClosing()) 839 result.Response = autorest.Response{Response: resp} 840 return 841} 842 843// GetVpnProfilePackageURL gets pre-generated VPN profile for P2S client of the virtual network gateway in the 844// specified resource group. The profile needs to be generated first using generateVpnProfile. 845// Parameters: 846// resourceGroupName - the name of the resource group. 847// virtualNetworkGatewayName - the name of the virtual network gateway. 848func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURL(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysGetVpnProfilePackageURLFuture, err error) { 849 if tracing.IsEnabled() { 850 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.GetVpnProfilePackageURL") 851 defer func() { 852 sc := -1 853 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 854 sc = result.FutureAPI.Response().StatusCode 855 } 856 tracing.EndSpan(ctx, sc, err) 857 }() 858 } 859 req, err := client.GetVpnProfilePackageURLPreparer(ctx, resourceGroupName, virtualNetworkGatewayName) 860 if err != nil { 861 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnProfilePackageURL", nil, "Failure preparing request") 862 return 863 } 864 865 result, err = client.GetVpnProfilePackageURLSender(req) 866 if err != nil { 867 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetVpnProfilePackageURL", nil, "Failure sending request") 868 return 869 } 870 871 return 872} 873 874// GetVpnProfilePackageURLPreparer prepares the GetVpnProfilePackageURL request. 875func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { 876 pathParameters := map[string]interface{}{ 877 "resourceGroupName": autorest.Encode("path", resourceGroupName), 878 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 879 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 880 } 881 882 const APIVersion = "2017-11-01" 883 queryParameters := map[string]interface{}{ 884 "api-version": APIVersion, 885 } 886 887 preparer := autorest.CreatePreparer( 888 autorest.AsPost(), 889 autorest.WithBaseURL(client.BaseURI), 890 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getvpnprofilepackageurl", pathParameters), 891 autorest.WithQueryParameters(queryParameters)) 892 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 893} 894 895// GetVpnProfilePackageURLSender sends the GetVpnProfilePackageURL request. The method will close the 896// http.Response Body if it receives an error. 897func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLSender(req *http.Request) (future VirtualNetworkGatewaysGetVpnProfilePackageURLFuture, err error) { 898 var resp *http.Response 899 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 900 if err != nil { 901 return 902 } 903 var azf azure.Future 904 azf, err = azure.NewFutureFromResponse(resp) 905 future.FutureAPI = &azf 906 future.Result = func(client VirtualNetworkGatewaysClient) (s String, err error) { 907 var done bool 908 done, err = future.DoneWithContext(context.Background(), client) 909 if err != nil { 910 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetVpnProfilePackageURLFuture", "Result", future.Response(), "Polling failure") 911 return 912 } 913 if !done { 914 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysGetVpnProfilePackageURLFuture") 915 return 916 } 917 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 918 s.Response.Response, err = future.GetResult(sender) 919 if s.Response.Response == nil && err == nil { 920 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetVpnProfilePackageURLFuture", "Result", nil, "received nil response and error") 921 } 922 if err == nil && s.Response.Response.StatusCode != http.StatusNoContent { 923 s, err = client.GetVpnProfilePackageURLResponder(s.Response.Response) 924 if err != nil { 925 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysGetVpnProfilePackageURLFuture", "Result", s.Response.Response, "Failure responding to request") 926 } 927 } 928 return 929 } 930 return 931} 932 933// GetVpnProfilePackageURLResponder handles the response to the GetVpnProfilePackageURL request. The method always 934// closes the http.Response Body. 935func (client VirtualNetworkGatewaysClient) GetVpnProfilePackageURLResponder(resp *http.Response) (result String, err error) { 936 err = autorest.Respond( 937 resp, 938 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 939 autorest.ByUnmarshallingJSON(&result), 940 autorest.ByClosing()) 941 result.Response = autorest.Response{Response: resp} 942 return 943} 944 945// List gets all virtual network gateways by resource group. 946// Parameters: 947// resourceGroupName - the name of the resource group. 948func (client VirtualNetworkGatewaysClient) List(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultPage, err error) { 949 if tracing.IsEnabled() { 950 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.List") 951 defer func() { 952 sc := -1 953 if result.vnglr.Response.Response != nil { 954 sc = result.vnglr.Response.Response.StatusCode 955 } 956 tracing.EndSpan(ctx, sc, err) 957 }() 958 } 959 result.fn = client.listNextResults 960 req, err := client.ListPreparer(ctx, resourceGroupName) 961 if err != nil { 962 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request") 963 return 964 } 965 966 resp, err := client.ListSender(req) 967 if err != nil { 968 result.vnglr.Response = autorest.Response{Response: resp} 969 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request") 970 return 971 } 972 973 result.vnglr, err = client.ListResponder(resp) 974 if err != nil { 975 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure responding to request") 976 return 977 } 978 if result.vnglr.hasNextLink() && result.vnglr.IsEmpty() { 979 err = result.NextWithContext(ctx) 980 return 981 } 982 983 return 984} 985 986// ListPreparer prepares the List request. 987func (client VirtualNetworkGatewaysClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 988 pathParameters := map[string]interface{}{ 989 "resourceGroupName": autorest.Encode("path", resourceGroupName), 990 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 991 } 992 993 const APIVersion = "2017-11-01" 994 queryParameters := map[string]interface{}{ 995 "api-version": APIVersion, 996 } 997 998 preparer := autorest.CreatePreparer( 999 autorest.AsGet(), 1000 autorest.WithBaseURL(client.BaseURI), 1001 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways", pathParameters), 1002 autorest.WithQueryParameters(queryParameters)) 1003 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1004} 1005 1006// ListSender sends the List request. The method will close the 1007// http.Response Body if it receives an error. 1008func (client VirtualNetworkGatewaysClient) ListSender(req *http.Request) (*http.Response, error) { 1009 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1010} 1011 1012// ListResponder handles the response to the List request. The method always 1013// closes the http.Response Body. 1014func (client VirtualNetworkGatewaysClient) ListResponder(resp *http.Response) (result VirtualNetworkGatewayListResult, err error) { 1015 err = autorest.Respond( 1016 resp, 1017 azure.WithErrorUnlessStatusCode(http.StatusOK), 1018 autorest.ByUnmarshallingJSON(&result), 1019 autorest.ByClosing()) 1020 result.Response = autorest.Response{Response: resp} 1021 return 1022} 1023 1024// listNextResults retrieves the next set of results, if any. 1025func (client VirtualNetworkGatewaysClient) listNextResults(ctx context.Context, lastResults VirtualNetworkGatewayListResult) (result VirtualNetworkGatewayListResult, err error) { 1026 req, err := lastResults.virtualNetworkGatewayListResultPreparer(ctx) 1027 if err != nil { 1028 return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", nil, "Failure preparing next results request") 1029 } 1030 if req == nil { 1031 return 1032 } 1033 resp, err := client.ListSender(req) 1034 if err != nil { 1035 result.Response = autorest.Response{Response: resp} 1036 return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure sending next results request") 1037 } 1038 result, err = client.ListResponder(resp) 1039 if err != nil { 1040 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listNextResults", resp, "Failure responding to next results request") 1041 } 1042 return 1043} 1044 1045// ListComplete enumerates all values, automatically crossing page boundaries as required. 1046func (client VirtualNetworkGatewaysClient) ListComplete(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayListResultIterator, err error) { 1047 if tracing.IsEnabled() { 1048 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.List") 1049 defer func() { 1050 sc := -1 1051 if result.Response().Response.Response != nil { 1052 sc = result.page.Response().Response.Response.StatusCode 1053 } 1054 tracing.EndSpan(ctx, sc, err) 1055 }() 1056 } 1057 result.page, err = client.List(ctx, resourceGroupName) 1058 return 1059} 1060 1061// ListConnections gets all the connections in a virtual network gateway. 1062// Parameters: 1063// resourceGroupName - the name of the resource group. 1064// virtualNetworkGatewayName - the name of the virtual network gateway. 1065func (client VirtualNetworkGatewaysClient) ListConnections(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewayListConnectionsResultPage, err error) { 1066 if tracing.IsEnabled() { 1067 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.ListConnections") 1068 defer func() { 1069 sc := -1 1070 if result.vnglcr.Response.Response != nil { 1071 sc = result.vnglcr.Response.Response.StatusCode 1072 } 1073 tracing.EndSpan(ctx, sc, err) 1074 }() 1075 } 1076 result.fn = client.listConnectionsNextResults 1077 req, err := client.ListConnectionsPreparer(ctx, resourceGroupName, virtualNetworkGatewayName) 1078 if err != nil { 1079 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", nil, "Failure preparing request") 1080 return 1081 } 1082 1083 resp, err := client.ListConnectionsSender(req) 1084 if err != nil { 1085 result.vnglcr.Response = autorest.Response{Response: resp} 1086 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", resp, "Failure sending request") 1087 return 1088 } 1089 1090 result.vnglcr, err = client.ListConnectionsResponder(resp) 1091 if err != nil { 1092 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ListConnections", resp, "Failure responding to request") 1093 return 1094 } 1095 if result.vnglcr.hasNextLink() && result.vnglcr.IsEmpty() { 1096 err = result.NextWithContext(ctx) 1097 return 1098 } 1099 1100 return 1101} 1102 1103// ListConnectionsPreparer prepares the ListConnections request. 1104func (client VirtualNetworkGatewaysClient) ListConnectionsPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { 1105 pathParameters := map[string]interface{}{ 1106 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1107 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1108 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 1109 } 1110 1111 const APIVersion = "2017-11-01" 1112 queryParameters := map[string]interface{}{ 1113 "api-version": APIVersion, 1114 } 1115 1116 preparer := autorest.CreatePreparer( 1117 autorest.AsGet(), 1118 autorest.WithBaseURL(client.BaseURI), 1119 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/connections", pathParameters), 1120 autorest.WithQueryParameters(queryParameters)) 1121 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1122} 1123 1124// ListConnectionsSender sends the ListConnections request. The method will close the 1125// http.Response Body if it receives an error. 1126func (client VirtualNetworkGatewaysClient) ListConnectionsSender(req *http.Request) (*http.Response, error) { 1127 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1128} 1129 1130// ListConnectionsResponder handles the response to the ListConnections request. The method always 1131// closes the http.Response Body. 1132func (client VirtualNetworkGatewaysClient) ListConnectionsResponder(resp *http.Response) (result VirtualNetworkGatewayListConnectionsResult, err error) { 1133 err = autorest.Respond( 1134 resp, 1135 azure.WithErrorUnlessStatusCode(http.StatusOK), 1136 autorest.ByUnmarshallingJSON(&result), 1137 autorest.ByClosing()) 1138 result.Response = autorest.Response{Response: resp} 1139 return 1140} 1141 1142// listConnectionsNextResults retrieves the next set of results, if any. 1143func (client VirtualNetworkGatewaysClient) listConnectionsNextResults(ctx context.Context, lastResults VirtualNetworkGatewayListConnectionsResult) (result VirtualNetworkGatewayListConnectionsResult, err error) { 1144 req, err := lastResults.virtualNetworkGatewayListConnectionsResultPreparer(ctx) 1145 if err != nil { 1146 return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", nil, "Failure preparing next results request") 1147 } 1148 if req == nil { 1149 return 1150 } 1151 resp, err := client.ListConnectionsSender(req) 1152 if err != nil { 1153 result.Response = autorest.Response{Response: resp} 1154 return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", resp, "Failure sending next results request") 1155 } 1156 result, err = client.ListConnectionsResponder(resp) 1157 if err != nil { 1158 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "listConnectionsNextResults", resp, "Failure responding to next results request") 1159 } 1160 return 1161} 1162 1163// ListConnectionsComplete enumerates all values, automatically crossing page boundaries as required. 1164func (client VirtualNetworkGatewaysClient) ListConnectionsComplete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewayListConnectionsResultIterator, err error) { 1165 if tracing.IsEnabled() { 1166 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.ListConnections") 1167 defer func() { 1168 sc := -1 1169 if result.Response().Response.Response != nil { 1170 sc = result.page.Response().Response.Response.StatusCode 1171 } 1172 tracing.EndSpan(ctx, sc, err) 1173 }() 1174 } 1175 result.page, err = client.ListConnections(ctx, resourceGroupName, virtualNetworkGatewayName) 1176 return 1177} 1178 1179// Reset resets the primary of the virtual network gateway in the specified resource group. 1180// Parameters: 1181// resourceGroupName - the name of the resource group. 1182// virtualNetworkGatewayName - the name of the virtual network gateway. 1183// gatewayVip - virtual network gateway vip address supplied to the begin reset of the active-active feature 1184// enabled gateway. 1185func (client VirtualNetworkGatewaysClient) Reset(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (result VirtualNetworkGatewaysResetFuture, err error) { 1186 if tracing.IsEnabled() { 1187 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.Reset") 1188 defer func() { 1189 sc := -1 1190 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 1191 sc = result.FutureAPI.Response().StatusCode 1192 } 1193 tracing.EndSpan(ctx, sc, err) 1194 }() 1195 } 1196 req, err := client.ResetPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, gatewayVip) 1197 if err != nil { 1198 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request") 1199 return 1200 } 1201 1202 result, err = client.ResetSender(req) 1203 if err != nil { 1204 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure sending request") 1205 return 1206 } 1207 1208 return 1209} 1210 1211// ResetPreparer prepares the Reset request. 1212func (client VirtualNetworkGatewaysClient) ResetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string) (*http.Request, error) { 1213 pathParameters := map[string]interface{}{ 1214 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1215 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1216 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 1217 } 1218 1219 const APIVersion = "2017-11-01" 1220 queryParameters := map[string]interface{}{ 1221 "api-version": APIVersion, 1222 } 1223 if len(gatewayVip) > 0 { 1224 queryParameters["gatewayVip"] = autorest.Encode("query", gatewayVip) 1225 } 1226 1227 preparer := autorest.CreatePreparer( 1228 autorest.AsPost(), 1229 autorest.WithBaseURL(client.BaseURI), 1230 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/reset", pathParameters), 1231 autorest.WithQueryParameters(queryParameters)) 1232 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1233} 1234 1235// ResetSender sends the Reset request. The method will close the 1236// http.Response Body if it receives an error. 1237func (client VirtualNetworkGatewaysClient) ResetSender(req *http.Request) (future VirtualNetworkGatewaysResetFuture, err error) { 1238 var resp *http.Response 1239 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1240 if err != nil { 1241 return 1242 } 1243 var azf azure.Future 1244 azf, err = azure.NewFutureFromResponse(resp) 1245 future.FutureAPI = &azf 1246 future.Result = func(client VirtualNetworkGatewaysClient) (vng VirtualNetworkGateway, err error) { 1247 var done bool 1248 done, err = future.DoneWithContext(context.Background(), client) 1249 if err != nil { 1250 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysResetFuture", "Result", future.Response(), "Polling failure") 1251 return 1252 } 1253 if !done { 1254 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysResetFuture") 1255 return 1256 } 1257 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1258 vng.Response.Response, err = future.GetResult(sender) 1259 if vng.Response.Response == nil && err == nil { 1260 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysResetFuture", "Result", nil, "received nil response and error") 1261 } 1262 if err == nil && vng.Response.Response.StatusCode != http.StatusNoContent { 1263 vng, err = client.ResetResponder(vng.Response.Response) 1264 if err != nil { 1265 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysResetFuture", "Result", vng.Response.Response, "Failure responding to request") 1266 } 1267 } 1268 return 1269 } 1270 return 1271} 1272 1273// ResetResponder handles the response to the Reset request. The method always 1274// closes the http.Response Body. 1275func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) { 1276 err = autorest.Respond( 1277 resp, 1278 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1279 autorest.ByUnmarshallingJSON(&result), 1280 autorest.ByClosing()) 1281 result.Response = autorest.Response{Response: resp} 1282 return 1283} 1284 1285// SupportedVpnDevices gets a xml format representation for supported vpn devices. 1286// Parameters: 1287// resourceGroupName - the name of the resource group. 1288// virtualNetworkGatewayName - the name of the virtual network gateway. 1289func (client VirtualNetworkGatewaysClient) SupportedVpnDevices(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result String, err error) { 1290 if tracing.IsEnabled() { 1291 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.SupportedVpnDevices") 1292 defer func() { 1293 sc := -1 1294 if result.Response.Response != nil { 1295 sc = result.Response.Response.StatusCode 1296 } 1297 tracing.EndSpan(ctx, sc, err) 1298 }() 1299 } 1300 req, err := client.SupportedVpnDevicesPreparer(ctx, resourceGroupName, virtualNetworkGatewayName) 1301 if err != nil { 1302 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SupportedVpnDevices", nil, "Failure preparing request") 1303 return 1304 } 1305 1306 resp, err := client.SupportedVpnDevicesSender(req) 1307 if err != nil { 1308 result.Response = autorest.Response{Response: resp} 1309 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SupportedVpnDevices", resp, "Failure sending request") 1310 return 1311 } 1312 1313 result, err = client.SupportedVpnDevicesResponder(resp) 1314 if err != nil { 1315 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "SupportedVpnDevices", resp, "Failure responding to request") 1316 return 1317 } 1318 1319 return 1320} 1321 1322// SupportedVpnDevicesPreparer prepares the SupportedVpnDevices request. 1323func (client VirtualNetworkGatewaysClient) SupportedVpnDevicesPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { 1324 pathParameters := map[string]interface{}{ 1325 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1326 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1327 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 1328 } 1329 1330 const APIVersion = "2017-11-01" 1331 queryParameters := map[string]interface{}{ 1332 "api-version": APIVersion, 1333 } 1334 1335 preparer := autorest.CreatePreparer( 1336 autorest.AsPost(), 1337 autorest.WithBaseURL(client.BaseURI), 1338 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/supportedvpndevices", pathParameters), 1339 autorest.WithQueryParameters(queryParameters)) 1340 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1341} 1342 1343// SupportedVpnDevicesSender sends the SupportedVpnDevices request. The method will close the 1344// http.Response Body if it receives an error. 1345func (client VirtualNetworkGatewaysClient) SupportedVpnDevicesSender(req *http.Request) (*http.Response, error) { 1346 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1347} 1348 1349// SupportedVpnDevicesResponder handles the response to the SupportedVpnDevices request. The method always 1350// closes the http.Response Body. 1351func (client VirtualNetworkGatewaysClient) SupportedVpnDevicesResponder(resp *http.Response) (result String, err error) { 1352 err = autorest.Respond( 1353 resp, 1354 azure.WithErrorUnlessStatusCode(http.StatusOK), 1355 autorest.ByUnmarshallingJSON(&result.Value), 1356 autorest.ByClosing()) 1357 result.Response = autorest.Response{Response: resp} 1358 return 1359} 1360 1361// UpdateTags updates a virtual network gateway tags. 1362// Parameters: 1363// resourceGroupName - the name of the resource group. 1364// virtualNetworkGatewayName - the name of the virtual network gateway. 1365// parameters - parameters supplied to update virtual network gateway tags. 1366func (client VirtualNetworkGatewaysClient) UpdateTags(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters TagsObject) (result VirtualNetworkGatewaysUpdateTagsFuture, err error) { 1367 if tracing.IsEnabled() { 1368 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.UpdateTags") 1369 defer func() { 1370 sc := -1 1371 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 1372 sc = result.FutureAPI.Response().StatusCode 1373 } 1374 tracing.EndSpan(ctx, sc, err) 1375 }() 1376 } 1377 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, virtualNetworkGatewayName, parameters) 1378 if err != nil { 1379 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "UpdateTags", nil, "Failure preparing request") 1380 return 1381 } 1382 1383 result, err = client.UpdateTagsSender(req) 1384 if err != nil { 1385 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "UpdateTags", nil, "Failure sending request") 1386 return 1387 } 1388 1389 return 1390} 1391 1392// UpdateTagsPreparer prepares the UpdateTags request. 1393func (client VirtualNetworkGatewaysClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string, parameters TagsObject) (*http.Request, error) { 1394 pathParameters := map[string]interface{}{ 1395 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1396 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1397 "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), 1398 } 1399 1400 const APIVersion = "2017-11-01" 1401 queryParameters := map[string]interface{}{ 1402 "api-version": APIVersion, 1403 } 1404 1405 preparer := autorest.CreatePreparer( 1406 autorest.AsContentType("application/json; charset=utf-8"), 1407 autorest.AsPatch(), 1408 autorest.WithBaseURL(client.BaseURI), 1409 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), 1410 autorest.WithJSON(parameters), 1411 autorest.WithQueryParameters(queryParameters)) 1412 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1413} 1414 1415// UpdateTagsSender sends the UpdateTags request. The method will close the 1416// http.Response Body if it receives an error. 1417func (client VirtualNetworkGatewaysClient) UpdateTagsSender(req *http.Request) (future VirtualNetworkGatewaysUpdateTagsFuture, err error) { 1418 var resp *http.Response 1419 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1420 if err != nil { 1421 return 1422 } 1423 var azf azure.Future 1424 azf, err = azure.NewFutureFromResponse(resp) 1425 future.FutureAPI = &azf 1426 future.Result = func(client VirtualNetworkGatewaysClient) (vng VirtualNetworkGateway, err error) { 1427 var done bool 1428 done, err = future.DoneWithContext(context.Background(), client) 1429 if err != nil { 1430 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysUpdateTagsFuture", "Result", future.Response(), "Polling failure") 1431 return 1432 } 1433 if !done { 1434 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysUpdateTagsFuture") 1435 return 1436 } 1437 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1438 vng.Response.Response, err = future.GetResult(sender) 1439 if vng.Response.Response == nil && err == nil { 1440 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysUpdateTagsFuture", "Result", nil, "received nil response and error") 1441 } 1442 if err == nil && vng.Response.Response.StatusCode != http.StatusNoContent { 1443 vng, err = client.UpdateTagsResponder(vng.Response.Response) 1444 if err != nil { 1445 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysUpdateTagsFuture", "Result", vng.Response.Response, "Failure responding to request") 1446 } 1447 } 1448 return 1449 } 1450 return 1451} 1452 1453// UpdateTagsResponder handles the response to the UpdateTags request. The method always 1454// closes the http.Response Body. 1455func (client VirtualNetworkGatewaysClient) UpdateTagsResponder(resp *http.Response) (result VirtualNetworkGateway, err error) { 1456 err = autorest.Respond( 1457 resp, 1458 azure.WithErrorUnlessStatusCode(http.StatusOK), 1459 autorest.ByUnmarshallingJSON(&result), 1460 autorest.ByClosing()) 1461 result.Response = autorest.Response{Response: resp} 1462 return 1463} 1464 1465// VpnDeviceConfigurationScript gets a xml format representation for vpn device configuration script. 1466// Parameters: 1467// resourceGroupName - the name of the resource group. 1468// virtualNetworkGatewayConnectionName - the name of the virtual network gateway connection for which the 1469// configuration script is generated. 1470// parameters - parameters supplied to the generate vpn device script operation. 1471func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScript(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VpnDeviceScriptParameters) (result String, err error) { 1472 if tracing.IsEnabled() { 1473 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewaysClient.VpnDeviceConfigurationScript") 1474 defer func() { 1475 sc := -1 1476 if result.Response.Response != nil { 1477 sc = result.Response.Response.StatusCode 1478 } 1479 tracing.EndSpan(ctx, sc, err) 1480 }() 1481 } 1482 req, err := client.VpnDeviceConfigurationScriptPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters) 1483 if err != nil { 1484 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "VpnDeviceConfigurationScript", nil, "Failure preparing request") 1485 return 1486 } 1487 1488 resp, err := client.VpnDeviceConfigurationScriptSender(req) 1489 if err != nil { 1490 result.Response = autorest.Response{Response: resp} 1491 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "VpnDeviceConfigurationScript", resp, "Failure sending request") 1492 return 1493 } 1494 1495 result, err = client.VpnDeviceConfigurationScriptResponder(resp) 1496 if err != nil { 1497 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "VpnDeviceConfigurationScript", resp, "Failure responding to request") 1498 return 1499 } 1500 1501 return 1502} 1503 1504// VpnDeviceConfigurationScriptPreparer prepares the VpnDeviceConfigurationScript request. 1505func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScriptPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VpnDeviceScriptParameters) (*http.Request, error) { 1506 pathParameters := map[string]interface{}{ 1507 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1508 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1509 "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), 1510 } 1511 1512 const APIVersion = "2017-11-01" 1513 queryParameters := map[string]interface{}{ 1514 "api-version": APIVersion, 1515 } 1516 1517 preparer := autorest.CreatePreparer( 1518 autorest.AsContentType("application/json; charset=utf-8"), 1519 autorest.AsPost(), 1520 autorest.WithBaseURL(client.BaseURI), 1521 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/vpndeviceconfigurationscript", pathParameters), 1522 autorest.WithJSON(parameters), 1523 autorest.WithQueryParameters(queryParameters)) 1524 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1525} 1526 1527// VpnDeviceConfigurationScriptSender sends the VpnDeviceConfigurationScript request. The method will close the 1528// http.Response Body if it receives an error. 1529func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScriptSender(req *http.Request) (*http.Response, error) { 1530 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1531} 1532 1533// VpnDeviceConfigurationScriptResponder handles the response to the VpnDeviceConfigurationScript request. The method always 1534// closes the http.Response Body. 1535func (client VirtualNetworkGatewaysClient) VpnDeviceConfigurationScriptResponder(resp *http.Response) (result String, err error) { 1536 err = autorest.Respond( 1537 resp, 1538 azure.WithErrorUnlessStatusCode(http.StatusOK), 1539 autorest.ByUnmarshallingJSON(&result.Value), 1540 autorest.ByClosing()) 1541 result.Response = autorest.Response{Response: resp} 1542 return 1543} 1544