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 = "2020-05-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 = "2020-05-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// DisconnectP2sVpnConnections disconnect P2S vpn connections of the virtual wan P2SVpnGateway in the specified 193// resource group. 194// Parameters: 195// resourceGroupName - the name of the resource group. 196// p2sVpnGatewayName - the name of the P2S Vpn Gateway. 197// request - the parameters are supplied to disconnect p2s vpn connections. 198func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnections(ctx context.Context, resourceGroupName string, p2sVpnGatewayName string, request P2SVpnConnectionRequest) (result P2sVpnGatewaysDisconnectP2sVpnConnectionsFuture, err error) { 199 if tracing.IsEnabled() { 200 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.DisconnectP2sVpnConnections") 201 defer func() { 202 sc := -1 203 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 204 sc = result.FutureAPI.Response().StatusCode 205 } 206 tracing.EndSpan(ctx, sc, err) 207 }() 208 } 209 req, err := client.DisconnectP2sVpnConnectionsPreparer(ctx, resourceGroupName, p2sVpnGatewayName, request) 210 if err != nil { 211 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "DisconnectP2sVpnConnections", nil, "Failure preparing request") 212 return 213 } 214 215 result, err = client.DisconnectP2sVpnConnectionsSender(req) 216 if err != nil { 217 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "DisconnectP2sVpnConnections", nil, "Failure sending request") 218 return 219 } 220 221 return 222} 223 224// DisconnectP2sVpnConnectionsPreparer prepares the DisconnectP2sVpnConnections request. 225func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsPreparer(ctx context.Context, resourceGroupName string, p2sVpnGatewayName string, request P2SVpnConnectionRequest) (*http.Request, error) { 226 pathParameters := map[string]interface{}{ 227 "p2sVpnGatewayName": autorest.Encode("path", p2sVpnGatewayName), 228 "resourceGroupName": autorest.Encode("path", resourceGroupName), 229 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 230 } 231 232 const APIVersion = "2020-05-01" 233 queryParameters := map[string]interface{}{ 234 "api-version": APIVersion, 235 } 236 237 preparer := autorest.CreatePreparer( 238 autorest.AsContentType("application/json; charset=utf-8"), 239 autorest.AsPost(), 240 autorest.WithBaseURL(client.BaseURI), 241 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{p2sVpnGatewayName}/disconnectP2sVpnConnections", pathParameters), 242 autorest.WithJSON(request), 243 autorest.WithQueryParameters(queryParameters)) 244 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 245} 246 247// DisconnectP2sVpnConnectionsSender sends the DisconnectP2sVpnConnections request. The method will close the 248// http.Response Body if it receives an error. 249func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsSender(req *http.Request) (future P2sVpnGatewaysDisconnectP2sVpnConnectionsFuture, err error) { 250 var resp *http.Response 251 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 252 if err != nil { 253 return 254 } 255 var azf azure.Future 256 azf, err = azure.NewFutureFromResponse(resp) 257 future.FutureAPI = &azf 258 future.Result = future.result 259 return 260} 261 262// DisconnectP2sVpnConnectionsResponder handles the response to the DisconnectP2sVpnConnections request. The method always 263// closes the http.Response Body. 264func (client P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsResponder(resp *http.Response) (result autorest.Response, err error) { 265 err = autorest.Respond( 266 resp, 267 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 268 autorest.ByClosing()) 269 result.Response = resp 270 return 271} 272 273// GenerateVpnProfile generates VPN profile for P2S client of the P2SVpnGateway in the specified resource group. 274// Parameters: 275// resourceGroupName - the name of the resource group. 276// gatewayName - the name of the P2SVpnGateway. 277// parameters - parameters supplied to the generate P2SVpnGateway VPN client package operation. 278func (client P2sVpnGatewaysClient) GenerateVpnProfile(ctx context.Context, resourceGroupName string, gatewayName string, parameters P2SVpnProfileParameters) (result P2sVpnGatewaysGenerateVpnProfileFuture, err error) { 279 if tracing.IsEnabled() { 280 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.GenerateVpnProfile") 281 defer func() { 282 sc := -1 283 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 284 sc = result.FutureAPI.Response().StatusCode 285 } 286 tracing.EndSpan(ctx, sc, err) 287 }() 288 } 289 req, err := client.GenerateVpnProfilePreparer(ctx, resourceGroupName, gatewayName, parameters) 290 if err != nil { 291 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GenerateVpnProfile", nil, "Failure preparing request") 292 return 293 } 294 295 result, err = client.GenerateVpnProfileSender(req) 296 if err != nil { 297 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GenerateVpnProfile", nil, "Failure sending request") 298 return 299 } 300 301 return 302} 303 304// GenerateVpnProfilePreparer prepares the GenerateVpnProfile request. 305func (client P2sVpnGatewaysClient) GenerateVpnProfilePreparer(ctx context.Context, resourceGroupName string, gatewayName string, parameters P2SVpnProfileParameters) (*http.Request, error) { 306 pathParameters := map[string]interface{}{ 307 "gatewayName": autorest.Encode("path", gatewayName), 308 "resourceGroupName": autorest.Encode("path", resourceGroupName), 309 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 310 } 311 312 const APIVersion = "2020-05-01" 313 queryParameters := map[string]interface{}{ 314 "api-version": APIVersion, 315 } 316 317 preparer := autorest.CreatePreparer( 318 autorest.AsContentType("application/json; charset=utf-8"), 319 autorest.AsPost(), 320 autorest.WithBaseURL(client.BaseURI), 321 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/generatevpnprofile", pathParameters), 322 autorest.WithJSON(parameters), 323 autorest.WithQueryParameters(queryParameters)) 324 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 325} 326 327// GenerateVpnProfileSender sends the GenerateVpnProfile request. The method will close the 328// http.Response Body if it receives an error. 329func (client P2sVpnGatewaysClient) GenerateVpnProfileSender(req *http.Request) (future P2sVpnGatewaysGenerateVpnProfileFuture, err error) { 330 var resp *http.Response 331 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 332 if err != nil { 333 return 334 } 335 var azf azure.Future 336 azf, err = azure.NewFutureFromResponse(resp) 337 future.FutureAPI = &azf 338 future.Result = future.result 339 return 340} 341 342// GenerateVpnProfileResponder handles the response to the GenerateVpnProfile request. The method always 343// closes the http.Response Body. 344func (client P2sVpnGatewaysClient) GenerateVpnProfileResponder(resp *http.Response) (result VpnProfileResponse, err error) { 345 err = autorest.Respond( 346 resp, 347 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 348 autorest.ByUnmarshallingJSON(&result), 349 autorest.ByClosing()) 350 result.Response = autorest.Response{Response: resp} 351 return 352} 353 354// Get retrieves the details of a virtual wan p2s vpn gateway. 355// Parameters: 356// resourceGroupName - the resource group name of the P2SVpnGateway. 357// gatewayName - the name of the gateway. 358func (client P2sVpnGatewaysClient) Get(ctx context.Context, resourceGroupName string, gatewayName string) (result P2SVpnGateway, err error) { 359 if tracing.IsEnabled() { 360 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.Get") 361 defer func() { 362 sc := -1 363 if result.Response.Response != nil { 364 sc = result.Response.Response.StatusCode 365 } 366 tracing.EndSpan(ctx, sc, err) 367 }() 368 } 369 req, err := client.GetPreparer(ctx, resourceGroupName, gatewayName) 370 if err != nil { 371 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Get", nil, "Failure preparing request") 372 return 373 } 374 375 resp, err := client.GetSender(req) 376 if err != nil { 377 result.Response = autorest.Response{Response: resp} 378 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Get", resp, "Failure sending request") 379 return 380 } 381 382 result, err = client.GetResponder(resp) 383 if err != nil { 384 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "Get", resp, "Failure responding to request") 385 return 386 } 387 388 return 389} 390 391// GetPreparer prepares the Get request. 392func (client P2sVpnGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) { 393 pathParameters := map[string]interface{}{ 394 "gatewayName": autorest.Encode("path", gatewayName), 395 "resourceGroupName": autorest.Encode("path", resourceGroupName), 396 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 397 } 398 399 const APIVersion = "2020-05-01" 400 queryParameters := map[string]interface{}{ 401 "api-version": APIVersion, 402 } 403 404 preparer := autorest.CreatePreparer( 405 autorest.AsGet(), 406 autorest.WithBaseURL(client.BaseURI), 407 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}", pathParameters), 408 autorest.WithQueryParameters(queryParameters)) 409 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 410} 411 412// GetSender sends the Get request. The method will close the 413// http.Response Body if it receives an error. 414func (client P2sVpnGatewaysClient) GetSender(req *http.Request) (*http.Response, error) { 415 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 416} 417 418// GetResponder handles the response to the Get request. The method always 419// closes the http.Response Body. 420func (client P2sVpnGatewaysClient) GetResponder(resp *http.Response) (result P2SVpnGateway, err error) { 421 err = autorest.Respond( 422 resp, 423 azure.WithErrorUnlessStatusCode(http.StatusOK), 424 autorest.ByUnmarshallingJSON(&result), 425 autorest.ByClosing()) 426 result.Response = autorest.Response{Response: resp} 427 return 428} 429 430// GetP2sVpnConnectionHealth gets the connection health of P2S clients of the virtual wan P2SVpnGateway in the 431// specified resource group. 432// Parameters: 433// resourceGroupName - the name of the resource group. 434// gatewayName - the name of the P2SVpnGateway. 435func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealth(ctx context.Context, resourceGroupName string, gatewayName string) (result P2sVpnGatewaysGetP2sVpnConnectionHealthFuture, err error) { 436 if tracing.IsEnabled() { 437 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.GetP2sVpnConnectionHealth") 438 defer func() { 439 sc := -1 440 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 441 sc = result.FutureAPI.Response().StatusCode 442 } 443 tracing.EndSpan(ctx, sc, err) 444 }() 445 } 446 req, err := client.GetP2sVpnConnectionHealthPreparer(ctx, resourceGroupName, gatewayName) 447 if err != nil { 448 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealth", nil, "Failure preparing request") 449 return 450 } 451 452 result, err = client.GetP2sVpnConnectionHealthSender(req) 453 if err != nil { 454 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealth", nil, "Failure sending request") 455 return 456 } 457 458 return 459} 460 461// GetP2sVpnConnectionHealthPreparer prepares the GetP2sVpnConnectionHealth request. 462func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthPreparer(ctx context.Context, resourceGroupName string, gatewayName string) (*http.Request, error) { 463 pathParameters := map[string]interface{}{ 464 "gatewayName": autorest.Encode("path", gatewayName), 465 "resourceGroupName": autorest.Encode("path", resourceGroupName), 466 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 467 } 468 469 const APIVersion = "2020-05-01" 470 queryParameters := map[string]interface{}{ 471 "api-version": APIVersion, 472 } 473 474 preparer := autorest.CreatePreparer( 475 autorest.AsPost(), 476 autorest.WithBaseURL(client.BaseURI), 477 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/getP2sVpnConnectionHealth", pathParameters), 478 autorest.WithQueryParameters(queryParameters)) 479 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 480} 481 482// GetP2sVpnConnectionHealthSender sends the GetP2sVpnConnectionHealth request. The method will close the 483// http.Response Body if it receives an error. 484func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthSender(req *http.Request) (future P2sVpnGatewaysGetP2sVpnConnectionHealthFuture, err error) { 485 var resp *http.Response 486 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 487 if err != nil { 488 return 489 } 490 var azf azure.Future 491 azf, err = azure.NewFutureFromResponse(resp) 492 future.FutureAPI = &azf 493 future.Result = future.result 494 return 495} 496 497// GetP2sVpnConnectionHealthResponder handles the response to the GetP2sVpnConnectionHealth request. The method always 498// closes the http.Response Body. 499func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthResponder(resp *http.Response) (result P2SVpnGateway, err error) { 500 err = autorest.Respond( 501 resp, 502 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 503 autorest.ByUnmarshallingJSON(&result), 504 autorest.ByClosing()) 505 result.Response = autorest.Response{Response: resp} 506 return 507} 508 509// GetP2sVpnConnectionHealthDetailed gets the sas url to get the connection health detail of P2S clients of the virtual 510// wan P2SVpnGateway in the specified resource group. 511// Parameters: 512// resourceGroupName - the name of the resource group. 513// gatewayName - the name of the P2SVpnGateway. 514// request - request parameters supplied to get p2s vpn connections detailed health. 515func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailed(ctx context.Context, resourceGroupName string, gatewayName string, request P2SVpnConnectionHealthRequest) (result P2sVpnGatewaysGetP2sVpnConnectionHealthDetailedFuture, err error) { 516 if tracing.IsEnabled() { 517 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.GetP2sVpnConnectionHealthDetailed") 518 defer func() { 519 sc := -1 520 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 521 sc = result.FutureAPI.Response().StatusCode 522 } 523 tracing.EndSpan(ctx, sc, err) 524 }() 525 } 526 req, err := client.GetP2sVpnConnectionHealthDetailedPreparer(ctx, resourceGroupName, gatewayName, request) 527 if err != nil { 528 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealthDetailed", nil, "Failure preparing request") 529 return 530 } 531 532 result, err = client.GetP2sVpnConnectionHealthDetailedSender(req) 533 if err != nil { 534 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "GetP2sVpnConnectionHealthDetailed", nil, "Failure sending request") 535 return 536 } 537 538 return 539} 540 541// GetP2sVpnConnectionHealthDetailedPreparer prepares the GetP2sVpnConnectionHealthDetailed request. 542func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedPreparer(ctx context.Context, resourceGroupName string, gatewayName string, request P2SVpnConnectionHealthRequest) (*http.Request, error) { 543 pathParameters := map[string]interface{}{ 544 "gatewayName": autorest.Encode("path", gatewayName), 545 "resourceGroupName": autorest.Encode("path", resourceGroupName), 546 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 547 } 548 549 const APIVersion = "2020-05-01" 550 queryParameters := map[string]interface{}{ 551 "api-version": APIVersion, 552 } 553 554 preparer := autorest.CreatePreparer( 555 autorest.AsContentType("application/json; charset=utf-8"), 556 autorest.AsPost(), 557 autorest.WithBaseURL(client.BaseURI), 558 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}/getP2sVpnConnectionHealthDetailed", pathParameters), 559 autorest.WithJSON(request), 560 autorest.WithQueryParameters(queryParameters)) 561 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 562} 563 564// GetP2sVpnConnectionHealthDetailedSender sends the GetP2sVpnConnectionHealthDetailed request. The method will close the 565// http.Response Body if it receives an error. 566func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedSender(req *http.Request) (future P2sVpnGatewaysGetP2sVpnConnectionHealthDetailedFuture, err error) { 567 var resp *http.Response 568 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 569 if err != nil { 570 return 571 } 572 var azf azure.Future 573 azf, err = azure.NewFutureFromResponse(resp) 574 future.FutureAPI = &azf 575 future.Result = future.result 576 return 577} 578 579// GetP2sVpnConnectionHealthDetailedResponder handles the response to the GetP2sVpnConnectionHealthDetailed request. The method always 580// closes the http.Response Body. 581func (client P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedResponder(resp *http.Response) (result P2SVpnConnectionHealth, err error) { 582 err = autorest.Respond( 583 resp, 584 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 585 autorest.ByUnmarshallingJSON(&result), 586 autorest.ByClosing()) 587 result.Response = autorest.Response{Response: resp} 588 return 589} 590 591// List lists all the P2SVpnGateways in a subscription. 592func (client P2sVpnGatewaysClient) List(ctx context.Context) (result ListP2SVpnGatewaysResultPage, err error) { 593 if tracing.IsEnabled() { 594 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.List") 595 defer func() { 596 sc := -1 597 if result.lpvgr.Response.Response != nil { 598 sc = result.lpvgr.Response.Response.StatusCode 599 } 600 tracing.EndSpan(ctx, sc, err) 601 }() 602 } 603 result.fn = client.listNextResults 604 req, err := client.ListPreparer(ctx) 605 if err != nil { 606 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "List", nil, "Failure preparing request") 607 return 608 } 609 610 resp, err := client.ListSender(req) 611 if err != nil { 612 result.lpvgr.Response = autorest.Response{Response: resp} 613 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "List", resp, "Failure sending request") 614 return 615 } 616 617 result.lpvgr, err = client.ListResponder(resp) 618 if err != nil { 619 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "List", resp, "Failure responding to request") 620 return 621 } 622 if result.lpvgr.hasNextLink() && result.lpvgr.IsEmpty() { 623 err = result.NextWithContext(ctx) 624 return 625 } 626 627 return 628} 629 630// ListPreparer prepares the List request. 631func (client P2sVpnGatewaysClient) ListPreparer(ctx context.Context) (*http.Request, error) { 632 pathParameters := map[string]interface{}{ 633 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 634 } 635 636 const APIVersion = "2020-05-01" 637 queryParameters := map[string]interface{}{ 638 "api-version": APIVersion, 639 } 640 641 preparer := autorest.CreatePreparer( 642 autorest.AsGet(), 643 autorest.WithBaseURL(client.BaseURI), 644 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/p2svpnGateways", pathParameters), 645 autorest.WithQueryParameters(queryParameters)) 646 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 647} 648 649// ListSender sends the List request. The method will close the 650// http.Response Body if it receives an error. 651func (client P2sVpnGatewaysClient) ListSender(req *http.Request) (*http.Response, error) { 652 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 653} 654 655// ListResponder handles the response to the List request. The method always 656// closes the http.Response Body. 657func (client P2sVpnGatewaysClient) ListResponder(resp *http.Response) (result ListP2SVpnGatewaysResult, err error) { 658 err = autorest.Respond( 659 resp, 660 azure.WithErrorUnlessStatusCode(http.StatusOK), 661 autorest.ByUnmarshallingJSON(&result), 662 autorest.ByClosing()) 663 result.Response = autorest.Response{Response: resp} 664 return 665} 666 667// listNextResults retrieves the next set of results, if any. 668func (client P2sVpnGatewaysClient) listNextResults(ctx context.Context, lastResults ListP2SVpnGatewaysResult) (result ListP2SVpnGatewaysResult, err error) { 669 req, err := lastResults.listP2SVpnGatewaysResultPreparer(ctx) 670 if err != nil { 671 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listNextResults", nil, "Failure preparing next results request") 672 } 673 if req == nil { 674 return 675 } 676 resp, err := client.ListSender(req) 677 if err != nil { 678 result.Response = autorest.Response{Response: resp} 679 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listNextResults", resp, "Failure sending next results request") 680 } 681 result, err = client.ListResponder(resp) 682 if err != nil { 683 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listNextResults", resp, "Failure responding to next results request") 684 } 685 return 686} 687 688// ListComplete enumerates all values, automatically crossing page boundaries as required. 689func (client P2sVpnGatewaysClient) ListComplete(ctx context.Context) (result ListP2SVpnGatewaysResultIterator, err error) { 690 if tracing.IsEnabled() { 691 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.List") 692 defer func() { 693 sc := -1 694 if result.Response().Response.Response != nil { 695 sc = result.page.Response().Response.Response.StatusCode 696 } 697 tracing.EndSpan(ctx, sc, err) 698 }() 699 } 700 result.page, err = client.List(ctx) 701 return 702} 703 704// ListByResourceGroup lists all the P2SVpnGateways in a resource group. 705// Parameters: 706// resourceGroupName - the resource group name of the P2SVpnGateway. 707func (client P2sVpnGatewaysClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListP2SVpnGatewaysResultPage, err error) { 708 if tracing.IsEnabled() { 709 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.ListByResourceGroup") 710 defer func() { 711 sc := -1 712 if result.lpvgr.Response.Response != nil { 713 sc = result.lpvgr.Response.Response.StatusCode 714 } 715 tracing.EndSpan(ctx, sc, err) 716 }() 717 } 718 result.fn = client.listByResourceGroupNextResults 719 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 720 if err != nil { 721 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "ListByResourceGroup", nil, "Failure preparing request") 722 return 723 } 724 725 resp, err := client.ListByResourceGroupSender(req) 726 if err != nil { 727 result.lpvgr.Response = autorest.Response{Response: resp} 728 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "ListByResourceGroup", resp, "Failure sending request") 729 return 730 } 731 732 result.lpvgr, err = client.ListByResourceGroupResponder(resp) 733 if err != nil { 734 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "ListByResourceGroup", resp, "Failure responding to request") 735 return 736 } 737 if result.lpvgr.hasNextLink() && result.lpvgr.IsEmpty() { 738 err = result.NextWithContext(ctx) 739 return 740 } 741 742 return 743} 744 745// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 746func (client P2sVpnGatewaysClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 747 pathParameters := map[string]interface{}{ 748 "resourceGroupName": autorest.Encode("path", resourceGroupName), 749 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 750 } 751 752 const APIVersion = "2020-05-01" 753 queryParameters := map[string]interface{}{ 754 "api-version": APIVersion, 755 } 756 757 preparer := autorest.CreatePreparer( 758 autorest.AsGet(), 759 autorest.WithBaseURL(client.BaseURI), 760 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways", pathParameters), 761 autorest.WithQueryParameters(queryParameters)) 762 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 763} 764 765// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 766// http.Response Body if it receives an error. 767func (client P2sVpnGatewaysClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 768 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 769} 770 771// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 772// closes the http.Response Body. 773func (client P2sVpnGatewaysClient) ListByResourceGroupResponder(resp *http.Response) (result ListP2SVpnGatewaysResult, err error) { 774 err = autorest.Respond( 775 resp, 776 azure.WithErrorUnlessStatusCode(http.StatusOK), 777 autorest.ByUnmarshallingJSON(&result), 778 autorest.ByClosing()) 779 result.Response = autorest.Response{Response: resp} 780 return 781} 782 783// listByResourceGroupNextResults retrieves the next set of results, if any. 784func (client P2sVpnGatewaysClient) listByResourceGroupNextResults(ctx context.Context, lastResults ListP2SVpnGatewaysResult) (result ListP2SVpnGatewaysResult, err error) { 785 req, err := lastResults.listP2SVpnGatewaysResultPreparer(ctx) 786 if err != nil { 787 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 788 } 789 if req == nil { 790 return 791 } 792 resp, err := client.ListByResourceGroupSender(req) 793 if err != nil { 794 result.Response = autorest.Response{Response: resp} 795 return result, autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 796 } 797 result, err = client.ListByResourceGroupResponder(resp) 798 if err != nil { 799 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 800 } 801 return 802} 803 804// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 805func (client P2sVpnGatewaysClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ListP2SVpnGatewaysResultIterator, err error) { 806 if tracing.IsEnabled() { 807 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.ListByResourceGroup") 808 defer func() { 809 sc := -1 810 if result.Response().Response.Response != nil { 811 sc = result.page.Response().Response.Response.StatusCode 812 } 813 tracing.EndSpan(ctx, sc, err) 814 }() 815 } 816 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) 817 return 818} 819 820// UpdateTags updates virtual wan p2s vpn gateway tags. 821// Parameters: 822// resourceGroupName - the resource group name of the P2SVpnGateway. 823// gatewayName - the name of the gateway. 824// p2SVpnGatewayParameters - parameters supplied to update a virtual wan p2s vpn gateway tags. 825func (client P2sVpnGatewaysClient) UpdateTags(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters TagsObject) (result P2SVpnGateway, err error) { 826 if tracing.IsEnabled() { 827 ctx = tracing.StartSpan(ctx, fqdn+"/P2sVpnGatewaysClient.UpdateTags") 828 defer func() { 829 sc := -1 830 if result.Response.Response != nil { 831 sc = result.Response.Response.StatusCode 832 } 833 tracing.EndSpan(ctx, sc, err) 834 }() 835 } 836 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, gatewayName, p2SVpnGatewayParameters) 837 if err != nil { 838 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "UpdateTags", nil, "Failure preparing request") 839 return 840 } 841 842 resp, err := client.UpdateTagsSender(req) 843 if err != nil { 844 result.Response = autorest.Response{Response: resp} 845 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "UpdateTags", resp, "Failure sending request") 846 return 847 } 848 849 result, err = client.UpdateTagsResponder(resp) 850 if err != nil { 851 err = autorest.NewErrorWithError(err, "network.P2sVpnGatewaysClient", "UpdateTags", resp, "Failure responding to request") 852 return 853 } 854 855 return 856} 857 858// UpdateTagsPreparer prepares the UpdateTags request. 859func (client P2sVpnGatewaysClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, gatewayName string, p2SVpnGatewayParameters TagsObject) (*http.Request, error) { 860 pathParameters := map[string]interface{}{ 861 "gatewayName": autorest.Encode("path", gatewayName), 862 "resourceGroupName": autorest.Encode("path", resourceGroupName), 863 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 864 } 865 866 const APIVersion = "2020-05-01" 867 queryParameters := map[string]interface{}{ 868 "api-version": APIVersion, 869 } 870 871 preparer := autorest.CreatePreparer( 872 autorest.AsContentType("application/json; charset=utf-8"), 873 autorest.AsPatch(), 874 autorest.WithBaseURL(client.BaseURI), 875 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/p2svpnGateways/{gatewayName}", pathParameters), 876 autorest.WithJSON(p2SVpnGatewayParameters), 877 autorest.WithQueryParameters(queryParameters)) 878 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 879} 880 881// UpdateTagsSender sends the UpdateTags request. The method will close the 882// http.Response Body if it receives an error. 883func (client P2sVpnGatewaysClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { 884 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 885} 886 887// UpdateTagsResponder handles the response to the UpdateTags request. The method always 888// closes the http.Response Body. 889func (client P2sVpnGatewaysClient) UpdateTagsResponder(resp *http.Response) (result P2SVpnGateway, err error) { 890 err = autorest.Respond( 891 resp, 892 azure.WithErrorUnlessStatusCode(http.StatusOK), 893 autorest.ByUnmarshallingJSON(&result), 894 autorest.ByClosing()) 895 result.Response = autorest.Response{Response: resp} 896 return 897} 898