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/tracing" 14 "net/http" 15) 16 17// ApplicationGatewaysClient is the network Client 18type ApplicationGatewaysClient struct { 19 BaseClient 20} 21 22// NewApplicationGatewaysClient creates an instance of the ApplicationGatewaysClient client. 23func NewApplicationGatewaysClient(subscriptionID string) ApplicationGatewaysClient { 24 return NewApplicationGatewaysClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewApplicationGatewaysClientWithBaseURI creates an instance of the ApplicationGatewaysClient client using a custom 28// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 29// stack). 30func NewApplicationGatewaysClientWithBaseURI(baseURI string, subscriptionID string) ApplicationGatewaysClient { 31 return ApplicationGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateOrUpdate creates or updates the specified application gateway. 35// Parameters: 36// resourceGroupName - the name of the resource group. 37// applicationGatewayName - the name of the application gateway. 38// parameters - parameters supplied to the create or update application gateway operation. 39func (client ApplicationGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationGatewayName string, parameters ApplicationGateway) (result ApplicationGatewaysCreateOrUpdateFuture, err error) { 40 if tracing.IsEnabled() { 41 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewaysClient.CreateOrUpdate") 42 defer func() { 43 sc := -1 44 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 45 sc = result.FutureAPI.Response().StatusCode 46 } 47 tracing.EndSpan(ctx, sc, err) 48 }() 49 } 50 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, applicationGatewayName, parameters) 51 if err != nil { 52 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") 53 return 54 } 55 56 result, err = client.CreateOrUpdateSender(req) 57 if err != nil { 58 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", nil, "Failure sending request") 59 return 60 } 61 62 return 63} 64 65// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 66func (client ApplicationGatewaysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string, parameters ApplicationGateway) (*http.Request, error) { 67 pathParameters := map[string]interface{}{ 68 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 69 "resourceGroupName": autorest.Encode("path", resourceGroupName), 70 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 71 } 72 73 const APIVersion = "2015-06-15" 74 queryParameters := map[string]interface{}{ 75 "api-version": APIVersion, 76 } 77 78 preparer := autorest.CreatePreparer( 79 autorest.AsContentType("application/json; charset=utf-8"), 80 autorest.AsPut(), 81 autorest.WithBaseURL(client.BaseURI), 82 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}", pathParameters), 83 autorest.WithJSON(parameters), 84 autorest.WithQueryParameters(queryParameters)) 85 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 86} 87 88// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 89// http.Response Body if it receives an error. 90func (client ApplicationGatewaysClient) CreateOrUpdateSender(req *http.Request) (future ApplicationGatewaysCreateOrUpdateFuture, err error) { 91 var resp *http.Response 92 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 93 if err != nil { 94 return 95 } 96 var azf azure.Future 97 azf, err = azure.NewFutureFromResponse(resp) 98 future.FutureAPI = &azf 99 future.Result = future.result 100 return 101} 102 103// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 104// closes the http.Response Body. 105func (client ApplicationGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationGateway, err error) { 106 err = autorest.Respond( 107 resp, 108 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 109 autorest.ByUnmarshallingJSON(&result), 110 autorest.ByClosing()) 111 result.Response = autorest.Response{Response: resp} 112 return 113} 114 115// Delete deletes the specified application gateway. 116// Parameters: 117// resourceGroupName - the name of the resource group. 118// applicationGatewayName - the name of the application gateway. 119func (client ApplicationGatewaysClient) Delete(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewaysDeleteFuture, err error) { 120 if tracing.IsEnabled() { 121 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewaysClient.Delete") 122 defer func() { 123 sc := -1 124 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 125 sc = result.FutureAPI.Response().StatusCode 126 } 127 tracing.EndSpan(ctx, sc, err) 128 }() 129 } 130 req, err := client.DeletePreparer(ctx, resourceGroupName, applicationGatewayName) 131 if err != nil { 132 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", nil, "Failure preparing request") 133 return 134 } 135 136 result, err = client.DeleteSender(req) 137 if err != nil { 138 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", nil, "Failure sending request") 139 return 140 } 141 142 return 143} 144 145// DeletePreparer prepares the Delete request. 146func (client ApplicationGatewaysClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string) (*http.Request, error) { 147 pathParameters := map[string]interface{}{ 148 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 149 "resourceGroupName": autorest.Encode("path", resourceGroupName), 150 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 151 } 152 153 const APIVersion = "2015-06-15" 154 queryParameters := map[string]interface{}{ 155 "api-version": APIVersion, 156 } 157 158 preparer := autorest.CreatePreparer( 159 autorest.AsDelete(), 160 autorest.WithBaseURL(client.BaseURI), 161 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}", pathParameters), 162 autorest.WithQueryParameters(queryParameters)) 163 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 164} 165 166// DeleteSender sends the Delete request. The method will close the 167// http.Response Body if it receives an error. 168func (client ApplicationGatewaysClient) DeleteSender(req *http.Request) (future ApplicationGatewaysDeleteFuture, err error) { 169 var resp *http.Response 170 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 171 if err != nil { 172 return 173 } 174 var azf azure.Future 175 azf, err = azure.NewFutureFromResponse(resp) 176 future.FutureAPI = &azf 177 future.Result = future.result 178 return 179} 180 181// DeleteResponder handles the response to the Delete request. The method always 182// closes the http.Response Body. 183func (client ApplicationGatewaysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 184 err = autorest.Respond( 185 resp, 186 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 187 autorest.ByClosing()) 188 result.Response = resp 189 return 190} 191 192// Get gets the specified application gateway. 193// Parameters: 194// resourceGroupName - the name of the resource group. 195// applicationGatewayName - the name of the application gateway. 196func (client ApplicationGatewaysClient) Get(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGateway, err error) { 197 if tracing.IsEnabled() { 198 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewaysClient.Get") 199 defer func() { 200 sc := -1 201 if result.Response.Response != nil { 202 sc = result.Response.Response.StatusCode 203 } 204 tracing.EndSpan(ctx, sc, err) 205 }() 206 } 207 req, err := client.GetPreparer(ctx, resourceGroupName, applicationGatewayName) 208 if err != nil { 209 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", nil, "Failure preparing request") 210 return 211 } 212 213 resp, err := client.GetSender(req) 214 if err != nil { 215 result.Response = autorest.Response{Response: resp} 216 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", resp, "Failure sending request") 217 return 218 } 219 220 result, err = client.GetResponder(resp) 221 if err != nil { 222 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", resp, "Failure responding to request") 223 return 224 } 225 226 return 227} 228 229// GetPreparer prepares the Get request. 230func (client ApplicationGatewaysClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string) (*http.Request, error) { 231 pathParameters := map[string]interface{}{ 232 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 233 "resourceGroupName": autorest.Encode("path", resourceGroupName), 234 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 235 } 236 237 const APIVersion = "2015-06-15" 238 queryParameters := map[string]interface{}{ 239 "api-version": APIVersion, 240 } 241 242 preparer := autorest.CreatePreparer( 243 autorest.AsGet(), 244 autorest.WithBaseURL(client.BaseURI), 245 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}", pathParameters), 246 autorest.WithQueryParameters(queryParameters)) 247 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 248} 249 250// GetSender sends the Get request. The method will close the 251// http.Response Body if it receives an error. 252func (client ApplicationGatewaysClient) GetSender(req *http.Request) (*http.Response, error) { 253 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 254} 255 256// GetResponder handles the response to the Get request. The method always 257// closes the http.Response Body. 258func (client ApplicationGatewaysClient) GetResponder(resp *http.Response) (result ApplicationGateway, err error) { 259 err = autorest.Respond( 260 resp, 261 azure.WithErrorUnlessStatusCode(http.StatusOK), 262 autorest.ByUnmarshallingJSON(&result), 263 autorest.ByClosing()) 264 result.Response = autorest.Response{Response: resp} 265 return 266} 267 268// List lists all application gateways in a resource group. 269// Parameters: 270// resourceGroupName - the name of the resource group. 271func (client ApplicationGatewaysClient) List(ctx context.Context, resourceGroupName string) (result ApplicationGatewayListResultPage, err error) { 272 if tracing.IsEnabled() { 273 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewaysClient.List") 274 defer func() { 275 sc := -1 276 if result.aglr.Response.Response != nil { 277 sc = result.aglr.Response.Response.StatusCode 278 } 279 tracing.EndSpan(ctx, sc, err) 280 }() 281 } 282 result.fn = client.listNextResults 283 req, err := client.ListPreparer(ctx, resourceGroupName) 284 if err != nil { 285 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", nil, "Failure preparing request") 286 return 287 } 288 289 resp, err := client.ListSender(req) 290 if err != nil { 291 result.aglr.Response = autorest.Response{Response: resp} 292 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", resp, "Failure sending request") 293 return 294 } 295 296 result.aglr, err = client.ListResponder(resp) 297 if err != nil { 298 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", resp, "Failure responding to request") 299 return 300 } 301 if result.aglr.hasNextLink() && result.aglr.IsEmpty() { 302 err = result.NextWithContext(ctx) 303 return 304 } 305 306 return 307} 308 309// ListPreparer prepares the List request. 310func (client ApplicationGatewaysClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 311 pathParameters := map[string]interface{}{ 312 "resourceGroupName": autorest.Encode("path", resourceGroupName), 313 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 314 } 315 316 const APIVersion = "2015-06-15" 317 queryParameters := map[string]interface{}{ 318 "api-version": APIVersion, 319 } 320 321 preparer := autorest.CreatePreparer( 322 autorest.AsGet(), 323 autorest.WithBaseURL(client.BaseURI), 324 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways", pathParameters), 325 autorest.WithQueryParameters(queryParameters)) 326 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 327} 328 329// ListSender sends the List request. The method will close the 330// http.Response Body if it receives an error. 331func (client ApplicationGatewaysClient) ListSender(req *http.Request) (*http.Response, error) { 332 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 333} 334 335// ListResponder handles the response to the List request. The method always 336// closes the http.Response Body. 337func (client ApplicationGatewaysClient) ListResponder(resp *http.Response) (result ApplicationGatewayListResult, err error) { 338 err = autorest.Respond( 339 resp, 340 azure.WithErrorUnlessStatusCode(http.StatusOK), 341 autorest.ByUnmarshallingJSON(&result), 342 autorest.ByClosing()) 343 result.Response = autorest.Response{Response: resp} 344 return 345} 346 347// listNextResults retrieves the next set of results, if any. 348func (client ApplicationGatewaysClient) listNextResults(ctx context.Context, lastResults ApplicationGatewayListResult) (result ApplicationGatewayListResult, err error) { 349 req, err := lastResults.applicationGatewayListResultPreparer(ctx) 350 if err != nil { 351 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "listNextResults", nil, "Failure preparing next results request") 352 } 353 if req == nil { 354 return 355 } 356 resp, err := client.ListSender(req) 357 if err != nil { 358 result.Response = autorest.Response{Response: resp} 359 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "listNextResults", resp, "Failure sending next results request") 360 } 361 result, err = client.ListResponder(resp) 362 if err != nil { 363 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "listNextResults", resp, "Failure responding to next results request") 364 } 365 return 366} 367 368// ListComplete enumerates all values, automatically crossing page boundaries as required. 369func (client ApplicationGatewaysClient) ListComplete(ctx context.Context, resourceGroupName string) (result ApplicationGatewayListResultIterator, err error) { 370 if tracing.IsEnabled() { 371 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewaysClient.List") 372 defer func() { 373 sc := -1 374 if result.Response().Response.Response != nil { 375 sc = result.page.Response().Response.Response.StatusCode 376 } 377 tracing.EndSpan(ctx, sc, err) 378 }() 379 } 380 result.page, err = client.List(ctx, resourceGroupName) 381 return 382} 383 384// ListAll gets all the application gateways in a subscription. 385func (client ApplicationGatewaysClient) ListAll(ctx context.Context) (result ApplicationGatewayListResultPage, err error) { 386 if tracing.IsEnabled() { 387 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewaysClient.ListAll") 388 defer func() { 389 sc := -1 390 if result.aglr.Response.Response != nil { 391 sc = result.aglr.Response.Response.StatusCode 392 } 393 tracing.EndSpan(ctx, sc, err) 394 }() 395 } 396 result.fn = client.listAllNextResults 397 req, err := client.ListAllPreparer(ctx) 398 if err != nil { 399 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", nil, "Failure preparing request") 400 return 401 } 402 403 resp, err := client.ListAllSender(req) 404 if err != nil { 405 result.aglr.Response = autorest.Response{Response: resp} 406 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", resp, "Failure sending request") 407 return 408 } 409 410 result.aglr, err = client.ListAllResponder(resp) 411 if err != nil { 412 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", resp, "Failure responding to request") 413 return 414 } 415 if result.aglr.hasNextLink() && result.aglr.IsEmpty() { 416 err = result.NextWithContext(ctx) 417 return 418 } 419 420 return 421} 422 423// ListAllPreparer prepares the ListAll request. 424func (client ApplicationGatewaysClient) ListAllPreparer(ctx context.Context) (*http.Request, error) { 425 pathParameters := map[string]interface{}{ 426 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 427 } 428 429 const APIVersion = "2015-06-15" 430 queryParameters := map[string]interface{}{ 431 "api-version": APIVersion, 432 } 433 434 preparer := autorest.CreatePreparer( 435 autorest.AsGet(), 436 autorest.WithBaseURL(client.BaseURI), 437 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/applicationGateways", pathParameters), 438 autorest.WithQueryParameters(queryParameters)) 439 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 440} 441 442// ListAllSender sends the ListAll request. The method will close the 443// http.Response Body if it receives an error. 444func (client ApplicationGatewaysClient) ListAllSender(req *http.Request) (*http.Response, error) { 445 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 446} 447 448// ListAllResponder handles the response to the ListAll request. The method always 449// closes the http.Response Body. 450func (client ApplicationGatewaysClient) ListAllResponder(resp *http.Response) (result ApplicationGatewayListResult, err error) { 451 err = autorest.Respond( 452 resp, 453 azure.WithErrorUnlessStatusCode(http.StatusOK), 454 autorest.ByUnmarshallingJSON(&result), 455 autorest.ByClosing()) 456 result.Response = autorest.Response{Response: resp} 457 return 458} 459 460// listAllNextResults retrieves the next set of results, if any. 461func (client ApplicationGatewaysClient) listAllNextResults(ctx context.Context, lastResults ApplicationGatewayListResult) (result ApplicationGatewayListResult, err error) { 462 req, err := lastResults.applicationGatewayListResultPreparer(ctx) 463 if err != nil { 464 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "listAllNextResults", nil, "Failure preparing next results request") 465 } 466 if req == nil { 467 return 468 } 469 resp, err := client.ListAllSender(req) 470 if err != nil { 471 result.Response = autorest.Response{Response: resp} 472 return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "listAllNextResults", resp, "Failure sending next results request") 473 } 474 result, err = client.ListAllResponder(resp) 475 if err != nil { 476 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "listAllNextResults", resp, "Failure responding to next results request") 477 } 478 return 479} 480 481// ListAllComplete enumerates all values, automatically crossing page boundaries as required. 482func (client ApplicationGatewaysClient) ListAllComplete(ctx context.Context) (result ApplicationGatewayListResultIterator, err error) { 483 if tracing.IsEnabled() { 484 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewaysClient.ListAll") 485 defer func() { 486 sc := -1 487 if result.Response().Response.Response != nil { 488 sc = result.page.Response().Response.Response.StatusCode 489 } 490 tracing.EndSpan(ctx, sc, err) 491 }() 492 } 493 result.page, err = client.ListAll(ctx) 494 return 495} 496 497// Start starts the specified application gateway. 498// Parameters: 499// resourceGroupName - the name of the resource group. 500// applicationGatewayName - the name of the application gateway. 501func (client ApplicationGatewaysClient) Start(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewaysStartFuture, err error) { 502 if tracing.IsEnabled() { 503 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewaysClient.Start") 504 defer func() { 505 sc := -1 506 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 507 sc = result.FutureAPI.Response().StatusCode 508 } 509 tracing.EndSpan(ctx, sc, err) 510 }() 511 } 512 req, err := client.StartPreparer(ctx, resourceGroupName, applicationGatewayName) 513 if err != nil { 514 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", nil, "Failure preparing request") 515 return 516 } 517 518 result, err = client.StartSender(req) 519 if err != nil { 520 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", nil, "Failure sending request") 521 return 522 } 523 524 return 525} 526 527// StartPreparer prepares the Start request. 528func (client ApplicationGatewaysClient) StartPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string) (*http.Request, error) { 529 pathParameters := map[string]interface{}{ 530 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 531 "resourceGroupName": autorest.Encode("path", resourceGroupName), 532 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 533 } 534 535 const APIVersion = "2015-06-15" 536 queryParameters := map[string]interface{}{ 537 "api-version": APIVersion, 538 } 539 540 preparer := autorest.CreatePreparer( 541 autorest.AsPost(), 542 autorest.WithBaseURL(client.BaseURI), 543 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/start", pathParameters), 544 autorest.WithQueryParameters(queryParameters)) 545 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 546} 547 548// StartSender sends the Start request. The method will close the 549// http.Response Body if it receives an error. 550func (client ApplicationGatewaysClient) StartSender(req *http.Request) (future ApplicationGatewaysStartFuture, err error) { 551 var resp *http.Response 552 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 553 if err != nil { 554 return 555 } 556 var azf azure.Future 557 azf, err = azure.NewFutureFromResponse(resp) 558 future.FutureAPI = &azf 559 future.Result = future.result 560 return 561} 562 563// StartResponder handles the response to the Start request. The method always 564// closes the http.Response Body. 565func (client ApplicationGatewaysClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { 566 err = autorest.Respond( 567 resp, 568 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 569 autorest.ByClosing()) 570 result.Response = resp 571 return 572} 573 574// Stop stops the specified application gateway in a resource group. 575// Parameters: 576// resourceGroupName - the name of the resource group. 577// applicationGatewayName - the name of the application gateway. 578func (client ApplicationGatewaysClient) Stop(ctx context.Context, resourceGroupName string, applicationGatewayName string) (result ApplicationGatewaysStopFuture, err error) { 579 if tracing.IsEnabled() { 580 ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationGatewaysClient.Stop") 581 defer func() { 582 sc := -1 583 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 584 sc = result.FutureAPI.Response().StatusCode 585 } 586 tracing.EndSpan(ctx, sc, err) 587 }() 588 } 589 req, err := client.StopPreparer(ctx, resourceGroupName, applicationGatewayName) 590 if err != nil { 591 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", nil, "Failure preparing request") 592 return 593 } 594 595 result, err = client.StopSender(req) 596 if err != nil { 597 err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", nil, "Failure sending request") 598 return 599 } 600 601 return 602} 603 604// StopPreparer prepares the Stop request. 605func (client ApplicationGatewaysClient) StopPreparer(ctx context.Context, resourceGroupName string, applicationGatewayName string) (*http.Request, error) { 606 pathParameters := map[string]interface{}{ 607 "applicationGatewayName": autorest.Encode("path", applicationGatewayName), 608 "resourceGroupName": autorest.Encode("path", resourceGroupName), 609 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 610 } 611 612 const APIVersion = "2015-06-15" 613 queryParameters := map[string]interface{}{ 614 "api-version": APIVersion, 615 } 616 617 preparer := autorest.CreatePreparer( 618 autorest.AsPost(), 619 autorest.WithBaseURL(client.BaseURI), 620 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/stop", pathParameters), 621 autorest.WithQueryParameters(queryParameters)) 622 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 623} 624 625// StopSender sends the Stop request. The method will close the 626// http.Response Body if it receives an error. 627func (client ApplicationGatewaysClient) StopSender(req *http.Request) (future ApplicationGatewaysStopFuture, err error) { 628 var resp *http.Response 629 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 630 if err != nil { 631 return 632 } 633 var azf azure.Future 634 azf, err = azure.NewFutureFromResponse(resp) 635 future.FutureAPI = &azf 636 future.Result = future.result 637 return 638} 639 640// StopResponder handles the response to the Stop request. The method always 641// closes the http.Response Body. 642func (client ApplicationGatewaysClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { 643 err = autorest.Respond( 644 resp, 645 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 646 autorest.ByClosing()) 647 result.Response = resp 648 return 649} 650