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/autorest/validation" 25 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// VirtualNetworkGatewayConnectionsClient is the network Client 30type VirtualNetworkGatewayConnectionsClient struct { 31 BaseClient 32} 33 34// NewVirtualNetworkGatewayConnectionsClient creates an instance of the VirtualNetworkGatewayConnectionsClient client. 35func NewVirtualNetworkGatewayConnectionsClient(subscriptionID string) VirtualNetworkGatewayConnectionsClient { 36 return NewVirtualNetworkGatewayConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewVirtualNetworkGatewayConnectionsClientWithBaseURI creates an instance of the 40// VirtualNetworkGatewayConnectionsClient client using a custom endpoint. Use this when interacting with an Azure 41// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 42func NewVirtualNetworkGatewayConnectionsClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkGatewayConnectionsClient { 43 return VirtualNetworkGatewayConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// CreateOrUpdate creates or updates a virtual network gateway connection in the specified resource group. 47// Parameters: 48// resourceGroupName - the name of the resource group. 49// virtualNetworkGatewayConnectionName - the name of the virtual network gateway connection. 50// parameters - parameters supplied to the create or update virtual network gateway connection operation. 51func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VirtualNetworkGatewayConnection) (result VirtualNetworkGatewayConnectionsCreateOrUpdateFuture, err error) { 52 if tracing.IsEnabled() { 53 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewayConnectionsClient.CreateOrUpdate") 54 defer func() { 55 sc := -1 56 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 57 sc = result.FutureAPI.Response().StatusCode 58 } 59 tracing.EndSpan(ctx, sc, err) 60 }() 61 } 62 if err := validation.Validate([]validation.Validation{ 63 {TargetValue: parameters, 64 Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat", Name: validation.Null, Rule: true, 65 Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1", Name: validation.Null, Rule: true, 66 Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}, 67 {Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2", Name: validation.Null, Rule: false, 68 Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}, 69 {Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2", Name: validation.Null, Rule: false, 70 Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}, 71 }}}}}); err != nil { 72 return result, validation.NewError("network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", err.Error()) 73 } 74 75 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters) 76 if err != nil { 77 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") 78 return 79 } 80 81 result, err = client.CreateOrUpdateSender(req) 82 if err != nil { 83 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", nil, "Failure sending request") 84 return 85 } 86 87 return 88} 89 90// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 91func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VirtualNetworkGatewayConnection) (*http.Request, error) { 92 pathParameters := map[string]interface{}{ 93 "resourceGroupName": autorest.Encode("path", resourceGroupName), 94 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 95 "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), 96 } 97 98 const APIVersion = "2018-02-01" 99 queryParameters := map[string]interface{}{ 100 "api-version": APIVersion, 101 } 102 103 preparer := autorest.CreatePreparer( 104 autorest.AsContentType("application/json; charset=utf-8"), 105 autorest.AsPut(), 106 autorest.WithBaseURL(client.BaseURI), 107 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters), 108 autorest.WithJSON(parameters), 109 autorest.WithQueryParameters(queryParameters)) 110 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 111} 112 113// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 114// http.Response Body if it receives an error. 115func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkGatewayConnectionsCreateOrUpdateFuture, err error) { 116 var resp *http.Response 117 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 118 if err != nil { 119 return 120 } 121 var azf azure.Future 122 azf, err = azure.NewFutureFromResponse(resp) 123 future.FutureAPI = &azf 124 future.Result = func(client VirtualNetworkGatewayConnectionsClient) (vngc VirtualNetworkGatewayConnection, err error) { 125 var done bool 126 done, err = future.DoneWithContext(context.Background(), client) 127 if err != nil { 128 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") 129 return 130 } 131 if !done { 132 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewayConnectionsCreateOrUpdateFuture") 133 return 134 } 135 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 136 vngc.Response.Response, err = future.GetResult(sender) 137 if vngc.Response.Response == nil && err == nil { 138 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsCreateOrUpdateFuture", "Result", nil, "received nil response and error") 139 } 140 if err == nil && vngc.Response.Response.StatusCode != http.StatusNoContent { 141 vngc, err = client.CreateOrUpdateResponder(vngc.Response.Response) 142 if err != nil { 143 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsCreateOrUpdateFuture", "Result", vngc.Response.Response, "Failure responding to request") 144 } 145 } 146 return 147 } 148 return 149} 150 151// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 152// closes the http.Response Body. 153func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGatewayConnection, err error) { 154 err = autorest.Respond( 155 resp, 156 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 157 autorest.ByUnmarshallingJSON(&result), 158 autorest.ByClosing()) 159 result.Response = autorest.Response{Response: resp} 160 return 161} 162 163// Delete deletes the specified virtual network Gateway connection. 164// Parameters: 165// resourceGroupName - the name of the resource group. 166// virtualNetworkGatewayConnectionName - the name of the virtual network gateway connection. 167func (client VirtualNetworkGatewayConnectionsClient) Delete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (result VirtualNetworkGatewayConnectionsDeleteFuture, err error) { 168 if tracing.IsEnabled() { 169 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewayConnectionsClient.Delete") 170 defer func() { 171 sc := -1 172 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 173 sc = result.FutureAPI.Response().StatusCode 174 } 175 tracing.EndSpan(ctx, sc, err) 176 }() 177 } 178 req, err := client.DeletePreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName) 179 if err != nil { 180 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", nil, "Failure preparing request") 181 return 182 } 183 184 result, err = client.DeleteSender(req) 185 if err != nil { 186 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", nil, "Failure sending request") 187 return 188 } 189 190 return 191} 192 193// DeletePreparer prepares the Delete request. 194func (client VirtualNetworkGatewayConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (*http.Request, error) { 195 pathParameters := map[string]interface{}{ 196 "resourceGroupName": autorest.Encode("path", resourceGroupName), 197 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 198 "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), 199 } 200 201 const APIVersion = "2018-02-01" 202 queryParameters := map[string]interface{}{ 203 "api-version": APIVersion, 204 } 205 206 preparer := autorest.CreatePreparer( 207 autorest.AsDelete(), 208 autorest.WithBaseURL(client.BaseURI), 209 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters), 210 autorest.WithQueryParameters(queryParameters)) 211 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 212} 213 214// DeleteSender sends the Delete request. The method will close the 215// http.Response Body if it receives an error. 216func (client VirtualNetworkGatewayConnectionsClient) DeleteSender(req *http.Request) (future VirtualNetworkGatewayConnectionsDeleteFuture, err error) { 217 var resp *http.Response 218 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 219 if err != nil { 220 return 221 } 222 var azf azure.Future 223 azf, err = azure.NewFutureFromResponse(resp) 224 future.FutureAPI = &azf 225 future.Result = func(client VirtualNetworkGatewayConnectionsClient) (ar autorest.Response, err error) { 226 var done bool 227 done, err = future.DoneWithContext(context.Background(), client) 228 if err != nil { 229 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") 230 return 231 } 232 if !done { 233 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewayConnectionsDeleteFuture") 234 return 235 } 236 ar.Response = future.Response() 237 return 238 } 239 return 240} 241 242// DeleteResponder handles the response to the Delete request. The method always 243// closes the http.Response Body. 244func (client VirtualNetworkGatewayConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 245 err = autorest.Respond( 246 resp, 247 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 248 autorest.ByClosing()) 249 result.Response = resp 250 return 251} 252 253// Get gets the specified virtual network gateway connection by resource group. 254// Parameters: 255// resourceGroupName - the name of the resource group. 256// virtualNetworkGatewayConnectionName - the name of the virtual network gateway connection. 257func (client VirtualNetworkGatewayConnectionsClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (result VirtualNetworkGatewayConnection, err error) { 258 if tracing.IsEnabled() { 259 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewayConnectionsClient.Get") 260 defer func() { 261 sc := -1 262 if result.Response.Response != nil { 263 sc = result.Response.Response.StatusCode 264 } 265 tracing.EndSpan(ctx, sc, err) 266 }() 267 } 268 req, err := client.GetPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName) 269 if err != nil { 270 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", nil, "Failure preparing request") 271 return 272 } 273 274 resp, err := client.GetSender(req) 275 if err != nil { 276 result.Response = autorest.Response{Response: resp} 277 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", resp, "Failure sending request") 278 return 279 } 280 281 result, err = client.GetResponder(resp) 282 if err != nil { 283 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", resp, "Failure responding to request") 284 return 285 } 286 287 return 288} 289 290// GetPreparer prepares the Get request. 291func (client VirtualNetworkGatewayConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (*http.Request, error) { 292 pathParameters := map[string]interface{}{ 293 "resourceGroupName": autorest.Encode("path", resourceGroupName), 294 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 295 "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), 296 } 297 298 const APIVersion = "2018-02-01" 299 queryParameters := map[string]interface{}{ 300 "api-version": APIVersion, 301 } 302 303 preparer := autorest.CreatePreparer( 304 autorest.AsGet(), 305 autorest.WithBaseURL(client.BaseURI), 306 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters), 307 autorest.WithQueryParameters(queryParameters)) 308 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 309} 310 311// GetSender sends the Get request. The method will close the 312// http.Response Body if it receives an error. 313func (client VirtualNetworkGatewayConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { 314 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 315} 316 317// GetResponder handles the response to the Get request. The method always 318// closes the http.Response Body. 319func (client VirtualNetworkGatewayConnectionsClient) GetResponder(resp *http.Response) (result VirtualNetworkGatewayConnection, err error) { 320 err = autorest.Respond( 321 resp, 322 azure.WithErrorUnlessStatusCode(http.StatusOK), 323 autorest.ByUnmarshallingJSON(&result), 324 autorest.ByClosing()) 325 result.Response = autorest.Response{Response: resp} 326 return 327} 328 329// GetSharedKey the Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified 330// virtual network gateway connection shared key through Network resource provider. 331// Parameters: 332// resourceGroupName - the name of the resource group. 333// virtualNetworkGatewayConnectionName - the virtual network gateway connection shared key name. 334func (client VirtualNetworkGatewayConnectionsClient) GetSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (result ConnectionSharedKey, err error) { 335 if tracing.IsEnabled() { 336 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewayConnectionsClient.GetSharedKey") 337 defer func() { 338 sc := -1 339 if result.Response.Response != nil { 340 sc = result.Response.Response.StatusCode 341 } 342 tracing.EndSpan(ctx, sc, err) 343 }() 344 } 345 req, err := client.GetSharedKeyPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName) 346 if err != nil { 347 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", nil, "Failure preparing request") 348 return 349 } 350 351 resp, err := client.GetSharedKeySender(req) 352 if err != nil { 353 result.Response = autorest.Response{Response: resp} 354 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", resp, "Failure sending request") 355 return 356 } 357 358 result, err = client.GetSharedKeyResponder(resp) 359 if err != nil { 360 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", resp, "Failure responding to request") 361 return 362 } 363 364 return 365} 366 367// GetSharedKeyPreparer prepares the GetSharedKey request. 368func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeyPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (*http.Request, error) { 369 pathParameters := map[string]interface{}{ 370 "resourceGroupName": autorest.Encode("path", resourceGroupName), 371 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 372 "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), 373 } 374 375 const APIVersion = "2018-02-01" 376 queryParameters := map[string]interface{}{ 377 "api-version": APIVersion, 378 } 379 380 preparer := autorest.CreatePreparer( 381 autorest.AsGet(), 382 autorest.WithBaseURL(client.BaseURI), 383 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey", pathParameters), 384 autorest.WithQueryParameters(queryParameters)) 385 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 386} 387 388// GetSharedKeySender sends the GetSharedKey request. The method will close the 389// http.Response Body if it receives an error. 390func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeySender(req *http.Request) (*http.Response, error) { 391 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 392} 393 394// GetSharedKeyResponder handles the response to the GetSharedKey request. The method always 395// closes the http.Response Body. 396func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeyResponder(resp *http.Response) (result ConnectionSharedKey, err error) { 397 err = autorest.Respond( 398 resp, 399 azure.WithErrorUnlessStatusCode(http.StatusOK), 400 autorest.ByUnmarshallingJSON(&result), 401 autorest.ByClosing()) 402 result.Response = autorest.Response{Response: resp} 403 return 404} 405 406// List the List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections 407// created. 408// Parameters: 409// resourceGroupName - the name of the resource group. 410func (client VirtualNetworkGatewayConnectionsClient) List(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayConnectionListResultPage, err error) { 411 if tracing.IsEnabled() { 412 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewayConnectionsClient.List") 413 defer func() { 414 sc := -1 415 if result.vngclr.Response.Response != nil { 416 sc = result.vngclr.Response.Response.StatusCode 417 } 418 tracing.EndSpan(ctx, sc, err) 419 }() 420 } 421 result.fn = client.listNextResults 422 req, err := client.ListPreparer(ctx, resourceGroupName) 423 if err != nil { 424 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", nil, "Failure preparing request") 425 return 426 } 427 428 resp, err := client.ListSender(req) 429 if err != nil { 430 result.vngclr.Response = autorest.Response{Response: resp} 431 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", resp, "Failure sending request") 432 return 433 } 434 435 result.vngclr, err = client.ListResponder(resp) 436 if err != nil { 437 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", resp, "Failure responding to request") 438 return 439 } 440 if result.vngclr.hasNextLink() && result.vngclr.IsEmpty() { 441 err = result.NextWithContext(ctx) 442 return 443 } 444 445 return 446} 447 448// ListPreparer prepares the List request. 449func (client VirtualNetworkGatewayConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 450 pathParameters := map[string]interface{}{ 451 "resourceGroupName": autorest.Encode("path", resourceGroupName), 452 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 453 } 454 455 const APIVersion = "2018-02-01" 456 queryParameters := map[string]interface{}{ 457 "api-version": APIVersion, 458 } 459 460 preparer := autorest.CreatePreparer( 461 autorest.AsGet(), 462 autorest.WithBaseURL(client.BaseURI), 463 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections", pathParameters), 464 autorest.WithQueryParameters(queryParameters)) 465 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 466} 467 468// ListSender sends the List request. The method will close the 469// http.Response Body if it receives an error. 470func (client VirtualNetworkGatewayConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { 471 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 472} 473 474// ListResponder handles the response to the List request. The method always 475// closes the http.Response Body. 476func (client VirtualNetworkGatewayConnectionsClient) ListResponder(resp *http.Response) (result VirtualNetworkGatewayConnectionListResult, err error) { 477 err = autorest.Respond( 478 resp, 479 azure.WithErrorUnlessStatusCode(http.StatusOK), 480 autorest.ByUnmarshallingJSON(&result), 481 autorest.ByClosing()) 482 result.Response = autorest.Response{Response: resp} 483 return 484} 485 486// listNextResults retrieves the next set of results, if any. 487func (client VirtualNetworkGatewayConnectionsClient) listNextResults(ctx context.Context, lastResults VirtualNetworkGatewayConnectionListResult) (result VirtualNetworkGatewayConnectionListResult, err error) { 488 req, err := lastResults.virtualNetworkGatewayConnectionListResultPreparer(ctx) 489 if err != nil { 490 return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "listNextResults", nil, "Failure preparing next results request") 491 } 492 if req == nil { 493 return 494 } 495 resp, err := client.ListSender(req) 496 if err != nil { 497 result.Response = autorest.Response{Response: resp} 498 return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "listNextResults", resp, "Failure sending next results request") 499 } 500 result, err = client.ListResponder(resp) 501 if err != nil { 502 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "listNextResults", resp, "Failure responding to next results request") 503 } 504 return 505} 506 507// ListComplete enumerates all values, automatically crossing page boundaries as required. 508func (client VirtualNetworkGatewayConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayConnectionListResultIterator, err error) { 509 if tracing.IsEnabled() { 510 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewayConnectionsClient.List") 511 defer func() { 512 sc := -1 513 if result.Response().Response.Response != nil { 514 sc = result.page.Response().Response.Response.StatusCode 515 } 516 tracing.EndSpan(ctx, sc, err) 517 }() 518 } 519 result.page, err = client.List(ctx, resourceGroupName) 520 return 521} 522 523// ResetSharedKey the VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway 524// connection shared key for passed virtual network gateway connection in the specified resource group through Network 525// resource provider. 526// Parameters: 527// resourceGroupName - the name of the resource group. 528// virtualNetworkGatewayConnectionName - the virtual network gateway connection reset shared key Name. 529// parameters - parameters supplied to the begin reset virtual network gateway connection shared key operation 530// through network resource provider. 531func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionResetSharedKey) (result VirtualNetworkGatewayConnectionsResetSharedKeyFuture, err error) { 532 if tracing.IsEnabled() { 533 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewayConnectionsClient.ResetSharedKey") 534 defer func() { 535 sc := -1 536 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 537 sc = result.FutureAPI.Response().StatusCode 538 } 539 tracing.EndSpan(ctx, sc, err) 540 }() 541 } 542 if err := validation.Validate([]validation.Validation{ 543 {TargetValue: parameters, 544 Constraints: []validation.Constraint{{Target: "parameters.KeyLength", Name: validation.Null, Rule: true, 545 Chain: []validation.Constraint{{Target: "parameters.KeyLength", Name: validation.InclusiveMaximum, Rule: int64(128), Chain: nil}, 546 {Target: "parameters.KeyLength", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, 547 }}}}}); err != nil { 548 return result, validation.NewError("network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", err.Error()) 549 } 550 551 req, err := client.ResetSharedKeyPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters) 552 if err != nil { 553 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", nil, "Failure preparing request") 554 return 555 } 556 557 result, err = client.ResetSharedKeySender(req) 558 if err != nil { 559 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", nil, "Failure sending request") 560 return 561 } 562 563 return 564} 565 566// ResetSharedKeyPreparer prepares the ResetSharedKey request. 567func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionResetSharedKey) (*http.Request, error) { 568 pathParameters := map[string]interface{}{ 569 "resourceGroupName": autorest.Encode("path", resourceGroupName), 570 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 571 "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), 572 } 573 574 const APIVersion = "2018-02-01" 575 queryParameters := map[string]interface{}{ 576 "api-version": APIVersion, 577 } 578 579 preparer := autorest.CreatePreparer( 580 autorest.AsContentType("application/json; charset=utf-8"), 581 autorest.AsPost(), 582 autorest.WithBaseURL(client.BaseURI), 583 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey/reset", pathParameters), 584 autorest.WithJSON(parameters), 585 autorest.WithQueryParameters(queryParameters)) 586 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 587} 588 589// ResetSharedKeySender sends the ResetSharedKey request. The method will close the 590// http.Response Body if it receives an error. 591func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeySender(req *http.Request) (future VirtualNetworkGatewayConnectionsResetSharedKeyFuture, err error) { 592 var resp *http.Response 593 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 594 if err != nil { 595 return 596 } 597 var azf azure.Future 598 azf, err = azure.NewFutureFromResponse(resp) 599 future.FutureAPI = &azf 600 future.Result = func(client VirtualNetworkGatewayConnectionsClient) (crsk ConnectionResetSharedKey, err error) { 601 var done bool 602 done, err = future.DoneWithContext(context.Background(), client) 603 if err != nil { 604 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsResetSharedKeyFuture", "Result", future.Response(), "Polling failure") 605 return 606 } 607 if !done { 608 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewayConnectionsResetSharedKeyFuture") 609 return 610 } 611 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 612 crsk.Response.Response, err = future.GetResult(sender) 613 if crsk.Response.Response == nil && err == nil { 614 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsResetSharedKeyFuture", "Result", nil, "received nil response and error") 615 } 616 if err == nil && crsk.Response.Response.StatusCode != http.StatusNoContent { 617 crsk, err = client.ResetSharedKeyResponder(crsk.Response.Response) 618 if err != nil { 619 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsResetSharedKeyFuture", "Result", crsk.Response.Response, "Failure responding to request") 620 } 621 } 622 return 623 } 624 return 625} 626 627// ResetSharedKeyResponder handles the response to the ResetSharedKey request. The method always 628// closes the http.Response Body. 629func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyResponder(resp *http.Response) (result ConnectionResetSharedKey, err error) { 630 err = autorest.Respond( 631 resp, 632 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 633 autorest.ByUnmarshallingJSON(&result), 634 autorest.ByClosing()) 635 result.Response = autorest.Response{Response: resp} 636 return 637} 638 639// SetSharedKey the Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection 640// shared key for passed virtual network gateway connection in the specified resource group through Network resource 641// provider. 642// Parameters: 643// resourceGroupName - the name of the resource group. 644// virtualNetworkGatewayConnectionName - the virtual network gateway connection name. 645// parameters - parameters supplied to the Begin Set Virtual Network Gateway connection Shared key operation 646// throughNetwork resource provider. 647func (client VirtualNetworkGatewayConnectionsClient) SetSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionSharedKey) (result VirtualNetworkGatewayConnectionsSetSharedKeyFuture, err error) { 648 if tracing.IsEnabled() { 649 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewayConnectionsClient.SetSharedKey") 650 defer func() { 651 sc := -1 652 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 653 sc = result.FutureAPI.Response().StatusCode 654 } 655 tracing.EndSpan(ctx, sc, err) 656 }() 657 } 658 if err := validation.Validate([]validation.Validation{ 659 {TargetValue: parameters, 660 Constraints: []validation.Constraint{{Target: "parameters.Value", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 661 return result, validation.NewError("network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", err.Error()) 662 } 663 664 req, err := client.SetSharedKeyPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters) 665 if err != nil { 666 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", nil, "Failure preparing request") 667 return 668 } 669 670 result, err = client.SetSharedKeySender(req) 671 if err != nil { 672 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", nil, "Failure sending request") 673 return 674 } 675 676 return 677} 678 679// SetSharedKeyPreparer prepares the SetSharedKey request. 680func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionSharedKey) (*http.Request, error) { 681 pathParameters := map[string]interface{}{ 682 "resourceGroupName": autorest.Encode("path", resourceGroupName), 683 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 684 "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), 685 } 686 687 const APIVersion = "2018-02-01" 688 queryParameters := map[string]interface{}{ 689 "api-version": APIVersion, 690 } 691 692 preparer := autorest.CreatePreparer( 693 autorest.AsContentType("application/json; charset=utf-8"), 694 autorest.AsPut(), 695 autorest.WithBaseURL(client.BaseURI), 696 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey", pathParameters), 697 autorest.WithJSON(parameters), 698 autorest.WithQueryParameters(queryParameters)) 699 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 700} 701 702// SetSharedKeySender sends the SetSharedKey request. The method will close the 703// http.Response Body if it receives an error. 704func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeySender(req *http.Request) (future VirtualNetworkGatewayConnectionsSetSharedKeyFuture, err error) { 705 var resp *http.Response 706 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 707 if err != nil { 708 return 709 } 710 var azf azure.Future 711 azf, err = azure.NewFutureFromResponse(resp) 712 future.FutureAPI = &azf 713 future.Result = func(client VirtualNetworkGatewayConnectionsClient) (csk ConnectionSharedKey, err error) { 714 var done bool 715 done, err = future.DoneWithContext(context.Background(), client) 716 if err != nil { 717 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsSetSharedKeyFuture", "Result", future.Response(), "Polling failure") 718 return 719 } 720 if !done { 721 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewayConnectionsSetSharedKeyFuture") 722 return 723 } 724 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 725 csk.Response.Response, err = future.GetResult(sender) 726 if csk.Response.Response == nil && err == nil { 727 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsSetSharedKeyFuture", "Result", nil, "received nil response and error") 728 } 729 if err == nil && csk.Response.Response.StatusCode != http.StatusNoContent { 730 csk, err = client.SetSharedKeyResponder(csk.Response.Response) 731 if err != nil { 732 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsSetSharedKeyFuture", "Result", csk.Response.Response, "Failure responding to request") 733 } 734 } 735 return 736 } 737 return 738} 739 740// SetSharedKeyResponder handles the response to the SetSharedKey request. The method always 741// closes the http.Response Body. 742func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyResponder(resp *http.Response) (result ConnectionSharedKey, err error) { 743 err = autorest.Respond( 744 resp, 745 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 746 autorest.ByUnmarshallingJSON(&result), 747 autorest.ByClosing()) 748 result.Response = autorest.Response{Response: resp} 749 return 750} 751 752// UpdateTags updates a virtual network gateway connection tags. 753// Parameters: 754// resourceGroupName - the name of the resource group. 755// virtualNetworkGatewayConnectionName - the name of the virtual network gateway connection. 756// parameters - parameters supplied to update virtual network gateway connection tags. 757func (client VirtualNetworkGatewayConnectionsClient) UpdateTags(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters TagsObject) (result VirtualNetworkGatewayConnectionsUpdateTagsFuture, err error) { 758 if tracing.IsEnabled() { 759 ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkGatewayConnectionsClient.UpdateTags") 760 defer func() { 761 sc := -1 762 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 763 sc = result.FutureAPI.Response().StatusCode 764 } 765 tracing.EndSpan(ctx, sc, err) 766 }() 767 } 768 req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters) 769 if err != nil { 770 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "UpdateTags", nil, "Failure preparing request") 771 return 772 } 773 774 result, err = client.UpdateTagsSender(req) 775 if err != nil { 776 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "UpdateTags", nil, "Failure sending request") 777 return 778 } 779 780 return 781} 782 783// UpdateTagsPreparer prepares the UpdateTags request. 784func (client VirtualNetworkGatewayConnectionsClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters TagsObject) (*http.Request, error) { 785 pathParameters := map[string]interface{}{ 786 "resourceGroupName": autorest.Encode("path", resourceGroupName), 787 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 788 "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), 789 } 790 791 const APIVersion = "2018-02-01" 792 queryParameters := map[string]interface{}{ 793 "api-version": APIVersion, 794 } 795 796 preparer := autorest.CreatePreparer( 797 autorest.AsContentType("application/json; charset=utf-8"), 798 autorest.AsPatch(), 799 autorest.WithBaseURL(client.BaseURI), 800 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters), 801 autorest.WithJSON(parameters), 802 autorest.WithQueryParameters(queryParameters)) 803 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 804} 805 806// UpdateTagsSender sends the UpdateTags request. The method will close the 807// http.Response Body if it receives an error. 808func (client VirtualNetworkGatewayConnectionsClient) UpdateTagsSender(req *http.Request) (future VirtualNetworkGatewayConnectionsUpdateTagsFuture, err error) { 809 var resp *http.Response 810 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 811 if err != nil { 812 return 813 } 814 var azf azure.Future 815 azf, err = azure.NewFutureFromResponse(resp) 816 future.FutureAPI = &azf 817 future.Result = func(client VirtualNetworkGatewayConnectionsClient) (vngcle VirtualNetworkGatewayConnectionListEntity, err error) { 818 var done bool 819 done, err = future.DoneWithContext(context.Background(), client) 820 if err != nil { 821 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsUpdateTagsFuture", "Result", future.Response(), "Polling failure") 822 return 823 } 824 if !done { 825 err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewayConnectionsUpdateTagsFuture") 826 return 827 } 828 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 829 vngcle.Response.Response, err = future.GetResult(sender) 830 if vngcle.Response.Response == nil && err == nil { 831 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsUpdateTagsFuture", "Result", nil, "received nil response and error") 832 } 833 if err == nil && vngcle.Response.Response.StatusCode != http.StatusNoContent { 834 vngcle, err = client.UpdateTagsResponder(vngcle.Response.Response) 835 if err != nil { 836 err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsUpdateTagsFuture", "Result", vngcle.Response.Response, "Failure responding to request") 837 } 838 } 839 return 840 } 841 return 842} 843 844// UpdateTagsResponder handles the response to the UpdateTags request. The method always 845// closes the http.Response Body. 846func (client VirtualNetworkGatewayConnectionsClient) UpdateTagsResponder(resp *http.Response) (result VirtualNetworkGatewayConnectionListEntity, err error) { 847 err = autorest.Respond( 848 resp, 849 azure.WithErrorUnlessStatusCode(http.StatusOK), 850 autorest.ByUnmarshallingJSON(&result), 851 autorest.ByClosing()) 852 result.Response = autorest.Response{Response: resp} 853 return 854} 855