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