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// P2sVpnGatewaysClient is the network Client 29type P2sVpnGatewaysClient struct { 30 BaseClient 31} 32 33// NewP2sVpnGatewaysClient creates an instance of the P2sVpnGatewaysClient client. 34func NewP2sVpnGatewaysClient(subscriptionID string) P2sVpnGatewaysClient { 35 return NewP2sVpnGatewaysClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewP2sVpnGatewaysClientWithBaseURI creates an instance of the P2sVpnGatewaysClient client using a custom endpoint. 39// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 40func NewP2sVpnGatewaysClientWithBaseURI(baseURI string, subscriptionID string) P2sVpnGatewaysClient { 41 return P2sVpnGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// CreateOrUpdate creates a virtual wan p2s vpn gateway if it doesn't exist else updates the existing gateway. 45// Parameters: 46// resourceGroupName - the resource group name of the P2SVpnGateway. 47// gatewayName - the name of the gateway. 48// p2SVpnGatewayParameters - parameters supplied to create or Update a virtual wan p2s vpn gateway. 49func (client P2sVpnGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters P2SVpnGateway) (result P2sVpnGatewaysCreateOrUpdateFuture, err error) { 50 if tracing.IsEnabled() { 51 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.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, p2SVpnGatewayParameters) 61 if err != nil { 62 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "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.P2sVpnGatewaysClient", "CreateOrUpdate", nil, "Failure sending request") 69 return 70 } 71 72 return 73} 74 75// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 76func (client P2sVpnGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters P2SVpnGateway) (*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 = "2020-07-01" 84 queryParameters := map[string]interface{}{ 85 "api-version": APIVersion, 86 } 87 88 p2SVpnGatewayParameters.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/p2svpnGateways/{gatewayName}", pathParameters), 94 autorest.WithJSON(p2SVpnGatewayParameters), 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 P2sVpnGatewaysClient) CreateOrUpdateSender(req *http.Request) (future P2sVpnGatewaysCreateOrUpdateFuture, 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 var azf azure.Future 108 azf, err = azure.NewFutureFromResponse(resp) 109 future.FutureAPI = &azf 110 future.Result = func(client P2sVpnGatewaysClient) (pvg P2SVpnGateway, err error) { 111 var done bool 112 done, err = future.DoneWithContext(context.Background(), client) 113 if err != nil { 114 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") 115 return 116 } 117 if !done { 118 err = azure.NewAsyncOpIncompleteError("network.P2sVpnGatewaysCreateOrUpdateFuture") 119 return 120 } 121 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 122 if pvg.Response.Response, err = future.GetResult(sender); err == nil && pvg.Response.Response.StatusCode != http.StatusNoContent { 123 pvg, err = client.CreateOrUpdateResponder(pvg.Response.Response) 124 if err != nil { 125 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysCreateOrUpdateFuture", "Result", pvg.Response.Response, "Failure responding to request") 126 } 127 } 128 return 129 } 130 return 131} 132 133// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 134// closes the http.Response Body. 135func (client P2sVpnGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result P2SVpnGateway, err error) { 136 err = autorest.Respond( 137 resp, 138 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 139 autorest.ByUnmarshallingJSON(&result), 140 autorest.ByClosing()) 141 result.Response = autorest.Response{Response: resp} 142 return 143} 144 145// Delete deletes a virtual wan p2s vpn gateway. 146// Parameters: 147// resourceGroupName - the resource group name of the P2SVpnGateway. 148// gatewayName - the name of the gateway. 149func (client P2sVpnGatewaysClient) Delete(ctx context.Context, resourceGroupName string, gatewayName string) (result P2sVpnGatewaysDeleteFuture, err error) { 150 if tracing.IsEnabled() { 151 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.Delete") 152 defer func() { 153 sc := -1 154 if result.Response() != nil { 155 sc = result.Response().StatusCode 156 } 157 tracing.EndSpan(ctx, sc, err) 158 }() 159 } 160 req, err := client.DeletePreparer(ctx, resourceGroupName, gatewayName) 161 if err != nil { 162 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Delete", nil, "Failure preparing request") 163 return 164 } 165 166 result, err = client.DeleteSender(req) 167 if err != nil { 168 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Delete", nil, "Failure sending request") 169 return 170 } 171 172 return 173} 174 175// DeletePreparer prepares the Delete request. 176func (client P2sVpnGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) { 177 pathParameters := map[string]interface{}{ 178 "gatewayName": autorest.Encode("path", gatewayName), 179 "resourceGroupName": autorest.Encode("path", resourceGroupName), 180 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 181 } 182 183 const APIVersion = "2020-07-01" 184 queryParameters := map[string]interface{}{ 185 "api-version": APIVersion, 186 } 187 188 preparer := autorest.CreatePreparer( 189 autorest.AsDelete(), 190 autorest.WithBaseURL(client.BaseURI), 191 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}", pathParameters), 192 autorest.WithQueryParameters(queryParameters)) 193 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 194} 195 196// DeleteSender sends the Delete request. The method will close the 197// http.Response Body if it receives an error. 198func (client P2sVpnGatewaysClient) DeleteSender(req *http.Request) (future P2sVpnGatewaysDeleteFuture, err error) { 199 var resp *http.Response 200 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 201 if err != nil { 202 return 203 } 204 var azf azure.Future 205 azf, err = azure.NewFutureFromResponse(resp) 206 future.FutureAPI = &azf 207 future.Result = func(client P2sVpnGatewaysClient) (ar autorest.Response, err error) { 208 var done bool 209 done, err = future.DoneWithContext(context.Background(), client) 210 if err != nil { 211 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysDeleteFuture", "Result", future.Response(), "Polling failure") 212 return 213 } 214 if !done { 215 err = azure.NewAsyncOpIncompleteError("network.P2sVpnGatewaysDeleteFuture") 216 return 217 } 218 ar.Response = future.Response() 219 return 220 } 221 return 222} 223 224// DeleteResponder handles the response to the Delete request. The method always 225// closes the http.Response Body. 226func (client P2sVpnGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 227 err = autorest.Respond( 228 resp, 229 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 230 autorest.ByClosing()) 231 result.Response = resp 232 return 233} 234 235// DisconnectP2sVpnConnections disconnect P2S vpn connections of the virtual wan P2SVpnGateway in the specified 236// resource group. 237// Parameters: 238// resourceGroupName - the name of the resource group. 239// p2sVpnGatewayName - the name of the P2S Vpn Gateway. 240// request - the parameters are supplied to disconnect p2s vpn connections. 241func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnections(ctx context.Context, resourceGroupName string, p2sVpnGatewayName string, request P2SVpnConnectionRequest) (result P2sVpnGatewaysDisconnectP2sVpnConnectionsFuture, err error) { 242 if tracing.IsEnabled() { 243 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.DisconnectP2sVpnConnections") 244 defer func() { 245 sc := -1 246 if result.Response() != nil { 247 sc = result.Response().StatusCode 248 } 249 tracing.EndSpan(ctx, sc, err) 250 }() 251 } 252 req, err := client.DisconnectP2sVpnConnectionsPreparer(ctx, resourceGroupName, p2sVpnGatewayName, request) 253 if err != nil { 254 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "DisconnectP2sVpnConnections", nil, "Failure preparing request") 255 return 256 } 257 258 result, err = client.DisconnectP2sVpnConnectionsSender(req) 259 if err != nil { 260 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "DisconnectP2sVpnConnections", nil, "Failure sending request") 261 return 262 } 263 264 return 265} 266 267// DisconnectP2sVpnConnectionsPreparer prepares the DisconnectP2sVpnConnections request. 268func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsPreparer(ctx context.Context, resourceGroupName string, p2sVpnGatewayName string, request P2SVpnConnectionRequest) (*http.Request, error) { 269 pathParameters := map[string]interface{}{ 270 "p2sVpnGatewayName": autorest.Encode("path", p2sVpnGatewayName), 271 "resourceGroupName": autorest.Encode("path", resourceGroupName), 272 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 273 } 274 275 const APIVersion = "2020-07-01" 276 queryParameters := map[string]interface{}{ 277 "api-version": APIVersion, 278 } 279 280 preparer := autorest.CreatePreparer( 281 autorest.AsContentType("application/json; charset=utf-8"), 282 autorest.AsPost(), 283 autorest.WithBaseURL(client.BaseURI), 284 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{p2sVpnGatewayName}/disconnectP2sVpnConnections", pathParameters), 285 autorest.WithJSON(request), 286 autorest.WithQueryParameters(queryParameters)) 287 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 288} 289 290// DisconnectP2sVpnConnectionsSender sends the DisconnectP2sVpnConnections request. The method will close the 291// http.Response Body if it receives an error. 292func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsSender(req *http.Request) (future P2sVpnGatewaysDisconnectP2sVpnConnectionsFuture, err error) { 293 var resp *http.Response 294 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 295 if err != nil { 296 return 297 } 298 var azf azure.Future 299 azf, err = azure.NewFutureFromResponse(resp) 300 future.FutureAPI = &azf 301 future.Result = func(client P2sVpnGatewaysClient) (ar autorest.Response, err error) { 302 var done bool 303 done, err = future.DoneWithContext(context.Background(), client) 304 if err != nil { 305 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysDisconnectP2sVpnConnectionsFuture", "Result", future.Response(), "Polling failure") 306 return 307 } 308 if !done { 309 err = azure.NewAsyncOpIncompleteError("network.P2sVpnGatewaysDisconnectP2sVpnConnectionsFuture") 310 return 311 } 312 ar.Response = future.Response() 313 return 314 } 315 return 316} 317 318// DisconnectP2sVpnConnectionsResponder handles the response to the DisconnectP2sVpnConnections request. The method always 319// closes the http.Response Body. 320func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsResponder(resp *http.Response) (result autorest.Response, err error) { 321 err = autorest.Respond( 322 resp, 323 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 324 autorest.ByClosing()) 325 result.Response = resp 326 return 327} 328 329// GenerateVpnProfile generates VPN profile for P2S client of the P2SVpnGateway in the specified resource group. 330// Parameters: 331// resourceGroupName - the name of the resource group. 332// gatewayName - the name of the P2SVpnGateway. 333// parameters - parameters supplied to the generate P2SVpnGateway VPN client package operation. 334func (client P2sVpnGatewaysClient) GenerateVpnProfile(ctx context.Context, resourceGroupName string, gatewayName string, parameters P2SVpnProfileParameters) (result P2sVpnGatewaysGenerateVpnProfileFuture, err error) { 335 if tracing.IsEnabled() { 336 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.GenerateVpnProfile") 337 defer func() { 338 sc := -1 339 if result.Response() != nil { 340 sc = result.Response().StatusCode 341 } 342 tracing.EndSpan(ctx, sc, err) 343 }() 344 } 345 req, err := client.GenerateVpnProfilePreparer(ctx, resourceGroupName, gatewayName, parameters) 346 if err != nil { 347 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GenerateVpnProfile", nil, "Failure preparing request") 348 return 349 } 350 351 result, err = client.GenerateVpnProfileSender(req) 352 if err != nil { 353 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GenerateVpnProfile", nil, "Failure sending request") 354 return 355 } 356 357 return 358} 359 360// GenerateVpnProfilePreparer prepares the GenerateVpnProfile request. 361func (client P2sVpnGatewaysClient) GenerateVpnProfilePreparer(ctx context.Context, resourceGroupName string, gatewayName string, parameters P2SVpnProfileParameters) (*http.Request, error) { 362 pathParameters := map[string]interface{}{ 363 "gatewayName": autorest.Encode("path", gatewayName), 364 "resourceGroupName": autorest.Encode("path", resourceGroupName), 365 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 366 } 367 368 const APIVersion = "2020-07-01" 369 queryParameters := map[string]interface{}{ 370 "api-version": APIVersion, 371 } 372 373 preparer := autorest.CreatePreparer( 374 autorest.AsContentType("application/json; charset=utf-8"), 375 autorest.AsPost(), 376 autorest.WithBaseURL(client.BaseURI), 377 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/generatevpnprofile", pathParameters), 378 autorest.WithJSON(parameters), 379 autorest.WithQueryParameters(queryParameters)) 380 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 381} 382 383// GenerateVpnProfileSender sends the GenerateVpnProfile request. The method will close the 384// http.Response Body if it receives an error. 385func (client P2sVpnGatewaysClient) GenerateVpnProfileSender(req *http.Request) (future P2sVpnGatewaysGenerateVpnProfileFuture, err error) { 386 var resp *http.Response 387 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 388 if err != nil { 389 return 390 } 391 var azf azure.Future 392 azf, err = azure.NewFutureFromResponse(resp) 393 future.FutureAPI = &azf 394 future.Result = func(client P2sVpnGatewaysClient) (vpr VpnProfileResponse, err error) { 395 var done bool 396 done, err = future.DoneWithContext(context.Background(), client) 397 if err != nil { 398 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysGenerateVpnProfileFuture", "Result", future.Response(), "Polling failure") 399 return 400 } 401 if !done { 402 err = azure.NewAsyncOpIncompleteError("network.P2sVpnGatewaysGenerateVpnProfileFuture") 403 return 404 } 405 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 406 if vpr.Response.Response, err = future.GetResult(sender); err == nil && vpr.Response.Response.StatusCode != http.StatusNoContent { 407 vpr, err = client.GenerateVpnProfileResponder(vpr.Response.Response) 408 if err != nil { 409 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysGenerateVpnProfileFuture", "Result", vpr.Response.Response, "Failure responding to request") 410 } 411 } 412 return 413 } 414 return 415} 416 417// GenerateVpnProfileResponder handles the response to the GenerateVpnProfile request. The method always 418// closes the http.Response Body. 419func (client P2sVpnGatewaysClient) GenerateVpnProfileResponder(resp *http.Response) (result VpnProfileResponse, err error) { 420 err = autorest.Respond( 421 resp, 422 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 423 autorest.ByUnmarshallingJSON(&result), 424 autorest.ByClosing()) 425 result.Response = autorest.Response{Response: resp} 426 return 427} 428 429// Get retrieves the details of a virtual wan p2s vpn gateway. 430// Parameters: 431// resourceGroupName - the resource group name of the P2SVpnGateway. 432// gatewayName - the name of the gateway. 433func (client P2sVpnGatewaysClient) Get(ctx context.Context, resourceGroupName string, gatewayName string) (result P2SVpnGateway, err error) { 434 if tracing.IsEnabled() { 435 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.Get") 436 defer func() { 437 sc := -1 438 if result.Response.Response != nil { 439 sc = result.Response.Response.StatusCode 440 } 441 tracing.EndSpan(ctx, sc, err) 442 }() 443 } 444 req, err := client.GetPreparer(ctx, resourceGroupName, gatewayName) 445 if err != nil { 446 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Get", nil, "Failure preparing request") 447 return 448 } 449 450 resp, err := client.GetSender(req) 451 if err != nil { 452 result.Response = autorest.Response{Response: resp} 453 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Get", resp, "Failure sending request") 454 return 455 } 456 457 result, err = client.GetResponder(resp) 458 if err != nil { 459 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Get", resp, "Failure responding to request") 460 return 461 } 462 463 return 464} 465 466// GetPreparer prepares the Get request. 467func (client P2sVpnGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) { 468 pathParameters := map[string]interface{}{ 469 "gatewayName": autorest.Encode("path", gatewayName), 470 "resourceGroupName": autorest.Encode("path", resourceGroupName), 471 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 472 } 473 474 const APIVersion = "2020-07-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/p2svpnGateways/{gatewayName}", pathParameters), 483 autorest.WithQueryParameters(queryParameters)) 484 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 485} 486 487// GetSender sends the Get request. The method will close the 488// http.Response Body if it receives an error. 489func (client P2sVpnGatewaysClient) GetSender(req *http.Request) (*http.Response, error) { 490 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 491} 492 493// GetResponder handles the response to the Get request. The method always 494// closes the http.Response Body. 495func (client P2sVpnGatewaysClient) GetResponder(resp *http.Response) (result P2SVpnGateway, 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// GetP2sVpnConnectionHealth gets the connection health of P2S clients of the virtual wan P2SVpnGateway in the 506// specified resource group. 507// Parameters: 508// resourceGroupName - the name of the resource group. 509// gatewayName - the name of the P2SVpnGateway. 510func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealth(ctx context.Context, resourceGroupName string, gatewayName string) (result P2sVpnGatewaysGetP2sVpnConnectionHealthFuture, err error) { 511 if tracing.IsEnabled() { 512 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.GetP2sVpnConnectionHealth") 513 defer func() { 514 sc := -1 515 if result.Response() != nil { 516 sc = result.Response().StatusCode 517 } 518 tracing.EndSpan(ctx, sc, err) 519 }() 520 } 521 req, err := client.GetP2sVpnConnectionHealthPreparer(ctx, resourceGroupName, gatewayName) 522 if err != nil { 523 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealth", nil, "Failure preparing request") 524 return 525 } 526 527 result, err = client.GetP2sVpnConnectionHealthSender(req) 528 if err != nil { 529 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealth", nil, "Failure sending request") 530 return 531 } 532 533 return 534} 535 536// GetP2sVpnConnectionHealthPreparer prepares the GetP2sVpnConnectionHealth request. 537func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) { 538 pathParameters := map[string]interface{}{ 539 "gatewayName": autorest.Encode("path", gatewayName), 540 "resourceGroupName": autorest.Encode("path", resourceGroupName), 541 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 542 } 543 544 const APIVersion = "2020-07-01" 545 queryParameters := map[string]interface{}{ 546 "api-version": APIVersion, 547 } 548 549 preparer := autorest.CreatePreparer( 550 autorest.AsPost(), 551 autorest.WithBaseURL(client.BaseURI), 552 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/getP2sVpnConnectionHealth", pathParameters), 553 autorest.WithQueryParameters(queryParameters)) 554 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 555} 556 557// GetP2sVpnConnectionHealthSender sends the GetP2sVpnConnectionHealth request. The method will close the 558// http.Response Body if it receives an error. 559func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthSender(req *http.Request) (future P2sVpnGatewaysGetP2sVpnConnectionHealthFuture, err error) { 560 var resp *http.Response 561 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 562 if err != nil { 563 return 564 } 565 var azf azure.Future 566 azf, err = azure.NewFutureFromResponse(resp) 567 future.FutureAPI = &azf 568 future.Result = func(client P2sVpnGatewaysClient) (pvg P2SVpnGateway, err error) { 569 var done bool 570 done, err = future.DoneWithContext(context.Background(), client) 571 if err != nil { 572 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysGetP2sVpnConnectionHealthFuture", "Result", future.Response(), "Polling failure") 573 return 574 } 575 if !done { 576 err = azure.NewAsyncOpIncompleteError("network.P2sVpnGatewaysGetP2sVpnConnectionHealthFuture") 577 return 578 } 579 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 580 if pvg.Response.Response, err = future.GetResult(sender); err == nil && pvg.Response.Response.StatusCode != http.StatusNoContent { 581 pvg, err = client.GetP2sVpnConnectionHealthResponder(pvg.Response.Response) 582 if err != nil { 583 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysGetP2sVpnConnectionHealthFuture", "Result", pvg.Response.Response, "Failure responding to request") 584 } 585 } 586 return 587 } 588 return 589} 590 591// GetP2sVpnConnectionHealthResponder handles the response to the GetP2sVpnConnectionHealth request. The method always 592// closes the http.Response Body. 593func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthResponder(resp *http.Response) (result P2SVpnGateway, err error) { 594 err = autorest.Respond( 595 resp, 596 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 597 autorest.ByUnmarshallingJSON(&result), 598 autorest.ByClosing()) 599 result.Response = autorest.Response{Response: resp} 600 return 601} 602 603// GetP2sVpnConnectionHealthDetailed gets the sas url to get the connection health detail of P2S clients of the virtual 604// wan P2SVpnGateway in the specified resource group. 605// Parameters: 606// resourceGroupName - the name of the resource group. 607// gatewayName - the name of the P2SVpnGateway. 608// request - request parameters supplied to get p2s vpn connections detailed health. 609func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailed(ctx context.Context, resourceGroupName string, gatewayName string, request P2SVpnConnectionHealthRequest) (result P2sVpnGatewaysGetP2sVpnConnectionHealthDetailedFuture, err error) { 610 if tracing.IsEnabled() { 611 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.GetP2sVpnConnectionHealthDetailed") 612 defer func() { 613 sc := -1 614 if result.Response() != nil { 615 sc = result.Response().StatusCode 616 } 617 tracing.EndSpan(ctx, sc, err) 618 }() 619 } 620 req, err := client.GetP2sVpnConnectionHealthDetailedPreparer(ctx, resourceGroupName, gatewayName, request) 621 if err != nil { 622 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealthDetailed", nil, "Failure preparing request") 623 return 624 } 625 626 result, err = client.GetP2sVpnConnectionHealthDetailedSender(req) 627 if err != nil { 628 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealthDetailed", nil, "Failure sending request") 629 return 630 } 631 632 return 633} 634 635// GetP2sVpnConnectionHealthDetailedPreparer prepares the GetP2sVpnConnectionHealthDetailed request. 636func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedPreparer(ctx context.Context, resourceGroupName string, gatewayName string, request P2SVpnConnectionHealthRequest) (*http.Request, error) { 637 pathParameters := map[string]interface{}{ 638 "gatewayName": autorest.Encode("path", gatewayName), 639 "resourceGroupName": autorest.Encode("path", resourceGroupName), 640 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 641 } 642 643 const APIVersion = "2020-07-01" 644 queryParameters := map[string]interface{}{ 645 "api-version": APIVersion, 646 } 647 648 preparer := autorest.CreatePreparer( 649 autorest.AsContentType("application/json; charset=utf-8"), 650 autorest.AsPost(), 651 autorest.WithBaseURL(client.BaseURI), 652 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/getP2sVpnConnectionHealthDetailed", pathParameters), 653 autorest.WithJSON(request), 654 autorest.WithQueryParameters(queryParameters)) 655 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 656} 657 658// GetP2sVpnConnectionHealthDetailedSender sends the GetP2sVpnConnectionHealthDetailed request. The method will close the 659// http.Response Body if it receives an error. 660func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedSender(req *http.Request) (future P2sVpnGatewaysGetP2sVpnConnectionHealthDetailedFuture, err error) { 661 var resp *http.Response 662 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 663 if err != nil { 664 return 665 } 666 var azf azure.Future 667 azf, err = azure.NewFutureFromResponse(resp) 668 future.FutureAPI = &azf 669 future.Result = func(client P2sVpnGatewaysClient) (pvch P2SVpnConnectionHealth, err error) { 670 var done bool 671 done, err = future.DoneWithContext(context.Background(), client) 672 if err != nil { 673 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysGetP2sVpnConnectionHealthDetailedFuture", "Result", future.Response(), "Polling failure") 674 return 675 } 676 if !done { 677 err = azure.NewAsyncOpIncompleteError("network.P2sVpnGatewaysGetP2sVpnConnectionHealthDetailedFuture") 678 return 679 } 680 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 681 if pvch.Response.Response, err = future.GetResult(sender); err == nil && pvch.Response.Response.StatusCode != http.StatusNoContent { 682 pvch, err = client.GetP2sVpnConnectionHealthDetailedResponder(pvch.Response.Response) 683 if err != nil { 684 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysGetP2sVpnConnectionHealthDetailedFuture", "Result", pvch.Response.Response, "Failure responding to request") 685 } 686 } 687 return 688 } 689 return 690} 691 692// GetP2sVpnConnectionHealthDetailedResponder handles the response to the GetP2sVpnConnectionHealthDetailed request. The method always 693// closes the http.Response Body. 694func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedResponder(resp *http.Response) (result P2SVpnConnectionHealth, err error) { 695 err = autorest.Respond( 696 resp, 697 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 698 autorest.ByUnmarshallingJSON(&result), 699 autorest.ByClosing()) 700 result.Response = autorest.Response{Response: resp} 701 return 702} 703 704// List lists all the P2SVpnGateways in a subscription. 705func (client P2sVpnGatewaysClient) List(ctx context.Context) (result ListP2SVpnGatewaysResultPage, err error) { 706 if tracing.IsEnabled() { 707 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.List") 708 defer func() { 709 sc := -1 710 if result.lpvgr.Response.Response != nil { 711 sc = result.lpvgr.Response.Response.StatusCode 712 } 713 tracing.EndSpan(ctx, sc, err) 714 }() 715 } 716 result.fn = client.listNextResults 717 req, err := client.ListPreparer(ctx) 718 if err != nil { 719 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "List", nil, "Failure preparing request") 720 return 721 } 722 723 resp, err := client.ListSender(req) 724 if err != nil { 725 result.lpvgr.Response = autorest.Response{Response: resp} 726 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "List", resp, "Failure sending request") 727 return 728 } 729 730 result.lpvgr, err = client.ListResponder(resp) 731 if err != nil { 732 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "List", resp, "Failure responding to request") 733 return 734 } 735 if result.lpvgr.hasNextLink() && result.lpvgr.IsEmpty() { 736 err = result.NextWithContext(ctx) 737 return 738 } 739 740 return 741} 742 743// ListPreparer prepares the List request. 744func (client P2sVpnGatewaysClient) ListPreparer(ctx context.Context) (*http.Request, error) { 745 pathParameters := map[string]interface{}{ 746 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 747 } 748 749 const APIVersion = "2020-07-01" 750 queryParameters := map[string]interface{}{ 751 "api-version": APIVersion, 752 } 753 754 preparer := autorest.CreatePreparer( 755 autorest.AsGet(), 756 autorest.WithBaseURL(client.BaseURI), 757 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/p2svpnGateways", pathParameters), 758 autorest.WithQueryParameters(queryParameters)) 759 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 760} 761 762// ListSender sends the List request. The method will close the 763// http.Response Body if it receives an error. 764func (client P2sVpnGatewaysClient) ListSender(req *http.Request) (*http.Response, error) { 765 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 766} 767 768// ListResponder handles the response to the List request. The method always 769// closes the http.Response Body. 770func (client P2sVpnGatewaysClient) ListResponder(resp *http.Response) (result ListP2SVpnGatewaysResult, err error) { 771 err = autorest.Respond( 772 resp, 773 azure.WithErrorUnlessStatusCode(http.StatusOK), 774 autorest.ByUnmarshallingJSON(&result), 775 autorest.ByClosing()) 776 result.Response = autorest.Response{Response: resp} 777 return 778} 779 780// listNextResults retrieves the next set of results, if any. 781func (client P2sVpnGatewaysClient) listNextResults(ctx context.Context, lastResults ListP2SVpnGatewaysResult) (result ListP2SVpnGatewaysResult, err error) { 782 req, err := lastResults.listP2SVpnGatewaysResultPreparer(ctx) 783 if err != nil { 784 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listNextResults", nil, "Failure preparing next results request") 785 } 786 if req == nil { 787 return 788 } 789 resp, err := client.ListSender(req) 790 if err != nil { 791 result.Response = autorest.Response{Response: resp} 792 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listNextResults", resp, "Failure sending next results request") 793 } 794 result, err = client.ListResponder(resp) 795 if err != nil { 796 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listNextResults", resp, "Failure responding to next results request") 797 } 798 return 799} 800 801// ListComplete enumerates all values, automatically crossing page boundaries as required. 802func (client P2sVpnGatewaysClient) ListComplete(ctx context.Context) (result ListP2SVpnGatewaysResultIterator, err error) { 803 if tracing.IsEnabled() { 804 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.List") 805 defer func() { 806 sc := -1 807 if result.Response().Response.Response != nil { 808 sc = result.page.Response().Response.Response.StatusCode 809 } 810 tracing.EndSpan(ctx, sc, err) 811 }() 812 } 813 result.page, err = client.List(ctx) 814 return 815} 816 817// ListByResourceGroup lists all the P2SVpnGateways in a resource group. 818// Parameters: 819// resourceGroupName - the resource group name of the P2SVpnGateway. 820func (client P2sVpnGatewaysClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListP2SVpnGatewaysResultPage, err error) { 821 if tracing.IsEnabled() { 822 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.ListByResourceGroup") 823 defer func() { 824 sc := -1 825 if result.lpvgr.Response.Response != nil { 826 sc = result.lpvgr.Response.Response.StatusCode 827 } 828 tracing.EndSpan(ctx, sc, err) 829 }() 830 } 831 result.fn = client.listByResourceGroupNextResults 832 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 833 if err != nil { 834 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "ListByResourceGroup", nil, "Failure preparing request") 835 return 836 } 837 838 resp, err := client.ListByResourceGroupSender(req) 839 if err != nil { 840 result.lpvgr.Response = autorest.Response{Response: resp} 841 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "ListByResourceGroup", resp, "Failure sending request") 842 return 843 } 844 845 result.lpvgr, err = client.ListByResourceGroupResponder(resp) 846 if err != nil { 847 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "ListByResourceGroup", resp, "Failure responding to request") 848 return 849 } 850 if result.lpvgr.hasNextLink() && result.lpvgr.IsEmpty() { 851 err = result.NextWithContext(ctx) 852 return 853 } 854 855 return 856} 857 858// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 859func (client P2sVpnGatewaysClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 860 pathParameters := map[string]interface{}{ 861 "resourceGroupName": autorest.Encode("path", resourceGroupName), 862 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 863 } 864 865 const APIVersion = "2020-07-01" 866 queryParameters := map[string]interface{}{ 867 "api-version": APIVersion, 868 } 869 870 preparer := autorest.CreatePreparer( 871 autorest.AsGet(), 872 autorest.WithBaseURL(client.BaseURI), 873 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways", pathParameters), 874 autorest.WithQueryParameters(queryParameters)) 875 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 876} 877 878// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 879// http.Response Body if it receives an error. 880func (client P2sVpnGatewaysClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 881 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 882} 883 884// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 885// closes the http.Response Body. 886func (client P2sVpnGatewaysClient) ListByResourceGroupResponder(resp *http.Response) (result ListP2SVpnGatewaysResult, err error) { 887 err = autorest.Respond( 888 resp, 889 azure.WithErrorUnlessStatusCode(http.StatusOK), 890 autorest.ByUnmarshallingJSON(&result), 891 autorest.ByClosing()) 892 result.Response = autorest.Response{Response: resp} 893 return 894} 895 896// listByResourceGroupNextResults retrieves the next set of results, if any. 897func (client P2sVpnGatewaysClient) listByResourceGroupNextResults(ctx context.Context, lastResults ListP2SVpnGatewaysResult) (result ListP2SVpnGatewaysResult, err error) { 898 req, err := lastResults.listP2SVpnGatewaysResultPreparer(ctx) 899 if err != nil { 900 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 901 } 902 if req == nil { 903 return 904 } 905 resp, err := client.ListByResourceGroupSender(req) 906 if err != nil { 907 result.Response = autorest.Response{Response: resp} 908 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 909 } 910 result, err = client.ListByResourceGroupResponder(resp) 911 if err != nil { 912 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 913 } 914 return 915} 916 917// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 918func (client P2sVpnGatewaysClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ListP2SVpnGatewaysResultIterator, err error) { 919 if tracing.IsEnabled() { 920 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.ListByResourceGroup") 921 defer func() { 922 sc := -1 923 if result.Response().Response.Response != nil { 924 sc = result.page.Response().Response.Response.StatusCode 925 } 926 tracing.EndSpan(ctx, sc, err) 927 }() 928 } 929 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) 930 return 931} 932 933// Reset resets the primary of the p2s vpn gateway in the specified resource group. 934// Parameters: 935// resourceGroupName - the resource group name of the P2SVpnGateway. 936// gatewayName - the name of the gateway. 937func (client P2sVpnGatewaysClient) Reset(ctx context.Context, resourceGroupName string, gatewayName string) (result P2SVpnGatewaysResetFuture, err error) { 938 if tracing.IsEnabled() { 939 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.Reset") 940 defer func() { 941 sc := -1 942 if result.Response() != nil { 943 sc = result.Response().StatusCode 944 } 945 tracing.EndSpan(ctx, sc, err) 946 }() 947 } 948 req, err := client.ResetPreparer(ctx, resourceGroupName, gatewayName) 949 if err != nil { 950 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Reset", nil, "Failure preparing request") 951 return 952 } 953 954 result, err = client.ResetSender(req) 955 if err != nil { 956 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Reset", nil, "Failure sending request") 957 return 958 } 959 960 return 961} 962 963// ResetPreparer prepares the Reset request. 964func (client P2sVpnGatewaysClient) ResetPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) { 965 pathParameters := map[string]interface{}{ 966 "gatewayName": autorest.Encode("path", gatewayName), 967 "resourceGroupName": autorest.Encode("path", resourceGroupName), 968 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 969 } 970 971 const APIVersion = "2020-07-01" 972 queryParameters := map[string]interface{}{ 973 "api-version": APIVersion, 974 } 975 976 preparer := autorest.CreatePreparer( 977 autorest.AsPost(), 978 autorest.WithBaseURL(client.BaseURI), 979 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/reset", pathParameters), 980 autorest.WithQueryParameters(queryParameters)) 981 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 982} 983 984// ResetSender sends the Reset request. The method will close the 985// http.Response Body if it receives an error. 986func (client P2sVpnGatewaysClient) ResetSender(req *http.Request) (future P2SVpnGatewaysResetFuture, err error) { 987 var resp *http.Response 988 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 989 if err != nil { 990 return 991 } 992 var azf azure.Future 993 azf, err = azure.NewFutureFromResponse(resp) 994 future.FutureAPI = &azf 995 future.Result = func(client P2sVpnGatewaysClient) (pvg P2SVpnGateway, err error) { 996 var done bool 997 done, err = future.DoneWithContext(context.Background(), client) 998 if err != nil { 999 err = autorest.NewErrorWithError(err, "network.P2SVpnGatewaysResetFuture", "Result", future.Response(), "Polling failure") 1000 return 1001 } 1002 if !done { 1003 err = azure.NewAsyncOpIncompleteError("network.P2SVpnGatewaysResetFuture") 1004 return 1005 } 1006 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1007 if pvg.Response.Response, err = future.GetResult(sender); err == nil && pvg.Response.Response.StatusCode != http.StatusNoContent { 1008 pvg, err = client.ResetResponder(pvg.Response.Response) 1009 if err != nil { 1010 err = autorest.NewErrorWithError(err, "network.P2SVpnGatewaysResetFuture", "Result", pvg.Response.Response, "Failure responding to request") 1011 } 1012 } 1013 return 1014 } 1015 return 1016} 1017 1018// ResetResponder handles the response to the Reset request. The method always 1019// closes the http.Response Body. 1020func (client P2sVpnGatewaysClient) ResetResponder(resp *http.Response) (result P2SVpnGateway, err error) { 1021 err = autorest.Respond( 1022 resp, 1023 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1024 autorest.ByUnmarshallingJSON(&result), 1025 autorest.ByClosing()) 1026 result.Response = autorest.Response{Response: resp} 1027 return 1028} 1029 1030// UpdateTags updates virtual wan p2s vpn gateway tags. 1031// Parameters: 1032// resourceGroupName - the resource group name of the P2SVpnGateway. 1033// gatewayName - the name of the gateway. 1034// p2SVpnGatewayParameters - parameters supplied to update a virtual wan p2s vpn gateway tags. 1035func (client P2sVpnGatewaysClient) UpdateTags(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters TagsObject) (result P2sVpnGatewaysUpdateTagsFuture, err error) { 1036 if tracing.IsEnabled() { 1037 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.UpdateTags") 1038 defer func() { 1039 sc := -1 1040 if result.Response() != nil { 1041 sc = result.Response().StatusCode 1042 } 1043 tracing.EndSpan(ctx, sc, err) 1044 }() 1045 } 1046 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, gatewayName, p2SVpnGatewayParameters) 1047 if err != nil { 1048 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "UpdateTags", nil, "Failure preparing request") 1049 return 1050 } 1051 1052 result, err = client.UpdateTagsSender(req) 1053 if err != nil { 1054 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "UpdateTags", nil, "Failure sending request") 1055 return 1056 } 1057 1058 return 1059} 1060 1061// UpdateTagsPreparer prepares the UpdateTags request. 1062func (client P2sVpnGatewaysClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters TagsObject) (*http.Request, error) { 1063 pathParameters := map[string]interface{}{ 1064 "gatewayName": autorest.Encode("path", gatewayName), 1065 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1066 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1067 } 1068 1069 const APIVersion = "2020-07-01" 1070 queryParameters := map[string]interface{}{ 1071 "api-version": APIVersion, 1072 } 1073 1074 preparer := autorest.CreatePreparer( 1075 autorest.AsContentType("application/json; charset=utf-8"), 1076 autorest.AsPatch(), 1077 autorest.WithBaseURL(client.BaseURI), 1078 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}", pathParameters), 1079 autorest.WithJSON(p2SVpnGatewayParameters), 1080 autorest.WithQueryParameters(queryParameters)) 1081 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1082} 1083 1084// UpdateTagsSender sends the UpdateTags request. The method will close the 1085// http.Response Body if it receives an error. 1086func (client P2sVpnGatewaysClient) UpdateTagsSender(req *http.Request) (future P2sVpnGatewaysUpdateTagsFuture, err error) { 1087 var resp *http.Response 1088 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1089 if err != nil { 1090 return 1091 } 1092 var azf azure.Future 1093 azf, err = azure.NewFutureFromResponse(resp) 1094 future.FutureAPI = &azf 1095 future.Result = func(client P2sVpnGatewaysClient) (pvg P2SVpnGateway, err error) { 1096 var done bool 1097 done, err = future.DoneWithContext(context.Background(), client) 1098 if err != nil { 1099 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysUpdateTagsFuture", "Result", future.Response(), "Polling failure") 1100 return 1101 } 1102 if !done { 1103 err = azure.NewAsyncOpIncompleteError("network.P2sVpnGatewaysUpdateTagsFuture") 1104 return 1105 } 1106 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1107 if pvg.Response.Response, err = future.GetResult(sender); err == nil && pvg.Response.Response.StatusCode != http.StatusNoContent { 1108 pvg, err = client.UpdateTagsResponder(pvg.Response.Response) 1109 if err != nil { 1110 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysUpdateTagsFuture", "Result", pvg.Response.Response, "Failure responding to request") 1111 } 1112 } 1113 return 1114 } 1115 return 1116} 1117 1118// UpdateTagsResponder handles the response to the UpdateTags request. The method always 1119// closes the http.Response Body. 1120func (client P2sVpnGatewaysClient) UpdateTagsResponder(resp *http.Response) (result P2SVpnGateway, err error) { 1121 err = autorest.Respond( 1122 resp, 1123 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1124 autorest.ByUnmarshallingJSON(&result), 1125 autorest.ByClosing()) 1126 result.Response = autorest.Response{Response: resp} 1127 return 1128} 1129