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