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