1package appplatform
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// ServicesClient is the REST API for Azure Spring Cloud
19type ServicesClient struct {
20	BaseClient
21}
22
23// NewServicesClient creates an instance of the ServicesClient client.
24func NewServicesClient(subscriptionID string) ServicesClient {
25	return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewServicesClientWithBaseURI creates an instance of the ServicesClient client using a custom endpoint.  Use this
29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient {
31	return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CheckNameAvailability checks that the resource name is valid and is not already in use.
35// Parameters:
36// location - the region
37// availabilityParameters - parameters supplied to the operation.
38func (client ServicesClient) CheckNameAvailability(ctx context.Context, location string, availabilityParameters NameAvailabilityParameters) (result NameAvailability, err error) {
39	if tracing.IsEnabled() {
40		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CheckNameAvailability")
41		defer func() {
42			sc := -1
43			if result.Response.Response != nil {
44				sc = result.Response.Response.StatusCode
45			}
46			tracing.EndSpan(ctx, sc, err)
47		}()
48	}
49	if err := validation.Validate([]validation.Validation{
50		{TargetValue: availabilityParameters,
51			Constraints: []validation.Constraint{{Target: "availabilityParameters.Type", Name: validation.Null, Rule: true, Chain: nil},
52				{Target: "availabilityParameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
53		return result, validation.NewError("appplatform.ServicesClient", "CheckNameAvailability", err.Error())
54	}
55
56	req, err := client.CheckNameAvailabilityPreparer(ctx, location, availabilityParameters)
57	if err != nil {
58		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CheckNameAvailability", nil, "Failure preparing request")
59		return
60	}
61
62	resp, err := client.CheckNameAvailabilitySender(req)
63	if err != nil {
64		result.Response = autorest.Response{Response: resp}
65		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CheckNameAvailability", resp, "Failure sending request")
66		return
67	}
68
69	result, err = client.CheckNameAvailabilityResponder(resp)
70	if err != nil {
71		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CheckNameAvailability", resp, "Failure responding to request")
72		return
73	}
74
75	return
76}
77
78// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request.
79func (client ServicesClient) CheckNameAvailabilityPreparer(ctx context.Context, location string, availabilityParameters NameAvailabilityParameters) (*http.Request, error) {
80	pathParameters := map[string]interface{}{
81		"location":       autorest.Encode("path", location),
82		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
83	}
84
85	const APIVersion = "2020-11-01-preview"
86	queryParameters := map[string]interface{}{
87		"api-version": APIVersion,
88	}
89
90	preparer := autorest.CreatePreparer(
91		autorest.AsContentType("application/json; charset=utf-8"),
92		autorest.AsPost(),
93		autorest.WithBaseURL(client.BaseURI),
94		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", pathParameters),
95		autorest.WithJSON(availabilityParameters),
96		autorest.WithQueryParameters(queryParameters))
97	return preparer.Prepare((&http.Request{}).WithContext(ctx))
98}
99
100// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the
101// http.Response Body if it receives an error.
102func (client ServicesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) {
103	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
104}
105
106// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always
107// closes the http.Response Body.
108func (client ServicesClient) CheckNameAvailabilityResponder(resp *http.Response) (result NameAvailability, err error) {
109	err = autorest.Respond(
110		resp,
111		azure.WithErrorUnlessStatusCode(http.StatusOK),
112		autorest.ByUnmarshallingJSON(&result),
113		autorest.ByClosing())
114	result.Response = autorest.Response{Response: resp}
115	return
116}
117
118// CreateOrUpdate create a new Service or update an exiting Service.
119// Parameters:
120// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
121// from the Azure Resource Manager API or the portal.
122// serviceName - the name of the Service resource.
123// resource - parameters for the create or update operation
124func (client ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, resource ServiceResource) (result ServicesCreateOrUpdateFuture, err error) {
125	if tracing.IsEnabled() {
126		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CreateOrUpdate")
127		defer func() {
128			sc := -1
129			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
130				sc = result.FutureAPI.Response().StatusCode
131			}
132			tracing.EndSpan(ctx, sc, err)
133		}()
134	}
135	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, resource)
136	if err != nil {
137		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CreateOrUpdate", nil, "Failure preparing request")
138		return
139	}
140
141	result, err = client.CreateOrUpdateSender(req)
142	if err != nil {
143		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CreateOrUpdate", nil, "Failure sending request")
144		return
145	}
146
147	return
148}
149
150// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
151func (client ServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, resource ServiceResource) (*http.Request, error) {
152	pathParameters := map[string]interface{}{
153		"resourceGroupName": autorest.Encode("path", resourceGroupName),
154		"serviceName":       autorest.Encode("path", serviceName),
155		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
156	}
157
158	const APIVersion = "2020-11-01-preview"
159	queryParameters := map[string]interface{}{
160		"api-version": APIVersion,
161	}
162
163	preparer := autorest.CreatePreparer(
164		autorest.AsContentType("application/json; charset=utf-8"),
165		autorest.AsPut(),
166		autorest.WithBaseURL(client.BaseURI),
167		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", pathParameters),
168		autorest.WithJSON(resource),
169		autorest.WithQueryParameters(queryParameters))
170	return preparer.Prepare((&http.Request{}).WithContext(ctx))
171}
172
173// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
174// http.Response Body if it receives an error.
175func (client ServicesClient) CreateOrUpdateSender(req *http.Request) (future ServicesCreateOrUpdateFuture, err error) {
176	var resp *http.Response
177	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
178	if err != nil {
179		return
180	}
181	var azf azure.Future
182	azf, err = azure.NewFutureFromResponse(resp)
183	future.FutureAPI = &azf
184	future.Result = future.result
185	return
186}
187
188// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
189// closes the http.Response Body.
190func (client ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceResource, err error) {
191	err = autorest.Respond(
192		resp,
193		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
194		autorest.ByUnmarshallingJSON(&result),
195		autorest.ByClosing())
196	result.Response = autorest.Response{Response: resp}
197	return
198}
199
200// Delete operation to delete a Service.
201// Parameters:
202// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
203// from the Azure Resource Manager API or the portal.
204// serviceName - the name of the Service resource.
205func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, serviceName string) (result ServicesDeleteFuture, err error) {
206	if tracing.IsEnabled() {
207		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Delete")
208		defer func() {
209			sc := -1
210			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
211				sc = result.FutureAPI.Response().StatusCode
212			}
213			tracing.EndSpan(ctx, sc, err)
214		}()
215	}
216	req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName)
217	if err != nil {
218		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Delete", nil, "Failure preparing request")
219		return
220	}
221
222	result, err = client.DeleteSender(req)
223	if err != nil {
224		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Delete", nil, "Failure sending request")
225		return
226	}
227
228	return
229}
230
231// DeletePreparer prepares the Delete request.
232func (client ServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
233	pathParameters := map[string]interface{}{
234		"resourceGroupName": autorest.Encode("path", resourceGroupName),
235		"serviceName":       autorest.Encode("path", serviceName),
236		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
237	}
238
239	const APIVersion = "2020-11-01-preview"
240	queryParameters := map[string]interface{}{
241		"api-version": APIVersion,
242	}
243
244	preparer := autorest.CreatePreparer(
245		autorest.AsDelete(),
246		autorest.WithBaseURL(client.BaseURI),
247		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", pathParameters),
248		autorest.WithQueryParameters(queryParameters))
249	return preparer.Prepare((&http.Request{}).WithContext(ctx))
250}
251
252// DeleteSender sends the Delete request. The method will close the
253// http.Response Body if it receives an error.
254func (client ServicesClient) DeleteSender(req *http.Request) (future ServicesDeleteFuture, err error) {
255	var resp *http.Response
256	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
257	if err != nil {
258		return
259	}
260	var azf azure.Future
261	azf, err = azure.NewFutureFromResponse(resp)
262	future.FutureAPI = &azf
263	future.Result = future.result
264	return
265}
266
267// DeleteResponder handles the response to the Delete request. The method always
268// closes the http.Response Body.
269func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
270	err = autorest.Respond(
271		resp,
272		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
273		autorest.ByClosing())
274	result.Response = resp
275	return
276}
277
278// DisableTestEndpoint disable test endpoint functionality for a Service.
279// Parameters:
280// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
281// from the Azure Resource Manager API or the portal.
282// serviceName - the name of the Service resource.
283func (client ServicesClient) DisableTestEndpoint(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) {
284	if tracing.IsEnabled() {
285		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.DisableTestEndpoint")
286		defer func() {
287			sc := -1
288			if result.Response != nil {
289				sc = result.Response.StatusCode
290			}
291			tracing.EndSpan(ctx, sc, err)
292		}()
293	}
294	req, err := client.DisableTestEndpointPreparer(ctx, resourceGroupName, serviceName)
295	if err != nil {
296		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "DisableTestEndpoint", nil, "Failure preparing request")
297		return
298	}
299
300	resp, err := client.DisableTestEndpointSender(req)
301	if err != nil {
302		result.Response = resp
303		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "DisableTestEndpoint", resp, "Failure sending request")
304		return
305	}
306
307	result, err = client.DisableTestEndpointResponder(resp)
308	if err != nil {
309		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "DisableTestEndpoint", resp, "Failure responding to request")
310		return
311	}
312
313	return
314}
315
316// DisableTestEndpointPreparer prepares the DisableTestEndpoint request.
317func (client ServicesClient) DisableTestEndpointPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
318	pathParameters := map[string]interface{}{
319		"resourceGroupName": autorest.Encode("path", resourceGroupName),
320		"serviceName":       autorest.Encode("path", serviceName),
321		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
322	}
323
324	const APIVersion = "2020-11-01-preview"
325	queryParameters := map[string]interface{}{
326		"api-version": APIVersion,
327	}
328
329	preparer := autorest.CreatePreparer(
330		autorest.AsPost(),
331		autorest.WithBaseURL(client.BaseURI),
332		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", pathParameters),
333		autorest.WithQueryParameters(queryParameters))
334	return preparer.Prepare((&http.Request{}).WithContext(ctx))
335}
336
337// DisableTestEndpointSender sends the DisableTestEndpoint request. The method will close the
338// http.Response Body if it receives an error.
339func (client ServicesClient) DisableTestEndpointSender(req *http.Request) (*http.Response, error) {
340	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
341}
342
343// DisableTestEndpointResponder handles the response to the DisableTestEndpoint request. The method always
344// closes the http.Response Body.
345func (client ServicesClient) DisableTestEndpointResponder(resp *http.Response) (result autorest.Response, err error) {
346	err = autorest.Respond(
347		resp,
348		azure.WithErrorUnlessStatusCode(http.StatusOK),
349		autorest.ByClosing())
350	result.Response = resp
351	return
352}
353
354// EnableTestEndpoint enable test endpoint functionality for a Service.
355// Parameters:
356// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
357// from the Azure Resource Manager API or the portal.
358// serviceName - the name of the Service resource.
359func (client ServicesClient) EnableTestEndpoint(ctx context.Context, resourceGroupName string, serviceName string) (result TestKeys, err error) {
360	if tracing.IsEnabled() {
361		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.EnableTestEndpoint")
362		defer func() {
363			sc := -1
364			if result.Response.Response != nil {
365				sc = result.Response.Response.StatusCode
366			}
367			tracing.EndSpan(ctx, sc, err)
368		}()
369	}
370	req, err := client.EnableTestEndpointPreparer(ctx, resourceGroupName, serviceName)
371	if err != nil {
372		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "EnableTestEndpoint", nil, "Failure preparing request")
373		return
374	}
375
376	resp, err := client.EnableTestEndpointSender(req)
377	if err != nil {
378		result.Response = autorest.Response{Response: resp}
379		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "EnableTestEndpoint", resp, "Failure sending request")
380		return
381	}
382
383	result, err = client.EnableTestEndpointResponder(resp)
384	if err != nil {
385		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "EnableTestEndpoint", resp, "Failure responding to request")
386		return
387	}
388
389	return
390}
391
392// EnableTestEndpointPreparer prepares the EnableTestEndpoint request.
393func (client ServicesClient) EnableTestEndpointPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
394	pathParameters := map[string]interface{}{
395		"resourceGroupName": autorest.Encode("path", resourceGroupName),
396		"serviceName":       autorest.Encode("path", serviceName),
397		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
398	}
399
400	const APIVersion = "2020-11-01-preview"
401	queryParameters := map[string]interface{}{
402		"api-version": APIVersion,
403	}
404
405	preparer := autorest.CreatePreparer(
406		autorest.AsPost(),
407		autorest.WithBaseURL(client.BaseURI),
408		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", pathParameters),
409		autorest.WithQueryParameters(queryParameters))
410	return preparer.Prepare((&http.Request{}).WithContext(ctx))
411}
412
413// EnableTestEndpointSender sends the EnableTestEndpoint request. The method will close the
414// http.Response Body if it receives an error.
415func (client ServicesClient) EnableTestEndpointSender(req *http.Request) (*http.Response, error) {
416	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
417}
418
419// EnableTestEndpointResponder handles the response to the EnableTestEndpoint request. The method always
420// closes the http.Response Body.
421func (client ServicesClient) EnableTestEndpointResponder(resp *http.Response) (result TestKeys, err error) {
422	err = autorest.Respond(
423		resp,
424		azure.WithErrorUnlessStatusCode(http.StatusOK),
425		autorest.ByUnmarshallingJSON(&result),
426		autorest.ByClosing())
427	result.Response = autorest.Response{Response: resp}
428	return
429}
430
431// Get get a Service and its properties.
432// Parameters:
433// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
434// from the Azure Resource Manager API or the portal.
435// serviceName - the name of the Service resource.
436func (client ServicesClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceResource, err error) {
437	if tracing.IsEnabled() {
438		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Get")
439		defer func() {
440			sc := -1
441			if result.Response.Response != nil {
442				sc = result.Response.Response.StatusCode
443			}
444			tracing.EndSpan(ctx, sc, err)
445		}()
446	}
447	req, err := client.GetPreparer(ctx, resourceGroupName, serviceName)
448	if err != nil {
449		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Get", nil, "Failure preparing request")
450		return
451	}
452
453	resp, err := client.GetSender(req)
454	if err != nil {
455		result.Response = autorest.Response{Response: resp}
456		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Get", resp, "Failure sending request")
457		return
458	}
459
460	result, err = client.GetResponder(resp)
461	if err != nil {
462		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Get", resp, "Failure responding to request")
463		return
464	}
465
466	return
467}
468
469// GetPreparer prepares the Get request.
470func (client ServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
471	pathParameters := map[string]interface{}{
472		"resourceGroupName": autorest.Encode("path", resourceGroupName),
473		"serviceName":       autorest.Encode("path", serviceName),
474		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
475	}
476
477	const APIVersion = "2020-11-01-preview"
478	queryParameters := map[string]interface{}{
479		"api-version": APIVersion,
480	}
481
482	preparer := autorest.CreatePreparer(
483		autorest.AsGet(),
484		autorest.WithBaseURL(client.BaseURI),
485		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", pathParameters),
486		autorest.WithQueryParameters(queryParameters))
487	return preparer.Prepare((&http.Request{}).WithContext(ctx))
488}
489
490// GetSender sends the Get request. The method will close the
491// http.Response Body if it receives an error.
492func (client ServicesClient) GetSender(req *http.Request) (*http.Response, error) {
493	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
494}
495
496// GetResponder handles the response to the Get request. The method always
497// closes the http.Response Body.
498func (client ServicesClient) GetResponder(resp *http.Response) (result ServiceResource, err error) {
499	err = autorest.Respond(
500		resp,
501		azure.WithErrorUnlessStatusCode(http.StatusOK),
502		autorest.ByUnmarshallingJSON(&result),
503		autorest.ByClosing())
504	result.Response = autorest.Response{Response: resp}
505	return
506}
507
508// List handles requests to list all resources in a resource group.
509// Parameters:
510// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
511// from the Azure Resource Manager API or the portal.
512func (client ServicesClient) List(ctx context.Context, resourceGroupName string) (result ServiceResourceListPage, err error) {
513	if tracing.IsEnabled() {
514		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.List")
515		defer func() {
516			sc := -1
517			if result.srl.Response.Response != nil {
518				sc = result.srl.Response.Response.StatusCode
519			}
520			tracing.EndSpan(ctx, sc, err)
521		}()
522	}
523	result.fn = client.listNextResults
524	req, err := client.ListPreparer(ctx, resourceGroupName)
525	if err != nil {
526		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "List", nil, "Failure preparing request")
527		return
528	}
529
530	resp, err := client.ListSender(req)
531	if err != nil {
532		result.srl.Response = autorest.Response{Response: resp}
533		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "List", resp, "Failure sending request")
534		return
535	}
536
537	result.srl, err = client.ListResponder(resp)
538	if err != nil {
539		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "List", resp, "Failure responding to request")
540		return
541	}
542	if result.srl.hasNextLink() && result.srl.IsEmpty() {
543		err = result.NextWithContext(ctx)
544		return
545	}
546
547	return
548}
549
550// ListPreparer prepares the List request.
551func (client ServicesClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
552	pathParameters := map[string]interface{}{
553		"resourceGroupName": autorest.Encode("path", resourceGroupName),
554		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
555	}
556
557	const APIVersion = "2020-11-01-preview"
558	queryParameters := map[string]interface{}{
559		"api-version": APIVersion,
560	}
561
562	preparer := autorest.CreatePreparer(
563		autorest.AsGet(),
564		autorest.WithBaseURL(client.BaseURI),
565		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", pathParameters),
566		autorest.WithQueryParameters(queryParameters))
567	return preparer.Prepare((&http.Request{}).WithContext(ctx))
568}
569
570// ListSender sends the List request. The method will close the
571// http.Response Body if it receives an error.
572func (client ServicesClient) ListSender(req *http.Request) (*http.Response, error) {
573	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
574}
575
576// ListResponder handles the response to the List request. The method always
577// closes the http.Response Body.
578func (client ServicesClient) ListResponder(resp *http.Response) (result ServiceResourceList, err error) {
579	err = autorest.Respond(
580		resp,
581		azure.WithErrorUnlessStatusCode(http.StatusOK),
582		autorest.ByUnmarshallingJSON(&result),
583		autorest.ByClosing())
584	result.Response = autorest.Response{Response: resp}
585	return
586}
587
588// listNextResults retrieves the next set of results, if any.
589func (client ServicesClient) listNextResults(ctx context.Context, lastResults ServiceResourceList) (result ServiceResourceList, err error) {
590	req, err := lastResults.serviceResourceListPreparer(ctx)
591	if err != nil {
592		return result, autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listNextResults", nil, "Failure preparing next results request")
593	}
594	if req == nil {
595		return
596	}
597	resp, err := client.ListSender(req)
598	if err != nil {
599		result.Response = autorest.Response{Response: resp}
600		return result, autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listNextResults", resp, "Failure sending next results request")
601	}
602	result, err = client.ListResponder(resp)
603	if err != nil {
604		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listNextResults", resp, "Failure responding to next results request")
605	}
606	return
607}
608
609// ListComplete enumerates all values, automatically crossing page boundaries as required.
610func (client ServicesClient) ListComplete(ctx context.Context, resourceGroupName string) (result ServiceResourceListIterator, err error) {
611	if tracing.IsEnabled() {
612		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.List")
613		defer func() {
614			sc := -1
615			if result.Response().Response.Response != nil {
616				sc = result.page.Response().Response.Response.StatusCode
617			}
618			tracing.EndSpan(ctx, sc, err)
619		}()
620	}
621	result.page, err = client.List(ctx, resourceGroupName)
622	return
623}
624
625// ListBySubscription handles requests to list all resources in a subscription.
626func (client ServicesClient) ListBySubscription(ctx context.Context) (result ServiceResourceListPage, err error) {
627	if tracing.IsEnabled() {
628		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListBySubscription")
629		defer func() {
630			sc := -1
631			if result.srl.Response.Response != nil {
632				sc = result.srl.Response.Response.StatusCode
633			}
634			tracing.EndSpan(ctx, sc, err)
635		}()
636	}
637	result.fn = client.listBySubscriptionNextResults
638	req, err := client.ListBySubscriptionPreparer(ctx)
639	if err != nil {
640		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListBySubscription", nil, "Failure preparing request")
641		return
642	}
643
644	resp, err := client.ListBySubscriptionSender(req)
645	if err != nil {
646		result.srl.Response = autorest.Response{Response: resp}
647		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListBySubscription", resp, "Failure sending request")
648		return
649	}
650
651	result.srl, err = client.ListBySubscriptionResponder(resp)
652	if err != nil {
653		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListBySubscription", resp, "Failure responding to request")
654		return
655	}
656	if result.srl.hasNextLink() && result.srl.IsEmpty() {
657		err = result.NextWithContext(ctx)
658		return
659	}
660
661	return
662}
663
664// ListBySubscriptionPreparer prepares the ListBySubscription request.
665func (client ServicesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
666	pathParameters := map[string]interface{}{
667		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
668	}
669
670	const APIVersion = "2020-11-01-preview"
671	queryParameters := map[string]interface{}{
672		"api-version": APIVersion,
673	}
674
675	preparer := autorest.CreatePreparer(
676		autorest.AsGet(),
677		autorest.WithBaseURL(client.BaseURI),
678		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring", pathParameters),
679		autorest.WithQueryParameters(queryParameters))
680	return preparer.Prepare((&http.Request{}).WithContext(ctx))
681}
682
683// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
684// http.Response Body if it receives an error.
685func (client ServicesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
686	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
687}
688
689// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
690// closes the http.Response Body.
691func (client ServicesClient) ListBySubscriptionResponder(resp *http.Response) (result ServiceResourceList, err error) {
692	err = autorest.Respond(
693		resp,
694		azure.WithErrorUnlessStatusCode(http.StatusOK),
695		autorest.ByUnmarshallingJSON(&result),
696		autorest.ByClosing())
697	result.Response = autorest.Response{Response: resp}
698	return
699}
700
701// listBySubscriptionNextResults retrieves the next set of results, if any.
702func (client ServicesClient) listBySubscriptionNextResults(ctx context.Context, lastResults ServiceResourceList) (result ServiceResourceList, err error) {
703	req, err := lastResults.serviceResourceListPreparer(ctx)
704	if err != nil {
705		return result, autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
706	}
707	if req == nil {
708		return
709	}
710	resp, err := client.ListBySubscriptionSender(req)
711	if err != nil {
712		result.Response = autorest.Response{Response: resp}
713		return result, autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
714	}
715	result, err = client.ListBySubscriptionResponder(resp)
716	if err != nil {
717		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
718	}
719	return
720}
721
722// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
723func (client ServicesClient) ListBySubscriptionComplete(ctx context.Context) (result ServiceResourceListIterator, err error) {
724	if tracing.IsEnabled() {
725		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListBySubscription")
726		defer func() {
727			sc := -1
728			if result.Response().Response.Response != nil {
729				sc = result.page.Response().Response.Response.StatusCode
730			}
731			tracing.EndSpan(ctx, sc, err)
732		}()
733	}
734	result.page, err = client.ListBySubscription(ctx)
735	return
736}
737
738// ListTestKeys list test keys for a Service.
739// Parameters:
740// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
741// from the Azure Resource Manager API or the portal.
742// serviceName - the name of the Service resource.
743func (client ServicesClient) ListTestKeys(ctx context.Context, resourceGroupName string, serviceName string) (result TestKeys, err error) {
744	if tracing.IsEnabled() {
745		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListTestKeys")
746		defer func() {
747			sc := -1
748			if result.Response.Response != nil {
749				sc = result.Response.Response.StatusCode
750			}
751			tracing.EndSpan(ctx, sc, err)
752		}()
753	}
754	req, err := client.ListTestKeysPreparer(ctx, resourceGroupName, serviceName)
755	if err != nil {
756		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListTestKeys", nil, "Failure preparing request")
757		return
758	}
759
760	resp, err := client.ListTestKeysSender(req)
761	if err != nil {
762		result.Response = autorest.Response{Response: resp}
763		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListTestKeys", resp, "Failure sending request")
764		return
765	}
766
767	result, err = client.ListTestKeysResponder(resp)
768	if err != nil {
769		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListTestKeys", resp, "Failure responding to request")
770		return
771	}
772
773	return
774}
775
776// ListTestKeysPreparer prepares the ListTestKeys request.
777func (client ServicesClient) ListTestKeysPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
778	pathParameters := map[string]interface{}{
779		"resourceGroupName": autorest.Encode("path", resourceGroupName),
780		"serviceName":       autorest.Encode("path", serviceName),
781		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
782	}
783
784	const APIVersion = "2020-11-01-preview"
785	queryParameters := map[string]interface{}{
786		"api-version": APIVersion,
787	}
788
789	preparer := autorest.CreatePreparer(
790		autorest.AsPost(),
791		autorest.WithBaseURL(client.BaseURI),
792		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", pathParameters),
793		autorest.WithQueryParameters(queryParameters))
794	return preparer.Prepare((&http.Request{}).WithContext(ctx))
795}
796
797// ListTestKeysSender sends the ListTestKeys request. The method will close the
798// http.Response Body if it receives an error.
799func (client ServicesClient) ListTestKeysSender(req *http.Request) (*http.Response, error) {
800	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
801}
802
803// ListTestKeysResponder handles the response to the ListTestKeys request. The method always
804// closes the http.Response Body.
805func (client ServicesClient) ListTestKeysResponder(resp *http.Response) (result TestKeys, err error) {
806	err = autorest.Respond(
807		resp,
808		azure.WithErrorUnlessStatusCode(http.StatusOK),
809		autorest.ByUnmarshallingJSON(&result),
810		autorest.ByClosing())
811	result.Response = autorest.Response{Response: resp}
812	return
813}
814
815// RegenerateTestKey regenerate a test key for a Service.
816// Parameters:
817// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
818// from the Azure Resource Manager API or the portal.
819// serviceName - the name of the Service resource.
820// regenerateTestKeyRequest - parameters for the operation
821func (client ServicesClient) RegenerateTestKey(ctx context.Context, resourceGroupName string, serviceName string, regenerateTestKeyRequest RegenerateTestKeyRequestPayload) (result TestKeys, err error) {
822	if tracing.IsEnabled() {
823		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.RegenerateTestKey")
824		defer func() {
825			sc := -1
826			if result.Response.Response != nil {
827				sc = result.Response.Response.StatusCode
828			}
829			tracing.EndSpan(ctx, sc, err)
830		}()
831	}
832	req, err := client.RegenerateTestKeyPreparer(ctx, resourceGroupName, serviceName, regenerateTestKeyRequest)
833	if err != nil {
834		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "RegenerateTestKey", nil, "Failure preparing request")
835		return
836	}
837
838	resp, err := client.RegenerateTestKeySender(req)
839	if err != nil {
840		result.Response = autorest.Response{Response: resp}
841		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "RegenerateTestKey", resp, "Failure sending request")
842		return
843	}
844
845	result, err = client.RegenerateTestKeyResponder(resp)
846	if err != nil {
847		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "RegenerateTestKey", resp, "Failure responding to request")
848		return
849	}
850
851	return
852}
853
854// RegenerateTestKeyPreparer prepares the RegenerateTestKey request.
855func (client ServicesClient) RegenerateTestKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, regenerateTestKeyRequest RegenerateTestKeyRequestPayload) (*http.Request, error) {
856	pathParameters := map[string]interface{}{
857		"resourceGroupName": autorest.Encode("path", resourceGroupName),
858		"serviceName":       autorest.Encode("path", serviceName),
859		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
860	}
861
862	const APIVersion = "2020-11-01-preview"
863	queryParameters := map[string]interface{}{
864		"api-version": APIVersion,
865	}
866
867	preparer := autorest.CreatePreparer(
868		autorest.AsContentType("application/json; charset=utf-8"),
869		autorest.AsPost(),
870		autorest.WithBaseURL(client.BaseURI),
871		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", pathParameters),
872		autorest.WithJSON(regenerateTestKeyRequest),
873		autorest.WithQueryParameters(queryParameters))
874	return preparer.Prepare((&http.Request{}).WithContext(ctx))
875}
876
877// RegenerateTestKeySender sends the RegenerateTestKey request. The method will close the
878// http.Response Body if it receives an error.
879func (client ServicesClient) RegenerateTestKeySender(req *http.Request) (*http.Response, error) {
880	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
881}
882
883// RegenerateTestKeyResponder handles the response to the RegenerateTestKey request. The method always
884// closes the http.Response Body.
885func (client ServicesClient) RegenerateTestKeyResponder(resp *http.Response) (result TestKeys, err error) {
886	err = autorest.Respond(
887		resp,
888		azure.WithErrorUnlessStatusCode(http.StatusOK),
889		autorest.ByUnmarshallingJSON(&result),
890		autorest.ByClosing())
891	result.Response = autorest.Response{Response: resp}
892	return
893}
894
895// Update operation to update an exiting Service.
896// Parameters:
897// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
898// from the Azure Resource Manager API or the portal.
899// serviceName - the name of the Service resource.
900// resource - parameters for the update operation
901func (client ServicesClient) Update(ctx context.Context, resourceGroupName string, serviceName string, resource ServiceResource) (result ServicesUpdateFuture, err error) {
902	if tracing.IsEnabled() {
903		ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Update")
904		defer func() {
905			sc := -1
906			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
907				sc = result.FutureAPI.Response().StatusCode
908			}
909			tracing.EndSpan(ctx, sc, err)
910		}()
911	}
912	req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, resource)
913	if err != nil {
914		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Update", nil, "Failure preparing request")
915		return
916	}
917
918	result, err = client.UpdateSender(req)
919	if err != nil {
920		err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Update", nil, "Failure sending request")
921		return
922	}
923
924	return
925}
926
927// UpdatePreparer prepares the Update request.
928func (client ServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, resource ServiceResource) (*http.Request, error) {
929	pathParameters := map[string]interface{}{
930		"resourceGroupName": autorest.Encode("path", resourceGroupName),
931		"serviceName":       autorest.Encode("path", serviceName),
932		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
933	}
934
935	const APIVersion = "2020-11-01-preview"
936	queryParameters := map[string]interface{}{
937		"api-version": APIVersion,
938	}
939
940	preparer := autorest.CreatePreparer(
941		autorest.AsContentType("application/json; charset=utf-8"),
942		autorest.AsPatch(),
943		autorest.WithBaseURL(client.BaseURI),
944		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", pathParameters),
945		autorest.WithJSON(resource),
946		autorest.WithQueryParameters(queryParameters))
947	return preparer.Prepare((&http.Request{}).WithContext(ctx))
948}
949
950// UpdateSender sends the Update request. The method will close the
951// http.Response Body if it receives an error.
952func (client ServicesClient) UpdateSender(req *http.Request) (future ServicesUpdateFuture, err error) {
953	var resp *http.Response
954	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
955	if err != nil {
956		return
957	}
958	var azf azure.Future
959	azf, err = azure.NewFutureFromResponse(resp)
960	future.FutureAPI = &azf
961	future.Result = future.result
962	return
963}
964
965// UpdateResponder handles the response to the Update request. The method always
966// closes the http.Response Body.
967func (client ServicesClient) UpdateResponder(resp *http.Response) (result ServiceResource, err error) {
968	err = autorest.Respond(
969		resp,
970		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
971		autorest.ByUnmarshallingJSON(&result),
972		autorest.ByClosing())
973	result.Response = autorest.Response{Response: resp}
974	return
975}
976