1package dtl
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// ServiceFabricsClient is the the DevTest Labs Client.
30type ServiceFabricsClient struct {
31	BaseClient
32}
33
34// NewServiceFabricsClient creates an instance of the ServiceFabricsClient client.
35func NewServiceFabricsClient(subscriptionID string) ServiceFabricsClient {
36	return NewServiceFabricsClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewServiceFabricsClientWithBaseURI creates an instance of the ServiceFabricsClient client.
40func NewServiceFabricsClientWithBaseURI(baseURI string, subscriptionID string) ServiceFabricsClient {
41	return ServiceFabricsClient{NewWithBaseURI(baseURI, subscriptionID)}
42}
43
44// CreateOrUpdate create or replace an existing service fabric. This operation can take a while to complete.
45// Parameters:
46// resourceGroupName - the name of the resource group.
47// labName - the name of the lab.
48// userName - the name of the user profile.
49// name - the name of the service fabric.
50// serviceFabric - a Service Fabric.
51func (client ServiceFabricsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, serviceFabric ServiceFabric) (result ServiceFabricsCreateOrUpdateFuture, err error) {
52	if tracing.IsEnabled() {
53		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceFabricsClient.CreateOrUpdate")
54		defer func() {
55			sc := -1
56			if result.Response() != nil {
57				sc = result.Response().StatusCode
58			}
59			tracing.EndSpan(ctx, sc, err)
60		}()
61	}
62	if err := validation.Validate([]validation.Validation{
63		{TargetValue: serviceFabric,
64			Constraints: []validation.Constraint{{Target: "serviceFabric.ServiceFabricProperties", Name: validation.Null, Rule: true,
65				Chain: []validation.Constraint{{Target: "serviceFabric.ServiceFabricProperties.ApplicableSchedule", Name: validation.Null, Rule: false,
66					Chain: []validation.Constraint{{Target: "serviceFabric.ServiceFabricProperties.ApplicableSchedule.ApplicableScheduleProperties", Name: validation.Null, Rule: true,
67						Chain: []validation.Constraint{{Target: "serviceFabric.ServiceFabricProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown", Name: validation.Null, Rule: false,
68							Chain: []validation.Constraint{{Target: "serviceFabric.ServiceFabricProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}},
69							{Target: "serviceFabric.ServiceFabricProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup", Name: validation.Null, Rule: false,
70								Chain: []validation.Constraint{{Target: "serviceFabric.ServiceFabricProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}},
71						}},
72					}},
73				}}}}}); err != nil {
74		return result, validation.NewError("dtl.ServiceFabricsClient", "CreateOrUpdate", err.Error())
75	}
76
77	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, labName, userName, name, serviceFabric)
78	if err != nil {
79		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "CreateOrUpdate", nil, "Failure preparing request")
80		return
81	}
82
83	result, err = client.CreateOrUpdateSender(req)
84	if err != nil {
85		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
86		return
87	}
88
89	return
90}
91
92// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
93func (client ServiceFabricsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string, serviceFabric ServiceFabric) (*http.Request, error) {
94	pathParameters := map[string]interface{}{
95		"labName":           autorest.Encode("path", labName),
96		"name":              autorest.Encode("path", name),
97		"resourceGroupName": autorest.Encode("path", resourceGroupName),
98		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
99		"userName":          autorest.Encode("path", userName),
100	}
101
102	const APIVersion = "2018-09-15"
103	queryParameters := map[string]interface{}{
104		"api-version": APIVersion,
105	}
106
107	preparer := autorest.CreatePreparer(
108		autorest.AsContentType("application/json; charset=utf-8"),
109		autorest.AsPut(),
110		autorest.WithBaseURL(client.BaseURI),
111		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}", pathParameters),
112		autorest.WithJSON(serviceFabric),
113		autorest.WithQueryParameters(queryParameters))
114	return preparer.Prepare((&http.Request{}).WithContext(ctx))
115}
116
117// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
118// http.Response Body if it receives an error.
119func (client ServiceFabricsClient) CreateOrUpdateSender(req *http.Request) (future ServiceFabricsCreateOrUpdateFuture, err error) {
120	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
121	var resp *http.Response
122	resp, err = autorest.SendWithSender(client, req, sd...)
123	if err != nil {
124		return
125	}
126	future.Future, err = azure.NewFutureFromResponse(resp)
127	return
128}
129
130// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
131// closes the http.Response Body.
132func (client ServiceFabricsClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceFabric, err error) {
133	err = autorest.Respond(
134		resp,
135		client.ByInspecting(),
136		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
137		autorest.ByUnmarshallingJSON(&result),
138		autorest.ByClosing())
139	result.Response = autorest.Response{Response: resp}
140	return
141}
142
143// Delete delete service fabric. This operation can take a while to complete.
144// Parameters:
145// resourceGroupName - the name of the resource group.
146// labName - the name of the lab.
147// userName - the name of the user profile.
148// name - the name of the service fabric.
149func (client ServiceFabricsClient) Delete(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (result ServiceFabricsDeleteFuture, err error) {
150	if tracing.IsEnabled() {
151		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceFabricsClient.Delete")
152		defer func() {
153			sc := -1
154			if result.Response() != nil {
155				sc = result.Response().StatusCode
156			}
157			tracing.EndSpan(ctx, sc, err)
158		}()
159	}
160	req, err := client.DeletePreparer(ctx, resourceGroupName, labName, userName, name)
161	if err != nil {
162		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Delete", nil, "Failure preparing request")
163		return
164	}
165
166	result, err = client.DeleteSender(req)
167	if err != nil {
168		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Delete", result.Response(), "Failure sending request")
169		return
170	}
171
172	return
173}
174
175// DeletePreparer prepares the Delete request.
176func (client ServiceFabricsClient) DeletePreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (*http.Request, error) {
177	pathParameters := map[string]interface{}{
178		"labName":           autorest.Encode("path", labName),
179		"name":              autorest.Encode("path", name),
180		"resourceGroupName": autorest.Encode("path", resourceGroupName),
181		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
182		"userName":          autorest.Encode("path", userName),
183	}
184
185	const APIVersion = "2018-09-15"
186	queryParameters := map[string]interface{}{
187		"api-version": APIVersion,
188	}
189
190	preparer := autorest.CreatePreparer(
191		autorest.AsDelete(),
192		autorest.WithBaseURL(client.BaseURI),
193		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}", pathParameters),
194		autorest.WithQueryParameters(queryParameters))
195	return preparer.Prepare((&http.Request{}).WithContext(ctx))
196}
197
198// DeleteSender sends the Delete request. The method will close the
199// http.Response Body if it receives an error.
200func (client ServiceFabricsClient) DeleteSender(req *http.Request) (future ServiceFabricsDeleteFuture, err error) {
201	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
202	var resp *http.Response
203	resp, err = autorest.SendWithSender(client, req, sd...)
204	if err != nil {
205		return
206	}
207	future.Future, err = azure.NewFutureFromResponse(resp)
208	return
209}
210
211// DeleteResponder handles the response to the Delete request. The method always
212// closes the http.Response Body.
213func (client ServiceFabricsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
214	err = autorest.Respond(
215		resp,
216		client.ByInspecting(),
217		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
218		autorest.ByClosing())
219	result.Response = resp
220	return
221}
222
223// Get get service fabric.
224// Parameters:
225// resourceGroupName - the name of the resource group.
226// labName - the name of the lab.
227// userName - the name of the user profile.
228// name - the name of the service fabric.
229// expand - specify the $expand query. Example: 'properties($expand=applicableSchedule)'
230func (client ServiceFabricsClient) Get(ctx context.Context, resourceGroupName string, labName string, userName string, name string, expand string) (result ServiceFabric, err error) {
231	if tracing.IsEnabled() {
232		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceFabricsClient.Get")
233		defer func() {
234			sc := -1
235			if result.Response.Response != nil {
236				sc = result.Response.Response.StatusCode
237			}
238			tracing.EndSpan(ctx, sc, err)
239		}()
240	}
241	req, err := client.GetPreparer(ctx, resourceGroupName, labName, userName, name, expand)
242	if err != nil {
243		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Get", nil, "Failure preparing request")
244		return
245	}
246
247	resp, err := client.GetSender(req)
248	if err != nil {
249		result.Response = autorest.Response{Response: resp}
250		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Get", resp, "Failure sending request")
251		return
252	}
253
254	result, err = client.GetResponder(resp)
255	if err != nil {
256		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Get", resp, "Failure responding to request")
257	}
258
259	return
260}
261
262// GetPreparer prepares the Get request.
263func (client ServiceFabricsClient) GetPreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string, expand string) (*http.Request, error) {
264	pathParameters := map[string]interface{}{
265		"labName":           autorest.Encode("path", labName),
266		"name":              autorest.Encode("path", name),
267		"resourceGroupName": autorest.Encode("path", resourceGroupName),
268		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
269		"userName":          autorest.Encode("path", userName),
270	}
271
272	const APIVersion = "2018-09-15"
273	queryParameters := map[string]interface{}{
274		"api-version": APIVersion,
275	}
276	if len(expand) > 0 {
277		queryParameters["$expand"] = autorest.Encode("query", expand)
278	}
279
280	preparer := autorest.CreatePreparer(
281		autorest.AsGet(),
282		autorest.WithBaseURL(client.BaseURI),
283		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}", pathParameters),
284		autorest.WithQueryParameters(queryParameters))
285	return preparer.Prepare((&http.Request{}).WithContext(ctx))
286}
287
288// GetSender sends the Get request. The method will close the
289// http.Response Body if it receives an error.
290func (client ServiceFabricsClient) GetSender(req *http.Request) (*http.Response, error) {
291	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
292	return autorest.SendWithSender(client, req, sd...)
293}
294
295// GetResponder handles the response to the Get request. The method always
296// closes the http.Response Body.
297func (client ServiceFabricsClient) GetResponder(resp *http.Response) (result ServiceFabric, err error) {
298	err = autorest.Respond(
299		resp,
300		client.ByInspecting(),
301		azure.WithErrorUnlessStatusCode(http.StatusOK),
302		autorest.ByUnmarshallingJSON(&result),
303		autorest.ByClosing())
304	result.Response = autorest.Response{Response: resp}
305	return
306}
307
308// List list service fabrics in a given user profile.
309// Parameters:
310// resourceGroupName - the name of the resource group.
311// labName - the name of the lab.
312// userName - the name of the user profile.
313// expand - specify the $expand query. Example: 'properties($expand=applicableSchedule)'
314// filter - the filter to apply to the operation. Example: '$filter=contains(name,'myName')
315// top - the maximum number of resources to return from the operation. Example: '$top=10'
316// orderby - the ordering expression for the results, using OData notation. Example: '$orderby=name desc'
317func (client ServiceFabricsClient) List(ctx context.Context, resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (result ServiceFabricListPage, err error) {
318	if tracing.IsEnabled() {
319		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceFabricsClient.List")
320		defer func() {
321			sc := -1
322			if result.sfl.Response.Response != nil {
323				sc = result.sfl.Response.Response.StatusCode
324			}
325			tracing.EndSpan(ctx, sc, err)
326		}()
327	}
328	result.fn = client.listNextResults
329	req, err := client.ListPreparer(ctx, resourceGroupName, labName, userName, expand, filter, top, orderby)
330	if err != nil {
331		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "List", nil, "Failure preparing request")
332		return
333	}
334
335	resp, err := client.ListSender(req)
336	if err != nil {
337		result.sfl.Response = autorest.Response{Response: resp}
338		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "List", resp, "Failure sending request")
339		return
340	}
341
342	result.sfl, err = client.ListResponder(resp)
343	if err != nil {
344		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "List", resp, "Failure responding to request")
345	}
346
347	return
348}
349
350// ListPreparer prepares the List request.
351func (client ServiceFabricsClient) ListPreparer(ctx context.Context, resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) {
352	pathParameters := map[string]interface{}{
353		"labName":           autorest.Encode("path", labName),
354		"resourceGroupName": autorest.Encode("path", resourceGroupName),
355		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
356		"userName":          autorest.Encode("path", userName),
357	}
358
359	const APIVersion = "2018-09-15"
360	queryParameters := map[string]interface{}{
361		"api-version": APIVersion,
362	}
363	if len(expand) > 0 {
364		queryParameters["$expand"] = autorest.Encode("query", expand)
365	}
366	if len(filter) > 0 {
367		queryParameters["$filter"] = autorest.Encode("query", filter)
368	}
369	if top != nil {
370		queryParameters["$top"] = autorest.Encode("query", *top)
371	}
372	if len(orderby) > 0 {
373		queryParameters["$orderby"] = autorest.Encode("query", orderby)
374	}
375
376	preparer := autorest.CreatePreparer(
377		autorest.AsGet(),
378		autorest.WithBaseURL(client.BaseURI),
379		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics", pathParameters),
380		autorest.WithQueryParameters(queryParameters))
381	return preparer.Prepare((&http.Request{}).WithContext(ctx))
382}
383
384// ListSender sends the List request. The method will close the
385// http.Response Body if it receives an error.
386func (client ServiceFabricsClient) ListSender(req *http.Request) (*http.Response, error) {
387	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
388	return autorest.SendWithSender(client, req, sd...)
389}
390
391// ListResponder handles the response to the List request. The method always
392// closes the http.Response Body.
393func (client ServiceFabricsClient) ListResponder(resp *http.Response) (result ServiceFabricList, err error) {
394	err = autorest.Respond(
395		resp,
396		client.ByInspecting(),
397		azure.WithErrorUnlessStatusCode(http.StatusOK),
398		autorest.ByUnmarshallingJSON(&result),
399		autorest.ByClosing())
400	result.Response = autorest.Response{Response: resp}
401	return
402}
403
404// listNextResults retrieves the next set of results, if any.
405func (client ServiceFabricsClient) listNextResults(ctx context.Context, lastResults ServiceFabricList) (result ServiceFabricList, err error) {
406	req, err := lastResults.serviceFabricListPreparer(ctx)
407	if err != nil {
408		return result, autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "listNextResults", nil, "Failure preparing next results request")
409	}
410	if req == nil {
411		return
412	}
413	resp, err := client.ListSender(req)
414	if err != nil {
415		result.Response = autorest.Response{Response: resp}
416		return result, autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "listNextResults", resp, "Failure sending next results request")
417	}
418	result, err = client.ListResponder(resp)
419	if err != nil {
420		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "listNextResults", resp, "Failure responding to next results request")
421	}
422	return
423}
424
425// ListComplete enumerates all values, automatically crossing page boundaries as required.
426func (client ServiceFabricsClient) ListComplete(ctx context.Context, resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (result ServiceFabricListIterator, err error) {
427	if tracing.IsEnabled() {
428		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceFabricsClient.List")
429		defer func() {
430			sc := -1
431			if result.Response().Response.Response != nil {
432				sc = result.page.Response().Response.Response.StatusCode
433			}
434			tracing.EndSpan(ctx, sc, err)
435		}()
436	}
437	result.page, err = client.List(ctx, resourceGroupName, labName, userName, expand, filter, top, orderby)
438	return
439}
440
441// ListApplicableSchedules lists the applicable start/stop schedules, if any.
442// Parameters:
443// resourceGroupName - the name of the resource group.
444// labName - the name of the lab.
445// userName - the name of the user profile.
446// name - the name of the service fabric.
447func (client ServiceFabricsClient) ListApplicableSchedules(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (result ApplicableSchedule, err error) {
448	if tracing.IsEnabled() {
449		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceFabricsClient.ListApplicableSchedules")
450		defer func() {
451			sc := -1
452			if result.Response.Response != nil {
453				sc = result.Response.Response.StatusCode
454			}
455			tracing.EndSpan(ctx, sc, err)
456		}()
457	}
458	req, err := client.ListApplicableSchedulesPreparer(ctx, resourceGroupName, labName, userName, name)
459	if err != nil {
460		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "ListApplicableSchedules", nil, "Failure preparing request")
461		return
462	}
463
464	resp, err := client.ListApplicableSchedulesSender(req)
465	if err != nil {
466		result.Response = autorest.Response{Response: resp}
467		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "ListApplicableSchedules", resp, "Failure sending request")
468		return
469	}
470
471	result, err = client.ListApplicableSchedulesResponder(resp)
472	if err != nil {
473		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "ListApplicableSchedules", resp, "Failure responding to request")
474	}
475
476	return
477}
478
479// ListApplicableSchedulesPreparer prepares the ListApplicableSchedules request.
480func (client ServiceFabricsClient) ListApplicableSchedulesPreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (*http.Request, error) {
481	pathParameters := map[string]interface{}{
482		"labName":           autorest.Encode("path", labName),
483		"name":              autorest.Encode("path", name),
484		"resourceGroupName": autorest.Encode("path", resourceGroupName),
485		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
486		"userName":          autorest.Encode("path", userName),
487	}
488
489	const APIVersion = "2018-09-15"
490	queryParameters := map[string]interface{}{
491		"api-version": APIVersion,
492	}
493
494	preparer := autorest.CreatePreparer(
495		autorest.AsPost(),
496		autorest.WithBaseURL(client.BaseURI),
497		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/listApplicableSchedules", pathParameters),
498		autorest.WithQueryParameters(queryParameters))
499	return preparer.Prepare((&http.Request{}).WithContext(ctx))
500}
501
502// ListApplicableSchedulesSender sends the ListApplicableSchedules request. The method will close the
503// http.Response Body if it receives an error.
504func (client ServiceFabricsClient) ListApplicableSchedulesSender(req *http.Request) (*http.Response, error) {
505	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
506	return autorest.SendWithSender(client, req, sd...)
507}
508
509// ListApplicableSchedulesResponder handles the response to the ListApplicableSchedules request. The method always
510// closes the http.Response Body.
511func (client ServiceFabricsClient) ListApplicableSchedulesResponder(resp *http.Response) (result ApplicableSchedule, err error) {
512	err = autorest.Respond(
513		resp,
514		client.ByInspecting(),
515		azure.WithErrorUnlessStatusCode(http.StatusOK),
516		autorest.ByUnmarshallingJSON(&result),
517		autorest.ByClosing())
518	result.Response = autorest.Response{Response: resp}
519	return
520}
521
522// Start start a service fabric. This operation can take a while to complete.
523// Parameters:
524// resourceGroupName - the name of the resource group.
525// labName - the name of the lab.
526// userName - the name of the user profile.
527// name - the name of the service fabric.
528func (client ServiceFabricsClient) Start(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (result ServiceFabricsStartFuture, err error) {
529	if tracing.IsEnabled() {
530		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceFabricsClient.Start")
531		defer func() {
532			sc := -1
533			if result.Response() != nil {
534				sc = result.Response().StatusCode
535			}
536			tracing.EndSpan(ctx, sc, err)
537		}()
538	}
539	req, err := client.StartPreparer(ctx, resourceGroupName, labName, userName, name)
540	if err != nil {
541		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Start", nil, "Failure preparing request")
542		return
543	}
544
545	result, err = client.StartSender(req)
546	if err != nil {
547		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Start", result.Response(), "Failure sending request")
548		return
549	}
550
551	return
552}
553
554// StartPreparer prepares the Start request.
555func (client ServiceFabricsClient) StartPreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (*http.Request, error) {
556	pathParameters := map[string]interface{}{
557		"labName":           autorest.Encode("path", labName),
558		"name":              autorest.Encode("path", name),
559		"resourceGroupName": autorest.Encode("path", resourceGroupName),
560		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
561		"userName":          autorest.Encode("path", userName),
562	}
563
564	const APIVersion = "2018-09-15"
565	queryParameters := map[string]interface{}{
566		"api-version": APIVersion,
567	}
568
569	preparer := autorest.CreatePreparer(
570		autorest.AsPost(),
571		autorest.WithBaseURL(client.BaseURI),
572		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/start", pathParameters),
573		autorest.WithQueryParameters(queryParameters))
574	return preparer.Prepare((&http.Request{}).WithContext(ctx))
575}
576
577// StartSender sends the Start request. The method will close the
578// http.Response Body if it receives an error.
579func (client ServiceFabricsClient) StartSender(req *http.Request) (future ServiceFabricsStartFuture, err error) {
580	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
581	var resp *http.Response
582	resp, err = autorest.SendWithSender(client, req, sd...)
583	if err != nil {
584		return
585	}
586	future.Future, err = azure.NewFutureFromResponse(resp)
587	return
588}
589
590// StartResponder handles the response to the Start request. The method always
591// closes the http.Response Body.
592func (client ServiceFabricsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) {
593	err = autorest.Respond(
594		resp,
595		client.ByInspecting(),
596		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
597		autorest.ByClosing())
598	result.Response = resp
599	return
600}
601
602// Stop stop a service fabric This operation can take a while to complete.
603// Parameters:
604// resourceGroupName - the name of the resource group.
605// labName - the name of the lab.
606// userName - the name of the user profile.
607// name - the name of the service fabric.
608func (client ServiceFabricsClient) Stop(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (result ServiceFabricsStopFuture, err error) {
609	if tracing.IsEnabled() {
610		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceFabricsClient.Stop")
611		defer func() {
612			sc := -1
613			if result.Response() != nil {
614				sc = result.Response().StatusCode
615			}
616			tracing.EndSpan(ctx, sc, err)
617		}()
618	}
619	req, err := client.StopPreparer(ctx, resourceGroupName, labName, userName, name)
620	if err != nil {
621		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Stop", nil, "Failure preparing request")
622		return
623	}
624
625	result, err = client.StopSender(req)
626	if err != nil {
627		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Stop", result.Response(), "Failure sending request")
628		return
629	}
630
631	return
632}
633
634// StopPreparer prepares the Stop request.
635func (client ServiceFabricsClient) StopPreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (*http.Request, error) {
636	pathParameters := map[string]interface{}{
637		"labName":           autorest.Encode("path", labName),
638		"name":              autorest.Encode("path", name),
639		"resourceGroupName": autorest.Encode("path", resourceGroupName),
640		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
641		"userName":          autorest.Encode("path", userName),
642	}
643
644	const APIVersion = "2018-09-15"
645	queryParameters := map[string]interface{}{
646		"api-version": APIVersion,
647	}
648
649	preparer := autorest.CreatePreparer(
650		autorest.AsPost(),
651		autorest.WithBaseURL(client.BaseURI),
652		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}/stop", pathParameters),
653		autorest.WithQueryParameters(queryParameters))
654	return preparer.Prepare((&http.Request{}).WithContext(ctx))
655}
656
657// StopSender sends the Stop request. The method will close the
658// http.Response Body if it receives an error.
659func (client ServiceFabricsClient) StopSender(req *http.Request) (future ServiceFabricsStopFuture, err error) {
660	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
661	var resp *http.Response
662	resp, err = autorest.SendWithSender(client, req, sd...)
663	if err != nil {
664		return
665	}
666	future.Future, err = azure.NewFutureFromResponse(resp)
667	return
668}
669
670// StopResponder handles the response to the Stop request. The method always
671// closes the http.Response Body.
672func (client ServiceFabricsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) {
673	err = autorest.Respond(
674		resp,
675		client.ByInspecting(),
676		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
677		autorest.ByClosing())
678	result.Response = resp
679	return
680}
681
682// Update allows modifying tags of service fabrics. All other properties will be ignored.
683// Parameters:
684// resourceGroupName - the name of the resource group.
685// labName - the name of the lab.
686// userName - the name of the user profile.
687// name - the name of the service fabric.
688// serviceFabric - a Service Fabric.
689func (client ServiceFabricsClient) Update(ctx context.Context, resourceGroupName string, labName string, userName string, name string, serviceFabric ServiceFabricFragment) (result ServiceFabric, err error) {
690	if tracing.IsEnabled() {
691		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceFabricsClient.Update")
692		defer func() {
693			sc := -1
694			if result.Response.Response != nil {
695				sc = result.Response.Response.StatusCode
696			}
697			tracing.EndSpan(ctx, sc, err)
698		}()
699	}
700	req, err := client.UpdatePreparer(ctx, resourceGroupName, labName, userName, name, serviceFabric)
701	if err != nil {
702		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Update", nil, "Failure preparing request")
703		return
704	}
705
706	resp, err := client.UpdateSender(req)
707	if err != nil {
708		result.Response = autorest.Response{Response: resp}
709		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Update", resp, "Failure sending request")
710		return
711	}
712
713	result, err = client.UpdateResponder(resp)
714	if err != nil {
715		err = autorest.NewErrorWithError(err, "dtl.ServiceFabricsClient", "Update", resp, "Failure responding to request")
716	}
717
718	return
719}
720
721// UpdatePreparer prepares the Update request.
722func (client ServiceFabricsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string, serviceFabric ServiceFabricFragment) (*http.Request, error) {
723	pathParameters := map[string]interface{}{
724		"labName":           autorest.Encode("path", labName),
725		"name":              autorest.Encode("path", name),
726		"resourceGroupName": autorest.Encode("path", resourceGroupName),
727		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
728		"userName":          autorest.Encode("path", userName),
729	}
730
731	const APIVersion = "2018-09-15"
732	queryParameters := map[string]interface{}{
733		"api-version": APIVersion,
734	}
735
736	preparer := autorest.CreatePreparer(
737		autorest.AsContentType("application/json; charset=utf-8"),
738		autorest.AsPatch(),
739		autorest.WithBaseURL(client.BaseURI),
740		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/servicefabrics/{name}", pathParameters),
741		autorest.WithJSON(serviceFabric),
742		autorest.WithQueryParameters(queryParameters))
743	return preparer.Prepare((&http.Request{}).WithContext(ctx))
744}
745
746// UpdateSender sends the Update request. The method will close the
747// http.Response Body if it receives an error.
748func (client ServiceFabricsClient) UpdateSender(req *http.Request) (*http.Response, error) {
749	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
750	return autorest.SendWithSender(client, req, sd...)
751}
752
753// UpdateResponder handles the response to the Update request. The method always
754// closes the http.Response Body.
755func (client ServiceFabricsClient) UpdateResponder(resp *http.Response) (result ServiceFabric, err error) {
756	err = autorest.Respond(
757		resp,
758		client.ByInspecting(),
759		azure.WithErrorUnlessStatusCode(http.StatusOK),
760		autorest.ByUnmarshallingJSON(&result),
761		autorest.ByClosing())
762	result.Response = autorest.Response{Response: resp}
763	return
764}
765