1package apimanagement 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// ServiceClient is the apiManagement Client 19type ServiceClient struct { 20 BaseClient 21} 22 23// NewServiceClient creates an instance of the ServiceClient client. 24func NewServiceClient(subscriptionID string) ServiceClient { 25 return NewServiceClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewServiceClientWithBaseURI creates an instance of the ServiceClient client using a custom endpoint. Use this when 29// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewServiceClientWithBaseURI(baseURI string, subscriptionID string) ServiceClient { 31 return ServiceClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// ApplyNetworkConfigurationUpdates updates the Microsoft.ApiManagement resource running in the Virtual network to pick 35// the updated network settings. 36// Parameters: 37// resourceGroupName - the name of the resource group. 38// serviceName - the name of the API Management service. 39// parameters - parameters supplied to the Apply Network Configuration operation. If the parameters are empty, 40// all the regions in which the Api Management service is deployed will be updated sequentially without 41// incurring downtime in the region. 42func (client ServiceClient) ApplyNetworkConfigurationUpdates(ctx context.Context, resourceGroupName string, serviceName string, parameters *ServiceApplyNetworkConfigurationParameters) (result ServiceApplyNetworkConfigurationUpdatesFuture, err error) { 43 if tracing.IsEnabled() { 44 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.ApplyNetworkConfigurationUpdates") 45 defer func() { 46 sc := -1 47 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 48 sc = result.FutureAPI.Response().StatusCode 49 } 50 tracing.EndSpan(ctx, sc, err) 51 }() 52 } 53 if err := validation.Validate([]validation.Validation{ 54 {TargetValue: serviceName, 55 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 56 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 57 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 58 return result, validation.NewError("apimanagement.ServiceClient", "ApplyNetworkConfigurationUpdates", err.Error()) 59 } 60 61 req, err := client.ApplyNetworkConfigurationUpdatesPreparer(ctx, resourceGroupName, serviceName, parameters) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ApplyNetworkConfigurationUpdates", nil, "Failure preparing request") 64 return 65 } 66 67 result, err = client.ApplyNetworkConfigurationUpdatesSender(req) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ApplyNetworkConfigurationUpdates", nil, "Failure sending request") 70 return 71 } 72 73 return 74} 75 76// ApplyNetworkConfigurationUpdatesPreparer prepares the ApplyNetworkConfigurationUpdates request. 77func (client ServiceClient) ApplyNetworkConfigurationUpdatesPreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters *ServiceApplyNetworkConfigurationParameters) (*http.Request, error) { 78 pathParameters := map[string]interface{}{ 79 "resourceGroupName": autorest.Encode("path", resourceGroupName), 80 "serviceName": autorest.Encode("path", serviceName), 81 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 82 } 83 84 const APIVersion = "2019-12-01" 85 queryParameters := map[string]interface{}{ 86 "api-version": APIVersion, 87 } 88 89 preparer := autorest.CreatePreparer( 90 autorest.AsContentType("application/json; charset=utf-8"), 91 autorest.AsPost(), 92 autorest.WithBaseURL(client.BaseURI), 93 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates", pathParameters), 94 autorest.WithQueryParameters(queryParameters)) 95 if parameters != nil { 96 preparer = autorest.DecoratePreparer(preparer, 97 autorest.WithJSON(parameters)) 98 } 99 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 100} 101 102// ApplyNetworkConfigurationUpdatesSender sends the ApplyNetworkConfigurationUpdates request. The method will close the 103// http.Response Body if it receives an error. 104func (client ServiceClient) ApplyNetworkConfigurationUpdatesSender(req *http.Request) (future ServiceApplyNetworkConfigurationUpdatesFuture, 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// ApplyNetworkConfigurationUpdatesResponder handles the response to the ApplyNetworkConfigurationUpdates request. The method always 118// closes the http.Response Body. 119func (client ServiceClient) ApplyNetworkConfigurationUpdatesResponder(resp *http.Response) (result ServiceResource, err error) { 120 err = autorest.Respond( 121 resp, 122 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 123 autorest.ByUnmarshallingJSON(&result), 124 autorest.ByClosing()) 125 result.Response = autorest.Response{Response: resp} 126 return 127} 128 129// Backup creates a backup of the API Management service to the given Azure Storage Account. This is long running 130// operation and could take several minutes to complete. 131// Parameters: 132// resourceGroupName - the name of the resource group. 133// serviceName - the name of the API Management service. 134// parameters - parameters supplied to the ApiManagementService_Backup operation. 135func (client ServiceClient) Backup(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (result ServiceBackupFuture, err error) { 136 if tracing.IsEnabled() { 137 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Backup") 138 defer func() { 139 sc := -1 140 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 141 sc = result.FutureAPI.Response().StatusCode 142 } 143 tracing.EndSpan(ctx, sc, err) 144 }() 145 } 146 if err := validation.Validate([]validation.Validation{ 147 {TargetValue: serviceName, 148 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 149 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 150 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 151 {TargetValue: parameters, 152 Constraints: []validation.Constraint{{Target: "parameters.StorageAccount", Name: validation.Null, Rule: true, Chain: nil}, 153 {Target: "parameters.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, 154 {Target: "parameters.ContainerName", Name: validation.Null, Rule: true, Chain: nil}, 155 {Target: "parameters.BackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 156 return result, validation.NewError("apimanagement.ServiceClient", "Backup", err.Error()) 157 } 158 159 req, err := client.BackupPreparer(ctx, resourceGroupName, serviceName, parameters) 160 if err != nil { 161 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Backup", nil, "Failure preparing request") 162 return 163 } 164 165 result, err = client.BackupSender(req) 166 if err != nil { 167 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Backup", nil, "Failure sending request") 168 return 169 } 170 171 return 172} 173 174// BackupPreparer prepares the Backup request. 175func (client ServiceClient) BackupPreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (*http.Request, error) { 176 pathParameters := map[string]interface{}{ 177 "resourceGroupName": autorest.Encode("path", resourceGroupName), 178 "serviceName": autorest.Encode("path", serviceName), 179 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 180 } 181 182 const APIVersion = "2019-12-01" 183 queryParameters := map[string]interface{}{ 184 "api-version": APIVersion, 185 } 186 187 preparer := autorest.CreatePreparer( 188 autorest.AsContentType("application/json; charset=utf-8"), 189 autorest.AsPost(), 190 autorest.WithBaseURL(client.BaseURI), 191 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup", pathParameters), 192 autorest.WithJSON(parameters), 193 autorest.WithQueryParameters(queryParameters)) 194 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 195} 196 197// BackupSender sends the Backup request. The method will close the 198// http.Response Body if it receives an error. 199func (client ServiceClient) BackupSender(req *http.Request) (future ServiceBackupFuture, err error) { 200 var resp *http.Response 201 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 202 if err != nil { 203 return 204 } 205 var azf azure.Future 206 azf, err = azure.NewFutureFromResponse(resp) 207 future.FutureAPI = &azf 208 future.Result = future.result 209 return 210} 211 212// BackupResponder handles the response to the Backup request. The method always 213// closes the http.Response Body. 214func (client ServiceClient) BackupResponder(resp *http.Response) (result ServiceResource, err error) { 215 err = autorest.Respond( 216 resp, 217 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 218 autorest.ByUnmarshallingJSON(&result), 219 autorest.ByClosing()) 220 result.Response = autorest.Response{Response: resp} 221 return 222} 223 224// CheckNameAvailability checks availability and correctness of a name for an API Management service. 225// Parameters: 226// parameters - parameters supplied to the CheckNameAvailability operation. 227func (client ServiceClient) CheckNameAvailability(ctx context.Context, parameters ServiceCheckNameAvailabilityParameters) (result ServiceNameAvailabilityResult, err error) { 228 if tracing.IsEnabled() { 229 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.CheckNameAvailability") 230 defer func() { 231 sc := -1 232 if result.Response.Response != nil { 233 sc = result.Response.Response.StatusCode 234 } 235 tracing.EndSpan(ctx, sc, err) 236 }() 237 } 238 if err := validation.Validate([]validation.Validation{ 239 {TargetValue: parameters, 240 Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 241 return result, validation.NewError("apimanagement.ServiceClient", "CheckNameAvailability", err.Error()) 242 } 243 244 req, err := client.CheckNameAvailabilityPreparer(ctx, parameters) 245 if err != nil { 246 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CheckNameAvailability", nil, "Failure preparing request") 247 return 248 } 249 250 resp, err := client.CheckNameAvailabilitySender(req) 251 if err != nil { 252 result.Response = autorest.Response{Response: resp} 253 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CheckNameAvailability", resp, "Failure sending request") 254 return 255 } 256 257 result, err = client.CheckNameAvailabilityResponder(resp) 258 if err != nil { 259 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CheckNameAvailability", resp, "Failure responding to request") 260 return 261 } 262 263 return 264} 265 266// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. 267func (client ServiceClient) CheckNameAvailabilityPreparer(ctx context.Context, parameters ServiceCheckNameAvailabilityParameters) (*http.Request, error) { 268 pathParameters := map[string]interface{}{ 269 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 270 } 271 272 const APIVersion = "2019-12-01" 273 queryParameters := map[string]interface{}{ 274 "api-version": APIVersion, 275 } 276 277 preparer := autorest.CreatePreparer( 278 autorest.AsContentType("application/json; charset=utf-8"), 279 autorest.AsPost(), 280 autorest.WithBaseURL(client.BaseURI), 281 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability", pathParameters), 282 autorest.WithJSON(parameters), 283 autorest.WithQueryParameters(queryParameters)) 284 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 285} 286 287// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the 288// http.Response Body if it receives an error. 289func (client ServiceClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { 290 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 291} 292 293// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always 294// closes the http.Response Body. 295func (client ServiceClient) CheckNameAvailabilityResponder(resp *http.Response) (result ServiceNameAvailabilityResult, err error) { 296 err = autorest.Respond( 297 resp, 298 azure.WithErrorUnlessStatusCode(http.StatusOK), 299 autorest.ByUnmarshallingJSON(&result), 300 autorest.ByClosing()) 301 result.Response = autorest.Response{Response: resp} 302 return 303} 304 305// CreateOrUpdate creates or updates an API Management service. This is long running operation and could take several 306// minutes to complete. 307// Parameters: 308// resourceGroupName - the name of the resource group. 309// serviceName - the name of the API Management service. 310// parameters - parameters supplied to the CreateOrUpdate API Management service operation. 311func (client ServiceClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceResource) (result ServiceCreateOrUpdateFuture, err error) { 312 if tracing.IsEnabled() { 313 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.CreateOrUpdate") 314 defer func() { 315 sc := -1 316 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 317 sc = result.FutureAPI.Response().StatusCode 318 } 319 tracing.EndSpan(ctx, sc, err) 320 }() 321 } 322 if err := validation.Validate([]validation.Validation{ 323 {TargetValue: serviceName, 324 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 325 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 326 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 327 {TargetValue: parameters, 328 Constraints: []validation.Constraint{{Target: "parameters.ServiceProperties", Name: validation.Null, Rule: true, 329 Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherEmail", Name: validation.Null, Rule: true, 330 Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherEmail", Name: validation.MaxLength, Rule: 100, Chain: nil}}}, 331 {Target: "parameters.ServiceProperties.PublisherName", Name: validation.Null, Rule: true, 332 Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherName", Name: validation.MaxLength, Rule: 100, Chain: nil}}}, 333 }}, 334 {Target: "parameters.Sku", Name: validation.Null, Rule: true, 335 Chain: []validation.Constraint{{Target: "parameters.Sku.Capacity", Name: validation.Null, Rule: true, Chain: nil}}}, 336 {Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 337 return result, validation.NewError("apimanagement.ServiceClient", "CreateOrUpdate", err.Error()) 338 } 339 340 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, parameters) 341 if err != nil { 342 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CreateOrUpdate", nil, "Failure preparing request") 343 return 344 } 345 346 result, err = client.CreateOrUpdateSender(req) 347 if err != nil { 348 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CreateOrUpdate", nil, "Failure sending request") 349 return 350 } 351 352 return 353} 354 355// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 356func (client ServiceClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceResource) (*http.Request, error) { 357 pathParameters := map[string]interface{}{ 358 "resourceGroupName": autorest.Encode("path", resourceGroupName), 359 "serviceName": autorest.Encode("path", serviceName), 360 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 361 } 362 363 const APIVersion = "2019-12-01" 364 queryParameters := map[string]interface{}{ 365 "api-version": APIVersion, 366 } 367 368 parameters.Etag = nil 369 preparer := autorest.CreatePreparer( 370 autorest.AsContentType("application/json; charset=utf-8"), 371 autorest.AsPut(), 372 autorest.WithBaseURL(client.BaseURI), 373 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), 374 autorest.WithJSON(parameters), 375 autorest.WithQueryParameters(queryParameters)) 376 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 377} 378 379// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 380// http.Response Body if it receives an error. 381func (client ServiceClient) CreateOrUpdateSender(req *http.Request) (future ServiceCreateOrUpdateFuture, err error) { 382 var resp *http.Response 383 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 384 if err != nil { 385 return 386 } 387 var azf azure.Future 388 azf, err = azure.NewFutureFromResponse(resp) 389 future.FutureAPI = &azf 390 future.Result = future.result 391 return 392} 393 394// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 395// closes the http.Response Body. 396func (client ServiceClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceResource, err error) { 397 err = autorest.Respond( 398 resp, 399 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), 400 autorest.ByUnmarshallingJSON(&result), 401 autorest.ByClosing()) 402 result.Response = autorest.Response{Response: resp} 403 return 404} 405 406// Delete deletes an existing API Management service. 407// Parameters: 408// resourceGroupName - the name of the resource group. 409// serviceName - the name of the API Management service. 410func (client ServiceClient) Delete(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceDeleteFuture, err error) { 411 if tracing.IsEnabled() { 412 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Delete") 413 defer func() { 414 sc := -1 415 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 416 sc = result.FutureAPI.Response().StatusCode 417 } 418 tracing.EndSpan(ctx, sc, err) 419 }() 420 } 421 if err := validation.Validate([]validation.Validation{ 422 {TargetValue: serviceName, 423 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 424 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 425 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 426 return result, validation.NewError("apimanagement.ServiceClient", "Delete", err.Error()) 427 } 428 429 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName) 430 if err != nil { 431 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Delete", nil, "Failure preparing request") 432 return 433 } 434 435 result, err = client.DeleteSender(req) 436 if err != nil { 437 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Delete", nil, "Failure sending request") 438 return 439 } 440 441 return 442} 443 444// DeletePreparer prepares the Delete request. 445func (client ServiceClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 446 pathParameters := map[string]interface{}{ 447 "resourceGroupName": autorest.Encode("path", resourceGroupName), 448 "serviceName": autorest.Encode("path", serviceName), 449 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 450 } 451 452 const APIVersion = "2019-12-01" 453 queryParameters := map[string]interface{}{ 454 "api-version": APIVersion, 455 } 456 457 preparer := autorest.CreatePreparer( 458 autorest.AsDelete(), 459 autorest.WithBaseURL(client.BaseURI), 460 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), 461 autorest.WithQueryParameters(queryParameters)) 462 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 463} 464 465// DeleteSender sends the Delete request. The method will close the 466// http.Response Body if it receives an error. 467func (client ServiceClient) DeleteSender(req *http.Request) (future ServiceDeleteFuture, err error) { 468 var resp *http.Response 469 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 470 if err != nil { 471 return 472 } 473 var azf azure.Future 474 azf, err = azure.NewFutureFromResponse(resp) 475 future.FutureAPI = &azf 476 future.Result = future.result 477 return 478} 479 480// DeleteResponder handles the response to the Delete request. The method always 481// closes the http.Response Body. 482func (client ServiceClient) DeleteResponder(resp *http.Response) (result ServiceResource, err error) { 483 err = autorest.Respond( 484 resp, 485 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 486 autorest.ByUnmarshallingJSON(&result), 487 autorest.ByClosing()) 488 result.Response = autorest.Response{Response: resp} 489 return 490} 491 492// Get gets an API Management service resource description. 493// Parameters: 494// resourceGroupName - the name of the resource group. 495// serviceName - the name of the API Management service. 496func (client ServiceClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceResource, err error) { 497 if tracing.IsEnabled() { 498 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Get") 499 defer func() { 500 sc := -1 501 if result.Response.Response != nil { 502 sc = result.Response.Response.StatusCode 503 } 504 tracing.EndSpan(ctx, sc, err) 505 }() 506 } 507 if err := validation.Validate([]validation.Validation{ 508 {TargetValue: serviceName, 509 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 510 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 511 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 512 return result, validation.NewError("apimanagement.ServiceClient", "Get", err.Error()) 513 } 514 515 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName) 516 if err != nil { 517 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Get", nil, "Failure preparing request") 518 return 519 } 520 521 resp, err := client.GetSender(req) 522 if err != nil { 523 result.Response = autorest.Response{Response: resp} 524 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Get", resp, "Failure sending request") 525 return 526 } 527 528 result, err = client.GetResponder(resp) 529 if err != nil { 530 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Get", resp, "Failure responding to request") 531 return 532 } 533 534 return 535} 536 537// GetPreparer prepares the Get request. 538func (client ServiceClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 539 pathParameters := map[string]interface{}{ 540 "resourceGroupName": autorest.Encode("path", resourceGroupName), 541 "serviceName": autorest.Encode("path", serviceName), 542 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 543 } 544 545 const APIVersion = "2019-12-01" 546 queryParameters := map[string]interface{}{ 547 "api-version": APIVersion, 548 } 549 550 preparer := autorest.CreatePreparer( 551 autorest.AsGet(), 552 autorest.WithBaseURL(client.BaseURI), 553 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), 554 autorest.WithQueryParameters(queryParameters)) 555 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 556} 557 558// GetSender sends the Get request. The method will close the 559// http.Response Body if it receives an error. 560func (client ServiceClient) GetSender(req *http.Request) (*http.Response, error) { 561 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 562} 563 564// GetResponder handles the response to the Get request. The method always 565// closes the http.Response Body. 566func (client ServiceClient) GetResponder(resp *http.Response) (result ServiceResource, err error) { 567 err = autorest.Respond( 568 resp, 569 azure.WithErrorUnlessStatusCode(http.StatusOK), 570 autorest.ByUnmarshallingJSON(&result), 571 autorest.ByClosing()) 572 result.Response = autorest.Response{Response: resp} 573 return 574} 575 576// GetSsoToken gets the Single-Sign-On token for the API Management Service which is valid for 5 Minutes. 577// Parameters: 578// resourceGroupName - the name of the resource group. 579// serviceName - the name of the API Management service. 580func (client ServiceClient) GetSsoToken(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceGetSsoTokenResult, err error) { 581 if tracing.IsEnabled() { 582 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.GetSsoToken") 583 defer func() { 584 sc := -1 585 if result.Response.Response != nil { 586 sc = result.Response.Response.StatusCode 587 } 588 tracing.EndSpan(ctx, sc, err) 589 }() 590 } 591 if err := validation.Validate([]validation.Validation{ 592 {TargetValue: serviceName, 593 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 594 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 595 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 596 return result, validation.NewError("apimanagement.ServiceClient", "GetSsoToken", err.Error()) 597 } 598 599 req, err := client.GetSsoTokenPreparer(ctx, resourceGroupName, serviceName) 600 if err != nil { 601 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetSsoToken", nil, "Failure preparing request") 602 return 603 } 604 605 resp, err := client.GetSsoTokenSender(req) 606 if err != nil { 607 result.Response = autorest.Response{Response: resp} 608 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetSsoToken", resp, "Failure sending request") 609 return 610 } 611 612 result, err = client.GetSsoTokenResponder(resp) 613 if err != nil { 614 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetSsoToken", resp, "Failure responding to request") 615 return 616 } 617 618 return 619} 620 621// GetSsoTokenPreparer prepares the GetSsoToken request. 622func (client ServiceClient) GetSsoTokenPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 623 pathParameters := map[string]interface{}{ 624 "resourceGroupName": autorest.Encode("path", resourceGroupName), 625 "serviceName": autorest.Encode("path", serviceName), 626 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 627 } 628 629 const APIVersion = "2019-12-01" 630 queryParameters := map[string]interface{}{ 631 "api-version": APIVersion, 632 } 633 634 preparer := autorest.CreatePreparer( 635 autorest.AsPost(), 636 autorest.WithBaseURL(client.BaseURI), 637 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken", pathParameters), 638 autorest.WithQueryParameters(queryParameters)) 639 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 640} 641 642// GetSsoTokenSender sends the GetSsoToken request. The method will close the 643// http.Response Body if it receives an error. 644func (client ServiceClient) GetSsoTokenSender(req *http.Request) (*http.Response, error) { 645 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 646} 647 648// GetSsoTokenResponder handles the response to the GetSsoToken request. The method always 649// closes the http.Response Body. 650func (client ServiceClient) GetSsoTokenResponder(resp *http.Response) (result ServiceGetSsoTokenResult, err error) { 651 err = autorest.Respond( 652 resp, 653 azure.WithErrorUnlessStatusCode(http.StatusOK), 654 autorest.ByUnmarshallingJSON(&result), 655 autorest.ByClosing()) 656 result.Response = autorest.Response{Response: resp} 657 return 658} 659 660// List lists all API Management services within an Azure subscription. 661func (client ServiceClient) List(ctx context.Context) (result ServiceListResultPage, err error) { 662 if tracing.IsEnabled() { 663 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.List") 664 defer func() { 665 sc := -1 666 if result.slr.Response.Response != nil { 667 sc = result.slr.Response.Response.StatusCode 668 } 669 tracing.EndSpan(ctx, sc, err) 670 }() 671 } 672 result.fn = client.listNextResults 673 req, err := client.ListPreparer(ctx) 674 if err != nil { 675 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "List", nil, "Failure preparing request") 676 return 677 } 678 679 resp, err := client.ListSender(req) 680 if err != nil { 681 result.slr.Response = autorest.Response{Response: resp} 682 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "List", resp, "Failure sending request") 683 return 684 } 685 686 result.slr, err = client.ListResponder(resp) 687 if err != nil { 688 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "List", resp, "Failure responding to request") 689 return 690 } 691 if result.slr.hasNextLink() && result.slr.IsEmpty() { 692 err = result.NextWithContext(ctx) 693 return 694 } 695 696 return 697} 698 699// ListPreparer prepares the List request. 700func (client ServiceClient) ListPreparer(ctx context.Context) (*http.Request, error) { 701 pathParameters := map[string]interface{}{ 702 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 703 } 704 705 const APIVersion = "2019-12-01" 706 queryParameters := map[string]interface{}{ 707 "api-version": APIVersion, 708 } 709 710 preparer := autorest.CreatePreparer( 711 autorest.AsGet(), 712 autorest.WithBaseURL(client.BaseURI), 713 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service", pathParameters), 714 autorest.WithQueryParameters(queryParameters)) 715 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 716} 717 718// ListSender sends the List request. The method will close the 719// http.Response Body if it receives an error. 720func (client ServiceClient) ListSender(req *http.Request) (*http.Response, error) { 721 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 722} 723 724// ListResponder handles the response to the List request. The method always 725// closes the http.Response Body. 726func (client ServiceClient) ListResponder(resp *http.Response) (result ServiceListResult, err error) { 727 err = autorest.Respond( 728 resp, 729 azure.WithErrorUnlessStatusCode(http.StatusOK), 730 autorest.ByUnmarshallingJSON(&result), 731 autorest.ByClosing()) 732 result.Response = autorest.Response{Response: resp} 733 return 734} 735 736// listNextResults retrieves the next set of results, if any. 737func (client ServiceClient) listNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) { 738 req, err := lastResults.serviceListResultPreparer(ctx) 739 if err != nil { 740 return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listNextResults", nil, "Failure preparing next results request") 741 } 742 if req == nil { 743 return 744 } 745 resp, err := client.ListSender(req) 746 if err != nil { 747 result.Response = autorest.Response{Response: resp} 748 return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listNextResults", resp, "Failure sending next results request") 749 } 750 result, err = client.ListResponder(resp) 751 if err != nil { 752 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listNextResults", resp, "Failure responding to next results request") 753 } 754 return 755} 756 757// ListComplete enumerates all values, automatically crossing page boundaries as required. 758func (client ServiceClient) ListComplete(ctx context.Context) (result ServiceListResultIterator, err error) { 759 if tracing.IsEnabled() { 760 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.List") 761 defer func() { 762 sc := -1 763 if result.Response().Response.Response != nil { 764 sc = result.page.Response().Response.Response.StatusCode 765 } 766 tracing.EndSpan(ctx, sc, err) 767 }() 768 } 769 result.page, err = client.List(ctx) 770 return 771} 772 773// ListByResourceGroup list all API Management services within a resource group. 774// Parameters: 775// resourceGroupName - the name of the resource group. 776func (client ServiceClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServiceListResultPage, err error) { 777 if tracing.IsEnabled() { 778 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.ListByResourceGroup") 779 defer func() { 780 sc := -1 781 if result.slr.Response.Response != nil { 782 sc = result.slr.Response.Response.StatusCode 783 } 784 tracing.EndSpan(ctx, sc, err) 785 }() 786 } 787 result.fn = client.listByResourceGroupNextResults 788 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 789 if err != nil { 790 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ListByResourceGroup", nil, "Failure preparing request") 791 return 792 } 793 794 resp, err := client.ListByResourceGroupSender(req) 795 if err != nil { 796 result.slr.Response = autorest.Response{Response: resp} 797 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ListByResourceGroup", resp, "Failure sending request") 798 return 799 } 800 801 result.slr, err = client.ListByResourceGroupResponder(resp) 802 if err != nil { 803 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ListByResourceGroup", resp, "Failure responding to request") 804 return 805 } 806 if result.slr.hasNextLink() && result.slr.IsEmpty() { 807 err = result.NextWithContext(ctx) 808 return 809 } 810 811 return 812} 813 814// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 815func (client ServiceClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 816 pathParameters := map[string]interface{}{ 817 "resourceGroupName": autorest.Encode("path", resourceGroupName), 818 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 819 } 820 821 const APIVersion = "2019-12-01" 822 queryParameters := map[string]interface{}{ 823 "api-version": APIVersion, 824 } 825 826 preparer := autorest.CreatePreparer( 827 autorest.AsGet(), 828 autorest.WithBaseURL(client.BaseURI), 829 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service", pathParameters), 830 autorest.WithQueryParameters(queryParameters)) 831 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 832} 833 834// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 835// http.Response Body if it receives an error. 836func (client ServiceClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 837 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 838} 839 840// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 841// closes the http.Response Body. 842func (client ServiceClient) ListByResourceGroupResponder(resp *http.Response) (result ServiceListResult, err error) { 843 err = autorest.Respond( 844 resp, 845 azure.WithErrorUnlessStatusCode(http.StatusOK), 846 autorest.ByUnmarshallingJSON(&result), 847 autorest.ByClosing()) 848 result.Response = autorest.Response{Response: resp} 849 return 850} 851 852// listByResourceGroupNextResults retrieves the next set of results, if any. 853func (client ServiceClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) { 854 req, err := lastResults.serviceListResultPreparer(ctx) 855 if err != nil { 856 return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 857 } 858 if req == nil { 859 return 860 } 861 resp, err := client.ListByResourceGroupSender(req) 862 if err != nil { 863 result.Response = autorest.Response{Response: resp} 864 return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 865 } 866 result, err = client.ListByResourceGroupResponder(resp) 867 if err != nil { 868 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 869 } 870 return 871} 872 873// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 874func (client ServiceClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServiceListResultIterator, err error) { 875 if tracing.IsEnabled() { 876 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.ListByResourceGroup") 877 defer func() { 878 sc := -1 879 if result.Response().Response.Response != nil { 880 sc = result.page.Response().Response.Response.StatusCode 881 } 882 tracing.EndSpan(ctx, sc, err) 883 }() 884 } 885 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) 886 return 887} 888 889// Restore restores a backup of an API Management service created using the ApiManagementService_Backup operation on 890// the current service. This is a long running operation and could take several minutes to complete. 891// Parameters: 892// resourceGroupName - the name of the resource group. 893// serviceName - the name of the API Management service. 894// parameters - parameters supplied to the Restore API Management service from backup operation. 895func (client ServiceClient) Restore(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (result ServiceRestoreFuture, err error) { 896 if tracing.IsEnabled() { 897 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Restore") 898 defer func() { 899 sc := -1 900 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 901 sc = result.FutureAPI.Response().StatusCode 902 } 903 tracing.EndSpan(ctx, sc, err) 904 }() 905 } 906 if err := validation.Validate([]validation.Validation{ 907 {TargetValue: serviceName, 908 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 909 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 910 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 911 {TargetValue: parameters, 912 Constraints: []validation.Constraint{{Target: "parameters.StorageAccount", Name: validation.Null, Rule: true, Chain: nil}, 913 {Target: "parameters.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, 914 {Target: "parameters.ContainerName", Name: validation.Null, Rule: true, Chain: nil}, 915 {Target: "parameters.BackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 916 return result, validation.NewError("apimanagement.ServiceClient", "Restore", err.Error()) 917 } 918 919 req, err := client.RestorePreparer(ctx, resourceGroupName, serviceName, parameters) 920 if err != nil { 921 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Restore", nil, "Failure preparing request") 922 return 923 } 924 925 result, err = client.RestoreSender(req) 926 if err != nil { 927 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Restore", nil, "Failure sending request") 928 return 929 } 930 931 return 932} 933 934// RestorePreparer prepares the Restore request. 935func (client ServiceClient) RestorePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (*http.Request, error) { 936 pathParameters := map[string]interface{}{ 937 "resourceGroupName": autorest.Encode("path", resourceGroupName), 938 "serviceName": autorest.Encode("path", serviceName), 939 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 940 } 941 942 const APIVersion = "2019-12-01" 943 queryParameters := map[string]interface{}{ 944 "api-version": APIVersion, 945 } 946 947 preparer := autorest.CreatePreparer( 948 autorest.AsContentType("application/json; charset=utf-8"), 949 autorest.AsPost(), 950 autorest.WithBaseURL(client.BaseURI), 951 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore", pathParameters), 952 autorest.WithJSON(parameters), 953 autorest.WithQueryParameters(queryParameters)) 954 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 955} 956 957// RestoreSender sends the Restore request. The method will close the 958// http.Response Body if it receives an error. 959func (client ServiceClient) RestoreSender(req *http.Request) (future ServiceRestoreFuture, err error) { 960 var resp *http.Response 961 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 962 if err != nil { 963 return 964 } 965 var azf azure.Future 966 azf, err = azure.NewFutureFromResponse(resp) 967 future.FutureAPI = &azf 968 future.Result = future.result 969 return 970} 971 972// RestoreResponder handles the response to the Restore request. The method always 973// closes the http.Response Body. 974func (client ServiceClient) RestoreResponder(resp *http.Response) (result ServiceResource, err error) { 975 err = autorest.Respond( 976 resp, 977 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 978 autorest.ByUnmarshallingJSON(&result), 979 autorest.ByClosing()) 980 result.Response = autorest.Response{Response: resp} 981 return 982} 983 984// Update updates an existing API Management service. 985// Parameters: 986// resourceGroupName - the name of the resource group. 987// serviceName - the name of the API Management service. 988// parameters - parameters supplied to the CreateOrUpdate API Management service operation. 989func (client ServiceClient) Update(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceUpdateParameters) (result ServiceUpdateFuture, err error) { 990 if tracing.IsEnabled() { 991 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Update") 992 defer func() { 993 sc := -1 994 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 995 sc = result.FutureAPI.Response().StatusCode 996 } 997 tracing.EndSpan(ctx, sc, err) 998 }() 999 } 1000 if err := validation.Validate([]validation.Validation{ 1001 {TargetValue: serviceName, 1002 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 1003 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 1004 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 1005 return result, validation.NewError("apimanagement.ServiceClient", "Update", err.Error()) 1006 } 1007 1008 req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, parameters) 1009 if err != nil { 1010 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Update", nil, "Failure preparing request") 1011 return 1012 } 1013 1014 result, err = client.UpdateSender(req) 1015 if err != nil { 1016 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Update", nil, "Failure sending request") 1017 return 1018 } 1019 1020 return 1021} 1022 1023// UpdatePreparer prepares the Update request. 1024func (client ServiceClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceUpdateParameters) (*http.Request, error) { 1025 pathParameters := map[string]interface{}{ 1026 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1027 "serviceName": autorest.Encode("path", serviceName), 1028 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1029 } 1030 1031 const APIVersion = "2019-12-01" 1032 queryParameters := map[string]interface{}{ 1033 "api-version": APIVersion, 1034 } 1035 1036 parameters.Etag = nil 1037 preparer := autorest.CreatePreparer( 1038 autorest.AsContentType("application/json; charset=utf-8"), 1039 autorest.AsPatch(), 1040 autorest.WithBaseURL(client.BaseURI), 1041 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), 1042 autorest.WithJSON(parameters), 1043 autorest.WithQueryParameters(queryParameters)) 1044 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1045} 1046 1047// UpdateSender sends the Update request. The method will close the 1048// http.Response Body if it receives an error. 1049func (client ServiceClient) UpdateSender(req *http.Request) (future ServiceUpdateFuture, err error) { 1050 var resp *http.Response 1051 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1052 if err != nil { 1053 return 1054 } 1055 var azf azure.Future 1056 azf, err = azure.NewFutureFromResponse(resp) 1057 future.FutureAPI = &azf 1058 future.Result = future.result 1059 return 1060} 1061 1062// UpdateResponder handles the response to the Update request. The method always 1063// closes the http.Response Body. 1064func (client ServiceClient) UpdateResponder(resp *http.Response) (result ServiceResource, err error) { 1065 err = autorest.Respond( 1066 resp, 1067 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1068 autorest.ByUnmarshallingJSON(&result), 1069 autorest.ByClosing()) 1070 result.Response = autorest.Response{Response: resp} 1071 return 1072} 1073