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