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