1package storagesync
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// CloudEndpointsClient is the microsoft Storage Sync Service API
19type CloudEndpointsClient struct {
20	BaseClient
21}
22
23// NewCloudEndpointsClient creates an instance of the CloudEndpointsClient client.
24func NewCloudEndpointsClient(subscriptionID string) CloudEndpointsClient {
25	return NewCloudEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewCloudEndpointsClientWithBaseURI creates an instance of the CloudEndpointsClient client using a custom endpoint.
29// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewCloudEndpointsClientWithBaseURI(baseURI string, subscriptionID string) CloudEndpointsClient {
31	return CloudEndpointsClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// Create create a new CloudEndpoint.
35// Parameters:
36// resourceGroupName - the name of the resource group. The name is case insensitive.
37// storageSyncServiceName - name of Storage Sync Service resource.
38// syncGroupName - name of Sync Group resource.
39// cloudEndpointName - name of Cloud Endpoint object.
40// parameters - body of Cloud Endpoint resource.
41func (client CloudEndpointsClient) Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters CloudEndpointCreateParameters) (result CloudEndpointsCreateFuture, err error) {
42	if tracing.IsEnabled() {
43		ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.Create")
44		defer func() {
45			sc := -1
46			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
47				sc = result.FutureAPI.Response().StatusCode
48			}
49			tracing.EndSpan(ctx, sc, err)
50		}()
51	}
52	if err := validation.Validate([]validation.Validation{
53		{TargetValue: client.SubscriptionID,
54			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
55		{TargetValue: resourceGroupName,
56			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
57				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
58				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
59		return result, validation.NewError("storagesync.CloudEndpointsClient", "Create", err.Error())
60	}
61
62	req, err := client.CreatePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters)
63	if err != nil {
64		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Create", nil, "Failure preparing request")
65		return
66	}
67
68	result, err = client.CreateSender(req)
69	if err != nil {
70		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Create", nil, "Failure sending request")
71		return
72	}
73
74	return
75}
76
77// CreatePreparer prepares the Create request.
78func (client CloudEndpointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters CloudEndpointCreateParameters) (*http.Request, error) {
79	pathParameters := map[string]interface{}{
80		"cloudEndpointName":      autorest.Encode("path", cloudEndpointName),
81		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
82		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
83		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
84		"syncGroupName":          autorest.Encode("path", syncGroupName),
85	}
86
87	const APIVersion = "2018-10-01"
88	queryParameters := map[string]interface{}{
89		"api-version": APIVersion,
90	}
91
92	preparer := autorest.CreatePreparer(
93		autorest.AsContentType("application/json; charset=utf-8"),
94		autorest.AsPut(),
95		autorest.WithBaseURL(client.BaseURI),
96		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}", pathParameters),
97		autorest.WithJSON(parameters),
98		autorest.WithQueryParameters(queryParameters))
99	return preparer.Prepare((&http.Request{}).WithContext(ctx))
100}
101
102// CreateSender sends the Create request. The method will close the
103// http.Response Body if it receives an error.
104func (client CloudEndpointsClient) CreateSender(req *http.Request) (future CloudEndpointsCreateFuture, err error) {
105	var resp *http.Response
106	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
107	if err != nil {
108		return
109	}
110	var azf azure.Future
111	azf, err = azure.NewFutureFromResponse(resp)
112	future.FutureAPI = &azf
113	future.Result = future.result
114	return
115}
116
117// CreateResponder handles the response to the Create request. The method always
118// closes the http.Response Body.
119func (client CloudEndpointsClient) CreateResponder(resp *http.Response) (result CloudEndpoint, err error) {
120	err = autorest.Respond(
121		resp,
122		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
123		autorest.ByUnmarshallingJSON(&result),
124		autorest.ByClosing())
125	result.Response = autorest.Response{Response: resp}
126	return
127}
128
129// Delete delete a given CloudEndpoint.
130// Parameters:
131// resourceGroupName - the name of the resource group. The name is case insensitive.
132// storageSyncServiceName - name of Storage Sync Service resource.
133// syncGroupName - name of Sync Group resource.
134// cloudEndpointName - name of Cloud Endpoint object.
135func (client CloudEndpointsClient) Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (result CloudEndpointsDeleteFuture, err error) {
136	if tracing.IsEnabled() {
137		ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.Delete")
138		defer func() {
139			sc := -1
140			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
141				sc = result.FutureAPI.Response().StatusCode
142			}
143			tracing.EndSpan(ctx, sc, err)
144		}()
145	}
146	if err := validation.Validate([]validation.Validation{
147		{TargetValue: client.SubscriptionID,
148			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
149		{TargetValue: resourceGroupName,
150			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
151				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
152				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
153		return result, validation.NewError("storagesync.CloudEndpointsClient", "Delete", err.Error())
154	}
155
156	req, err := client.DeletePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName)
157	if err != nil {
158		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Delete", nil, "Failure preparing request")
159		return
160	}
161
162	result, err = client.DeleteSender(req)
163	if err != nil {
164		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Delete", nil, "Failure sending request")
165		return
166	}
167
168	return
169}
170
171// DeletePreparer prepares the Delete request.
172func (client CloudEndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (*http.Request, error) {
173	pathParameters := map[string]interface{}{
174		"cloudEndpointName":      autorest.Encode("path", cloudEndpointName),
175		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
176		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
177		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
178		"syncGroupName":          autorest.Encode("path", syncGroupName),
179	}
180
181	const APIVersion = "2018-10-01"
182	queryParameters := map[string]interface{}{
183		"api-version": APIVersion,
184	}
185
186	preparer := autorest.CreatePreparer(
187		autorest.AsDelete(),
188		autorest.WithBaseURL(client.BaseURI),
189		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}", pathParameters),
190		autorest.WithQueryParameters(queryParameters))
191	return preparer.Prepare((&http.Request{}).WithContext(ctx))
192}
193
194// DeleteSender sends the Delete request. The method will close the
195// http.Response Body if it receives an error.
196func (client CloudEndpointsClient) DeleteSender(req *http.Request) (future CloudEndpointsDeleteFuture, err error) {
197	var resp *http.Response
198	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
199	if err != nil {
200		return
201	}
202	var azf azure.Future
203	azf, err = azure.NewFutureFromResponse(resp)
204	future.FutureAPI = &azf
205	future.Result = future.result
206	return
207}
208
209// DeleteResponder handles the response to the Delete request. The method always
210// closes the http.Response Body.
211func (client CloudEndpointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
212	err = autorest.Respond(
213		resp,
214		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
215		autorest.ByClosing())
216	result.Response = resp
217	return
218}
219
220// Get get a given CloudEndpoint.
221// Parameters:
222// resourceGroupName - the name of the resource group. The name is case insensitive.
223// storageSyncServiceName - name of Storage Sync Service resource.
224// syncGroupName - name of Sync Group resource.
225// cloudEndpointName - name of Cloud Endpoint object.
226func (client CloudEndpointsClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (result CloudEndpoint, err error) {
227	if tracing.IsEnabled() {
228		ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.Get")
229		defer func() {
230			sc := -1
231			if result.Response.Response != nil {
232				sc = result.Response.Response.StatusCode
233			}
234			tracing.EndSpan(ctx, sc, err)
235		}()
236	}
237	if err := validation.Validate([]validation.Validation{
238		{TargetValue: client.SubscriptionID,
239			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
240		{TargetValue: resourceGroupName,
241			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
242				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
243				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
244		return result, validation.NewError("storagesync.CloudEndpointsClient", "Get", err.Error())
245	}
246
247	req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName)
248	if err != nil {
249		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Get", nil, "Failure preparing request")
250		return
251	}
252
253	resp, err := client.GetSender(req)
254	if err != nil {
255		result.Response = autorest.Response{Response: resp}
256		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Get", resp, "Failure sending request")
257		return
258	}
259
260	result, err = client.GetResponder(resp)
261	if err != nil {
262		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Get", resp, "Failure responding to request")
263		return
264	}
265
266	return
267}
268
269// GetPreparer prepares the Get request.
270func (client CloudEndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (*http.Request, error) {
271	pathParameters := map[string]interface{}{
272		"cloudEndpointName":      autorest.Encode("path", cloudEndpointName),
273		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
274		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
275		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
276		"syncGroupName":          autorest.Encode("path", syncGroupName),
277	}
278
279	const APIVersion = "2018-10-01"
280	queryParameters := map[string]interface{}{
281		"api-version": APIVersion,
282	}
283
284	preparer := autorest.CreatePreparer(
285		autorest.AsGet(),
286		autorest.WithBaseURL(client.BaseURI),
287		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}", pathParameters),
288		autorest.WithQueryParameters(queryParameters))
289	return preparer.Prepare((&http.Request{}).WithContext(ctx))
290}
291
292// GetSender sends the Get request. The method will close the
293// http.Response Body if it receives an error.
294func (client CloudEndpointsClient) GetSender(req *http.Request) (*http.Response, error) {
295	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
296}
297
298// GetResponder handles the response to the Get request. The method always
299// closes the http.Response Body.
300func (client CloudEndpointsClient) GetResponder(resp *http.Response) (result CloudEndpoint, err error) {
301	err = autorest.Respond(
302		resp,
303		azure.WithErrorUnlessStatusCode(http.StatusOK),
304		autorest.ByUnmarshallingJSON(&result),
305		autorest.ByClosing())
306	result.Response = autorest.Response{Response: resp}
307	return
308}
309
310// ListBySyncGroup get a CloudEndpoint List.
311// Parameters:
312// resourceGroupName - the name of the resource group. The name is case insensitive.
313// storageSyncServiceName - name of Storage Sync Service resource.
314// syncGroupName - name of Sync Group resource.
315func (client CloudEndpointsClient) ListBySyncGroup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result CloudEndpointArray, err error) {
316	if tracing.IsEnabled() {
317		ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.ListBySyncGroup")
318		defer func() {
319			sc := -1
320			if result.Response.Response != nil {
321				sc = result.Response.Response.StatusCode
322			}
323			tracing.EndSpan(ctx, sc, err)
324		}()
325	}
326	if err := validation.Validate([]validation.Validation{
327		{TargetValue: client.SubscriptionID,
328			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
329		{TargetValue: resourceGroupName,
330			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
331				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
332				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
333		return result, validation.NewError("storagesync.CloudEndpointsClient", "ListBySyncGroup", err.Error())
334	}
335
336	req, err := client.ListBySyncGroupPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName)
337	if err != nil {
338		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "ListBySyncGroup", nil, "Failure preparing request")
339		return
340	}
341
342	resp, err := client.ListBySyncGroupSender(req)
343	if err != nil {
344		result.Response = autorest.Response{Response: resp}
345		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "ListBySyncGroup", resp, "Failure sending request")
346		return
347	}
348
349	result, err = client.ListBySyncGroupResponder(resp)
350	if err != nil {
351		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "ListBySyncGroup", resp, "Failure responding to request")
352		return
353	}
354
355	return
356}
357
358// ListBySyncGroupPreparer prepares the ListBySyncGroup request.
359func (client CloudEndpointsClient) ListBySyncGroupPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (*http.Request, error) {
360	pathParameters := map[string]interface{}{
361		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
362		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
363		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
364		"syncGroupName":          autorest.Encode("path", syncGroupName),
365	}
366
367	const APIVersion = "2018-10-01"
368	queryParameters := map[string]interface{}{
369		"api-version": APIVersion,
370	}
371
372	preparer := autorest.CreatePreparer(
373		autorest.AsGet(),
374		autorest.WithBaseURL(client.BaseURI),
375		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints", pathParameters),
376		autorest.WithQueryParameters(queryParameters))
377	return preparer.Prepare((&http.Request{}).WithContext(ctx))
378}
379
380// ListBySyncGroupSender sends the ListBySyncGroup request. The method will close the
381// http.Response Body if it receives an error.
382func (client CloudEndpointsClient) ListBySyncGroupSender(req *http.Request) (*http.Response, error) {
383	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
384}
385
386// ListBySyncGroupResponder handles the response to the ListBySyncGroup request. The method always
387// closes the http.Response Body.
388func (client CloudEndpointsClient) ListBySyncGroupResponder(resp *http.Response) (result CloudEndpointArray, err error) {
389	err = autorest.Respond(
390		resp,
391		azure.WithErrorUnlessStatusCode(http.StatusOK),
392		autorest.ByUnmarshallingJSON(&result),
393		autorest.ByClosing())
394	result.Response = autorest.Response{Response: resp}
395	return
396}
397
398// PostBackup post Backup a given CloudEndpoint.
399// Parameters:
400// resourceGroupName - the name of the resource group. The name is case insensitive.
401// storageSyncServiceName - name of Storage Sync Service resource.
402// syncGroupName - name of Sync Group resource.
403// cloudEndpointName - name of Cloud Endpoint object.
404// parameters - body of Backup request.
405func (client CloudEndpointsClient) PostBackup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters BackupRequest) (result CloudEndpointsPostBackupFuture, err error) {
406	if tracing.IsEnabled() {
407		ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.PostBackup")
408		defer func() {
409			sc := -1
410			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
411				sc = result.FutureAPI.Response().StatusCode
412			}
413			tracing.EndSpan(ctx, sc, err)
414		}()
415	}
416	if err := validation.Validate([]validation.Validation{
417		{TargetValue: client.SubscriptionID,
418			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
419		{TargetValue: resourceGroupName,
420			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
421				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
422				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
423		return result, validation.NewError("storagesync.CloudEndpointsClient", "PostBackup", err.Error())
424	}
425
426	req, err := client.PostBackupPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters)
427	if err != nil {
428		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PostBackup", nil, "Failure preparing request")
429		return
430	}
431
432	result, err = client.PostBackupSender(req)
433	if err != nil {
434		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PostBackup", nil, "Failure sending request")
435		return
436	}
437
438	return
439}
440
441// PostBackupPreparer prepares the PostBackup request.
442func (client CloudEndpointsClient) PostBackupPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters BackupRequest) (*http.Request, error) {
443	pathParameters := map[string]interface{}{
444		"cloudEndpointName":      autorest.Encode("path", cloudEndpointName),
445		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
446		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
447		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
448		"syncGroupName":          autorest.Encode("path", syncGroupName),
449	}
450
451	const APIVersion = "2018-10-01"
452	queryParameters := map[string]interface{}{
453		"api-version": APIVersion,
454	}
455
456	preparer := autorest.CreatePreparer(
457		autorest.AsContentType("application/json; charset=utf-8"),
458		autorest.AsPost(),
459		autorest.WithBaseURL(client.BaseURI),
460		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postbackup", pathParameters),
461		autorest.WithJSON(parameters),
462		autorest.WithQueryParameters(queryParameters))
463	return preparer.Prepare((&http.Request{}).WithContext(ctx))
464}
465
466// PostBackupSender sends the PostBackup request. The method will close the
467// http.Response Body if it receives an error.
468func (client CloudEndpointsClient) PostBackupSender(req *http.Request) (future CloudEndpointsPostBackupFuture, err error) {
469	var resp *http.Response
470	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
471	if err != nil {
472		return
473	}
474	var azf azure.Future
475	azf, err = azure.NewFutureFromResponse(resp)
476	future.FutureAPI = &azf
477	future.Result = future.result
478	return
479}
480
481// PostBackupResponder handles the response to the PostBackup request. The method always
482// closes the http.Response Body.
483func (client CloudEndpointsClient) PostBackupResponder(resp *http.Response) (result PostBackupResponse, err error) {
484	err = autorest.Respond(
485		resp,
486		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
487		autorest.ByUnmarshallingJSON(&result),
488		autorest.ByClosing())
489	result.Response = autorest.Response{Response: resp}
490	return
491}
492
493// PostRestore post Restore a given CloudEndpoint.
494// Parameters:
495// resourceGroupName - the name of the resource group. The name is case insensitive.
496// storageSyncServiceName - name of Storage Sync Service resource.
497// syncGroupName - name of Sync Group resource.
498// cloudEndpointName - name of Cloud Endpoint object.
499// parameters - body of Cloud Endpoint object.
500func (client CloudEndpointsClient) PostRestore(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters PostRestoreRequest) (result CloudEndpointsPostRestoreFuture, err error) {
501	if tracing.IsEnabled() {
502		ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.PostRestore")
503		defer func() {
504			sc := -1
505			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
506				sc = result.FutureAPI.Response().StatusCode
507			}
508			tracing.EndSpan(ctx, sc, err)
509		}()
510	}
511	if err := validation.Validate([]validation.Validation{
512		{TargetValue: client.SubscriptionID,
513			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
514		{TargetValue: resourceGroupName,
515			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
516				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
517				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
518		return result, validation.NewError("storagesync.CloudEndpointsClient", "PostRestore", err.Error())
519	}
520
521	req, err := client.PostRestorePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters)
522	if err != nil {
523		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PostRestore", nil, "Failure preparing request")
524		return
525	}
526
527	result, err = client.PostRestoreSender(req)
528	if err != nil {
529		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PostRestore", nil, "Failure sending request")
530		return
531	}
532
533	return
534}
535
536// PostRestorePreparer prepares the PostRestore request.
537func (client CloudEndpointsClient) PostRestorePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters PostRestoreRequest) (*http.Request, error) {
538	pathParameters := map[string]interface{}{
539		"cloudEndpointName":      autorest.Encode("path", cloudEndpointName),
540		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
541		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
542		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
543		"syncGroupName":          autorest.Encode("path", syncGroupName),
544	}
545
546	const APIVersion = "2018-10-01"
547	queryParameters := map[string]interface{}{
548		"api-version": APIVersion,
549	}
550
551	preparer := autorest.CreatePreparer(
552		autorest.AsContentType("application/json; charset=utf-8"),
553		autorest.AsPost(),
554		autorest.WithBaseURL(client.BaseURI),
555		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postrestore", pathParameters),
556		autorest.WithJSON(parameters),
557		autorest.WithQueryParameters(queryParameters))
558	return preparer.Prepare((&http.Request{}).WithContext(ctx))
559}
560
561// PostRestoreSender sends the PostRestore request. The method will close the
562// http.Response Body if it receives an error.
563func (client CloudEndpointsClient) PostRestoreSender(req *http.Request) (future CloudEndpointsPostRestoreFuture, err error) {
564	var resp *http.Response
565	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
566	if err != nil {
567		return
568	}
569	var azf azure.Future
570	azf, err = azure.NewFutureFromResponse(resp)
571	future.FutureAPI = &azf
572	future.Result = future.result
573	return
574}
575
576// PostRestoreResponder handles the response to the PostRestore request. The method always
577// closes the http.Response Body.
578func (client CloudEndpointsClient) PostRestoreResponder(resp *http.Response) (result autorest.Response, err error) {
579	err = autorest.Respond(
580		resp,
581		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
582		autorest.ByClosing())
583	result.Response = resp
584	return
585}
586
587// PreBackup pre Backup a given CloudEndpoint.
588// Parameters:
589// resourceGroupName - the name of the resource group. The name is case insensitive.
590// storageSyncServiceName - name of Storage Sync Service resource.
591// syncGroupName - name of Sync Group resource.
592// cloudEndpointName - name of Cloud Endpoint object.
593// parameters - body of Backup request.
594func (client CloudEndpointsClient) PreBackup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters BackupRequest) (result CloudEndpointsPreBackupFuture, err error) {
595	if tracing.IsEnabled() {
596		ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.PreBackup")
597		defer func() {
598			sc := -1
599			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
600				sc = result.FutureAPI.Response().StatusCode
601			}
602			tracing.EndSpan(ctx, sc, err)
603		}()
604	}
605	if err := validation.Validate([]validation.Validation{
606		{TargetValue: client.SubscriptionID,
607			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
608		{TargetValue: resourceGroupName,
609			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
610				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
611				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
612		return result, validation.NewError("storagesync.CloudEndpointsClient", "PreBackup", err.Error())
613	}
614
615	req, err := client.PreBackupPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters)
616	if err != nil {
617		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PreBackup", nil, "Failure preparing request")
618		return
619	}
620
621	result, err = client.PreBackupSender(req)
622	if err != nil {
623		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PreBackup", nil, "Failure sending request")
624		return
625	}
626
627	return
628}
629
630// PreBackupPreparer prepares the PreBackup request.
631func (client CloudEndpointsClient) PreBackupPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters BackupRequest) (*http.Request, error) {
632	pathParameters := map[string]interface{}{
633		"cloudEndpointName":      autorest.Encode("path", cloudEndpointName),
634		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
635		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
636		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
637		"syncGroupName":          autorest.Encode("path", syncGroupName),
638	}
639
640	const APIVersion = "2018-10-01"
641	queryParameters := map[string]interface{}{
642		"api-version": APIVersion,
643	}
644
645	preparer := autorest.CreatePreparer(
646		autorest.AsContentType("application/json; charset=utf-8"),
647		autorest.AsPost(),
648		autorest.WithBaseURL(client.BaseURI),
649		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prebackup", pathParameters),
650		autorest.WithJSON(parameters),
651		autorest.WithQueryParameters(queryParameters))
652	return preparer.Prepare((&http.Request{}).WithContext(ctx))
653}
654
655// PreBackupSender sends the PreBackup request. The method will close the
656// http.Response Body if it receives an error.
657func (client CloudEndpointsClient) PreBackupSender(req *http.Request) (future CloudEndpointsPreBackupFuture, err error) {
658	var resp *http.Response
659	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
660	if err != nil {
661		return
662	}
663	var azf azure.Future
664	azf, err = azure.NewFutureFromResponse(resp)
665	future.FutureAPI = &azf
666	future.Result = future.result
667	return
668}
669
670// PreBackupResponder handles the response to the PreBackup request. The method always
671// closes the http.Response Body.
672func (client CloudEndpointsClient) PreBackupResponder(resp *http.Response) (result autorest.Response, err error) {
673	err = autorest.Respond(
674		resp,
675		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
676		autorest.ByClosing())
677	result.Response = resp
678	return
679}
680
681// PreRestore pre Restore a given CloudEndpoint.
682// Parameters:
683// resourceGroupName - the name of the resource group. The name is case insensitive.
684// storageSyncServiceName - name of Storage Sync Service resource.
685// syncGroupName - name of Sync Group resource.
686// cloudEndpointName - name of Cloud Endpoint object.
687// parameters - body of Cloud Endpoint object.
688func (client CloudEndpointsClient) PreRestore(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters PreRestoreRequest) (result CloudEndpointsPreRestoreFuture, err error) {
689	if tracing.IsEnabled() {
690		ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.PreRestore")
691		defer func() {
692			sc := -1
693			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
694				sc = result.FutureAPI.Response().StatusCode
695			}
696			tracing.EndSpan(ctx, sc, err)
697		}()
698	}
699	if err := validation.Validate([]validation.Validation{
700		{TargetValue: client.SubscriptionID,
701			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
702		{TargetValue: resourceGroupName,
703			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
704				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
705				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
706		return result, validation.NewError("storagesync.CloudEndpointsClient", "PreRestore", err.Error())
707	}
708
709	req, err := client.PreRestorePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters)
710	if err != nil {
711		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PreRestore", nil, "Failure preparing request")
712		return
713	}
714
715	result, err = client.PreRestoreSender(req)
716	if err != nil {
717		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PreRestore", nil, "Failure sending request")
718		return
719	}
720
721	return
722}
723
724// PreRestorePreparer prepares the PreRestore request.
725func (client CloudEndpointsClient) PreRestorePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters PreRestoreRequest) (*http.Request, error) {
726	pathParameters := map[string]interface{}{
727		"cloudEndpointName":      autorest.Encode("path", cloudEndpointName),
728		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
729		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
730		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
731		"syncGroupName":          autorest.Encode("path", syncGroupName),
732	}
733
734	const APIVersion = "2018-10-01"
735	queryParameters := map[string]interface{}{
736		"api-version": APIVersion,
737	}
738
739	preparer := autorest.CreatePreparer(
740		autorest.AsContentType("application/json; charset=utf-8"),
741		autorest.AsPost(),
742		autorest.WithBaseURL(client.BaseURI),
743		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prerestore", pathParameters),
744		autorest.WithJSON(parameters),
745		autorest.WithQueryParameters(queryParameters))
746	return preparer.Prepare((&http.Request{}).WithContext(ctx))
747}
748
749// PreRestoreSender sends the PreRestore request. The method will close the
750// http.Response Body if it receives an error.
751func (client CloudEndpointsClient) PreRestoreSender(req *http.Request) (future CloudEndpointsPreRestoreFuture, err error) {
752	var resp *http.Response
753	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
754	if err != nil {
755		return
756	}
757	var azf azure.Future
758	azf, err = azure.NewFutureFromResponse(resp)
759	future.FutureAPI = &azf
760	future.Result = future.result
761	return
762}
763
764// PreRestoreResponder handles the response to the PreRestore request. The method always
765// closes the http.Response Body.
766func (client CloudEndpointsClient) PreRestoreResponder(resp *http.Response) (result autorest.Response, err error) {
767	err = autorest.Respond(
768		resp,
769		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
770		autorest.ByClosing())
771	result.Response = resp
772	return
773}
774
775// Restoreheartbeat restore Heartbeat a given CloudEndpoint.
776// Parameters:
777// resourceGroupName - the name of the resource group. The name is case insensitive.
778// storageSyncServiceName - name of Storage Sync Service resource.
779// syncGroupName - name of Sync Group resource.
780// cloudEndpointName - name of Cloud Endpoint object.
781func (client CloudEndpointsClient) Restoreheartbeat(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (result autorest.Response, err error) {
782	if tracing.IsEnabled() {
783		ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.Restoreheartbeat")
784		defer func() {
785			sc := -1
786			if result.Response != nil {
787				sc = result.Response.StatusCode
788			}
789			tracing.EndSpan(ctx, sc, err)
790		}()
791	}
792	if err := validation.Validate([]validation.Validation{
793		{TargetValue: client.SubscriptionID,
794			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
795		{TargetValue: resourceGroupName,
796			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
797				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
798				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
799		return result, validation.NewError("storagesync.CloudEndpointsClient", "Restoreheartbeat", err.Error())
800	}
801
802	req, err := client.RestoreheartbeatPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName)
803	if err != nil {
804		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Restoreheartbeat", nil, "Failure preparing request")
805		return
806	}
807
808	resp, err := client.RestoreheartbeatSender(req)
809	if err != nil {
810		result.Response = resp
811		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Restoreheartbeat", resp, "Failure sending request")
812		return
813	}
814
815	result, err = client.RestoreheartbeatResponder(resp)
816	if err != nil {
817		err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Restoreheartbeat", resp, "Failure responding to request")
818		return
819	}
820
821	return
822}
823
824// RestoreheartbeatPreparer prepares the Restoreheartbeat request.
825func (client CloudEndpointsClient) RestoreheartbeatPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (*http.Request, error) {
826	pathParameters := map[string]interface{}{
827		"cloudEndpointName":      autorest.Encode("path", cloudEndpointName),
828		"resourceGroupName":      autorest.Encode("path", resourceGroupName),
829		"storageSyncServiceName": autorest.Encode("path", storageSyncServiceName),
830		"subscriptionId":         autorest.Encode("path", client.SubscriptionID),
831		"syncGroupName":          autorest.Encode("path", syncGroupName),
832	}
833
834	const APIVersion = "2018-10-01"
835	queryParameters := map[string]interface{}{
836		"api-version": APIVersion,
837	}
838
839	preparer := autorest.CreatePreparer(
840		autorest.AsPost(),
841		autorest.WithBaseURL(client.BaseURI),
842		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/restoreheartbeat", pathParameters),
843		autorest.WithQueryParameters(queryParameters))
844	return preparer.Prepare((&http.Request{}).WithContext(ctx))
845}
846
847// RestoreheartbeatSender sends the Restoreheartbeat request. The method will close the
848// http.Response Body if it receives an error.
849func (client CloudEndpointsClient) RestoreheartbeatSender(req *http.Request) (*http.Response, error) {
850	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
851}
852
853// RestoreheartbeatResponder handles the response to the Restoreheartbeat request. The method always
854// closes the http.Response Body.
855func (client CloudEndpointsClient) RestoreheartbeatResponder(resp *http.Response) (result autorest.Response, err error) {
856	err = autorest.Respond(
857		resp,
858		azure.WithErrorUnlessStatusCode(http.StatusOK),
859		autorest.ByClosing())
860	result.Response = resp
861	return
862}
863