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