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// BackendsClient is the apiManagement Client 19type BackendsClient struct { 20 BaseClient 21} 22 23// NewBackendsClient creates an instance of the BackendsClient client. 24func NewBackendsClient(subscriptionID string) BackendsClient { 25 return NewBackendsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewBackendsClientWithBaseURI creates an instance of the BackendsClient client using a custom endpoint. Use this 29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewBackendsClientWithBaseURI(baseURI string, subscriptionID string) BackendsClient { 31 return BackendsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateOrUpdate creates or Updates a backend. 35// Parameters: 36// resourceGroupName - the name of the resource group. 37// serviceName - the name of the API Management service. 38// backendid - user identifier. Must be unique in the current API Management service instance. 39// parameters - create parameters. 40func (client BackendsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, backendid string, parameters BackendContract) (result autorest.Response, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/BackendsClient.CreateOrUpdate") 43 defer func() { 44 sc := -1 45 if result.Response != nil { 46 sc = result.Response.StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 if err := validation.Validate([]validation.Validation{ 52 {TargetValue: serviceName, 53 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 54 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 55 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 56 {TargetValue: backendid, 57 Constraints: []validation.Constraint{{Target: "backendid", Name: validation.MaxLength, Rule: 255, Chain: nil}, 58 {Target: "backendid", Name: validation.MinLength, Rule: 1, Chain: nil}, 59 {Target: "backendid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 60 {TargetValue: parameters, 61 Constraints: []validation.Constraint{{Target: "parameters.Host", Name: validation.Null, Rule: true, 62 Chain: []validation.Constraint{{Target: "parameters.Host", Name: validation.MaxLength, Rule: 255, Chain: nil}, 63 {Target: "parameters.Host", Name: validation.MinLength, Rule: 1, Chain: nil}, 64 }}}}}); err != nil { 65 return result, validation.NewError("apimanagement.BackendsClient", "CreateOrUpdate", err.Error()) 66 } 67 68 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, backendid, parameters) 69 if err != nil { 70 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "CreateOrUpdate", nil, "Failure preparing request") 71 return 72 } 73 74 resp, err := client.CreateOrUpdateSender(req) 75 if err != nil { 76 result.Response = resp 77 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "CreateOrUpdate", resp, "Failure sending request") 78 return 79 } 80 81 result, err = client.CreateOrUpdateResponder(resp) 82 if err != nil { 83 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "CreateOrUpdate", resp, "Failure responding to request") 84 return 85 } 86 87 return 88} 89 90// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 91func (client BackendsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, backendid string, parameters BackendContract) (*http.Request, error) { 92 pathParameters := map[string]interface{}{ 93 "backendid": autorest.Encode("path", backendid), 94 "resourceGroupName": autorest.Encode("path", resourceGroupName), 95 "serviceName": autorest.Encode("path", serviceName), 96 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 97 } 98 99 const APIVersion = "2016-07-07" 100 queryParameters := map[string]interface{}{ 101 "api-version": APIVersion, 102 } 103 104 preparer := autorest.CreatePreparer( 105 autorest.AsContentType("application/json; charset=utf-8"), 106 autorest.AsPut(), 107 autorest.WithBaseURL(client.BaseURI), 108 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendid}", pathParameters), 109 autorest.WithJSON(parameters), 110 autorest.WithQueryParameters(queryParameters)) 111 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 112} 113 114// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 115// http.Response Body if it receives an error. 116func (client BackendsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 117 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 118} 119 120// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 121// closes the http.Response Body. 122func (client BackendsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { 123 err = autorest.Respond( 124 resp, 125 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), 126 autorest.ByClosing()) 127 result.Response = resp 128 return 129} 130 131// Delete deletes the specified backend. 132// Parameters: 133// resourceGroupName - the name of the resource group. 134// serviceName - the name of the API Management service. 135// backendid - user identifier. Must be unique in the current API Management service instance. 136// ifMatch - the entity state (Etag) version of the backend to delete. A value of "*" can be used for If-Match 137// to unconditionally apply the operation. 138func (client BackendsClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, backendid string, ifMatch string) (result autorest.Response, err error) { 139 if tracing.IsEnabled() { 140 ctx = tracing.StartSpan(ctx, fqdn+"/BackendsClient.Delete") 141 defer func() { 142 sc := -1 143 if result.Response != nil { 144 sc = result.Response.StatusCode 145 } 146 tracing.EndSpan(ctx, sc, err) 147 }() 148 } 149 if err := validation.Validate([]validation.Validation{ 150 {TargetValue: serviceName, 151 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 152 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 153 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 154 {TargetValue: backendid, 155 Constraints: []validation.Constraint{{Target: "backendid", Name: validation.MaxLength, Rule: 255, Chain: nil}, 156 {Target: "backendid", Name: validation.MinLength, Rule: 1, Chain: nil}, 157 {Target: "backendid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 158 return result, validation.NewError("apimanagement.BackendsClient", "Delete", err.Error()) 159 } 160 161 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, backendid, ifMatch) 162 if err != nil { 163 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Delete", nil, "Failure preparing request") 164 return 165 } 166 167 resp, err := client.DeleteSender(req) 168 if err != nil { 169 result.Response = resp 170 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Delete", resp, "Failure sending request") 171 return 172 } 173 174 result, err = client.DeleteResponder(resp) 175 if err != nil { 176 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Delete", resp, "Failure responding to request") 177 return 178 } 179 180 return 181} 182 183// DeletePreparer prepares the Delete request. 184func (client BackendsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, backendid string, ifMatch string) (*http.Request, error) { 185 pathParameters := map[string]interface{}{ 186 "backendid": autorest.Encode("path", backendid), 187 "resourceGroupName": autorest.Encode("path", resourceGroupName), 188 "serviceName": autorest.Encode("path", serviceName), 189 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 190 } 191 192 const APIVersion = "2016-07-07" 193 queryParameters := map[string]interface{}{ 194 "api-version": APIVersion, 195 } 196 197 preparer := autorest.CreatePreparer( 198 autorest.AsDelete(), 199 autorest.WithBaseURL(client.BaseURI), 200 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendid}", pathParameters), 201 autorest.WithQueryParameters(queryParameters), 202 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 203 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 204} 205 206// DeleteSender sends the Delete request. The method will close the 207// http.Response Body if it receives an error. 208func (client BackendsClient) DeleteSender(req *http.Request) (*http.Response, error) { 209 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 210} 211 212// DeleteResponder handles the response to the Delete request. The method always 213// closes the http.Response Body. 214func (client BackendsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 215 err = autorest.Respond( 216 resp, 217 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 218 autorest.ByClosing()) 219 result.Response = resp 220 return 221} 222 223// Get gets the details of the backend specified by its identifier. 224// Parameters: 225// resourceGroupName - the name of the resource group. 226// serviceName - the name of the API Management service. 227// backendid - user identifier. Must be unique in the current API Management service instance. 228func (client BackendsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, backendid string) (result BackendResponse, err error) { 229 if tracing.IsEnabled() { 230 ctx = tracing.StartSpan(ctx, fqdn+"/BackendsClient.Get") 231 defer func() { 232 sc := -1 233 if result.Response.Response != nil { 234 sc = result.Response.Response.StatusCode 235 } 236 tracing.EndSpan(ctx, sc, err) 237 }() 238 } 239 if err := validation.Validate([]validation.Validation{ 240 {TargetValue: serviceName, 241 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 242 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 243 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 244 {TargetValue: backendid, 245 Constraints: []validation.Constraint{{Target: "backendid", Name: validation.MaxLength, Rule: 255, Chain: nil}, 246 {Target: "backendid", Name: validation.MinLength, Rule: 1, Chain: nil}, 247 {Target: "backendid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 248 return result, validation.NewError("apimanagement.BackendsClient", "Get", err.Error()) 249 } 250 251 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, backendid) 252 if err != nil { 253 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Get", nil, "Failure preparing request") 254 return 255 } 256 257 resp, err := client.GetSender(req) 258 if err != nil { 259 result.Response = autorest.Response{Response: resp} 260 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Get", resp, "Failure sending request") 261 return 262 } 263 264 result, err = client.GetResponder(resp) 265 if err != nil { 266 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Get", resp, "Failure responding to request") 267 return 268 } 269 270 return 271} 272 273// GetPreparer prepares the Get request. 274func (client BackendsClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, backendid string) (*http.Request, error) { 275 pathParameters := map[string]interface{}{ 276 "backendid": autorest.Encode("path", backendid), 277 "resourceGroupName": autorest.Encode("path", resourceGroupName), 278 "serviceName": autorest.Encode("path", serviceName), 279 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 280 } 281 282 const APIVersion = "2016-07-07" 283 queryParameters := map[string]interface{}{ 284 "api-version": APIVersion, 285 } 286 287 preparer := autorest.CreatePreparer( 288 autorest.AsGet(), 289 autorest.WithBaseURL(client.BaseURI), 290 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendid}", pathParameters), 291 autorest.WithQueryParameters(queryParameters)) 292 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 293} 294 295// GetSender sends the Get request. The method will close the 296// http.Response Body if it receives an error. 297func (client BackendsClient) GetSender(req *http.Request) (*http.Response, error) { 298 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 299} 300 301// GetResponder handles the response to the Get request. The method always 302// closes the http.Response Body. 303func (client BackendsClient) GetResponder(resp *http.Response) (result BackendResponse, err error) { 304 err = autorest.Respond( 305 resp, 306 azure.WithErrorUnlessStatusCode(http.StatusOK), 307 autorest.ByUnmarshallingJSON(&result), 308 autorest.ByClosing()) 309 result.Response = autorest.Response{Response: resp} 310 return 311} 312 313// ListByService lists a collection of backends in the specified service instance. 314// Parameters: 315// resourceGroupName - the name of the resource group. 316// serviceName - the name of the API Management service. 317// filter - | Field | Supported operators | Supported functions | 318// |-------|------------------------|---------------------------------------------| 319// | id | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | 320// | host | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | 321// top - number of records to return. 322// skip - number of records to skip. 323func (client BackendsClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result BackendCollectionPage, err error) { 324 if tracing.IsEnabled() { 325 ctx = tracing.StartSpan(ctx, fqdn+"/BackendsClient.ListByService") 326 defer func() { 327 sc := -1 328 if result.bc.Response.Response != nil { 329 sc = result.bc.Response.Response.StatusCode 330 } 331 tracing.EndSpan(ctx, sc, err) 332 }() 333 } 334 if err := validation.Validate([]validation.Validation{ 335 {TargetValue: serviceName, 336 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 337 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 338 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 339 {TargetValue: top, 340 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 341 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, 342 {TargetValue: skip, 343 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 344 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { 345 return result, validation.NewError("apimanagement.BackendsClient", "ListByService", err.Error()) 346 } 347 348 result.fn = client.listByServiceNextResults 349 req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) 350 if err != nil { 351 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "ListByService", nil, "Failure preparing request") 352 return 353 } 354 355 resp, err := client.ListByServiceSender(req) 356 if err != nil { 357 result.bc.Response = autorest.Response{Response: resp} 358 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "ListByService", resp, "Failure sending request") 359 return 360 } 361 362 result.bc, err = client.ListByServiceResponder(resp) 363 if err != nil { 364 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "ListByService", resp, "Failure responding to request") 365 return 366 } 367 if result.bc.hasNextLink() && result.bc.IsEmpty() { 368 err = result.NextWithContext(ctx) 369 return 370 } 371 372 return 373} 374 375// ListByServicePreparer prepares the ListByService request. 376func (client BackendsClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { 377 pathParameters := map[string]interface{}{ 378 "resourceGroupName": autorest.Encode("path", resourceGroupName), 379 "serviceName": autorest.Encode("path", serviceName), 380 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 381 } 382 383 const APIVersion = "2016-07-07" 384 queryParameters := map[string]interface{}{ 385 "api-version": APIVersion, 386 } 387 if len(filter) > 0 { 388 queryParameters["$filter"] = autorest.Encode("query", filter) 389 } 390 if top != nil { 391 queryParameters["$top"] = autorest.Encode("query", *top) 392 } 393 if skip != nil { 394 queryParameters["$skip"] = autorest.Encode("query", *skip) 395 } 396 397 preparer := autorest.CreatePreparer( 398 autorest.AsGet(), 399 autorest.WithBaseURL(client.BaseURI), 400 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends", pathParameters), 401 autorest.WithQueryParameters(queryParameters)) 402 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 403} 404 405// ListByServiceSender sends the ListByService request. The method will close the 406// http.Response Body if it receives an error. 407func (client BackendsClient) ListByServiceSender(req *http.Request) (*http.Response, error) { 408 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 409} 410 411// ListByServiceResponder handles the response to the ListByService request. The method always 412// closes the http.Response Body. 413func (client BackendsClient) ListByServiceResponder(resp *http.Response) (result BackendCollection, err error) { 414 err = autorest.Respond( 415 resp, 416 azure.WithErrorUnlessStatusCode(http.StatusOK), 417 autorest.ByUnmarshallingJSON(&result), 418 autorest.ByClosing()) 419 result.Response = autorest.Response{Response: resp} 420 return 421} 422 423// listByServiceNextResults retrieves the next set of results, if any. 424func (client BackendsClient) listByServiceNextResults(ctx context.Context, lastResults BackendCollection) (result BackendCollection, err error) { 425 req, err := lastResults.backendCollectionPreparer(ctx) 426 if err != nil { 427 return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "listByServiceNextResults", nil, "Failure preparing next results request") 428 } 429 if req == nil { 430 return 431 } 432 resp, err := client.ListByServiceSender(req) 433 if err != nil { 434 result.Response = autorest.Response{Response: resp} 435 return result, autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "listByServiceNextResults", resp, "Failure sending next results request") 436 } 437 result, err = client.ListByServiceResponder(resp) 438 if err != nil { 439 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "listByServiceNextResults", resp, "Failure responding to next results request") 440 } 441 return 442} 443 444// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. 445func (client BackendsClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result BackendCollectionIterator, err error) { 446 if tracing.IsEnabled() { 447 ctx = tracing.StartSpan(ctx, fqdn+"/BackendsClient.ListByService") 448 defer func() { 449 sc := -1 450 if result.Response().Response.Response != nil { 451 sc = result.page.Response().Response.Response.StatusCode 452 } 453 tracing.EndSpan(ctx, sc, err) 454 }() 455 } 456 result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) 457 return 458} 459 460// Update updates an existing backend. 461// Parameters: 462// resourceGroupName - the name of the resource group. 463// serviceName - the name of the API Management service. 464// backendid - user identifier. Must be unique in the current API Management service instance. 465// parameters - update parameters. 466// ifMatch - the entity state (Etag) version of the backend to update. A value of "*" can be used for If-Match 467// to unconditionally apply the operation. 468func (client BackendsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, backendid string, parameters BackendUpdateParameters, ifMatch string) (result autorest.Response, err error) { 469 if tracing.IsEnabled() { 470 ctx = tracing.StartSpan(ctx, fqdn+"/BackendsClient.Update") 471 defer func() { 472 sc := -1 473 if result.Response != nil { 474 sc = result.Response.StatusCode 475 } 476 tracing.EndSpan(ctx, sc, err) 477 }() 478 } 479 if err := validation.Validate([]validation.Validation{ 480 {TargetValue: serviceName, 481 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 482 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 483 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 484 {TargetValue: backendid, 485 Constraints: []validation.Constraint{{Target: "backendid", Name: validation.MaxLength, Rule: 255, Chain: nil}, 486 {Target: "backendid", Name: validation.MinLength, Rule: 1, Chain: nil}, 487 {Target: "backendid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 488 return result, validation.NewError("apimanagement.BackendsClient", "Update", err.Error()) 489 } 490 491 req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, backendid, parameters, ifMatch) 492 if err != nil { 493 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Update", nil, "Failure preparing request") 494 return 495 } 496 497 resp, err := client.UpdateSender(req) 498 if err != nil { 499 result.Response = resp 500 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Update", resp, "Failure sending request") 501 return 502 } 503 504 result, err = client.UpdateResponder(resp) 505 if err != nil { 506 err = autorest.NewErrorWithError(err, "apimanagement.BackendsClient", "Update", resp, "Failure responding to request") 507 return 508 } 509 510 return 511} 512 513// UpdatePreparer prepares the Update request. 514func (client BackendsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, backendid string, parameters BackendUpdateParameters, ifMatch string) (*http.Request, error) { 515 pathParameters := map[string]interface{}{ 516 "backendid": autorest.Encode("path", backendid), 517 "resourceGroupName": autorest.Encode("path", resourceGroupName), 518 "serviceName": autorest.Encode("path", serviceName), 519 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 520 } 521 522 const APIVersion = "2016-07-07" 523 queryParameters := map[string]interface{}{ 524 "api-version": APIVersion, 525 } 526 527 preparer := autorest.CreatePreparer( 528 autorest.AsContentType("application/json; charset=utf-8"), 529 autorest.AsPatch(), 530 autorest.WithBaseURL(client.BaseURI), 531 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendid}", pathParameters), 532 autorest.WithJSON(parameters), 533 autorest.WithQueryParameters(queryParameters), 534 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 535 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 536} 537 538// UpdateSender sends the Update request. The method will close the 539// http.Response Body if it receives an error. 540func (client BackendsClient) UpdateSender(req *http.Request) (*http.Response, error) { 541 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 542} 543 544// UpdateResponder handles the response to the Update request. The method always 545// closes the http.Response Body. 546func (client BackendsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { 547 err = autorest.Respond( 548 resp, 549 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 550 autorest.ByClosing()) 551 result.Response = resp 552 return 553} 554