1 package mysqlflexibleservers
2
3
4
5
6
7
8
9 import (
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
19
20
21 type ServersClient struct {
22 BaseClient
23 }
24
25
26 func NewServersClient(subscriptionID string) ServersClient {
27 return NewServersClientWithBaseURI(DefaultBaseURI, subscriptionID)
28 }
29
30
31
32 func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient {
33 return ServersClient{NewWithBaseURI(baseURI, subscriptionID)}
34 }
35
36
37
38
39
40
41 func (client ServersClient) Create(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (result ServersCreateFuture, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Create")
44 defer func() {
45 sc := -1
46 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
47 sc = result.FutureAPI.Response().StatusCode
48 }
49 tracing.EndSpan(ctx, sc, err)
50 }()
51 }
52 if err := validation.Validate([]validation.Validation{
53 {TargetValue: client.SubscriptionID,
54 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
55 {TargetValue: resourceGroupName,
56 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
57 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
58 {TargetValue: parameters,
59 Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false,
60 Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}},
61 {Target: "parameters.ServerProperties", Name: validation.Null, Rule: false,
62 Chain: []validation.Constraint{{Target: "parameters.ServerProperties.ReplicaCapacity", Name: validation.Null, Rule: false,
63 Chain: []validation.Constraint{{Target: "parameters.ServerProperties.ReplicaCapacity", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}},
64 }}}}}); err != nil {
65 return result, validation.NewError("mysqlflexibleservers.ServersClient", "Create", err.Error())
66 }
67
68 req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, parameters)
69 if err != nil {
70 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Create", nil, "Failure preparing request")
71 return
72 }
73
74 result, err = client.CreateSender(req)
75 if err != nil {
76 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Create", result.Response(), "Failure sending request")
77 return
78 }
79
80 return
81 }
82
83
84 func (client ServersClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (*http.Request, error) {
85 pathParameters := map[string]interface{}{
86 "resourceGroupName": autorest.Encode("path", resourceGroupName),
87 "serverName": autorest.Encode("path", serverName),
88 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
89 }
90
91 const APIVersion = "2021-05-01-preview"
92 queryParameters := map[string]interface{}{
93 "api-version": APIVersion,
94 }
95
96 parameters.SystemData = nil
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.DBforMySQL/flexibleServers/{serverName}", pathParameters),
102 autorest.WithJSON(parameters),
103 autorest.WithQueryParameters(queryParameters))
104 return preparer.Prepare((&http.Request{}).WithContext(ctx))
105 }
106
107
108
109 func (client ServersClient) CreateSender(req *http.Request) (future ServersCreateFuture, err error) {
110 var resp *http.Response
111 future.FutureAPI = &azure.Future{}
112 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
113 if err != nil {
114 return
115 }
116 var azf azure.Future
117 azf, err = azure.NewFutureFromResponse(resp)
118 future.FutureAPI = &azf
119 future.Result = future.result
120 return
121 }
122
123
124
125 func (client ServersClient) CreateResponder(resp *http.Response) (result Server, err error) {
126 err = autorest.Respond(
127 resp,
128 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
129 autorest.ByUnmarshallingJSON(&result),
130 autorest.ByClosing())
131 result.Response = autorest.Response{Response: resp}
132 return
133 }
134
135
136
137
138
139 func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) {
140 if tracing.IsEnabled() {
141 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Delete")
142 defer func() {
143 sc := -1
144 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
145 sc = result.FutureAPI.Response().StatusCode
146 }
147 tracing.EndSpan(ctx, sc, err)
148 }()
149 }
150 if err := validation.Validate([]validation.Validation{
151 {TargetValue: client.SubscriptionID,
152 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
153 {TargetValue: resourceGroupName,
154 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
155 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
156 return result, validation.NewError("mysqlflexibleservers.ServersClient", "Delete", err.Error())
157 }
158
159 req, err := client.DeletePreparer(ctx, resourceGroupName, serverName)
160 if err != nil {
161 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Delete", nil, "Failure preparing request")
162 return
163 }
164
165 result, err = client.DeleteSender(req)
166 if err != nil {
167 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Delete", result.Response(), "Failure sending request")
168 return
169 }
170
171 return
172 }
173
174
175 func (client ServersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) {
176 pathParameters := map[string]interface{}{
177 "resourceGroupName": autorest.Encode("path", resourceGroupName),
178 "serverName": autorest.Encode("path", serverName),
179 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
180 }
181
182 const APIVersion = "2021-05-01-preview"
183 queryParameters := map[string]interface{}{
184 "api-version": APIVersion,
185 }
186
187 preparer := autorest.CreatePreparer(
188 autorest.AsDelete(),
189 autorest.WithBaseURL(client.BaseURI),
190 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}", pathParameters),
191 autorest.WithQueryParameters(queryParameters))
192 return preparer.Prepare((&http.Request{}).WithContext(ctx))
193 }
194
195
196
197 func (client ServersClient) DeleteSender(req *http.Request) (future ServersDeleteFuture, err error) {
198 var resp *http.Response
199 future.FutureAPI = &azure.Future{}
200 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
201 if err != nil {
202 return
203 }
204 var azf azure.Future
205 azf, err = azure.NewFutureFromResponse(resp)
206 future.FutureAPI = &azf
207 future.Result = future.result
208 return
209 }
210
211
212
213 func (client ServersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
214 err = autorest.Respond(
215 resp,
216 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
217 autorest.ByClosing())
218 result.Response = resp
219 return
220 }
221
222
223
224
225
226 func (client ServersClient) Failover(ctx context.Context, resourceGroupName string, serverName string) (result ServersFailoverFuture, err error) {
227 if tracing.IsEnabled() {
228 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Failover")
229 defer func() {
230 sc := -1
231 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
232 sc = result.FutureAPI.Response().StatusCode
233 }
234 tracing.EndSpan(ctx, sc, err)
235 }()
236 }
237 if err := validation.Validate([]validation.Validation{
238 {TargetValue: client.SubscriptionID,
239 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
240 {TargetValue: resourceGroupName,
241 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
242 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
243 return result, validation.NewError("mysqlflexibleservers.ServersClient", "Failover", err.Error())
244 }
245
246 req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName)
247 if err != nil {
248 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Failover", nil, "Failure preparing request")
249 return
250 }
251
252 result, err = client.FailoverSender(req)
253 if err != nil {
254 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Failover", result.Response(), "Failure sending request")
255 return
256 }
257
258 return
259 }
260
261
262 func (client ServersClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) {
263 pathParameters := map[string]interface{}{
264 "resourceGroupName": autorest.Encode("path", resourceGroupName),
265 "serverName": autorest.Encode("path", serverName),
266 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
267 }
268
269 const APIVersion = "2021-05-01-preview"
270 queryParameters := map[string]interface{}{
271 "api-version": APIVersion,
272 }
273
274 preparer := autorest.CreatePreparer(
275 autorest.AsPost(),
276 autorest.WithBaseURL(client.BaseURI),
277 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/failover", pathParameters),
278 autorest.WithQueryParameters(queryParameters))
279 return preparer.Prepare((&http.Request{}).WithContext(ctx))
280 }
281
282
283
284 func (client ServersClient) FailoverSender(req *http.Request) (future ServersFailoverFuture, err error) {
285 var resp *http.Response
286 future.FutureAPI = &azure.Future{}
287 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
288 if err != nil {
289 return
290 }
291 var azf azure.Future
292 azf, err = azure.NewFutureFromResponse(resp)
293 future.FutureAPI = &azf
294 future.Result = future.result
295 return
296 }
297
298
299
300 func (client ServersClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) {
301 err = autorest.Respond(
302 resp,
303 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
304 autorest.ByClosing())
305 result.Response = resp
306 return
307 }
308
309
310
311
312
313 func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result Server, err error) {
314 if tracing.IsEnabled() {
315 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Get")
316 defer func() {
317 sc := -1
318 if result.Response.Response != nil {
319 sc = result.Response.Response.StatusCode
320 }
321 tracing.EndSpan(ctx, sc, err)
322 }()
323 }
324 if err := validation.Validate([]validation.Validation{
325 {TargetValue: client.SubscriptionID,
326 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
327 {TargetValue: resourceGroupName,
328 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
329 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
330 return result, validation.NewError("mysqlflexibleservers.ServersClient", "Get", err.Error())
331 }
332
333 req, err := client.GetPreparer(ctx, resourceGroupName, serverName)
334 if err != nil {
335 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Get", nil, "Failure preparing request")
336 return
337 }
338
339 resp, err := client.GetSender(req)
340 if err != nil {
341 result.Response = autorest.Response{Response: resp}
342 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Get", resp, "Failure sending request")
343 return
344 }
345
346 result, err = client.GetResponder(resp)
347 if err != nil {
348 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Get", resp, "Failure responding to request")
349 return
350 }
351
352 return
353 }
354
355
356 func (client ServersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) {
357 pathParameters := map[string]interface{}{
358 "resourceGroupName": autorest.Encode("path", resourceGroupName),
359 "serverName": autorest.Encode("path", serverName),
360 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
361 }
362
363 const APIVersion = "2021-05-01-preview"
364 queryParameters := map[string]interface{}{
365 "api-version": APIVersion,
366 }
367
368 preparer := autorest.CreatePreparer(
369 autorest.AsGet(),
370 autorest.WithBaseURL(client.BaseURI),
371 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}", pathParameters),
372 autorest.WithQueryParameters(queryParameters))
373 return preparer.Prepare((&http.Request{}).WithContext(ctx))
374 }
375
376
377
378 func (client ServersClient) GetSender(req *http.Request) (*http.Response, error) {
379 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
380 }
381
382
383
384 func (client ServersClient) GetResponder(resp *http.Response) (result Server, err error) {
385 err = autorest.Respond(
386 resp,
387 azure.WithErrorUnlessStatusCode(http.StatusOK),
388 autorest.ByUnmarshallingJSON(&result),
389 autorest.ByClosing())
390 result.Response = autorest.Response{Response: resp}
391 return
392 }
393
394
395 func (client ServersClient) List(ctx context.Context) (result ServerListResultPage, err error) {
396 if tracing.IsEnabled() {
397 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List")
398 defer func() {
399 sc := -1
400 if result.slr.Response.Response != nil {
401 sc = result.slr.Response.Response.StatusCode
402 }
403 tracing.EndSpan(ctx, sc, err)
404 }()
405 }
406 if err := validation.Validate([]validation.Validation{
407 {TargetValue: client.SubscriptionID,
408 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
409 return result, validation.NewError("mysqlflexibleservers.ServersClient", "List", err.Error())
410 }
411
412 result.fn = client.listNextResults
413 req, err := client.ListPreparer(ctx)
414 if err != nil {
415 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "List", nil, "Failure preparing request")
416 return
417 }
418
419 resp, err := client.ListSender(req)
420 if err != nil {
421 result.slr.Response = autorest.Response{Response: resp}
422 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "List", resp, "Failure sending request")
423 return
424 }
425
426 result.slr, err = client.ListResponder(resp)
427 if err != nil {
428 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "List", resp, "Failure responding to request")
429 return
430 }
431 if result.slr.hasNextLink() && result.slr.IsEmpty() {
432 err = result.NextWithContext(ctx)
433 return
434 }
435
436 return
437 }
438
439
440 func (client ServersClient) ListPreparer(ctx context.Context) (*http.Request, error) {
441 pathParameters := map[string]interface{}{
442 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
443 }
444
445 const APIVersion = "2021-05-01-preview"
446 queryParameters := map[string]interface{}{
447 "api-version": APIVersion,
448 }
449
450 preparer := autorest.CreatePreparer(
451 autorest.AsGet(),
452 autorest.WithBaseURL(client.BaseURI),
453 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/flexibleServers", pathParameters),
454 autorest.WithQueryParameters(queryParameters))
455 return preparer.Prepare((&http.Request{}).WithContext(ctx))
456 }
457
458
459
460 func (client ServersClient) ListSender(req *http.Request) (*http.Response, error) {
461 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
462 }
463
464
465
466 func (client ServersClient) ListResponder(resp *http.Response) (result ServerListResult, err error) {
467 err = autorest.Respond(
468 resp,
469 azure.WithErrorUnlessStatusCode(http.StatusOK),
470 autorest.ByUnmarshallingJSON(&result),
471 autorest.ByClosing())
472 result.Response = autorest.Response{Response: resp}
473 return
474 }
475
476
477 func (client ServersClient) listNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) {
478 req, err := lastResults.serverListResultPreparer(ctx)
479 if err != nil {
480 return result, autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "listNextResults", nil, "Failure preparing next results request")
481 }
482 if req == nil {
483 return
484 }
485 resp, err := client.ListSender(req)
486 if err != nil {
487 result.Response = autorest.Response{Response: resp}
488 return result, autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "listNextResults", resp, "Failure sending next results request")
489 }
490 result, err = client.ListResponder(resp)
491 if err != nil {
492 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "listNextResults", resp, "Failure responding to next results request")
493 }
494 return
495 }
496
497
498 func (client ServersClient) ListComplete(ctx context.Context) (result ServerListResultIterator, err error) {
499 if tracing.IsEnabled() {
500 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List")
501 defer func() {
502 sc := -1
503 if result.Response().Response.Response != nil {
504 sc = result.page.Response().Response.Response.StatusCode
505 }
506 tracing.EndSpan(ctx, sc, err)
507 }()
508 }
509 result.page, err = client.List(ctx)
510 return
511 }
512
513
514
515
516 func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServerListResultPage, err error) {
517 if tracing.IsEnabled() {
518 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup")
519 defer func() {
520 sc := -1
521 if result.slr.Response.Response != nil {
522 sc = result.slr.Response.Response.StatusCode
523 }
524 tracing.EndSpan(ctx, sc, err)
525 }()
526 }
527 if err := validation.Validate([]validation.Validation{
528 {TargetValue: client.SubscriptionID,
529 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
530 {TargetValue: resourceGroupName,
531 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
532 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
533 return result, validation.NewError("mysqlflexibleservers.ServersClient", "ListByResourceGroup", err.Error())
534 }
535
536 result.fn = client.listByResourceGroupNextResults
537 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
538 if err != nil {
539 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "ListByResourceGroup", nil, "Failure preparing request")
540 return
541 }
542
543 resp, err := client.ListByResourceGroupSender(req)
544 if err != nil {
545 result.slr.Response = autorest.Response{Response: resp}
546 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "ListByResourceGroup", resp, "Failure sending request")
547 return
548 }
549
550 result.slr, err = client.ListByResourceGroupResponder(resp)
551 if err != nil {
552 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "ListByResourceGroup", resp, "Failure responding to request")
553 return
554 }
555 if result.slr.hasNextLink() && result.slr.IsEmpty() {
556 err = result.NextWithContext(ctx)
557 return
558 }
559
560 return
561 }
562
563
564 func (client ServersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
565 pathParameters := map[string]interface{}{
566 "resourceGroupName": autorest.Encode("path", resourceGroupName),
567 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
568 }
569
570 const APIVersion = "2021-05-01-preview"
571 queryParameters := map[string]interface{}{
572 "api-version": APIVersion,
573 }
574
575 preparer := autorest.CreatePreparer(
576 autorest.AsGet(),
577 autorest.WithBaseURL(client.BaseURI),
578 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers", pathParameters),
579 autorest.WithQueryParameters(queryParameters))
580 return preparer.Prepare((&http.Request{}).WithContext(ctx))
581 }
582
583
584
585 func (client ServersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
586 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
587 }
588
589
590
591 func (client ServersClient) ListByResourceGroupResponder(resp *http.Response) (result ServerListResult, err error) {
592 err = autorest.Respond(
593 resp,
594 azure.WithErrorUnlessStatusCode(http.StatusOK),
595 autorest.ByUnmarshallingJSON(&result),
596 autorest.ByClosing())
597 result.Response = autorest.Response{Response: resp}
598 return
599 }
600
601
602 func (client ServersClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) {
603 req, err := lastResults.serverListResultPreparer(ctx)
604 if err != nil {
605 return result, autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
606 }
607 if req == nil {
608 return
609 }
610 resp, err := client.ListByResourceGroupSender(req)
611 if err != nil {
612 result.Response = autorest.Response{Response: resp}
613 return result, autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
614 }
615 result, err = client.ListByResourceGroupResponder(resp)
616 if err != nil {
617 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
618 }
619 return
620 }
621
622
623 func (client ServersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServerListResultIterator, err error) {
624 if tracing.IsEnabled() {
625 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup")
626 defer func() {
627 sc := -1
628 if result.Response().Response.Response != nil {
629 sc = result.page.Response().Response.Response.StatusCode
630 }
631 tracing.EndSpan(ctx, sc, err)
632 }()
633 }
634 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
635 return
636 }
637
638
639
640
641
642
643 func (client ServersClient) Restart(ctx context.Context, resourceGroupName string, serverName string, parameters ServerRestartParameter) (result ServersRestartFuture, err error) {
644 if tracing.IsEnabled() {
645 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Restart")
646 defer func() {
647 sc := -1
648 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
649 sc = result.FutureAPI.Response().StatusCode
650 }
651 tracing.EndSpan(ctx, sc, err)
652 }()
653 }
654 if err := validation.Validate([]validation.Validation{
655 {TargetValue: client.SubscriptionID,
656 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
657 {TargetValue: resourceGroupName,
658 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
659 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
660 return result, validation.NewError("mysqlflexibleservers.ServersClient", "Restart", err.Error())
661 }
662
663 req, err := client.RestartPreparer(ctx, resourceGroupName, serverName, parameters)
664 if err != nil {
665 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Restart", nil, "Failure preparing request")
666 return
667 }
668
669 result, err = client.RestartSender(req)
670 if err != nil {
671 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Restart", result.Response(), "Failure sending request")
672 return
673 }
674
675 return
676 }
677
678
679 func (client ServersClient) RestartPreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerRestartParameter) (*http.Request, error) {
680 pathParameters := map[string]interface{}{
681 "resourceGroupName": autorest.Encode("path", resourceGroupName),
682 "serverName": autorest.Encode("path", serverName),
683 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
684 }
685
686 const APIVersion = "2021-05-01-preview"
687 queryParameters := map[string]interface{}{
688 "api-version": APIVersion,
689 }
690
691 preparer := autorest.CreatePreparer(
692 autorest.AsContentType("application/json; charset=utf-8"),
693 autorest.AsPost(),
694 autorest.WithBaseURL(client.BaseURI),
695 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/restart", pathParameters),
696 autorest.WithJSON(parameters),
697 autorest.WithQueryParameters(queryParameters))
698 return preparer.Prepare((&http.Request{}).WithContext(ctx))
699 }
700
701
702
703 func (client ServersClient) RestartSender(req *http.Request) (future ServersRestartFuture, err error) {
704 var resp *http.Response
705 future.FutureAPI = &azure.Future{}
706 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
707 if err != nil {
708 return
709 }
710 var azf azure.Future
711 azf, err = azure.NewFutureFromResponse(resp)
712 future.FutureAPI = &azf
713 future.Result = future.result
714 return
715 }
716
717
718
719 func (client ServersClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) {
720 err = autorest.Respond(
721 resp,
722 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
723 autorest.ByClosing())
724 result.Response = resp
725 return
726 }
727
728
729
730
731
732 func (client ServersClient) Start(ctx context.Context, resourceGroupName string, serverName string) (result ServersStartFuture, err error) {
733 if tracing.IsEnabled() {
734 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Start")
735 defer func() {
736 sc := -1
737 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
738 sc = result.FutureAPI.Response().StatusCode
739 }
740 tracing.EndSpan(ctx, sc, err)
741 }()
742 }
743 if err := validation.Validate([]validation.Validation{
744 {TargetValue: client.SubscriptionID,
745 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
746 {TargetValue: resourceGroupName,
747 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
748 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
749 return result, validation.NewError("mysqlflexibleservers.ServersClient", "Start", err.Error())
750 }
751
752 req, err := client.StartPreparer(ctx, resourceGroupName, serverName)
753 if err != nil {
754 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Start", nil, "Failure preparing request")
755 return
756 }
757
758 result, err = client.StartSender(req)
759 if err != nil {
760 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Start", result.Response(), "Failure sending request")
761 return
762 }
763
764 return
765 }
766
767
768 func (client ServersClient) StartPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) {
769 pathParameters := map[string]interface{}{
770 "resourceGroupName": autorest.Encode("path", resourceGroupName),
771 "serverName": autorest.Encode("path", serverName),
772 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
773 }
774
775 const APIVersion = "2021-05-01-preview"
776 queryParameters := map[string]interface{}{
777 "api-version": APIVersion,
778 }
779
780 preparer := autorest.CreatePreparer(
781 autorest.AsPost(),
782 autorest.WithBaseURL(client.BaseURI),
783 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/start", pathParameters),
784 autorest.WithQueryParameters(queryParameters))
785 return preparer.Prepare((&http.Request{}).WithContext(ctx))
786 }
787
788
789
790 func (client ServersClient) StartSender(req *http.Request) (future ServersStartFuture, err error) {
791 var resp *http.Response
792 future.FutureAPI = &azure.Future{}
793 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
794 if err != nil {
795 return
796 }
797 var azf azure.Future
798 azf, err = azure.NewFutureFromResponse(resp)
799 future.FutureAPI = &azf
800 future.Result = future.result
801 return
802 }
803
804
805
806 func (client ServersClient) StartResponder(resp *http.Response) (result autorest.Response, err error) {
807 err = autorest.Respond(
808 resp,
809 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
810 autorest.ByClosing())
811 result.Response = resp
812 return
813 }
814
815
816
817
818
819 func (client ServersClient) Stop(ctx context.Context, resourceGroupName string, serverName string) (result ServersStopFuture, err error) {
820 if tracing.IsEnabled() {
821 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Stop")
822 defer func() {
823 sc := -1
824 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
825 sc = result.FutureAPI.Response().StatusCode
826 }
827 tracing.EndSpan(ctx, sc, err)
828 }()
829 }
830 if err := validation.Validate([]validation.Validation{
831 {TargetValue: client.SubscriptionID,
832 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
833 {TargetValue: resourceGroupName,
834 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
835 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
836 return result, validation.NewError("mysqlflexibleservers.ServersClient", "Stop", err.Error())
837 }
838
839 req, err := client.StopPreparer(ctx, resourceGroupName, serverName)
840 if err != nil {
841 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Stop", nil, "Failure preparing request")
842 return
843 }
844
845 result, err = client.StopSender(req)
846 if err != nil {
847 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Stop", result.Response(), "Failure sending request")
848 return
849 }
850
851 return
852 }
853
854
855 func (client ServersClient) StopPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) {
856 pathParameters := map[string]interface{}{
857 "resourceGroupName": autorest.Encode("path", resourceGroupName),
858 "serverName": autorest.Encode("path", serverName),
859 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
860 }
861
862 const APIVersion = "2021-05-01-preview"
863 queryParameters := map[string]interface{}{
864 "api-version": APIVersion,
865 }
866
867 preparer := autorest.CreatePreparer(
868 autorest.AsPost(),
869 autorest.WithBaseURL(client.BaseURI),
870 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/stop", pathParameters),
871 autorest.WithQueryParameters(queryParameters))
872 return preparer.Prepare((&http.Request{}).WithContext(ctx))
873 }
874
875
876
877 func (client ServersClient) StopSender(req *http.Request) (future ServersStopFuture, err error) {
878 var resp *http.Response
879 future.FutureAPI = &azure.Future{}
880 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
881 if err != nil {
882 return
883 }
884 var azf azure.Future
885 azf, err = azure.NewFutureFromResponse(resp)
886 future.FutureAPI = &azf
887 future.Result = future.result
888 return
889 }
890
891
892
893 func (client ServersClient) StopResponder(resp *http.Response) (result autorest.Response, err error) {
894 err = autorest.Respond(
895 resp,
896 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
897 autorest.ByClosing())
898 result.Response = resp
899 return
900 }
901
902
903
904
905
906
907
908 func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate) (result ServersUpdateFuture, err error) {
909 if tracing.IsEnabled() {
910 ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Update")
911 defer func() {
912 sc := -1
913 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
914 sc = result.FutureAPI.Response().StatusCode
915 }
916 tracing.EndSpan(ctx, sc, err)
917 }()
918 }
919 if err := validation.Validate([]validation.Validation{
920 {TargetValue: client.SubscriptionID,
921 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
922 {TargetValue: resourceGroupName,
923 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
924 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
925 return result, validation.NewError("mysqlflexibleservers.ServersClient", "Update", err.Error())
926 }
927
928 req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters)
929 if err != nil {
930 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Update", nil, "Failure preparing request")
931 return
932 }
933
934 result, err = client.UpdateSender(req)
935 if err != nil {
936 err = autorest.NewErrorWithError(err, "mysqlflexibleservers.ServersClient", "Update", result.Response(), "Failure sending request")
937 return
938 }
939
940 return
941 }
942
943
944 func (client ServersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate) (*http.Request, error) {
945 pathParameters := map[string]interface{}{
946 "resourceGroupName": autorest.Encode("path", resourceGroupName),
947 "serverName": autorest.Encode("path", serverName),
948 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
949 }
950
951 const APIVersion = "2021-05-01-preview"
952 queryParameters := map[string]interface{}{
953 "api-version": APIVersion,
954 }
955
956 preparer := autorest.CreatePreparer(
957 autorest.AsContentType("application/json; charset=utf-8"),
958 autorest.AsPatch(),
959 autorest.WithBaseURL(client.BaseURI),
960 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}", pathParameters),
961 autorest.WithJSON(parameters),
962 autorest.WithQueryParameters(queryParameters))
963 return preparer.Prepare((&http.Request{}).WithContext(ctx))
964 }
965
966
967
968 func (client ServersClient) UpdateSender(req *http.Request) (future ServersUpdateFuture, err error) {
969 var resp *http.Response
970 future.FutureAPI = &azure.Future{}
971 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
972 if err != nil {
973 return
974 }
975 var azf azure.Future
976 azf, err = azure.NewFutureFromResponse(resp)
977 future.FutureAPI = &azf
978 future.Result = future.result
979 return
980 }
981
982
983
984 func (client ServersClient) UpdateResponder(resp *http.Response) (result Server, err error) {
985 err = autorest.Respond(
986 resp,
987 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
988 autorest.ByUnmarshallingJSON(&result),
989 autorest.ByClosing())
990 result.Response = autorest.Response{Response: resp}
991 return
992 }
993
View as plain text