1package appplatform
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// AppsClient is the REST API for Azure Spring Cloud
30type AppsClient struct {
31	BaseClient
32}
33
34// NewAppsClient creates an instance of the AppsClient client.
35func NewAppsClient(subscriptionID string) AppsClient {
36	return NewAppsClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewAppsClientWithBaseURI creates an instance of the AppsClient client using a custom endpoint.  Use this when
40// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
41func NewAppsClientWithBaseURI(baseURI string, subscriptionID string) AppsClient {
42	return AppsClient{NewWithBaseURI(baseURI, subscriptionID)}
43}
44
45// CreateOrUpdate create a new App or update an exiting App.
46// Parameters:
47// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
48// from the Azure Resource Manager API or the portal.
49// serviceName - the name of the Service resource.
50// appName - the name of the App resource.
51// appResource - parameters for the create or update operation
52func (client AppsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource AppResource) (result AppsCreateOrUpdateFuture, err error) {
53	if tracing.IsEnabled() {
54		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.CreateOrUpdate")
55		defer func() {
56			sc := -1
57			if result.Response() != nil {
58				sc = result.Response().StatusCode
59			}
60			tracing.EndSpan(ctx, sc, err)
61		}()
62	}
63	if err := validation.Validate([]validation.Validation{
64		{TargetValue: appResource,
65			Constraints: []validation.Constraint{{Target: "appResource.Properties", Name: validation.Null, Rule: false,
66				Chain: []validation.Constraint{{Target: "appResource.Properties.TemporaryDisk", Name: validation.Null, Rule: false,
67					Chain: []validation.Constraint{{Target: "appResource.Properties.TemporaryDisk.SizeInGB", Name: validation.Null, Rule: false,
68						Chain: []validation.Constraint{{Target: "appResource.Properties.TemporaryDisk.SizeInGB", Name: validation.InclusiveMaximum, Rule: int64(5), Chain: nil},
69							{Target: "appResource.Properties.TemporaryDisk.SizeInGB", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
70						}},
71					}},
72					{Target: "appResource.Properties.PersistentDisk", Name: validation.Null, Rule: false,
73						Chain: []validation.Constraint{{Target: "appResource.Properties.PersistentDisk.SizeInGB", Name: validation.Null, Rule: false,
74							Chain: []validation.Constraint{{Target: "appResource.Properties.PersistentDisk.SizeInGB", Name: validation.InclusiveMaximum, Rule: int64(50), Chain: nil},
75								{Target: "appResource.Properties.PersistentDisk.SizeInGB", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
76							}},
77							{Target: "appResource.Properties.PersistentDisk.UsedInGB", Name: validation.Null, Rule: false,
78								Chain: []validation.Constraint{{Target: "appResource.Properties.PersistentDisk.UsedInGB", Name: validation.InclusiveMaximum, Rule: int64(50), Chain: nil},
79									{Target: "appResource.Properties.PersistentDisk.UsedInGB", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
80								}},
81						}},
82				}}}}}); err != nil {
83		return result, validation.NewError("appplatform.AppsClient", "CreateOrUpdate", err.Error())
84	}
85
86	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, appName, appResource)
87	if err != nil {
88		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "CreateOrUpdate", nil, "Failure preparing request")
89		return
90	}
91
92	result, err = client.CreateOrUpdateSender(req)
93	if err != nil {
94		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "CreateOrUpdate", nil, "Failure sending request")
95		return
96	}
97
98	return
99}
100
101// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
102func (client AppsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource AppResource) (*http.Request, error) {
103	pathParameters := map[string]interface{}{
104		"appName":           autorest.Encode("path", appName),
105		"resourceGroupName": autorest.Encode("path", resourceGroupName),
106		"serviceName":       autorest.Encode("path", serviceName),
107		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
108	}
109
110	const APIVersion = "2019-05-01-preview"
111	queryParameters := map[string]interface{}{
112		"api-version": APIVersion,
113	}
114
115	preparer := autorest.CreatePreparer(
116		autorest.AsContentType("application/json; charset=utf-8"),
117		autorest.AsPut(),
118		autorest.WithBaseURL(client.BaseURI),
119		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", pathParameters),
120		autorest.WithJSON(appResource),
121		autorest.WithQueryParameters(queryParameters))
122	return preparer.Prepare((&http.Request{}).WithContext(ctx))
123}
124
125// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
126// http.Response Body if it receives an error.
127func (client AppsClient) CreateOrUpdateSender(req *http.Request) (future AppsCreateOrUpdateFuture, err error) {
128	var resp *http.Response
129	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
130	if err != nil {
131		return
132	}
133	var azf azure.Future
134	azf, err = azure.NewFutureFromResponse(resp)
135	future.FutureAPI = &azf
136	future.Result = func(client AppsClient) (ar AppResource, err error) {
137		var done bool
138		done, err = future.DoneWithContext(context.Background(), client)
139		if err != nil {
140			err = autorest.NewErrorWithError(err, "appplatform.AppsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
141			return
142		}
143		if !done {
144			err = azure.NewAsyncOpIncompleteError("appplatform.AppsCreateOrUpdateFuture")
145			return
146		}
147		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
148		if ar.Response.Response, err = future.GetResult(sender); err == nil && ar.Response.Response.StatusCode != http.StatusNoContent {
149			ar, err = client.CreateOrUpdateResponder(ar.Response.Response)
150			if err != nil {
151				err = autorest.NewErrorWithError(err, "appplatform.AppsCreateOrUpdateFuture", "Result", ar.Response.Response, "Failure responding to request")
152			}
153		}
154		return
155	}
156	return
157}
158
159// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
160// closes the http.Response Body.
161func (client AppsClient) CreateOrUpdateResponder(resp *http.Response) (result AppResource, err error) {
162	err = autorest.Respond(
163		resp,
164		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
165		autorest.ByUnmarshallingJSON(&result),
166		autorest.ByClosing())
167	result.Response = autorest.Response{Response: resp}
168	return
169}
170
171// Delete operation to delete an App.
172// Parameters:
173// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
174// from the Azure Resource Manager API or the portal.
175// serviceName - the name of the Service resource.
176// appName - the name of the App resource.
177func (client AppsClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, appName string) (result autorest.Response, err error) {
178	if tracing.IsEnabled() {
179		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Delete")
180		defer func() {
181			sc := -1
182			if result.Response != nil {
183				sc = result.Response.StatusCode
184			}
185			tracing.EndSpan(ctx, sc, err)
186		}()
187	}
188	req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, appName)
189	if err != nil {
190		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Delete", nil, "Failure preparing request")
191		return
192	}
193
194	resp, err := client.DeleteSender(req)
195	if err != nil {
196		result.Response = resp
197		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Delete", resp, "Failure sending request")
198		return
199	}
200
201	result, err = client.DeleteResponder(resp)
202	if err != nil {
203		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Delete", resp, "Failure responding to request")
204		return
205	}
206
207	return
208}
209
210// DeletePreparer prepares the Delete request.
211func (client AppsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, appName string) (*http.Request, error) {
212	pathParameters := map[string]interface{}{
213		"appName":           autorest.Encode("path", appName),
214		"resourceGroupName": autorest.Encode("path", resourceGroupName),
215		"serviceName":       autorest.Encode("path", serviceName),
216		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
217	}
218
219	const APIVersion = "2019-05-01-preview"
220	queryParameters := map[string]interface{}{
221		"api-version": APIVersion,
222	}
223
224	preparer := autorest.CreatePreparer(
225		autorest.AsDelete(),
226		autorest.WithBaseURL(client.BaseURI),
227		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", pathParameters),
228		autorest.WithQueryParameters(queryParameters))
229	return preparer.Prepare((&http.Request{}).WithContext(ctx))
230}
231
232// DeleteSender sends the Delete request. The method will close the
233// http.Response Body if it receives an error.
234func (client AppsClient) DeleteSender(req *http.Request) (*http.Response, error) {
235	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
236}
237
238// DeleteResponder handles the response to the Delete request. The method always
239// closes the http.Response Body.
240func (client AppsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
241	err = autorest.Respond(
242		resp,
243		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
244		autorest.ByClosing())
245	result.Response = resp
246	return
247}
248
249// Get get an App and its properties.
250// Parameters:
251// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
252// from the Azure Resource Manager API or the portal.
253// serviceName - the name of the Service resource.
254// appName - the name of the App resource.
255// syncStatus - indicates whether sync status
256func (client AppsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, appName string, syncStatus string) (result AppResource, err error) {
257	if tracing.IsEnabled() {
258		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Get")
259		defer func() {
260			sc := -1
261			if result.Response.Response != nil {
262				sc = result.Response.Response.StatusCode
263			}
264			tracing.EndSpan(ctx, sc, err)
265		}()
266	}
267	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, appName, syncStatus)
268	if err != nil {
269		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Get", nil, "Failure preparing request")
270		return
271	}
272
273	resp, err := client.GetSender(req)
274	if err != nil {
275		result.Response = autorest.Response{Response: resp}
276		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Get", resp, "Failure sending request")
277		return
278	}
279
280	result, err = client.GetResponder(resp)
281	if err != nil {
282		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Get", resp, "Failure responding to request")
283		return
284	}
285
286	return
287}
288
289// GetPreparer prepares the Get request.
290func (client AppsClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, appName string, syncStatus string) (*http.Request, error) {
291	pathParameters := map[string]interface{}{
292		"appName":           autorest.Encode("path", appName),
293		"resourceGroupName": autorest.Encode("path", resourceGroupName),
294		"serviceName":       autorest.Encode("path", serviceName),
295		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
296	}
297
298	const APIVersion = "2019-05-01-preview"
299	queryParameters := map[string]interface{}{
300		"api-version": APIVersion,
301	}
302	if len(syncStatus) > 0 {
303		queryParameters["syncStatus"] = autorest.Encode("query", syncStatus)
304	}
305
306	preparer := autorest.CreatePreparer(
307		autorest.AsGet(),
308		autorest.WithBaseURL(client.BaseURI),
309		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", pathParameters),
310		autorest.WithQueryParameters(queryParameters))
311	return preparer.Prepare((&http.Request{}).WithContext(ctx))
312}
313
314// GetSender sends the Get request. The method will close the
315// http.Response Body if it receives an error.
316func (client AppsClient) GetSender(req *http.Request) (*http.Response, error) {
317	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
318}
319
320// GetResponder handles the response to the Get request. The method always
321// closes the http.Response Body.
322func (client AppsClient) GetResponder(resp *http.Response) (result AppResource, err error) {
323	err = autorest.Respond(
324		resp,
325		azure.WithErrorUnlessStatusCode(http.StatusOK),
326		autorest.ByUnmarshallingJSON(&result),
327		autorest.ByClosing())
328	result.Response = autorest.Response{Response: resp}
329	return
330}
331
332// GetResourceUploadURL get an resource upload URL for an App, which may be artifacts or source archive.
333// Parameters:
334// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
335// from the Azure Resource Manager API or the portal.
336// serviceName - the name of the Service resource.
337// appName - the name of the App resource.
338func (client AppsClient) GetResourceUploadURL(ctx context.Context, resourceGroupName string, serviceName string, appName string) (result ResourceUploadDefinition, err error) {
339	if tracing.IsEnabled() {
340		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.GetResourceUploadURL")
341		defer func() {
342			sc := -1
343			if result.Response.Response != nil {
344				sc = result.Response.Response.StatusCode
345			}
346			tracing.EndSpan(ctx, sc, err)
347		}()
348	}
349	req, err := client.GetResourceUploadURLPreparer(ctx, resourceGroupName, serviceName, appName)
350	if err != nil {
351		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "GetResourceUploadURL", nil, "Failure preparing request")
352		return
353	}
354
355	resp, err := client.GetResourceUploadURLSender(req)
356	if err != nil {
357		result.Response = autorest.Response{Response: resp}
358		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "GetResourceUploadURL", resp, "Failure sending request")
359		return
360	}
361
362	result, err = client.GetResourceUploadURLResponder(resp)
363	if err != nil {
364		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "GetResourceUploadURL", resp, "Failure responding to request")
365		return
366	}
367
368	return
369}
370
371// GetResourceUploadURLPreparer prepares the GetResourceUploadURL request.
372func (client AppsClient) GetResourceUploadURLPreparer(ctx context.Context, resourceGroupName string, serviceName string, appName string) (*http.Request, error) {
373	pathParameters := map[string]interface{}{
374		"appName":           autorest.Encode("path", appName),
375		"resourceGroupName": autorest.Encode("path", resourceGroupName),
376		"serviceName":       autorest.Encode("path", serviceName),
377		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
378	}
379
380	const APIVersion = "2019-05-01-preview"
381	queryParameters := map[string]interface{}{
382		"api-version": APIVersion,
383	}
384
385	preparer := autorest.CreatePreparer(
386		autorest.AsPost(),
387		autorest.WithBaseURL(client.BaseURI),
388		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/getResourceUploadUrl", pathParameters),
389		autorest.WithQueryParameters(queryParameters))
390	return preparer.Prepare((&http.Request{}).WithContext(ctx))
391}
392
393// GetResourceUploadURLSender sends the GetResourceUploadURL request. The method will close the
394// http.Response Body if it receives an error.
395func (client AppsClient) GetResourceUploadURLSender(req *http.Request) (*http.Response, error) {
396	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
397}
398
399// GetResourceUploadURLResponder handles the response to the GetResourceUploadURL request. The method always
400// closes the http.Response Body.
401func (client AppsClient) GetResourceUploadURLResponder(resp *http.Response) (result ResourceUploadDefinition, err error) {
402	err = autorest.Respond(
403		resp,
404		azure.WithErrorUnlessStatusCode(http.StatusOK),
405		autorest.ByUnmarshallingJSON(&result),
406		autorest.ByClosing())
407	result.Response = autorest.Response{Response: resp}
408	return
409}
410
411// List handles requests to list all resources in a Service.
412// Parameters:
413// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
414// from the Azure Resource Manager API or the portal.
415// serviceName - the name of the Service resource.
416func (client AppsClient) List(ctx context.Context, resourceGroupName string, serviceName string) (result AppResourceCollectionPage, err error) {
417	if tracing.IsEnabled() {
418		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.List")
419		defer func() {
420			sc := -1
421			if result.arc.Response.Response != nil {
422				sc = result.arc.Response.Response.StatusCode
423			}
424			tracing.EndSpan(ctx, sc, err)
425		}()
426	}
427	result.fn = client.listNextResults
428	req, err := client.ListPreparer(ctx, resourceGroupName, serviceName)
429	if err != nil {
430		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "List", nil, "Failure preparing request")
431		return
432	}
433
434	resp, err := client.ListSender(req)
435	if err != nil {
436		result.arc.Response = autorest.Response{Response: resp}
437		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "List", resp, "Failure sending request")
438		return
439	}
440
441	result.arc, err = client.ListResponder(resp)
442	if err != nil {
443		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "List", resp, "Failure responding to request")
444		return
445	}
446	if result.arc.hasNextLink() && result.arc.IsEmpty() {
447		err = result.NextWithContext(ctx)
448		return
449	}
450
451	return
452}
453
454// ListPreparer prepares the List request.
455func (client AppsClient) ListPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
456	pathParameters := map[string]interface{}{
457		"resourceGroupName": autorest.Encode("path", resourceGroupName),
458		"serviceName":       autorest.Encode("path", serviceName),
459		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
460	}
461
462	const APIVersion = "2019-05-01-preview"
463	queryParameters := map[string]interface{}{
464		"api-version": APIVersion,
465	}
466
467	preparer := autorest.CreatePreparer(
468		autorest.AsGet(),
469		autorest.WithBaseURL(client.BaseURI),
470		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps", pathParameters),
471		autorest.WithQueryParameters(queryParameters))
472	return preparer.Prepare((&http.Request{}).WithContext(ctx))
473}
474
475// ListSender sends the List request. The method will close the
476// http.Response Body if it receives an error.
477func (client AppsClient) ListSender(req *http.Request) (*http.Response, error) {
478	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
479}
480
481// ListResponder handles the response to the List request. The method always
482// closes the http.Response Body.
483func (client AppsClient) ListResponder(resp *http.Response) (result AppResourceCollection, err error) {
484	err = autorest.Respond(
485		resp,
486		azure.WithErrorUnlessStatusCode(http.StatusOK),
487		autorest.ByUnmarshallingJSON(&result),
488		autorest.ByClosing())
489	result.Response = autorest.Response{Response: resp}
490	return
491}
492
493// listNextResults retrieves the next set of results, if any.
494func (client AppsClient) listNextResults(ctx context.Context, lastResults AppResourceCollection) (result AppResourceCollection, err error) {
495	req, err := lastResults.appResourceCollectionPreparer(ctx)
496	if err != nil {
497		return result, autorest.NewErrorWithError(err, "appplatform.AppsClient", "listNextResults", nil, "Failure preparing next results request")
498	}
499	if req == nil {
500		return
501	}
502	resp, err := client.ListSender(req)
503	if err != nil {
504		result.Response = autorest.Response{Response: resp}
505		return result, autorest.NewErrorWithError(err, "appplatform.AppsClient", "listNextResults", resp, "Failure sending next results request")
506	}
507	result, err = client.ListResponder(resp)
508	if err != nil {
509		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "listNextResults", resp, "Failure responding to next results request")
510	}
511	return
512}
513
514// ListComplete enumerates all values, automatically crossing page boundaries as required.
515func (client AppsClient) ListComplete(ctx context.Context, resourceGroupName string, serviceName string) (result AppResourceCollectionIterator, err error) {
516	if tracing.IsEnabled() {
517		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.List")
518		defer func() {
519			sc := -1
520			if result.Response().Response.Response != nil {
521				sc = result.page.Response().Response.Response.StatusCode
522			}
523			tracing.EndSpan(ctx, sc, err)
524		}()
525	}
526	result.page, err = client.List(ctx, resourceGroupName, serviceName)
527	return
528}
529
530// Update operation to update an exiting App.
531// Parameters:
532// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
533// from the Azure Resource Manager API or the portal.
534// serviceName - the name of the Service resource.
535// appName - the name of the App resource.
536// appResource - parameters for the update operation
537func (client AppsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource AppResource) (result AppsUpdateFuture, err error) {
538	if tracing.IsEnabled() {
539		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Update")
540		defer func() {
541			sc := -1
542			if result.Response() != nil {
543				sc = result.Response().StatusCode
544			}
545			tracing.EndSpan(ctx, sc, err)
546		}()
547	}
548	req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, appName, appResource)
549	if err != nil {
550		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Update", nil, "Failure preparing request")
551		return
552	}
553
554	result, err = client.UpdateSender(req)
555	if err != nil {
556		err = autorest.NewErrorWithError(err, "appplatform.AppsClient", "Update", nil, "Failure sending request")
557		return
558	}
559
560	return
561}
562
563// UpdatePreparer prepares the Update request.
564func (client AppsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, appName string, appResource AppResource) (*http.Request, error) {
565	pathParameters := map[string]interface{}{
566		"appName":           autorest.Encode("path", appName),
567		"resourceGroupName": autorest.Encode("path", resourceGroupName),
568		"serviceName":       autorest.Encode("path", serviceName),
569		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
570	}
571
572	const APIVersion = "2019-05-01-preview"
573	queryParameters := map[string]interface{}{
574		"api-version": APIVersion,
575	}
576
577	preparer := autorest.CreatePreparer(
578		autorest.AsContentType("application/json; charset=utf-8"),
579		autorest.AsPatch(),
580		autorest.WithBaseURL(client.BaseURI),
581		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}", pathParameters),
582		autorest.WithJSON(appResource),
583		autorest.WithQueryParameters(queryParameters))
584	return preparer.Prepare((&http.Request{}).WithContext(ctx))
585}
586
587// UpdateSender sends the Update request. The method will close the
588// http.Response Body if it receives an error.
589func (client AppsClient) UpdateSender(req *http.Request) (future AppsUpdateFuture, err error) {
590	var resp *http.Response
591	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
592	if err != nil {
593		return
594	}
595	var azf azure.Future
596	azf, err = azure.NewFutureFromResponse(resp)
597	future.FutureAPI = &azf
598	future.Result = func(client AppsClient) (ar AppResource, err error) {
599		var done bool
600		done, err = future.DoneWithContext(context.Background(), client)
601		if err != nil {
602			err = autorest.NewErrorWithError(err, "appplatform.AppsUpdateFuture", "Result", future.Response(), "Polling failure")
603			return
604		}
605		if !done {
606			err = azure.NewAsyncOpIncompleteError("appplatform.AppsUpdateFuture")
607			return
608		}
609		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
610		if ar.Response.Response, err = future.GetResult(sender); err == nil && ar.Response.Response.StatusCode != http.StatusNoContent {
611			ar, err = client.UpdateResponder(ar.Response.Response)
612			if err != nil {
613				err = autorest.NewErrorWithError(err, "appplatform.AppsUpdateFuture", "Result", ar.Response.Response, "Failure responding to request")
614			}
615		}
616		return
617	}
618	return
619}
620
621// UpdateResponder handles the response to the Update request. The method always
622// closes the http.Response Body.
623func (client AppsClient) UpdateResponder(resp *http.Response) (result AppResource, err error) {
624	err = autorest.Respond(
625		resp,
626		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
627		autorest.ByUnmarshallingJSON(&result),
628		autorest.ByClosing())
629	result.Response = autorest.Response{Response: resp}
630	return
631}
632