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