1package sql
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/tracing"
25	"net/http"
26)
27
28// SyncMembersClient is the the Azure SQL Database management API provides a RESTful set of web services that interact
29// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and
30// delete databases.
31type SyncMembersClient struct {
32	BaseClient
33}
34
35// NewSyncMembersClient creates an instance of the SyncMembersClient client.
36func NewSyncMembersClient(subscriptionID string) SyncMembersClient {
37	return NewSyncMembersClientWithBaseURI(DefaultBaseURI, subscriptionID)
38}
39
40// NewSyncMembersClientWithBaseURI creates an instance of the SyncMembersClient client using a custom endpoint.  Use
41// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
42func NewSyncMembersClientWithBaseURI(baseURI string, subscriptionID string) SyncMembersClient {
43	return SyncMembersClient{NewWithBaseURI(baseURI, subscriptionID)}
44}
45
46// CreateOrUpdate creates or updates a sync member.
47// Parameters:
48// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
49// from the Azure Resource Manager API or the portal.
50// serverName - the name of the server.
51// databaseName - the name of the database on which the sync group is hosted.
52// syncGroupName - the name of the sync group on which the sync member is hosted.
53// syncMemberName - the name of the sync member.
54// parameters - the requested sync member resource state.
55func (client SyncMembersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (result SyncMembersCreateOrUpdateFuture, err error) {
56	if tracing.IsEnabled() {
57		ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.CreateOrUpdate")
58		defer func() {
59			sc := -1
60			if result.Response() != nil {
61				sc = result.Response().StatusCode
62			}
63			tracing.EndSpan(ctx, sc, err)
64		}()
65	}
66	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters)
67	if err != nil {
68		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "CreateOrUpdate", nil, "Failure preparing request")
69		return
70	}
71
72	result, err = client.CreateOrUpdateSender(req)
73	if err != nil {
74		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "CreateOrUpdate", result.Response(), "Failure sending request")
75		return
76	}
77
78	return
79}
80
81// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
82func (client SyncMembersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (*http.Request, error) {
83	pathParameters := map[string]interface{}{
84		"databaseName":      autorest.Encode("path", databaseName),
85		"resourceGroupName": autorest.Encode("path", resourceGroupName),
86		"serverName":        autorest.Encode("path", serverName),
87		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
88		"syncGroupName":     autorest.Encode("path", syncGroupName),
89		"syncMemberName":    autorest.Encode("path", syncMemberName),
90	}
91
92	const APIVersion = "2015-05-01-preview"
93	queryParameters := map[string]interface{}{
94		"api-version": APIVersion,
95	}
96
97	preparer := autorest.CreatePreparer(
98		autorest.AsContentType("application/json; charset=utf-8"),
99		autorest.AsPut(),
100		autorest.WithBaseURL(client.BaseURI),
101		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", pathParameters),
102		autorest.WithJSON(parameters),
103		autorest.WithQueryParameters(queryParameters))
104	return preparer.Prepare((&http.Request{}).WithContext(ctx))
105}
106
107// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
108// http.Response Body if it receives an error.
109func (client SyncMembersClient) CreateOrUpdateSender(req *http.Request) (future SyncMembersCreateOrUpdateFuture, err error) {
110	var resp *http.Response
111	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
112	if err != nil {
113		return
114	}
115	future.Future, err = azure.NewFutureFromResponse(resp)
116	return
117}
118
119// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
120// closes the http.Response Body.
121func (client SyncMembersClient) CreateOrUpdateResponder(resp *http.Response) (result SyncMember, err error) {
122	err = autorest.Respond(
123		resp,
124		client.ByInspecting(),
125		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
126		autorest.ByUnmarshallingJSON(&result),
127		autorest.ByClosing())
128	result.Response = autorest.Response{Response: resp}
129	return
130}
131
132// Delete deletes a sync member.
133// Parameters:
134// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
135// from the Azure Resource Manager API or the portal.
136// serverName - the name of the server.
137// databaseName - the name of the database on which the sync group is hosted.
138// syncGroupName - the name of the sync group on which the sync member is hosted.
139// syncMemberName - the name of the sync member.
140func (client SyncMembersClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMembersDeleteFuture, err error) {
141	if tracing.IsEnabled() {
142		ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Delete")
143		defer func() {
144			sc := -1
145			if result.Response() != nil {
146				sc = result.Response().StatusCode
147			}
148			tracing.EndSpan(ctx, sc, err)
149		}()
150	}
151	req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName)
152	if err != nil {
153		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Delete", nil, "Failure preparing request")
154		return
155	}
156
157	result, err = client.DeleteSender(req)
158	if err != nil {
159		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Delete", result.Response(), "Failure sending request")
160		return
161	}
162
163	return
164}
165
166// DeletePreparer prepares the Delete request.
167func (client SyncMembersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (*http.Request, error) {
168	pathParameters := map[string]interface{}{
169		"databaseName":      autorest.Encode("path", databaseName),
170		"resourceGroupName": autorest.Encode("path", resourceGroupName),
171		"serverName":        autorest.Encode("path", serverName),
172		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
173		"syncGroupName":     autorest.Encode("path", syncGroupName),
174		"syncMemberName":    autorest.Encode("path", syncMemberName),
175	}
176
177	const APIVersion = "2015-05-01-preview"
178	queryParameters := map[string]interface{}{
179		"api-version": APIVersion,
180	}
181
182	preparer := autorest.CreatePreparer(
183		autorest.AsDelete(),
184		autorest.WithBaseURL(client.BaseURI),
185		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", pathParameters),
186		autorest.WithQueryParameters(queryParameters))
187	return preparer.Prepare((&http.Request{}).WithContext(ctx))
188}
189
190// DeleteSender sends the Delete request. The method will close the
191// http.Response Body if it receives an error.
192func (client SyncMembersClient) DeleteSender(req *http.Request) (future SyncMembersDeleteFuture, err error) {
193	var resp *http.Response
194	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
195	if err != nil {
196		return
197	}
198	future.Future, err = azure.NewFutureFromResponse(resp)
199	return
200}
201
202// DeleteResponder handles the response to the Delete request. The method always
203// closes the http.Response Body.
204func (client SyncMembersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
205	err = autorest.Respond(
206		resp,
207		client.ByInspecting(),
208		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
209		autorest.ByClosing())
210	result.Response = resp
211	return
212}
213
214// Get gets a sync member.
215// Parameters:
216// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
217// from the Azure Resource Manager API or the portal.
218// serverName - the name of the server.
219// databaseName - the name of the database on which the sync group is hosted.
220// syncGroupName - the name of the sync group on which the sync member is hosted.
221// syncMemberName - the name of the sync member.
222func (client SyncMembersClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMember, err error) {
223	if tracing.IsEnabled() {
224		ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Get")
225		defer func() {
226			sc := -1
227			if result.Response.Response != nil {
228				sc = result.Response.Response.StatusCode
229			}
230			tracing.EndSpan(ctx, sc, err)
231		}()
232	}
233	req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName)
234	if err != nil {
235		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Get", nil, "Failure preparing request")
236		return
237	}
238
239	resp, err := client.GetSender(req)
240	if err != nil {
241		result.Response = autorest.Response{Response: resp}
242		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Get", resp, "Failure sending request")
243		return
244	}
245
246	result, err = client.GetResponder(resp)
247	if err != nil {
248		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Get", resp, "Failure responding to request")
249	}
250
251	return
252}
253
254// GetPreparer prepares the Get request.
255func (client SyncMembersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (*http.Request, error) {
256	pathParameters := map[string]interface{}{
257		"databaseName":      autorest.Encode("path", databaseName),
258		"resourceGroupName": autorest.Encode("path", resourceGroupName),
259		"serverName":        autorest.Encode("path", serverName),
260		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
261		"syncGroupName":     autorest.Encode("path", syncGroupName),
262		"syncMemberName":    autorest.Encode("path", syncMemberName),
263	}
264
265	const APIVersion = "2015-05-01-preview"
266	queryParameters := map[string]interface{}{
267		"api-version": APIVersion,
268	}
269
270	preparer := autorest.CreatePreparer(
271		autorest.AsGet(),
272		autorest.WithBaseURL(client.BaseURI),
273		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", pathParameters),
274		autorest.WithQueryParameters(queryParameters))
275	return preparer.Prepare((&http.Request{}).WithContext(ctx))
276}
277
278// GetSender sends the Get request. The method will close the
279// http.Response Body if it receives an error.
280func (client SyncMembersClient) GetSender(req *http.Request) (*http.Response, error) {
281	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
282}
283
284// GetResponder handles the response to the Get request. The method always
285// closes the http.Response Body.
286func (client SyncMembersClient) GetResponder(resp *http.Response) (result SyncMember, err error) {
287	err = autorest.Respond(
288		resp,
289		client.ByInspecting(),
290		azure.WithErrorUnlessStatusCode(http.StatusOK),
291		autorest.ByUnmarshallingJSON(&result),
292		autorest.ByClosing())
293	result.Response = autorest.Response{Response: resp}
294	return
295}
296
297// ListBySyncGroup lists sync members in the given sync group.
298// Parameters:
299// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
300// from the Azure Resource Manager API or the portal.
301// serverName - the name of the server.
302// databaseName - the name of the database on which the sync group is hosted.
303// syncGroupName - the name of the sync group.
304func (client SyncMembersClient) ListBySyncGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncMemberListResultPage, err error) {
305	if tracing.IsEnabled() {
306		ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListBySyncGroup")
307		defer func() {
308			sc := -1
309			if result.smlr.Response.Response != nil {
310				sc = result.smlr.Response.Response.StatusCode
311			}
312			tracing.EndSpan(ctx, sc, err)
313		}()
314	}
315	result.fn = client.listBySyncGroupNextResults
316	req, err := client.ListBySyncGroupPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName)
317	if err != nil {
318		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", nil, "Failure preparing request")
319		return
320	}
321
322	resp, err := client.ListBySyncGroupSender(req)
323	if err != nil {
324		result.smlr.Response = autorest.Response{Response: resp}
325		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", resp, "Failure sending request")
326		return
327	}
328
329	result.smlr, err = client.ListBySyncGroupResponder(resp)
330	if err != nil {
331		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", resp, "Failure responding to request")
332	}
333
334	return
335}
336
337// ListBySyncGroupPreparer prepares the ListBySyncGroup request.
338func (client SyncMembersClient) ListBySyncGroupPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (*http.Request, error) {
339	pathParameters := map[string]interface{}{
340		"databaseName":      autorest.Encode("path", databaseName),
341		"resourceGroupName": autorest.Encode("path", resourceGroupName),
342		"serverName":        autorest.Encode("path", serverName),
343		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
344		"syncGroupName":     autorest.Encode("path", syncGroupName),
345	}
346
347	const APIVersion = "2015-05-01-preview"
348	queryParameters := map[string]interface{}{
349		"api-version": APIVersion,
350	}
351
352	preparer := autorest.CreatePreparer(
353		autorest.AsGet(),
354		autorest.WithBaseURL(client.BaseURI),
355		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers", pathParameters),
356		autorest.WithQueryParameters(queryParameters))
357	return preparer.Prepare((&http.Request{}).WithContext(ctx))
358}
359
360// ListBySyncGroupSender sends the ListBySyncGroup request. The method will close the
361// http.Response Body if it receives an error.
362func (client SyncMembersClient) ListBySyncGroupSender(req *http.Request) (*http.Response, error) {
363	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
364}
365
366// ListBySyncGroupResponder handles the response to the ListBySyncGroup request. The method always
367// closes the http.Response Body.
368func (client SyncMembersClient) ListBySyncGroupResponder(resp *http.Response) (result SyncMemberListResult, err error) {
369	err = autorest.Respond(
370		resp,
371		client.ByInspecting(),
372		azure.WithErrorUnlessStatusCode(http.StatusOK),
373		autorest.ByUnmarshallingJSON(&result),
374		autorest.ByClosing())
375	result.Response = autorest.Response{Response: resp}
376	return
377}
378
379// listBySyncGroupNextResults retrieves the next set of results, if any.
380func (client SyncMembersClient) listBySyncGroupNextResults(ctx context.Context, lastResults SyncMemberListResult) (result SyncMemberListResult, err error) {
381	req, err := lastResults.syncMemberListResultPreparer(ctx)
382	if err != nil {
383		return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", nil, "Failure preparing next results request")
384	}
385	if req == nil {
386		return
387	}
388	resp, err := client.ListBySyncGroupSender(req)
389	if err != nil {
390		result.Response = autorest.Response{Response: resp}
391		return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", resp, "Failure sending next results request")
392	}
393	result, err = client.ListBySyncGroupResponder(resp)
394	if err != nil {
395		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", resp, "Failure responding to next results request")
396	}
397	return
398}
399
400// ListBySyncGroupComplete enumerates all values, automatically crossing page boundaries as required.
401func (client SyncMembersClient) ListBySyncGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncMemberListResultIterator, err error) {
402	if tracing.IsEnabled() {
403		ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListBySyncGroup")
404		defer func() {
405			sc := -1
406			if result.Response().Response.Response != nil {
407				sc = result.page.Response().Response.Response.StatusCode
408			}
409			tracing.EndSpan(ctx, sc, err)
410		}()
411	}
412	result.page, err = client.ListBySyncGroup(ctx, resourceGroupName, serverName, databaseName, syncGroupName)
413	return
414}
415
416// ListMemberSchemas gets a sync member database schema.
417// Parameters:
418// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
419// from the Azure Resource Manager API or the portal.
420// serverName - the name of the server.
421// databaseName - the name of the database on which the sync group is hosted.
422// syncGroupName - the name of the sync group on which the sync member is hosted.
423// syncMemberName - the name of the sync member.
424func (client SyncMembersClient) ListMemberSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncFullSchemaPropertiesListResultPage, err error) {
425	if tracing.IsEnabled() {
426		ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListMemberSchemas")
427		defer func() {
428			sc := -1
429			if result.sfsplr.Response.Response != nil {
430				sc = result.sfsplr.Response.Response.StatusCode
431			}
432			tracing.EndSpan(ctx, sc, err)
433		}()
434	}
435	result.fn = client.listMemberSchemasNextResults
436	req, err := client.ListMemberSchemasPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName)
437	if err != nil {
438		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", nil, "Failure preparing request")
439		return
440	}
441
442	resp, err := client.ListMemberSchemasSender(req)
443	if err != nil {
444		result.sfsplr.Response = autorest.Response{Response: resp}
445		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", resp, "Failure sending request")
446		return
447	}
448
449	result.sfsplr, err = client.ListMemberSchemasResponder(resp)
450	if err != nil {
451		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", resp, "Failure responding to request")
452	}
453
454	return
455}
456
457// ListMemberSchemasPreparer prepares the ListMemberSchemas request.
458func (client SyncMembersClient) ListMemberSchemasPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (*http.Request, error) {
459	pathParameters := map[string]interface{}{
460		"databaseName":      autorest.Encode("path", databaseName),
461		"resourceGroupName": autorest.Encode("path", resourceGroupName),
462		"serverName":        autorest.Encode("path", serverName),
463		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
464		"syncGroupName":     autorest.Encode("path", syncGroupName),
465		"syncMemberName":    autorest.Encode("path", syncMemberName),
466	}
467
468	const APIVersion = "2015-05-01-preview"
469	queryParameters := map[string]interface{}{
470		"api-version": APIVersion,
471	}
472
473	preparer := autorest.CreatePreparer(
474		autorest.AsGet(),
475		autorest.WithBaseURL(client.BaseURI),
476		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas", pathParameters),
477		autorest.WithQueryParameters(queryParameters))
478	return preparer.Prepare((&http.Request{}).WithContext(ctx))
479}
480
481// ListMemberSchemasSender sends the ListMemberSchemas request. The method will close the
482// http.Response Body if it receives an error.
483func (client SyncMembersClient) ListMemberSchemasSender(req *http.Request) (*http.Response, error) {
484	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
485}
486
487// ListMemberSchemasResponder handles the response to the ListMemberSchemas request. The method always
488// closes the http.Response Body.
489func (client SyncMembersClient) ListMemberSchemasResponder(resp *http.Response) (result SyncFullSchemaPropertiesListResult, err error) {
490	err = autorest.Respond(
491		resp,
492		client.ByInspecting(),
493		azure.WithErrorUnlessStatusCode(http.StatusOK),
494		autorest.ByUnmarshallingJSON(&result),
495		autorest.ByClosing())
496	result.Response = autorest.Response{Response: resp}
497	return
498}
499
500// listMemberSchemasNextResults retrieves the next set of results, if any.
501func (client SyncMembersClient) listMemberSchemasNextResults(ctx context.Context, lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) {
502	req, err := lastResults.syncFullSchemaPropertiesListResultPreparer(ctx)
503	if err != nil {
504		return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", nil, "Failure preparing next results request")
505	}
506	if req == nil {
507		return
508	}
509	resp, err := client.ListMemberSchemasSender(req)
510	if err != nil {
511		result.Response = autorest.Response{Response: resp}
512		return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", resp, "Failure sending next results request")
513	}
514	result, err = client.ListMemberSchemasResponder(resp)
515	if err != nil {
516		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", resp, "Failure responding to next results request")
517	}
518	return
519}
520
521// ListMemberSchemasComplete enumerates all values, automatically crossing page boundaries as required.
522func (client SyncMembersClient) ListMemberSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncFullSchemaPropertiesListResultIterator, err error) {
523	if tracing.IsEnabled() {
524		ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListMemberSchemas")
525		defer func() {
526			sc := -1
527			if result.Response().Response.Response != nil {
528				sc = result.page.Response().Response.Response.StatusCode
529			}
530			tracing.EndSpan(ctx, sc, err)
531		}()
532	}
533	result.page, err = client.ListMemberSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName)
534	return
535}
536
537// RefreshMemberSchema refreshes a sync member database schema.
538// Parameters:
539// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
540// from the Azure Resource Manager API or the portal.
541// serverName - the name of the server.
542// databaseName - the name of the database on which the sync group is hosted.
543// syncGroupName - the name of the sync group on which the sync member is hosted.
544// syncMemberName - the name of the sync member.
545func (client SyncMembersClient) RefreshMemberSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMembersRefreshMemberSchemaFuture, err error) {
546	if tracing.IsEnabled() {
547		ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.RefreshMemberSchema")
548		defer func() {
549			sc := -1
550			if result.Response() != nil {
551				sc = result.Response().StatusCode
552			}
553			tracing.EndSpan(ctx, sc, err)
554		}()
555	}
556	req, err := client.RefreshMemberSchemaPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName)
557	if err != nil {
558		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "RefreshMemberSchema", nil, "Failure preparing request")
559		return
560	}
561
562	result, err = client.RefreshMemberSchemaSender(req)
563	if err != nil {
564		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "RefreshMemberSchema", result.Response(), "Failure sending request")
565		return
566	}
567
568	return
569}
570
571// RefreshMemberSchemaPreparer prepares the RefreshMemberSchema request.
572func (client SyncMembersClient) RefreshMemberSchemaPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (*http.Request, error) {
573	pathParameters := map[string]interface{}{
574		"databaseName":      autorest.Encode("path", databaseName),
575		"resourceGroupName": autorest.Encode("path", resourceGroupName),
576		"serverName":        autorest.Encode("path", serverName),
577		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
578		"syncGroupName":     autorest.Encode("path", syncGroupName),
579		"syncMemberName":    autorest.Encode("path", syncMemberName),
580	}
581
582	const APIVersion = "2015-05-01-preview"
583	queryParameters := map[string]interface{}{
584		"api-version": APIVersion,
585	}
586
587	preparer := autorest.CreatePreparer(
588		autorest.AsPost(),
589		autorest.WithBaseURL(client.BaseURI),
590		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema", pathParameters),
591		autorest.WithQueryParameters(queryParameters))
592	return preparer.Prepare((&http.Request{}).WithContext(ctx))
593}
594
595// RefreshMemberSchemaSender sends the RefreshMemberSchema request. The method will close the
596// http.Response Body if it receives an error.
597func (client SyncMembersClient) RefreshMemberSchemaSender(req *http.Request) (future SyncMembersRefreshMemberSchemaFuture, err error) {
598	var resp *http.Response
599	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
600	if err != nil {
601		return
602	}
603	future.Future, err = azure.NewFutureFromResponse(resp)
604	return
605}
606
607// RefreshMemberSchemaResponder handles the response to the RefreshMemberSchema request. The method always
608// closes the http.Response Body.
609func (client SyncMembersClient) RefreshMemberSchemaResponder(resp *http.Response) (result autorest.Response, err error) {
610	err = autorest.Respond(
611		resp,
612		client.ByInspecting(),
613		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
614		autorest.ByClosing())
615	result.Response = resp
616	return
617}
618
619// Update updates an existing sync member.
620// Parameters:
621// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
622// from the Azure Resource Manager API or the portal.
623// serverName - the name of the server.
624// databaseName - the name of the database on which the sync group is hosted.
625// syncGroupName - the name of the sync group on which the sync member is hosted.
626// syncMemberName - the name of the sync member.
627// parameters - the requested sync member resource state.
628func (client SyncMembersClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (result SyncMembersUpdateFuture, err error) {
629	if tracing.IsEnabled() {
630		ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Update")
631		defer func() {
632			sc := -1
633			if result.Response() != nil {
634				sc = result.Response().StatusCode
635			}
636			tracing.EndSpan(ctx, sc, err)
637		}()
638	}
639	req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters)
640	if err != nil {
641		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Update", nil, "Failure preparing request")
642		return
643	}
644
645	result, err = client.UpdateSender(req)
646	if err != nil {
647		err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Update", result.Response(), "Failure sending request")
648		return
649	}
650
651	return
652}
653
654// UpdatePreparer prepares the Update request.
655func (client SyncMembersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (*http.Request, error) {
656	pathParameters := map[string]interface{}{
657		"databaseName":      autorest.Encode("path", databaseName),
658		"resourceGroupName": autorest.Encode("path", resourceGroupName),
659		"serverName":        autorest.Encode("path", serverName),
660		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
661		"syncGroupName":     autorest.Encode("path", syncGroupName),
662		"syncMemberName":    autorest.Encode("path", syncMemberName),
663	}
664
665	const APIVersion = "2015-05-01-preview"
666	queryParameters := map[string]interface{}{
667		"api-version": APIVersion,
668	}
669
670	preparer := autorest.CreatePreparer(
671		autorest.AsContentType("application/json; charset=utf-8"),
672		autorest.AsPatch(),
673		autorest.WithBaseURL(client.BaseURI),
674		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", pathParameters),
675		autorest.WithJSON(parameters),
676		autorest.WithQueryParameters(queryParameters))
677	return preparer.Prepare((&http.Request{}).WithContext(ctx))
678}
679
680// UpdateSender sends the Update request. The method will close the
681// http.Response Body if it receives an error.
682func (client SyncMembersClient) UpdateSender(req *http.Request) (future SyncMembersUpdateFuture, err error) {
683	var resp *http.Response
684	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
685	if err != nil {
686		return
687	}
688	future.Future, err = azure.NewFutureFromResponse(resp)
689	return
690}
691
692// UpdateResponder handles the response to the Update request. The method always
693// closes the http.Response Body.
694func (client SyncMembersClient) UpdateResponder(resp *http.Response) (result SyncMember, err error) {
695	err = autorest.Respond(
696		resp,
697		client.ByInspecting(),
698		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
699		autorest.ByUnmarshallingJSON(&result),
700		autorest.ByClosing())
701	result.Response = autorest.Response{Response: resp}
702	return
703}
704