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