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