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/tracing" 25 "net/http" 26) 27 28// VpnGatewaysClient is the network Client 29type VpnGatewaysClient struct { 30 BaseClient 31} 32 33// NewVpnGatewaysClient creates an instance of the VpnGatewaysClient client. 34func NewVpnGatewaysClient(subscriptionID string) VpnGatewaysClient { 35 return NewVpnGatewaysClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewVpnGatewaysClientWithBaseURI creates an instance of the VpnGatewaysClient client using a custom endpoint. Use 39// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 40func NewVpnGatewaysClientWithBaseURI(baseURI string, subscriptionID string) VpnGatewaysClient { 41 return VpnGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// CreateOrUpdate creates a virtual wan vpn gateway if it doesn't exist else updates the existing gateway. 45// Parameters: 46// resourceGroupName - the resource group name of the VpnGateway. 47// gatewayName - the name of the gateway. 48// vpnGatewayParameters - parameters supplied to create or Update a virtual wan vpn gateway. 49func (client VpnGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, vpnGatewayParameters VpnGateway) (result VpnGatewaysCreateOrUpdateFuture, err error) { 50 if tracing.IsEnabled() { 51 ctx = tracing.StartSpan(ctx, fqdn+"/VpnGatewaysClient.CreateOrUpdate") 52 defer func() { 53 sc := -1 54 if result.Response() != nil { 55 sc = result.Response().StatusCode 56 } 57 tracing.EndSpan(ctx, sc, err) 58 }() 59 } 60 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, gatewayName, vpnGatewayParameters) 61 if err != nil { 62 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") 63 return 64 } 65 66 result, err = client.CreateOrUpdateSender(req) 67 if err != nil { 68 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "CreateOrUpdate", result.Response(), "Failure sending request") 69 return 70 } 71 72 return 73} 74 75// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 76func (client VpnGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, gatewayName string, vpnGatewayParameters VpnGateway) (*http.Request, error) { 77 pathParameters := map[string]interface{}{ 78 "gatewayName": autorest.Encode("path", gatewayName), 79 "resourceGroupName": autorest.Encode("path", resourceGroupName), 80 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 81 } 82 83 const APIVersion = "2019-11-01" 84 queryParameters := map[string]interface{}{ 85 "api-version": APIVersion, 86 } 87 88 vpnGatewayParameters.Etag = nil 89 preparer := autorest.CreatePreparer( 90 autorest.AsContentType("application/json; charset=utf-8"), 91 autorest.AsPut(), 92 autorest.WithBaseURL(client.BaseURI), 93 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}", pathParameters), 94 autorest.WithJSON(vpnGatewayParameters), 95 autorest.WithQueryParameters(queryParameters)) 96 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 97} 98 99// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 100// http.Response Body if it receives an error. 101func (client VpnGatewaysClient) CreateOrUpdateSender(req *http.Request) (future VpnGatewaysCreateOrUpdateFuture, err error) { 102 var resp *http.Response 103 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 104 if err != nil { 105 return 106 } 107 future.Future, err = azure.NewFutureFromResponse(resp) 108 return 109} 110 111// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 112// closes the http.Response Body. 113func (client VpnGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result VpnGateway, err error) { 114 err = autorest.Respond( 115 resp, 116 client.ByInspecting(), 117 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 118 autorest.ByUnmarshallingJSON(&result), 119 autorest.ByClosing()) 120 result.Response = autorest.Response{Response: resp} 121 return 122} 123 124// Delete deletes a virtual wan vpn gateway. 125// Parameters: 126// resourceGroupName - the resource group name of the VpnGateway. 127// gatewayName - the name of the gateway. 128func (client VpnGatewaysClient) Delete(ctx context.Context, resourceGroupName string, gatewayName string) (result VpnGatewaysDeleteFuture, err error) { 129 if tracing.IsEnabled() { 130 ctx = tracing.StartSpan(ctx, fqdn+"/VpnGatewaysClient.Delete") 131 defer func() { 132 sc := -1 133 if result.Response() != nil { 134 sc = result.Response().StatusCode 135 } 136 tracing.EndSpan(ctx, sc, err) 137 }() 138 } 139 req, err := client.DeletePreparer(ctx, resourceGroupName, gatewayName) 140 if err != nil { 141 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "Delete", nil, "Failure preparing request") 142 return 143 } 144 145 result, err = client.DeleteSender(req) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "Delete", result.Response(), "Failure sending request") 148 return 149 } 150 151 return 152} 153 154// DeletePreparer prepares the Delete request. 155func (client VpnGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) { 156 pathParameters := map[string]interface{}{ 157 "gatewayName": autorest.Encode("path", gatewayName), 158 "resourceGroupName": autorest.Encode("path", resourceGroupName), 159 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 160 } 161 162 const APIVersion = "2019-11-01" 163 queryParameters := map[string]interface{}{ 164 "api-version": APIVersion, 165 } 166 167 preparer := autorest.CreatePreparer( 168 autorest.AsDelete(), 169 autorest.WithBaseURL(client.BaseURI), 170 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}", pathParameters), 171 autorest.WithQueryParameters(queryParameters)) 172 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 173} 174 175// DeleteSender sends the Delete request. The method will close the 176// http.Response Body if it receives an error. 177func (client VpnGatewaysClient) DeleteSender(req *http.Request) (future VpnGatewaysDeleteFuture, err error) { 178 var resp *http.Response 179 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 180 if err != nil { 181 return 182 } 183 future.Future, err = azure.NewFutureFromResponse(resp) 184 return 185} 186 187// DeleteResponder handles the response to the Delete request. The method always 188// closes the http.Response Body. 189func (client VpnGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 190 err = autorest.Respond( 191 resp, 192 client.ByInspecting(), 193 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 194 autorest.ByClosing()) 195 result.Response = resp 196 return 197} 198 199// Get retrieves the details of a virtual wan vpn gateway. 200// Parameters: 201// resourceGroupName - the resource group name of the VpnGateway. 202// gatewayName - the name of the gateway. 203func (client VpnGatewaysClient) Get(ctx context.Context, resourceGroupName string, gatewayName string) (result VpnGateway, err error) { 204 if tracing.IsEnabled() { 205 ctx = tracing.StartSpan(ctx, fqdn+"/VpnGatewaysClient.Get") 206 defer func() { 207 sc := -1 208 if result.Response.Response != nil { 209 sc = result.Response.Response.StatusCode 210 } 211 tracing.EndSpan(ctx, sc, err) 212 }() 213 } 214 req, err := client.GetPreparer(ctx, resourceGroupName, gatewayName) 215 if err != nil { 216 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "Get", nil, "Failure preparing request") 217 return 218 } 219 220 resp, err := client.GetSender(req) 221 if err != nil { 222 result.Response = autorest.Response{Response: resp} 223 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "Get", resp, "Failure sending request") 224 return 225 } 226 227 result, err = client.GetResponder(resp) 228 if err != nil { 229 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "Get", resp, "Failure responding to request") 230 } 231 232 return 233} 234 235// GetPreparer prepares the Get request. 236func (client VpnGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) { 237 pathParameters := map[string]interface{}{ 238 "gatewayName": autorest.Encode("path", gatewayName), 239 "resourceGroupName": autorest.Encode("path", resourceGroupName), 240 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 241 } 242 243 const APIVersion = "2019-11-01" 244 queryParameters := map[string]interface{}{ 245 "api-version": APIVersion, 246 } 247 248 preparer := autorest.CreatePreparer( 249 autorest.AsGet(), 250 autorest.WithBaseURL(client.BaseURI), 251 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}", pathParameters), 252 autorest.WithQueryParameters(queryParameters)) 253 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 254} 255 256// GetSender sends the Get request. The method will close the 257// http.Response Body if it receives an error. 258func (client VpnGatewaysClient) GetSender(req *http.Request) (*http.Response, error) { 259 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 260} 261 262// GetResponder handles the response to the Get request. The method always 263// closes the http.Response Body. 264func (client VpnGatewaysClient) GetResponder(resp *http.Response) (result VpnGateway, err error) { 265 err = autorest.Respond( 266 resp, 267 client.ByInspecting(), 268 azure.WithErrorUnlessStatusCode(http.StatusOK), 269 autorest.ByUnmarshallingJSON(&result), 270 autorest.ByClosing()) 271 result.Response = autorest.Response{Response: resp} 272 return 273} 274 275// List lists all the VpnGateways in a subscription. 276func (client VpnGatewaysClient) List(ctx context.Context) (result ListVpnGatewaysResultPage, err error) { 277 if tracing.IsEnabled() { 278 ctx = tracing.StartSpan(ctx, fqdn+"/VpnGatewaysClient.List") 279 defer func() { 280 sc := -1 281 if result.lvgr.Response.Response != nil { 282 sc = result.lvgr.Response.Response.StatusCode 283 } 284 tracing.EndSpan(ctx, sc, err) 285 }() 286 } 287 result.fn = client.listNextResults 288 req, err := client.ListPreparer(ctx) 289 if err != nil { 290 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "List", nil, "Failure preparing request") 291 return 292 } 293 294 resp, err := client.ListSender(req) 295 if err != nil { 296 result.lvgr.Response = autorest.Response{Response: resp} 297 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "List", resp, "Failure sending request") 298 return 299 } 300 301 result.lvgr, err = client.ListResponder(resp) 302 if err != nil { 303 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "List", resp, "Failure responding to request") 304 } 305 306 return 307} 308 309// ListPreparer prepares the List request. 310func (client VpnGatewaysClient) ListPreparer(ctx context.Context) (*http.Request, error) { 311 pathParameters := map[string]interface{}{ 312 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 313 } 314 315 const APIVersion = "2019-11-01" 316 queryParameters := map[string]interface{}{ 317 "api-version": APIVersion, 318 } 319 320 preparer := autorest.CreatePreparer( 321 autorest.AsGet(), 322 autorest.WithBaseURL(client.BaseURI), 323 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/vpnGateways", pathParameters), 324 autorest.WithQueryParameters(queryParameters)) 325 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 326} 327 328// ListSender sends the List request. The method will close the 329// http.Response Body if it receives an error. 330func (client VpnGatewaysClient) ListSender(req *http.Request) (*http.Response, error) { 331 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 332} 333 334// ListResponder handles the response to the List request. The method always 335// closes the http.Response Body. 336func (client VpnGatewaysClient) ListResponder(resp *http.Response) (result ListVpnGatewaysResult, err error) { 337 err = autorest.Respond( 338 resp, 339 client.ByInspecting(), 340 azure.WithErrorUnlessStatusCode(http.StatusOK), 341 autorest.ByUnmarshallingJSON(&result), 342 autorest.ByClosing()) 343 result.Response = autorest.Response{Response: resp} 344 return 345} 346 347// listNextResults retrieves the next set of results, if any. 348func (client VpnGatewaysClient) listNextResults(ctx context.Context, lastResults ListVpnGatewaysResult) (result ListVpnGatewaysResult, err error) { 349 req, err := lastResults.listVpnGatewaysResultPreparer(ctx) 350 if err != nil { 351 return result, autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "listNextResults", nil, "Failure preparing next results request") 352 } 353 if req == nil { 354 return 355 } 356 resp, err := client.ListSender(req) 357 if err != nil { 358 result.Response = autorest.Response{Response: resp} 359 return result, autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "listNextResults", resp, "Failure sending next results request") 360 } 361 result, err = client.ListResponder(resp) 362 if err != nil { 363 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "listNextResults", resp, "Failure responding to next results request") 364 } 365 return 366} 367 368// ListComplete enumerates all values, automatically crossing page boundaries as required. 369func (client VpnGatewaysClient) ListComplete(ctx context.Context) (result ListVpnGatewaysResultIterator, err error) { 370 if tracing.IsEnabled() { 371 ctx = tracing.StartSpan(ctx, fqdn+"/VpnGatewaysClient.List") 372 defer func() { 373 sc := -1 374 if result.Response().Response.Response != nil { 375 sc = result.page.Response().Response.Response.StatusCode 376 } 377 tracing.EndSpan(ctx, sc, err) 378 }() 379 } 380 result.page, err = client.List(ctx) 381 return 382} 383 384// ListByResourceGroup lists all the VpnGateways in a resource group. 385// Parameters: 386// resourceGroupName - the resource group name of the VpnGateway. 387func (client VpnGatewaysClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListVpnGatewaysResultPage, err error) { 388 if tracing.IsEnabled() { 389 ctx = tracing.StartSpan(ctx, fqdn+"/VpnGatewaysClient.ListByResourceGroup") 390 defer func() { 391 sc := -1 392 if result.lvgr.Response.Response != nil { 393 sc = result.lvgr.Response.Response.StatusCode 394 } 395 tracing.EndSpan(ctx, sc, err) 396 }() 397 } 398 result.fn = client.listByResourceGroupNextResults 399 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 400 if err != nil { 401 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "ListByResourceGroup", nil, "Failure preparing request") 402 return 403 } 404 405 resp, err := client.ListByResourceGroupSender(req) 406 if err != nil { 407 result.lvgr.Response = autorest.Response{Response: resp} 408 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "ListByResourceGroup", resp, "Failure sending request") 409 return 410 } 411 412 result.lvgr, err = client.ListByResourceGroupResponder(resp) 413 if err != nil { 414 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "ListByResourceGroup", resp, "Failure responding to request") 415 } 416 417 return 418} 419 420// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 421func (client VpnGatewaysClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 422 pathParameters := map[string]interface{}{ 423 "resourceGroupName": autorest.Encode("path", resourceGroupName), 424 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 425 } 426 427 const APIVersion = "2019-11-01" 428 queryParameters := map[string]interface{}{ 429 "api-version": APIVersion, 430 } 431 432 preparer := autorest.CreatePreparer( 433 autorest.AsGet(), 434 autorest.WithBaseURL(client.BaseURI), 435 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways", pathParameters), 436 autorest.WithQueryParameters(queryParameters)) 437 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 438} 439 440// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 441// http.Response Body if it receives an error. 442func (client VpnGatewaysClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 443 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 444} 445 446// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 447// closes the http.Response Body. 448func (client VpnGatewaysClient) ListByResourceGroupResponder(resp *http.Response) (result ListVpnGatewaysResult, err error) { 449 err = autorest.Respond( 450 resp, 451 client.ByInspecting(), 452 azure.WithErrorUnlessStatusCode(http.StatusOK), 453 autorest.ByUnmarshallingJSON(&result), 454 autorest.ByClosing()) 455 result.Response = autorest.Response{Response: resp} 456 return 457} 458 459// listByResourceGroupNextResults retrieves the next set of results, if any. 460func (client VpnGatewaysClient) listByResourceGroupNextResults(ctx context.Context, lastResults ListVpnGatewaysResult) (result ListVpnGatewaysResult, err error) { 461 req, err := lastResults.listVpnGatewaysResultPreparer(ctx) 462 if err != nil { 463 return result, autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 464 } 465 if req == nil { 466 return 467 } 468 resp, err := client.ListByResourceGroupSender(req) 469 if err != nil { 470 result.Response = autorest.Response{Response: resp} 471 return result, autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 472 } 473 result, err = client.ListByResourceGroupResponder(resp) 474 if err != nil { 475 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 476 } 477 return 478} 479 480// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 481func (client VpnGatewaysClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ListVpnGatewaysResultIterator, err error) { 482 if tracing.IsEnabled() { 483 ctx = tracing.StartSpan(ctx, fqdn+"/VpnGatewaysClient.ListByResourceGroup") 484 defer func() { 485 sc := -1 486 if result.Response().Response.Response != nil { 487 sc = result.page.Response().Response.Response.StatusCode 488 } 489 tracing.EndSpan(ctx, sc, err) 490 }() 491 } 492 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) 493 return 494} 495 496// Reset resets the primary of the vpn gateway in the specified resource group. 497// Parameters: 498// resourceGroupName - the resource group name of the VpnGateway. 499// gatewayName - the name of the gateway. 500func (client VpnGatewaysClient) Reset(ctx context.Context, resourceGroupName string, gatewayName string) (result VpnGatewaysResetFuture, err error) { 501 if tracing.IsEnabled() { 502 ctx = tracing.StartSpan(ctx, fqdn+"/VpnGatewaysClient.Reset") 503 defer func() { 504 sc := -1 505 if result.Response() != nil { 506 sc = result.Response().StatusCode 507 } 508 tracing.EndSpan(ctx, sc, err) 509 }() 510 } 511 req, err := client.ResetPreparer(ctx, resourceGroupName, gatewayName) 512 if err != nil { 513 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "Reset", nil, "Failure preparing request") 514 return 515 } 516 517 result, err = client.ResetSender(req) 518 if err != nil { 519 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "Reset", result.Response(), "Failure sending request") 520 return 521 } 522 523 return 524} 525 526// ResetPreparer prepares the Reset request. 527func (client VpnGatewaysClient) ResetPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) { 528 pathParameters := map[string]interface{}{ 529 "gatewayName": autorest.Encode("path", gatewayName), 530 "resourceGroupName": autorest.Encode("path", resourceGroupName), 531 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 532 } 533 534 const APIVersion = "2019-11-01" 535 queryParameters := map[string]interface{}{ 536 "api-version": APIVersion, 537 } 538 539 preparer := autorest.CreatePreparer( 540 autorest.AsPost(), 541 autorest.WithBaseURL(client.BaseURI), 542 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/reset", pathParameters), 543 autorest.WithQueryParameters(queryParameters)) 544 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 545} 546 547// ResetSender sends the Reset request. The method will close the 548// http.Response Body if it receives an error. 549func (client VpnGatewaysClient) ResetSender(req *http.Request) (future VpnGatewaysResetFuture, err error) { 550 var resp *http.Response 551 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 552 if err != nil { 553 return 554 } 555 future.Future, err = azure.NewFutureFromResponse(resp) 556 return 557} 558 559// ResetResponder handles the response to the Reset request. The method always 560// closes the http.Response Body. 561func (client VpnGatewaysClient) ResetResponder(resp *http.Response) (result VpnGateway, err error) { 562 err = autorest.Respond( 563 resp, 564 client.ByInspecting(), 565 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 566 autorest.ByUnmarshallingJSON(&result), 567 autorest.ByClosing()) 568 result.Response = autorest.Response{Response: resp} 569 return 570} 571 572// UpdateTags updates virtual wan vpn gateway tags. 573// Parameters: 574// resourceGroupName - the resource group name of the VpnGateway. 575// gatewayName - the name of the gateway. 576// vpnGatewayParameters - parameters supplied to update a virtual wan vpn gateway tags. 577func (client VpnGatewaysClient) UpdateTags(ctx context.Context, resourceGroupName string, gatewayName string, vpnGatewayParameters TagsObject) (result VpnGateway, err error) { 578 if tracing.IsEnabled() { 579 ctx = tracing.StartSpan(ctx, fqdn+"/VpnGatewaysClient.UpdateTags") 580 defer func() { 581 sc := -1 582 if result.Response.Response != nil { 583 sc = result.Response.Response.StatusCode 584 } 585 tracing.EndSpan(ctx, sc, err) 586 }() 587 } 588 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, gatewayName, vpnGatewayParameters) 589 if err != nil { 590 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "UpdateTags", nil, "Failure preparing request") 591 return 592 } 593 594 resp, err := client.UpdateTagsSender(req) 595 if err != nil { 596 result.Response = autorest.Response{Response: resp} 597 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "UpdateTags", resp, "Failure sending request") 598 return 599 } 600 601 result, err = client.UpdateTagsResponder(resp) 602 if err != nil { 603 err = autorest.NewErrorWithError(err, "network.VpnGatewaysClient", "UpdateTags", resp, "Failure responding to request") 604 } 605 606 return 607} 608 609// UpdateTagsPreparer prepares the UpdateTags request. 610func (client VpnGatewaysClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, gatewayName string, vpnGatewayParameters TagsObject) (*http.Request, error) { 611 pathParameters := map[string]interface{}{ 612 "gatewayName": autorest.Encode("path", gatewayName), 613 "resourceGroupName": autorest.Encode("path", resourceGroupName), 614 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 615 } 616 617 const APIVersion = "2019-11-01" 618 queryParameters := map[string]interface{}{ 619 "api-version": APIVersion, 620 } 621 622 preparer := autorest.CreatePreparer( 623 autorest.AsContentType("application/json; charset=utf-8"), 624 autorest.AsPatch(), 625 autorest.WithBaseURL(client.BaseURI), 626 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}", pathParameters), 627 autorest.WithJSON(vpnGatewayParameters), 628 autorest.WithQueryParameters(queryParameters)) 629 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 630} 631 632// UpdateTagsSender sends the UpdateTags request. The method will close the 633// http.Response Body if it receives an error. 634func (client VpnGatewaysClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { 635 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 636} 637 638// UpdateTagsResponder handles the response to the UpdateTags request. The method always 639// closes the http.Response Body. 640func (client VpnGatewaysClient) UpdateTagsResponder(resp *http.Response) (result VpnGateway, err error) { 641 err = autorest.Respond( 642 resp, 643 client.ByInspecting(), 644 azure.WithErrorUnlessStatusCode(http.StatusOK), 645 autorest.ByUnmarshallingJSON(&result), 646 autorest.ByClosing()) 647 result.Response = autorest.Response{Response: resp} 648 return 649} 650