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