1// Package network implements the Azure ARM Network service API version . 2// 3// Network Client 4package network 5 6// Copyright (c) Microsoft and contributors. All rights reserved. 7// 8// Licensed under the Apache License, Version 2.0 (the "License"); 9// you may not use this file except in compliance with the License. 10// You may obtain a copy of the License at 11// http://www.apache.org/licenses/LICENSE-2.0 12// 13// Unless required by applicable law or agreed to in writing, software 14// distributed under the License is distributed on an "AS IS" BASIS, 15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16// 17// See the License for the specific language governing permissions and 18// limitations under the License. 19// 20// Code generated by Microsoft (R) AutoRest Code Generator. 21// Changes may cause incorrect behavior and will be lost if the code is regenerated. 22 23import ( 24 "context" 25 "github.com/Azure/go-autorest/autorest" 26 "github.com/Azure/go-autorest/autorest/azure" 27 "github.com/Azure/go-autorest/tracing" 28 "net/http" 29) 30 31const ( 32 // DefaultBaseURI is the default URI used for the service Network 33 DefaultBaseURI = "https://management.azure.com" 34) 35 36// BaseClient is the base client for Network. 37type BaseClient struct { 38 autorest.Client 39 BaseURI string 40 SubscriptionID string 41} 42 43// New creates an instance of the BaseClient client. 44func New(subscriptionID string) BaseClient { 45 return NewWithBaseURI(DefaultBaseURI, subscriptionID) 46} 47 48// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with 49// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 50func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { 51 return BaseClient{ 52 Client: autorest.NewClientWithUserAgent(UserAgent()), 53 BaseURI: baseURI, 54 SubscriptionID: subscriptionID, 55 } 56} 57 58// CheckDNSNameAvailability checks whether a domain name in the cloudapp.azure.com zone is available for use. 59// Parameters: 60// location - the location of the domain name. 61// domainNameLabel - the domain name to be verified. It must conform to the following regular expression: 62// ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. 63func (client BaseClient) CheckDNSNameAvailability(ctx context.Context, location string, domainNameLabel string) (result DNSNameAvailabilityResult, err error) { 64 if tracing.IsEnabled() { 65 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.CheckDNSNameAvailability") 66 defer func() { 67 sc := -1 68 if result.Response.Response != nil { 69 sc = result.Response.Response.StatusCode 70 } 71 tracing.EndSpan(ctx, sc, err) 72 }() 73 } 74 req, err := client.CheckDNSNameAvailabilityPreparer(ctx, location, domainNameLabel) 75 if err != nil { 76 err = autorest.NewErrorWithError(err, "network.BaseClient", "CheckDNSNameAvailability", nil, "Failure preparing request") 77 return 78 } 79 80 resp, err := client.CheckDNSNameAvailabilitySender(req) 81 if err != nil { 82 result.Response = autorest.Response{Response: resp} 83 err = autorest.NewErrorWithError(err, "network.BaseClient", "CheckDNSNameAvailability", resp, "Failure sending request") 84 return 85 } 86 87 result, err = client.CheckDNSNameAvailabilityResponder(resp) 88 if err != nil { 89 err = autorest.NewErrorWithError(err, "network.BaseClient", "CheckDNSNameAvailability", resp, "Failure responding to request") 90 } 91 92 return 93} 94 95// CheckDNSNameAvailabilityPreparer prepares the CheckDNSNameAvailability request. 96func (client BaseClient) CheckDNSNameAvailabilityPreparer(ctx context.Context, location string, domainNameLabel string) (*http.Request, error) { 97 pathParameters := map[string]interface{}{ 98 "location": autorest.Encode("path", location), 99 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 100 } 101 102 const APIVersion = "2020-03-01" 103 queryParameters := map[string]interface{}{ 104 "api-version": APIVersion, 105 "domainNameLabel": autorest.Encode("query", domainNameLabel), 106 } 107 108 preparer := autorest.CreatePreparer( 109 autorest.AsGet(), 110 autorest.WithBaseURL(client.BaseURI), 111 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability", pathParameters), 112 autorest.WithQueryParameters(queryParameters)) 113 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 114} 115 116// CheckDNSNameAvailabilitySender sends the CheckDNSNameAvailability request. The method will close the 117// http.Response Body if it receives an error. 118func (client BaseClient) CheckDNSNameAvailabilitySender(req *http.Request) (*http.Response, error) { 119 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 120} 121 122// CheckDNSNameAvailabilityResponder handles the response to the CheckDNSNameAvailability request. The method always 123// closes the http.Response Body. 124func (client BaseClient) CheckDNSNameAvailabilityResponder(resp *http.Response) (result DNSNameAvailabilityResult, err error) { 125 err = autorest.Respond( 126 resp, 127 client.ByInspecting(), 128 azure.WithErrorUnlessStatusCode(http.StatusOK), 129 autorest.ByUnmarshallingJSON(&result), 130 autorest.ByClosing()) 131 result.Response = autorest.Response{Response: resp} 132 return 133} 134 135// DeleteBastionShareableLink deletes the Bastion Shareable Links for all the VMs specified in the request. 136// Parameters: 137// resourceGroupName - the name of the resource group. 138// bastionHostName - the name of the Bastion Host. 139// bslRequest - post request for all the Bastion Shareable Link endpoints. 140func (client BaseClient) DeleteBastionShareableLink(ctx context.Context, resourceGroupName string, bastionHostName string, bslRequest BastionShareableLinkListRequest) (result DeleteBastionShareableLinkFuture, err error) { 141 if tracing.IsEnabled() { 142 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.DeleteBastionShareableLink") 143 defer func() { 144 sc := -1 145 if result.Response() != nil { 146 sc = result.Response().StatusCode 147 } 148 tracing.EndSpan(ctx, sc, err) 149 }() 150 } 151 req, err := client.DeleteBastionShareableLinkPreparer(ctx, resourceGroupName, bastionHostName, bslRequest) 152 if err != nil { 153 err = autorest.NewErrorWithError(err, "network.BaseClient", "DeleteBastionShareableLink", nil, "Failure preparing request") 154 return 155 } 156 157 result, err = client.DeleteBastionShareableLinkSender(req) 158 if err != nil { 159 err = autorest.NewErrorWithError(err, "network.BaseClient", "DeleteBastionShareableLink", result.Response(), "Failure sending request") 160 return 161 } 162 163 return 164} 165 166// DeleteBastionShareableLinkPreparer prepares the DeleteBastionShareableLink request. 167func (client BaseClient) DeleteBastionShareableLinkPreparer(ctx context.Context, resourceGroupName string, bastionHostName string, bslRequest BastionShareableLinkListRequest) (*http.Request, error) { 168 pathParameters := map[string]interface{}{ 169 "bastionHostName": autorest.Encode("path", bastionHostName), 170 "resourceGroupName": autorest.Encode("path", resourceGroupName), 171 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 172 } 173 174 const APIVersion = "2020-03-01" 175 queryParameters := map[string]interface{}{ 176 "api-version": APIVersion, 177 } 178 179 preparer := autorest.CreatePreparer( 180 autorest.AsContentType("application/json; charset=utf-8"), 181 autorest.AsPost(), 182 autorest.WithBaseURL(client.BaseURI), 183 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/bastionHosts/{bastionHostName}/deleteShareableLinks", pathParameters), 184 autorest.WithJSON(bslRequest), 185 autorest.WithQueryParameters(queryParameters)) 186 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 187} 188 189// DeleteBastionShareableLinkSender sends the DeleteBastionShareableLink request. The method will close the 190// http.Response Body if it receives an error. 191func (client BaseClient) DeleteBastionShareableLinkSender(req *http.Request) (future DeleteBastionShareableLinkFuture, err error) { 192 var resp *http.Response 193 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 194 if err != nil { 195 return 196 } 197 future.Future, err = azure.NewFutureFromResponse(resp) 198 return 199} 200 201// DeleteBastionShareableLinkResponder handles the response to the DeleteBastionShareableLink request. The method always 202// closes the http.Response Body. 203func (client BaseClient) DeleteBastionShareableLinkResponder(resp *http.Response) (result autorest.Response, err error) { 204 err = autorest.Respond( 205 resp, 206 client.ByInspecting(), 207 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 208 autorest.ByClosing()) 209 result.Response = resp 210 return 211} 212 213// DisconnectActiveSessions returns the list of currently active sessions on the Bastion. 214// Parameters: 215// resourceGroupName - the name of the resource group. 216// bastionHostName - the name of the Bastion Host. 217// sessionIds - the list of sessionids to disconnect. 218func (client BaseClient) DisconnectActiveSessions(ctx context.Context, resourceGroupName string, bastionHostName string, sessionIds SessionIds) (result BastionSessionDeleteResultPage, err error) { 219 if tracing.IsEnabled() { 220 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.DisconnectActiveSessions") 221 defer func() { 222 sc := -1 223 if result.bsdr.Response.Response != nil { 224 sc = result.bsdr.Response.Response.StatusCode 225 } 226 tracing.EndSpan(ctx, sc, err) 227 }() 228 } 229 result.fn = client.disconnectActiveSessionsNextResults 230 req, err := client.DisconnectActiveSessionsPreparer(ctx, resourceGroupName, bastionHostName, sessionIds) 231 if err != nil { 232 err = autorest.NewErrorWithError(err, "network.BaseClient", "DisconnectActiveSessions", nil, "Failure preparing request") 233 return 234 } 235 236 resp, err := client.DisconnectActiveSessionsSender(req) 237 if err != nil { 238 result.bsdr.Response = autorest.Response{Response: resp} 239 err = autorest.NewErrorWithError(err, "network.BaseClient", "DisconnectActiveSessions", resp, "Failure sending request") 240 return 241 } 242 243 result.bsdr, err = client.DisconnectActiveSessionsResponder(resp) 244 if err != nil { 245 err = autorest.NewErrorWithError(err, "network.BaseClient", "DisconnectActiveSessions", resp, "Failure responding to request") 246 } 247 248 return 249} 250 251// DisconnectActiveSessionsPreparer prepares the DisconnectActiveSessions request. 252func (client BaseClient) DisconnectActiveSessionsPreparer(ctx context.Context, resourceGroupName string, bastionHostName string, sessionIds SessionIds) (*http.Request, error) { 253 pathParameters := map[string]interface{}{ 254 "bastionHostName": autorest.Encode("path", bastionHostName), 255 "resourceGroupName": autorest.Encode("path", resourceGroupName), 256 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 257 } 258 259 const APIVersion = "2020-03-01" 260 queryParameters := map[string]interface{}{ 261 "api-version": APIVersion, 262 } 263 264 preparer := autorest.CreatePreparer( 265 autorest.AsContentType("application/json; charset=utf-8"), 266 autorest.AsPost(), 267 autorest.WithBaseURL(client.BaseURI), 268 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/bastionHosts/{bastionHostName}/disconnectActiveSessions", pathParameters), 269 autorest.WithJSON(sessionIds), 270 autorest.WithQueryParameters(queryParameters)) 271 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 272} 273 274// DisconnectActiveSessionsSender sends the DisconnectActiveSessions request. The method will close the 275// http.Response Body if it receives an error. 276func (client BaseClient) DisconnectActiveSessionsSender(req *http.Request) (*http.Response, error) { 277 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 278} 279 280// DisconnectActiveSessionsResponder handles the response to the DisconnectActiveSessions request. The method always 281// closes the http.Response Body. 282func (client BaseClient) DisconnectActiveSessionsResponder(resp *http.Response) (result BastionSessionDeleteResult, err error) { 283 err = autorest.Respond( 284 resp, 285 client.ByInspecting(), 286 azure.WithErrorUnlessStatusCode(http.StatusOK), 287 autorest.ByUnmarshallingJSON(&result), 288 autorest.ByClosing()) 289 result.Response = autorest.Response{Response: resp} 290 return 291} 292 293// disconnectActiveSessionsNextResults retrieves the next set of results, if any. 294func (client BaseClient) disconnectActiveSessionsNextResults(ctx context.Context, lastResults BastionSessionDeleteResult) (result BastionSessionDeleteResult, err error) { 295 req, err := lastResults.bastionSessionDeleteResultPreparer(ctx) 296 if err != nil { 297 return result, autorest.NewErrorWithError(err, "network.BaseClient", "disconnectActiveSessionsNextResults", nil, "Failure preparing next results request") 298 } 299 if req == nil { 300 return 301 } 302 resp, err := client.DisconnectActiveSessionsSender(req) 303 if err != nil { 304 result.Response = autorest.Response{Response: resp} 305 return result, autorest.NewErrorWithError(err, "network.BaseClient", "disconnectActiveSessionsNextResults", resp, "Failure sending next results request") 306 } 307 result, err = client.DisconnectActiveSessionsResponder(resp) 308 if err != nil { 309 err = autorest.NewErrorWithError(err, "network.BaseClient", "disconnectActiveSessionsNextResults", resp, "Failure responding to next results request") 310 } 311 return 312} 313 314// DisconnectActiveSessionsComplete enumerates all values, automatically crossing page boundaries as required. 315func (client BaseClient) DisconnectActiveSessionsComplete(ctx context.Context, resourceGroupName string, bastionHostName string, sessionIds SessionIds) (result BastionSessionDeleteResultIterator, err error) { 316 if tracing.IsEnabled() { 317 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.DisconnectActiveSessions") 318 defer func() { 319 sc := -1 320 if result.Response().Response.Response != nil { 321 sc = result.page.Response().Response.Response.StatusCode 322 } 323 tracing.EndSpan(ctx, sc, err) 324 }() 325 } 326 result.page, err = client.DisconnectActiveSessions(ctx, resourceGroupName, bastionHostName, sessionIds) 327 return 328} 329 330// Generatevirtualwanvpnserverconfigurationvpnprofile generates a unique VPN profile for P2S clients for VirtualWan and 331// associated VpnServerConfiguration combination in the specified resource group. 332// Parameters: 333// resourceGroupName - the resource group name. 334// virtualWANName - the name of the VirtualWAN whose associated VpnServerConfigurations is needed. 335// vpnClientParams - parameters supplied to the generate VirtualWan VPN profile generation operation. 336func (client BaseClient) Generatevirtualwanvpnserverconfigurationvpnprofile(ctx context.Context, resourceGroupName string, virtualWANName string, vpnClientParams VirtualWanVpnProfileParameters) (result GeneratevirtualwanvpnserverconfigurationvpnprofileFuture, err error) { 337 if tracing.IsEnabled() { 338 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.Generatevirtualwanvpnserverconfigurationvpnprofile") 339 defer func() { 340 sc := -1 341 if result.Response() != nil { 342 sc = result.Response().StatusCode 343 } 344 tracing.EndSpan(ctx, sc, err) 345 }() 346 } 347 req, err := client.GeneratevirtualwanvpnserverconfigurationvpnprofilePreparer(ctx, resourceGroupName, virtualWANName, vpnClientParams) 348 if err != nil { 349 err = autorest.NewErrorWithError(err, "network.BaseClient", "Generatevirtualwanvpnserverconfigurationvpnprofile", nil, "Failure preparing request") 350 return 351 } 352 353 result, err = client.GeneratevirtualwanvpnserverconfigurationvpnprofileSender(req) 354 if err != nil { 355 err = autorest.NewErrorWithError(err, "network.BaseClient", "Generatevirtualwanvpnserverconfigurationvpnprofile", result.Response(), "Failure sending request") 356 return 357 } 358 359 return 360} 361 362// GeneratevirtualwanvpnserverconfigurationvpnprofilePreparer prepares the Generatevirtualwanvpnserverconfigurationvpnprofile request. 363func (client BaseClient) GeneratevirtualwanvpnserverconfigurationvpnprofilePreparer(ctx context.Context, resourceGroupName string, virtualWANName string, vpnClientParams VirtualWanVpnProfileParameters) (*http.Request, error) { 364 pathParameters := map[string]interface{}{ 365 "resourceGroupName": autorest.Encode("path", resourceGroupName), 366 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 367 "virtualWANName": autorest.Encode("path", virtualWANName), 368 } 369 370 const APIVersion = "2020-03-01" 371 queryParameters := map[string]interface{}{ 372 "api-version": APIVersion, 373 } 374 375 preparer := autorest.CreatePreparer( 376 autorest.AsContentType("application/json; charset=utf-8"), 377 autorest.AsPost(), 378 autorest.WithBaseURL(client.BaseURI), 379 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/GenerateVpnProfile", pathParameters), 380 autorest.WithJSON(vpnClientParams), 381 autorest.WithQueryParameters(queryParameters)) 382 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 383} 384 385// GeneratevirtualwanvpnserverconfigurationvpnprofileSender sends the Generatevirtualwanvpnserverconfigurationvpnprofile request. The method will close the 386// http.Response Body if it receives an error. 387func (client BaseClient) GeneratevirtualwanvpnserverconfigurationvpnprofileSender(req *http.Request) (future GeneratevirtualwanvpnserverconfigurationvpnprofileFuture, err error) { 388 var resp *http.Response 389 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 390 if err != nil { 391 return 392 } 393 future.Future, err = azure.NewFutureFromResponse(resp) 394 return 395} 396 397// GeneratevirtualwanvpnserverconfigurationvpnprofileResponder handles the response to the Generatevirtualwanvpnserverconfigurationvpnprofile request. The method always 398// closes the http.Response Body. 399func (client BaseClient) GeneratevirtualwanvpnserverconfigurationvpnprofileResponder(resp *http.Response) (result VpnProfileResponse, err error) { 400 err = autorest.Respond( 401 resp, 402 client.ByInspecting(), 403 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 404 autorest.ByUnmarshallingJSON(&result), 405 autorest.ByClosing()) 406 result.Response = autorest.Response{Response: resp} 407 return 408} 409 410// GetActiveSessions returns the list of currently active sessions on the Bastion. 411// Parameters: 412// resourceGroupName - the name of the resource group. 413// bastionHostName - the name of the Bastion Host. 414func (client BaseClient) GetActiveSessions(ctx context.Context, resourceGroupName string, bastionHostName string) (result GetActiveSessionsFuture, err error) { 415 if tracing.IsEnabled() { 416 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.GetActiveSessions") 417 defer func() { 418 sc := -1 419 if result.Response() != nil { 420 sc = result.Response().StatusCode 421 } 422 tracing.EndSpan(ctx, sc, err) 423 }() 424 } 425 req, err := client.GetActiveSessionsPreparer(ctx, resourceGroupName, bastionHostName) 426 if err != nil { 427 err = autorest.NewErrorWithError(err, "network.BaseClient", "GetActiveSessions", nil, "Failure preparing request") 428 return 429 } 430 431 result, err = client.GetActiveSessionsSender(req) 432 if err != nil { 433 err = autorest.NewErrorWithError(err, "network.BaseClient", "GetActiveSessions", result.Response(), "Failure sending request") 434 return 435 } 436 437 return 438} 439 440// GetActiveSessionsPreparer prepares the GetActiveSessions request. 441func (client BaseClient) GetActiveSessionsPreparer(ctx context.Context, resourceGroupName string, bastionHostName string) (*http.Request, error) { 442 pathParameters := map[string]interface{}{ 443 "bastionHostName": autorest.Encode("path", bastionHostName), 444 "resourceGroupName": autorest.Encode("path", resourceGroupName), 445 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 446 } 447 448 const APIVersion = "2020-03-01" 449 queryParameters := map[string]interface{}{ 450 "api-version": APIVersion, 451 } 452 453 preparer := autorest.CreatePreparer( 454 autorest.AsPost(), 455 autorest.WithBaseURL(client.BaseURI), 456 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/bastionHosts/{bastionHostName}/getActiveSessions", pathParameters), 457 autorest.WithQueryParameters(queryParameters)) 458 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 459} 460 461// GetActiveSessionsSender sends the GetActiveSessions request. The method will close the 462// http.Response Body if it receives an error. 463func (client BaseClient) GetActiveSessionsSender(req *http.Request) (future GetActiveSessionsFuture, err error) { 464 var resp *http.Response 465 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 466 if err != nil { 467 return 468 } 469 future.Future, err = azure.NewFutureFromResponse(resp) 470 return 471} 472 473// GetActiveSessionsResponder handles the response to the GetActiveSessions request. The method always 474// closes the http.Response Body. 475func (client BaseClient) GetActiveSessionsResponder(resp *http.Response) (result BastionActiveSessionListResultPage, err error) { 476 result.baslr, err = client.getActiveSessionsResponder(resp) 477 result.fn = client.getActiveSessionsNextResults 478 return 479} 480 481func (client BaseClient) getActiveSessionsResponder(resp *http.Response) (result BastionActiveSessionListResult, err error) { 482 err = autorest.Respond( 483 resp, 484 client.ByInspecting(), 485 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 486 autorest.ByUnmarshallingJSON(&result), 487 autorest.ByClosing()) 488 result.Response = autorest.Response{Response: resp} 489 return 490} 491 492// getActiveSessionsNextResults retrieves the next set of results, if any. 493func (client BaseClient) getActiveSessionsNextResults(ctx context.Context, lastResults BastionActiveSessionListResult) (result BastionActiveSessionListResult, err error) { 494 req, err := lastResults.bastionActiveSessionListResultPreparer(ctx) 495 if err != nil { 496 return result, autorest.NewErrorWithError(err, "network.BaseClient", "getActiveSessionsNextResults", nil, "Failure preparing next results request") 497 } 498 if req == nil { 499 return 500 } 501 var resp *http.Response 502 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 503 if err != nil { 504 return result, autorest.NewErrorWithError(err, "network.BaseClient", "getActiveSessionsNextResults", resp, "Failure sending next results request") 505 } 506 return client.getActiveSessionsResponder(resp) 507} 508 509// GetActiveSessionsComplete enumerates all values, automatically crossing page boundaries as required. 510func (client BaseClient) GetActiveSessionsComplete(ctx context.Context, resourceGroupName string, bastionHostName string) (result GetActiveSessionsAllFuture, err error) { 511 if tracing.IsEnabled() { 512 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.GetActiveSessions") 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 var future GetActiveSessionsFuture 522 future, err = client.GetActiveSessions(ctx, resourceGroupName, bastionHostName) 523 result.Future = future.Future 524 return 525} 526 527// GetBastionShareableLink return the Bastion Shareable Links for all the VMs specified in the request. 528// Parameters: 529// resourceGroupName - the name of the resource group. 530// bastionHostName - the name of the Bastion Host. 531// bslRequest - post request for all the Bastion Shareable Link endpoints. 532func (client BaseClient) GetBastionShareableLink(ctx context.Context, resourceGroupName string, bastionHostName string, bslRequest BastionShareableLinkListRequest) (result BastionShareableLinkListResultPage, err error) { 533 if tracing.IsEnabled() { 534 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.GetBastionShareableLink") 535 defer func() { 536 sc := -1 537 if result.bsllr.Response.Response != nil { 538 sc = result.bsllr.Response.Response.StatusCode 539 } 540 tracing.EndSpan(ctx, sc, err) 541 }() 542 } 543 result.fn = client.getBastionShareableLinkNextResults 544 req, err := client.GetBastionShareableLinkPreparer(ctx, resourceGroupName, bastionHostName, bslRequest) 545 if err != nil { 546 err = autorest.NewErrorWithError(err, "network.BaseClient", "GetBastionShareableLink", nil, "Failure preparing request") 547 return 548 } 549 550 resp, err := client.GetBastionShareableLinkSender(req) 551 if err != nil { 552 result.bsllr.Response = autorest.Response{Response: resp} 553 err = autorest.NewErrorWithError(err, "network.BaseClient", "GetBastionShareableLink", resp, "Failure sending request") 554 return 555 } 556 557 result.bsllr, err = client.GetBastionShareableLinkResponder(resp) 558 if err != nil { 559 err = autorest.NewErrorWithError(err, "network.BaseClient", "GetBastionShareableLink", resp, "Failure responding to request") 560 } 561 562 return 563} 564 565// GetBastionShareableLinkPreparer prepares the GetBastionShareableLink request. 566func (client BaseClient) GetBastionShareableLinkPreparer(ctx context.Context, resourceGroupName string, bastionHostName string, bslRequest BastionShareableLinkListRequest) (*http.Request, error) { 567 pathParameters := map[string]interface{}{ 568 "bastionHostName": autorest.Encode("path", bastionHostName), 569 "resourceGroupName": autorest.Encode("path", resourceGroupName), 570 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 571 } 572 573 const APIVersion = "2020-03-01" 574 queryParameters := map[string]interface{}{ 575 "api-version": APIVersion, 576 } 577 578 preparer := autorest.CreatePreparer( 579 autorest.AsContentType("application/json; charset=utf-8"), 580 autorest.AsPost(), 581 autorest.WithBaseURL(client.BaseURI), 582 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/bastionHosts/{bastionHostName}/getShareableLinks", pathParameters), 583 autorest.WithJSON(bslRequest), 584 autorest.WithQueryParameters(queryParameters)) 585 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 586} 587 588// GetBastionShareableLinkSender sends the GetBastionShareableLink request. The method will close the 589// http.Response Body if it receives an error. 590func (client BaseClient) GetBastionShareableLinkSender(req *http.Request) (*http.Response, error) { 591 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 592} 593 594// GetBastionShareableLinkResponder handles the response to the GetBastionShareableLink request. The method always 595// closes the http.Response Body. 596func (client BaseClient) GetBastionShareableLinkResponder(resp *http.Response) (result BastionShareableLinkListResult, err error) { 597 err = autorest.Respond( 598 resp, 599 client.ByInspecting(), 600 azure.WithErrorUnlessStatusCode(http.StatusOK), 601 autorest.ByUnmarshallingJSON(&result), 602 autorest.ByClosing()) 603 result.Response = autorest.Response{Response: resp} 604 return 605} 606 607// getBastionShareableLinkNextResults retrieves the next set of results, if any. 608func (client BaseClient) getBastionShareableLinkNextResults(ctx context.Context, lastResults BastionShareableLinkListResult) (result BastionShareableLinkListResult, err error) { 609 req, err := lastResults.bastionShareableLinkListResultPreparer(ctx) 610 if err != nil { 611 return result, autorest.NewErrorWithError(err, "network.BaseClient", "getBastionShareableLinkNextResults", nil, "Failure preparing next results request") 612 } 613 if req == nil { 614 return 615 } 616 resp, err := client.GetBastionShareableLinkSender(req) 617 if err != nil { 618 result.Response = autorest.Response{Response: resp} 619 return result, autorest.NewErrorWithError(err, "network.BaseClient", "getBastionShareableLinkNextResults", resp, "Failure sending next results request") 620 } 621 result, err = client.GetBastionShareableLinkResponder(resp) 622 if err != nil { 623 err = autorest.NewErrorWithError(err, "network.BaseClient", "getBastionShareableLinkNextResults", resp, "Failure responding to next results request") 624 } 625 return 626} 627 628// GetBastionShareableLinkComplete enumerates all values, automatically crossing page boundaries as required. 629func (client BaseClient) GetBastionShareableLinkComplete(ctx context.Context, resourceGroupName string, bastionHostName string, bslRequest BastionShareableLinkListRequest) (result BastionShareableLinkListResultIterator, err error) { 630 if tracing.IsEnabled() { 631 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.GetBastionShareableLink") 632 defer func() { 633 sc := -1 634 if result.Response().Response.Response != nil { 635 sc = result.page.Response().Response.Response.StatusCode 636 } 637 tracing.EndSpan(ctx, sc, err) 638 }() 639 } 640 result.page, err = client.GetBastionShareableLink(ctx, resourceGroupName, bastionHostName, bslRequest) 641 return 642} 643 644// PutBastionShareableLink creates a Bastion Shareable Links for all the VMs specified in the request. 645// Parameters: 646// resourceGroupName - the name of the resource group. 647// bastionHostName - the name of the Bastion Host. 648// bslRequest - post request for all the Bastion Shareable Link endpoints. 649func (client BaseClient) PutBastionShareableLink(ctx context.Context, resourceGroupName string, bastionHostName string, bslRequest BastionShareableLinkListRequest) (result PutBastionShareableLinkFuture, err error) { 650 if tracing.IsEnabled() { 651 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.PutBastionShareableLink") 652 defer func() { 653 sc := -1 654 if result.Response() != nil { 655 sc = result.Response().StatusCode 656 } 657 tracing.EndSpan(ctx, sc, err) 658 }() 659 } 660 req, err := client.PutBastionShareableLinkPreparer(ctx, resourceGroupName, bastionHostName, bslRequest) 661 if err != nil { 662 err = autorest.NewErrorWithError(err, "network.BaseClient", "PutBastionShareableLink", nil, "Failure preparing request") 663 return 664 } 665 666 result, err = client.PutBastionShareableLinkSender(req) 667 if err != nil { 668 err = autorest.NewErrorWithError(err, "network.BaseClient", "PutBastionShareableLink", result.Response(), "Failure sending request") 669 return 670 } 671 672 return 673} 674 675// PutBastionShareableLinkPreparer prepares the PutBastionShareableLink request. 676func (client BaseClient) PutBastionShareableLinkPreparer(ctx context.Context, resourceGroupName string, bastionHostName string, bslRequest BastionShareableLinkListRequest) (*http.Request, error) { 677 pathParameters := map[string]interface{}{ 678 "bastionHostName": autorest.Encode("path", bastionHostName), 679 "resourceGroupName": autorest.Encode("path", resourceGroupName), 680 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 681 } 682 683 const APIVersion = "2020-03-01" 684 queryParameters := map[string]interface{}{ 685 "api-version": APIVersion, 686 } 687 688 preparer := autorest.CreatePreparer( 689 autorest.AsContentType("application/json; charset=utf-8"), 690 autorest.AsPost(), 691 autorest.WithBaseURL(client.BaseURI), 692 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/bastionHosts/{bastionHostName}/createShareableLinks", pathParameters), 693 autorest.WithJSON(bslRequest), 694 autorest.WithQueryParameters(queryParameters)) 695 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 696} 697 698// PutBastionShareableLinkSender sends the PutBastionShareableLink request. The method will close the 699// http.Response Body if it receives an error. 700func (client BaseClient) PutBastionShareableLinkSender(req *http.Request) (future PutBastionShareableLinkFuture, err error) { 701 var resp *http.Response 702 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 703 if err != nil { 704 return 705 } 706 future.Future, err = azure.NewFutureFromResponse(resp) 707 return 708} 709 710// PutBastionShareableLinkResponder handles the response to the PutBastionShareableLink request. The method always 711// closes the http.Response Body. 712func (client BaseClient) PutBastionShareableLinkResponder(resp *http.Response) (result BastionShareableLinkListResultPage, err error) { 713 result.bsllr, err = client.putBastionShareableLinkResponder(resp) 714 result.fn = client.putBastionShareableLinkNextResults 715 return 716} 717 718func (client BaseClient) putBastionShareableLinkResponder(resp *http.Response) (result BastionShareableLinkListResult, err error) { 719 err = autorest.Respond( 720 resp, 721 client.ByInspecting(), 722 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 723 autorest.ByUnmarshallingJSON(&result), 724 autorest.ByClosing()) 725 result.Response = autorest.Response{Response: resp} 726 return 727} 728 729// putBastionShareableLinkNextResults retrieves the next set of results, if any. 730func (client BaseClient) putBastionShareableLinkNextResults(ctx context.Context, lastResults BastionShareableLinkListResult) (result BastionShareableLinkListResult, err error) { 731 req, err := lastResults.bastionShareableLinkListResultPreparer(ctx) 732 if err != nil { 733 return result, autorest.NewErrorWithError(err, "network.BaseClient", "putBastionShareableLinkNextResults", nil, "Failure preparing next results request") 734 } 735 if req == nil { 736 return 737 } 738 var resp *http.Response 739 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 740 if err != nil { 741 return result, autorest.NewErrorWithError(err, "network.BaseClient", "putBastionShareableLinkNextResults", resp, "Failure sending next results request") 742 } 743 return client.putBastionShareableLinkResponder(resp) 744} 745 746// PutBastionShareableLinkComplete enumerates all values, automatically crossing page boundaries as required. 747func (client BaseClient) PutBastionShareableLinkComplete(ctx context.Context, resourceGroupName string, bastionHostName string, bslRequest BastionShareableLinkListRequest) (result PutBastionShareableLinkAllFuture, err error) { 748 if tracing.IsEnabled() { 749 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.PutBastionShareableLink") 750 defer func() { 751 sc := -1 752 if result.Response() != nil { 753 sc = result.Response().StatusCode 754 } 755 tracing.EndSpan(ctx, sc, err) 756 }() 757 } 758 var future PutBastionShareableLinkFuture 759 future, err = client.PutBastionShareableLink(ctx, resourceGroupName, bastionHostName, bslRequest) 760 result.Future = future.Future 761 return 762} 763 764// SupportedSecurityProviders gives the supported security providers for the virtual wan. 765// Parameters: 766// resourceGroupName - the resource group name. 767// virtualWANName - the name of the VirtualWAN for which supported security providers are needed. 768func (client BaseClient) SupportedSecurityProviders(ctx context.Context, resourceGroupName string, virtualWANName string) (result VirtualWanSecurityProviders, err error) { 769 if tracing.IsEnabled() { 770 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.SupportedSecurityProviders") 771 defer func() { 772 sc := -1 773 if result.Response.Response != nil { 774 sc = result.Response.Response.StatusCode 775 } 776 tracing.EndSpan(ctx, sc, err) 777 }() 778 } 779 req, err := client.SupportedSecurityProvidersPreparer(ctx, resourceGroupName, virtualWANName) 780 if err != nil { 781 err = autorest.NewErrorWithError(err, "network.BaseClient", "SupportedSecurityProviders", nil, "Failure preparing request") 782 return 783 } 784 785 resp, err := client.SupportedSecurityProvidersSender(req) 786 if err != nil { 787 result.Response = autorest.Response{Response: resp} 788 err = autorest.NewErrorWithError(err, "network.BaseClient", "SupportedSecurityProviders", resp, "Failure sending request") 789 return 790 } 791 792 result, err = client.SupportedSecurityProvidersResponder(resp) 793 if err != nil { 794 err = autorest.NewErrorWithError(err, "network.BaseClient", "SupportedSecurityProviders", resp, "Failure responding to request") 795 } 796 797 return 798} 799 800// SupportedSecurityProvidersPreparer prepares the SupportedSecurityProviders request. 801func (client BaseClient) SupportedSecurityProvidersPreparer(ctx context.Context, resourceGroupName string, virtualWANName string) (*http.Request, error) { 802 pathParameters := map[string]interface{}{ 803 "resourceGroupName": autorest.Encode("path", resourceGroupName), 804 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 805 "virtualWANName": autorest.Encode("path", virtualWANName), 806 } 807 808 const APIVersion = "2020-03-01" 809 queryParameters := map[string]interface{}{ 810 "api-version": APIVersion, 811 } 812 813 preparer := autorest.CreatePreparer( 814 autorest.AsGet(), 815 autorest.WithBaseURL(client.BaseURI), 816 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/supportedSecurityProviders", pathParameters), 817 autorest.WithQueryParameters(queryParameters)) 818 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 819} 820 821// SupportedSecurityProvidersSender sends the SupportedSecurityProviders request. The method will close the 822// http.Response Body if it receives an error. 823func (client BaseClient) SupportedSecurityProvidersSender(req *http.Request) (*http.Response, error) { 824 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 825} 826 827// SupportedSecurityProvidersResponder handles the response to the SupportedSecurityProviders request. The method always 828// closes the http.Response Body. 829func (client BaseClient) SupportedSecurityProvidersResponder(resp *http.Response) (result VirtualWanSecurityProviders, err error) { 830 err = autorest.Respond( 831 resp, 832 client.ByInspecting(), 833 azure.WithErrorUnlessStatusCode(http.StatusOK), 834 autorest.ByUnmarshallingJSON(&result), 835 autorest.ByClosing()) 836 result.Response = autorest.Response{Response: resp} 837 return 838} 839