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