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