1 package postgresqlflexibleservers
2
3
4
5
6
7
8
9 import (
10 "context"
11 "encoding/json"
12 "github.com/Azure/go-autorest/autorest"
13 "github.com/Azure/go-autorest/autorest/azure"
14 "github.com/Azure/go-autorest/autorest/date"
15 "github.com/Azure/go-autorest/autorest/to"
16 "github.com/Azure/go-autorest/tracing"
17 "net/http"
18 )
19
20
21 const fqdn = "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers"
22
23
24 type AzureEntityResource struct {
25
26 Etag *string `json:"etag,omitempty"`
27
28 ID *string `json:"id,omitempty"`
29
30 Name *string `json:"name,omitempty"`
31
32 Type *string `json:"type,omitempty"`
33 }
34
35
36 func (aer AzureEntityResource) MarshalJSON() ([]byte, error) {
37 objectMap := make(map[string]interface{})
38 return json.Marshal(objectMap)
39 }
40
41
42 type Backup struct {
43
44 BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"`
45
46 GeoRedundantBackup GeoRedundantBackupEnum `json:"geoRedundantBackup,omitempty"`
47
48 EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"`
49 }
50
51
52 func (b Backup) MarshalJSON() ([]byte, error) {
53 objectMap := make(map[string]interface{})
54 if b.BackupRetentionDays != nil {
55 objectMap["backupRetentionDays"] = b.BackupRetentionDays
56 }
57 if b.GeoRedundantBackup != "" {
58 objectMap["geoRedundantBackup"] = b.GeoRedundantBackup
59 }
60 return json.Marshal(objectMap)
61 }
62
63
64 type CapabilitiesListResult struct {
65 autorest.Response `json:"-"`
66
67 Value *[]CapabilityProperties `json:"value,omitempty"`
68
69 NextLink *string `json:"nextLink,omitempty"`
70 }
71
72
73 func (clr CapabilitiesListResult) MarshalJSON() ([]byte, error) {
74 objectMap := make(map[string]interface{})
75 return json.Marshal(objectMap)
76 }
77
78
79 type CapabilitiesListResultIterator struct {
80 i int
81 page CapabilitiesListResultPage
82 }
83
84
85
86 func (iter *CapabilitiesListResultIterator) NextWithContext(ctx context.Context) (err error) {
87 if tracing.IsEnabled() {
88 ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesListResultIterator.NextWithContext")
89 defer func() {
90 sc := -1
91 if iter.Response().Response.Response != nil {
92 sc = iter.Response().Response.Response.StatusCode
93 }
94 tracing.EndSpan(ctx, sc, err)
95 }()
96 }
97 iter.i++
98 if iter.i < len(iter.page.Values()) {
99 return nil
100 }
101 err = iter.page.NextWithContext(ctx)
102 if err != nil {
103 iter.i--
104 return err
105 }
106 iter.i = 0
107 return nil
108 }
109
110
111
112
113 func (iter *CapabilitiesListResultIterator) Next() error {
114 return iter.NextWithContext(context.Background())
115 }
116
117
118 func (iter CapabilitiesListResultIterator) NotDone() bool {
119 return iter.page.NotDone() && iter.i < len(iter.page.Values())
120 }
121
122
123 func (iter CapabilitiesListResultIterator) Response() CapabilitiesListResult {
124 return iter.page.Response()
125 }
126
127
128
129 func (iter CapabilitiesListResultIterator) Value() CapabilityProperties {
130 if !iter.page.NotDone() {
131 return CapabilityProperties{}
132 }
133 return iter.page.Values()[iter.i]
134 }
135
136
137 func NewCapabilitiesListResultIterator(page CapabilitiesListResultPage) CapabilitiesListResultIterator {
138 return CapabilitiesListResultIterator{page: page}
139 }
140
141
142 func (clr CapabilitiesListResult) IsEmpty() bool {
143 return clr.Value == nil || len(*clr.Value) == 0
144 }
145
146
147 func (clr CapabilitiesListResult) hasNextLink() bool {
148 return clr.NextLink != nil && len(*clr.NextLink) != 0
149 }
150
151
152
153 func (clr CapabilitiesListResult) capabilitiesListResultPreparer(ctx context.Context) (*http.Request, error) {
154 if !clr.hasNextLink() {
155 return nil, nil
156 }
157 return autorest.Prepare((&http.Request{}).WithContext(ctx),
158 autorest.AsJSON(),
159 autorest.AsGet(),
160 autorest.WithBaseURL(to.String(clr.NextLink)))
161 }
162
163
164 type CapabilitiesListResultPage struct {
165 fn func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error)
166 clr CapabilitiesListResult
167 }
168
169
170
171 func (page *CapabilitiesListResultPage) NextWithContext(ctx context.Context) (err error) {
172 if tracing.IsEnabled() {
173 ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesListResultPage.NextWithContext")
174 defer func() {
175 sc := -1
176 if page.Response().Response.Response != nil {
177 sc = page.Response().Response.Response.StatusCode
178 }
179 tracing.EndSpan(ctx, sc, err)
180 }()
181 }
182 for {
183 next, err := page.fn(ctx, page.clr)
184 if err != nil {
185 return err
186 }
187 page.clr = next
188 if !next.hasNextLink() || !next.IsEmpty() {
189 break
190 }
191 }
192 return nil
193 }
194
195
196
197
198 func (page *CapabilitiesListResultPage) Next() error {
199 return page.NextWithContext(context.Background())
200 }
201
202
203 func (page CapabilitiesListResultPage) NotDone() bool {
204 return !page.clr.IsEmpty()
205 }
206
207
208 func (page CapabilitiesListResultPage) Response() CapabilitiesListResult {
209 return page.clr
210 }
211
212
213 func (page CapabilitiesListResultPage) Values() []CapabilityProperties {
214 if page.clr.IsEmpty() {
215 return nil
216 }
217 return *page.clr.Value
218 }
219
220
221 func NewCapabilitiesListResultPage(cur CapabilitiesListResult, getNextPage func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error)) CapabilitiesListResultPage {
222 return CapabilitiesListResultPage{
223 fn: getNextPage,
224 clr: cur,
225 }
226 }
227
228
229 type CapabilityProperties struct {
230
231 Zone *string `json:"zone,omitempty"`
232
233 GeoBackupSupported *bool `json:"geoBackupSupported,omitempty"`
234
235 ZoneRedundantHaSupported *bool `json:"zoneRedundantHaSupported,omitempty"`
236
237 ZoneRedundantHaAndGeoBackupSupported *bool `json:"zoneRedundantHaAndGeoBackupSupported,omitempty"`
238
239 SupportedFlexibleServerEditions *[]FlexibleServerEditionCapability `json:"supportedFlexibleServerEditions,omitempty"`
240
241 SupportedHyperscaleNodeEditions *[]HyperscaleNodeEditionCapability `json:"supportedHyperscaleNodeEditions,omitempty"`
242
243 Status *string `json:"status,omitempty"`
244 }
245
246
247 func (cp CapabilityProperties) MarshalJSON() ([]byte, error) {
248 objectMap := make(map[string]interface{})
249 return json.Marshal(objectMap)
250 }
251
252
253 type CloudError struct {
254 Error *ErrorResponse `json:"error,omitempty"`
255 }
256
257
258 type Configuration struct {
259 autorest.Response `json:"-"`
260
261 *ConfigurationProperties `json:"properties,omitempty"`
262
263 SystemData *SystemData `json:"systemData,omitempty"`
264
265 ID *string `json:"id,omitempty"`
266
267 Name *string `json:"name,omitempty"`
268
269 Type *string `json:"type,omitempty"`
270 }
271
272
273 func (c Configuration) MarshalJSON() ([]byte, error) {
274 objectMap := make(map[string]interface{})
275 if c.ConfigurationProperties != nil {
276 objectMap["properties"] = c.ConfigurationProperties
277 }
278 return json.Marshal(objectMap)
279 }
280
281
282 func (c *Configuration) UnmarshalJSON(body []byte) error {
283 var m map[string]*json.RawMessage
284 err := json.Unmarshal(body, &m)
285 if err != nil {
286 return err
287 }
288 for k, v := range m {
289 switch k {
290 case "properties":
291 if v != nil {
292 var configurationProperties ConfigurationProperties
293 err = json.Unmarshal(*v, &configurationProperties)
294 if err != nil {
295 return err
296 }
297 c.ConfigurationProperties = &configurationProperties
298 }
299 case "systemData":
300 if v != nil {
301 var systemData SystemData
302 err = json.Unmarshal(*v, &systemData)
303 if err != nil {
304 return err
305 }
306 c.SystemData = &systemData
307 }
308 case "id":
309 if v != nil {
310 var ID string
311 err = json.Unmarshal(*v, &ID)
312 if err != nil {
313 return err
314 }
315 c.ID = &ID
316 }
317 case "name":
318 if v != nil {
319 var name string
320 err = json.Unmarshal(*v, &name)
321 if err != nil {
322 return err
323 }
324 c.Name = &name
325 }
326 case "type":
327 if v != nil {
328 var typeVar string
329 err = json.Unmarshal(*v, &typeVar)
330 if err != nil {
331 return err
332 }
333 c.Type = &typeVar
334 }
335 }
336 }
337
338 return nil
339 }
340
341
342 type ConfigurationListResult struct {
343 autorest.Response `json:"-"`
344
345 Value *[]Configuration `json:"value,omitempty"`
346
347 NextLink *string `json:"nextLink,omitempty"`
348 }
349
350
351 type ConfigurationListResultIterator struct {
352 i int
353 page ConfigurationListResultPage
354 }
355
356
357
358 func (iter *ConfigurationListResultIterator) NextWithContext(ctx context.Context) (err error) {
359 if tracing.IsEnabled() {
360 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultIterator.NextWithContext")
361 defer func() {
362 sc := -1
363 if iter.Response().Response.Response != nil {
364 sc = iter.Response().Response.Response.StatusCode
365 }
366 tracing.EndSpan(ctx, sc, err)
367 }()
368 }
369 iter.i++
370 if iter.i < len(iter.page.Values()) {
371 return nil
372 }
373 err = iter.page.NextWithContext(ctx)
374 if err != nil {
375 iter.i--
376 return err
377 }
378 iter.i = 0
379 return nil
380 }
381
382
383
384
385 func (iter *ConfigurationListResultIterator) Next() error {
386 return iter.NextWithContext(context.Background())
387 }
388
389
390 func (iter ConfigurationListResultIterator) NotDone() bool {
391 return iter.page.NotDone() && iter.i < len(iter.page.Values())
392 }
393
394
395 func (iter ConfigurationListResultIterator) Response() ConfigurationListResult {
396 return iter.page.Response()
397 }
398
399
400
401 func (iter ConfigurationListResultIterator) Value() Configuration {
402 if !iter.page.NotDone() {
403 return Configuration{}
404 }
405 return iter.page.Values()[iter.i]
406 }
407
408
409 func NewConfigurationListResultIterator(page ConfigurationListResultPage) ConfigurationListResultIterator {
410 return ConfigurationListResultIterator{page: page}
411 }
412
413
414 func (clr ConfigurationListResult) IsEmpty() bool {
415 return clr.Value == nil || len(*clr.Value) == 0
416 }
417
418
419 func (clr ConfigurationListResult) hasNextLink() bool {
420 return clr.NextLink != nil && len(*clr.NextLink) != 0
421 }
422
423
424
425 func (clr ConfigurationListResult) configurationListResultPreparer(ctx context.Context) (*http.Request, error) {
426 if !clr.hasNextLink() {
427 return nil, nil
428 }
429 return autorest.Prepare((&http.Request{}).WithContext(ctx),
430 autorest.AsJSON(),
431 autorest.AsGet(),
432 autorest.WithBaseURL(to.String(clr.NextLink)))
433 }
434
435
436 type ConfigurationListResultPage struct {
437 fn func(context.Context, ConfigurationListResult) (ConfigurationListResult, error)
438 clr ConfigurationListResult
439 }
440
441
442
443 func (page *ConfigurationListResultPage) NextWithContext(ctx context.Context) (err error) {
444 if tracing.IsEnabled() {
445 ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultPage.NextWithContext")
446 defer func() {
447 sc := -1
448 if page.Response().Response.Response != nil {
449 sc = page.Response().Response.Response.StatusCode
450 }
451 tracing.EndSpan(ctx, sc, err)
452 }()
453 }
454 for {
455 next, err := page.fn(ctx, page.clr)
456 if err != nil {
457 return err
458 }
459 page.clr = next
460 if !next.hasNextLink() || !next.IsEmpty() {
461 break
462 }
463 }
464 return nil
465 }
466
467
468
469
470 func (page *ConfigurationListResultPage) Next() error {
471 return page.NextWithContext(context.Background())
472 }
473
474
475 func (page ConfigurationListResultPage) NotDone() bool {
476 return !page.clr.IsEmpty()
477 }
478
479
480 func (page ConfigurationListResultPage) Response() ConfigurationListResult {
481 return page.clr
482 }
483
484
485 func (page ConfigurationListResultPage) Values() []Configuration {
486 if page.clr.IsEmpty() {
487 return nil
488 }
489 return *page.clr.Value
490 }
491
492
493 func NewConfigurationListResultPage(cur ConfigurationListResult, getNextPage func(context.Context, ConfigurationListResult) (ConfigurationListResult, error)) ConfigurationListResultPage {
494 return ConfigurationListResultPage{
495 fn: getNextPage,
496 clr: cur,
497 }
498 }
499
500
501 type ConfigurationProperties struct {
502
503 Value *string `json:"value,omitempty"`
504
505 Description *string `json:"description,omitempty"`
506
507 DefaultValue *string `json:"defaultValue,omitempty"`
508
509 DataType ConfigurationDataType `json:"dataType,omitempty"`
510
511 AllowedValues *string `json:"allowedValues,omitempty"`
512
513 Source *string `json:"source,omitempty"`
514 }
515
516
517 func (cp ConfigurationProperties) MarshalJSON() ([]byte, error) {
518 objectMap := make(map[string]interface{})
519 if cp.Value != nil {
520 objectMap["value"] = cp.Value
521 }
522 if cp.Source != nil {
523 objectMap["source"] = cp.Source
524 }
525 return json.Marshal(objectMap)
526 }
527
528
529
530 type ConfigurationsPutFuture struct {
531 azure.FutureAPI
532
533
534 Result func(ConfigurationsClient) (Configuration, error)
535 }
536
537
538 func (future *ConfigurationsPutFuture) UnmarshalJSON(body []byte) error {
539 var azFuture azure.Future
540 if err := json.Unmarshal(body, &azFuture); err != nil {
541 return err
542 }
543 future.FutureAPI = &azFuture
544 future.Result = future.result
545 return nil
546 }
547
548
549 func (future *ConfigurationsPutFuture) result(client ConfigurationsClient) (c Configuration, err error) {
550 var done bool
551 done, err = future.DoneWithContext(context.Background(), client)
552 if err != nil {
553 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsPutFuture", "Result", future.Response(), "Polling failure")
554 return
555 }
556 if !done {
557 c.Response.Response = future.Response()
558 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ConfigurationsPutFuture")
559 return
560 }
561 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
562 if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent {
563 c, err = client.PutResponder(c.Response.Response)
564 if err != nil {
565 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsPutFuture", "Result", c.Response.Response, "Failure responding to request")
566 }
567 }
568 return
569 }
570
571
572
573 type ConfigurationsUpdateFuture struct {
574 azure.FutureAPI
575
576
577 Result func(ConfigurationsClient) (Configuration, error)
578 }
579
580
581 func (future *ConfigurationsUpdateFuture) UnmarshalJSON(body []byte) error {
582 var azFuture azure.Future
583 if err := json.Unmarshal(body, &azFuture); err != nil {
584 return err
585 }
586 future.FutureAPI = &azFuture
587 future.Result = future.result
588 return nil
589 }
590
591
592 func (future *ConfigurationsUpdateFuture) result(client ConfigurationsClient) (c Configuration, err error) {
593 var done bool
594 done, err = future.DoneWithContext(context.Background(), client)
595 if err != nil {
596 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsUpdateFuture", "Result", future.Response(), "Polling failure")
597 return
598 }
599 if !done {
600 c.Response.Response = future.Response()
601 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ConfigurationsUpdateFuture")
602 return
603 }
604 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
605 if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent {
606 c, err = client.UpdateResponder(c.Response.Response)
607 if err != nil {
608 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsUpdateFuture", "Result", c.Response.Response, "Failure responding to request")
609 }
610 }
611 return
612 }
613
614
615 type Database struct {
616 autorest.Response `json:"-"`
617
618 *DatabaseProperties `json:"properties,omitempty"`
619
620 SystemData *SystemData `json:"systemData,omitempty"`
621
622 ID *string `json:"id,omitempty"`
623
624 Name *string `json:"name,omitempty"`
625
626 Type *string `json:"type,omitempty"`
627 }
628
629
630 func (d Database) MarshalJSON() ([]byte, error) {
631 objectMap := make(map[string]interface{})
632 if d.DatabaseProperties != nil {
633 objectMap["properties"] = d.DatabaseProperties
634 }
635 return json.Marshal(objectMap)
636 }
637
638
639 func (d *Database) UnmarshalJSON(body []byte) error {
640 var m map[string]*json.RawMessage
641 err := json.Unmarshal(body, &m)
642 if err != nil {
643 return err
644 }
645 for k, v := range m {
646 switch k {
647 case "properties":
648 if v != nil {
649 var databaseProperties DatabaseProperties
650 err = json.Unmarshal(*v, &databaseProperties)
651 if err != nil {
652 return err
653 }
654 d.DatabaseProperties = &databaseProperties
655 }
656 case "systemData":
657 if v != nil {
658 var systemData SystemData
659 err = json.Unmarshal(*v, &systemData)
660 if err != nil {
661 return err
662 }
663 d.SystemData = &systemData
664 }
665 case "id":
666 if v != nil {
667 var ID string
668 err = json.Unmarshal(*v, &ID)
669 if err != nil {
670 return err
671 }
672 d.ID = &ID
673 }
674 case "name":
675 if v != nil {
676 var name string
677 err = json.Unmarshal(*v, &name)
678 if err != nil {
679 return err
680 }
681 d.Name = &name
682 }
683 case "type":
684 if v != nil {
685 var typeVar string
686 err = json.Unmarshal(*v, &typeVar)
687 if err != nil {
688 return err
689 }
690 d.Type = &typeVar
691 }
692 }
693 }
694
695 return nil
696 }
697
698
699 type DatabaseListResult struct {
700 autorest.Response `json:"-"`
701
702 Value *[]Database `json:"value,omitempty"`
703
704 NextLink *string `json:"nextLink,omitempty"`
705 }
706
707
708 type DatabaseListResultIterator struct {
709 i int
710 page DatabaseListResultPage
711 }
712
713
714
715 func (iter *DatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) {
716 if tracing.IsEnabled() {
717 ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultIterator.NextWithContext")
718 defer func() {
719 sc := -1
720 if iter.Response().Response.Response != nil {
721 sc = iter.Response().Response.Response.StatusCode
722 }
723 tracing.EndSpan(ctx, sc, err)
724 }()
725 }
726 iter.i++
727 if iter.i < len(iter.page.Values()) {
728 return nil
729 }
730 err = iter.page.NextWithContext(ctx)
731 if err != nil {
732 iter.i--
733 return err
734 }
735 iter.i = 0
736 return nil
737 }
738
739
740
741
742 func (iter *DatabaseListResultIterator) Next() error {
743 return iter.NextWithContext(context.Background())
744 }
745
746
747 func (iter DatabaseListResultIterator) NotDone() bool {
748 return iter.page.NotDone() && iter.i < len(iter.page.Values())
749 }
750
751
752 func (iter DatabaseListResultIterator) Response() DatabaseListResult {
753 return iter.page.Response()
754 }
755
756
757
758 func (iter DatabaseListResultIterator) Value() Database {
759 if !iter.page.NotDone() {
760 return Database{}
761 }
762 return iter.page.Values()[iter.i]
763 }
764
765
766 func NewDatabaseListResultIterator(page DatabaseListResultPage) DatabaseListResultIterator {
767 return DatabaseListResultIterator{page: page}
768 }
769
770
771 func (dlr DatabaseListResult) IsEmpty() bool {
772 return dlr.Value == nil || len(*dlr.Value) == 0
773 }
774
775
776 func (dlr DatabaseListResult) hasNextLink() bool {
777 return dlr.NextLink != nil && len(*dlr.NextLink) != 0
778 }
779
780
781
782 func (dlr DatabaseListResult) databaseListResultPreparer(ctx context.Context) (*http.Request, error) {
783 if !dlr.hasNextLink() {
784 return nil, nil
785 }
786 return autorest.Prepare((&http.Request{}).WithContext(ctx),
787 autorest.AsJSON(),
788 autorest.AsGet(),
789 autorest.WithBaseURL(to.String(dlr.NextLink)))
790 }
791
792
793 type DatabaseListResultPage struct {
794 fn func(context.Context, DatabaseListResult) (DatabaseListResult, error)
795 dlr DatabaseListResult
796 }
797
798
799
800 func (page *DatabaseListResultPage) NextWithContext(ctx context.Context) (err error) {
801 if tracing.IsEnabled() {
802 ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultPage.NextWithContext")
803 defer func() {
804 sc := -1
805 if page.Response().Response.Response != nil {
806 sc = page.Response().Response.Response.StatusCode
807 }
808 tracing.EndSpan(ctx, sc, err)
809 }()
810 }
811 for {
812 next, err := page.fn(ctx, page.dlr)
813 if err != nil {
814 return err
815 }
816 page.dlr = next
817 if !next.hasNextLink() || !next.IsEmpty() {
818 break
819 }
820 }
821 return nil
822 }
823
824
825
826
827 func (page *DatabaseListResultPage) Next() error {
828 return page.NextWithContext(context.Background())
829 }
830
831
832 func (page DatabaseListResultPage) NotDone() bool {
833 return !page.dlr.IsEmpty()
834 }
835
836
837 func (page DatabaseListResultPage) Response() DatabaseListResult {
838 return page.dlr
839 }
840
841
842 func (page DatabaseListResultPage) Values() []Database {
843 if page.dlr.IsEmpty() {
844 return nil
845 }
846 return *page.dlr.Value
847 }
848
849
850 func NewDatabaseListResultPage(cur DatabaseListResult, getNextPage func(context.Context, DatabaseListResult) (DatabaseListResult, error)) DatabaseListResultPage {
851 return DatabaseListResultPage{
852 fn: getNextPage,
853 dlr: cur,
854 }
855 }
856
857
858 type DatabaseProperties struct {
859
860 Charset *string `json:"charset,omitempty"`
861
862 Collation *string `json:"collation,omitempty"`
863 }
864
865
866
867 type DatabasesCreateFuture struct {
868 azure.FutureAPI
869
870
871 Result func(DatabasesClient) (Database, error)
872 }
873
874
875 func (future *DatabasesCreateFuture) UnmarshalJSON(body []byte) error {
876 var azFuture azure.Future
877 if err := json.Unmarshal(body, &azFuture); err != nil {
878 return err
879 }
880 future.FutureAPI = &azFuture
881 future.Result = future.result
882 return nil
883 }
884
885
886 func (future *DatabasesCreateFuture) result(client DatabasesClient) (d Database, err error) {
887 var done bool
888 done, err = future.DoneWithContext(context.Background(), client)
889 if err != nil {
890 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesCreateFuture", "Result", future.Response(), "Polling failure")
891 return
892 }
893 if !done {
894 d.Response.Response = future.Response()
895 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.DatabasesCreateFuture")
896 return
897 }
898 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
899 if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent {
900 d, err = client.CreateResponder(d.Response.Response)
901 if err != nil {
902 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesCreateFuture", "Result", d.Response.Response, "Failure responding to request")
903 }
904 }
905 return
906 }
907
908
909
910 type DatabasesDeleteFuture struct {
911 azure.FutureAPI
912
913
914 Result func(DatabasesClient) (autorest.Response, error)
915 }
916
917
918 func (future *DatabasesDeleteFuture) UnmarshalJSON(body []byte) error {
919 var azFuture azure.Future
920 if err := json.Unmarshal(body, &azFuture); err != nil {
921 return err
922 }
923 future.FutureAPI = &azFuture
924 future.Result = future.result
925 return nil
926 }
927
928
929 func (future *DatabasesDeleteFuture) result(client DatabasesClient) (ar autorest.Response, err error) {
930 var done bool
931 done, err = future.DoneWithContext(context.Background(), client)
932 if err != nil {
933 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure")
934 return
935 }
936 if !done {
937 ar.Response = future.Response()
938 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.DatabasesDeleteFuture")
939 return
940 }
941 ar.Response = future.Response()
942 return
943 }
944
945
946 type DelegatedSubnetUsage struct {
947
948 SubnetName *string `json:"subnetName,omitempty"`
949
950 Usage *int64 `json:"usage,omitempty"`
951 }
952
953
954 func (dsu DelegatedSubnetUsage) MarshalJSON() ([]byte, error) {
955 objectMap := make(map[string]interface{})
956 return json.Marshal(objectMap)
957 }
958
959
960 type ErrorAdditionalInfo struct {
961
962 Type *string `json:"type,omitempty"`
963
964 Info interface{} `json:"info,omitempty"`
965 }
966
967
968 func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) {
969 objectMap := make(map[string]interface{})
970 return json.Marshal(objectMap)
971 }
972
973
974
975 type ErrorResponse struct {
976
977 Code *string `json:"code,omitempty"`
978
979 Message *string `json:"message,omitempty"`
980
981 Target *string `json:"target,omitempty"`
982
983 Details *[]ErrorResponse `json:"details,omitempty"`
984
985 AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
986 }
987
988
989 func (er ErrorResponse) MarshalJSON() ([]byte, error) {
990 objectMap := make(map[string]interface{})
991 return json.Marshal(objectMap)
992 }
993
994
995 type FirewallRule struct {
996 autorest.Response `json:"-"`
997
998 *FirewallRuleProperties `json:"properties,omitempty"`
999
1000 SystemData *SystemData `json:"systemData,omitempty"`
1001
1002 ID *string `json:"id,omitempty"`
1003
1004 Name *string `json:"name,omitempty"`
1005
1006 Type *string `json:"type,omitempty"`
1007 }
1008
1009
1010 func (fr FirewallRule) MarshalJSON() ([]byte, error) {
1011 objectMap := make(map[string]interface{})
1012 if fr.FirewallRuleProperties != nil {
1013 objectMap["properties"] = fr.FirewallRuleProperties
1014 }
1015 return json.Marshal(objectMap)
1016 }
1017
1018
1019 func (fr *FirewallRule) UnmarshalJSON(body []byte) error {
1020 var m map[string]*json.RawMessage
1021 err := json.Unmarshal(body, &m)
1022 if err != nil {
1023 return err
1024 }
1025 for k, v := range m {
1026 switch k {
1027 case "properties":
1028 if v != nil {
1029 var firewallRuleProperties FirewallRuleProperties
1030 err = json.Unmarshal(*v, &firewallRuleProperties)
1031 if err != nil {
1032 return err
1033 }
1034 fr.FirewallRuleProperties = &firewallRuleProperties
1035 }
1036 case "systemData":
1037 if v != nil {
1038 var systemData SystemData
1039 err = json.Unmarshal(*v, &systemData)
1040 if err != nil {
1041 return err
1042 }
1043 fr.SystemData = &systemData
1044 }
1045 case "id":
1046 if v != nil {
1047 var ID string
1048 err = json.Unmarshal(*v, &ID)
1049 if err != nil {
1050 return err
1051 }
1052 fr.ID = &ID
1053 }
1054 case "name":
1055 if v != nil {
1056 var name string
1057 err = json.Unmarshal(*v, &name)
1058 if err != nil {
1059 return err
1060 }
1061 fr.Name = &name
1062 }
1063 case "type":
1064 if v != nil {
1065 var typeVar string
1066 err = json.Unmarshal(*v, &typeVar)
1067 if err != nil {
1068 return err
1069 }
1070 fr.Type = &typeVar
1071 }
1072 }
1073 }
1074
1075 return nil
1076 }
1077
1078
1079 type FirewallRuleListResult struct {
1080 autorest.Response `json:"-"`
1081
1082 Value *[]FirewallRule `json:"value,omitempty"`
1083
1084 NextLink *string `json:"nextLink,omitempty"`
1085 }
1086
1087
1088 type FirewallRuleListResultIterator struct {
1089 i int
1090 page FirewallRuleListResultPage
1091 }
1092
1093
1094
1095 func (iter *FirewallRuleListResultIterator) NextWithContext(ctx context.Context) (err error) {
1096 if tracing.IsEnabled() {
1097 ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultIterator.NextWithContext")
1098 defer func() {
1099 sc := -1
1100 if iter.Response().Response.Response != nil {
1101 sc = iter.Response().Response.Response.StatusCode
1102 }
1103 tracing.EndSpan(ctx, sc, err)
1104 }()
1105 }
1106 iter.i++
1107 if iter.i < len(iter.page.Values()) {
1108 return nil
1109 }
1110 err = iter.page.NextWithContext(ctx)
1111 if err != nil {
1112 iter.i--
1113 return err
1114 }
1115 iter.i = 0
1116 return nil
1117 }
1118
1119
1120
1121
1122 func (iter *FirewallRuleListResultIterator) Next() error {
1123 return iter.NextWithContext(context.Background())
1124 }
1125
1126
1127 func (iter FirewallRuleListResultIterator) NotDone() bool {
1128 return iter.page.NotDone() && iter.i < len(iter.page.Values())
1129 }
1130
1131
1132 func (iter FirewallRuleListResultIterator) Response() FirewallRuleListResult {
1133 return iter.page.Response()
1134 }
1135
1136
1137
1138 func (iter FirewallRuleListResultIterator) Value() FirewallRule {
1139 if !iter.page.NotDone() {
1140 return FirewallRule{}
1141 }
1142 return iter.page.Values()[iter.i]
1143 }
1144
1145
1146 func NewFirewallRuleListResultIterator(page FirewallRuleListResultPage) FirewallRuleListResultIterator {
1147 return FirewallRuleListResultIterator{page: page}
1148 }
1149
1150
1151 func (frlr FirewallRuleListResult) IsEmpty() bool {
1152 return frlr.Value == nil || len(*frlr.Value) == 0
1153 }
1154
1155
1156 func (frlr FirewallRuleListResult) hasNextLink() bool {
1157 return frlr.NextLink != nil && len(*frlr.NextLink) != 0
1158 }
1159
1160
1161
1162 func (frlr FirewallRuleListResult) firewallRuleListResultPreparer(ctx context.Context) (*http.Request, error) {
1163 if !frlr.hasNextLink() {
1164 return nil, nil
1165 }
1166 return autorest.Prepare((&http.Request{}).WithContext(ctx),
1167 autorest.AsJSON(),
1168 autorest.AsGet(),
1169 autorest.WithBaseURL(to.String(frlr.NextLink)))
1170 }
1171
1172
1173 type FirewallRuleListResultPage struct {
1174 fn func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)
1175 frlr FirewallRuleListResult
1176 }
1177
1178
1179
1180 func (page *FirewallRuleListResultPage) NextWithContext(ctx context.Context) (err error) {
1181 if tracing.IsEnabled() {
1182 ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultPage.NextWithContext")
1183 defer func() {
1184 sc := -1
1185 if page.Response().Response.Response != nil {
1186 sc = page.Response().Response.Response.StatusCode
1187 }
1188 tracing.EndSpan(ctx, sc, err)
1189 }()
1190 }
1191 for {
1192 next, err := page.fn(ctx, page.frlr)
1193 if err != nil {
1194 return err
1195 }
1196 page.frlr = next
1197 if !next.hasNextLink() || !next.IsEmpty() {
1198 break
1199 }
1200 }
1201 return nil
1202 }
1203
1204
1205
1206
1207 func (page *FirewallRuleListResultPage) Next() error {
1208 return page.NextWithContext(context.Background())
1209 }
1210
1211
1212 func (page FirewallRuleListResultPage) NotDone() bool {
1213 return !page.frlr.IsEmpty()
1214 }
1215
1216
1217 func (page FirewallRuleListResultPage) Response() FirewallRuleListResult {
1218 return page.frlr
1219 }
1220
1221
1222 func (page FirewallRuleListResultPage) Values() []FirewallRule {
1223 if page.frlr.IsEmpty() {
1224 return nil
1225 }
1226 return *page.frlr.Value
1227 }
1228
1229
1230 func NewFirewallRuleListResultPage(cur FirewallRuleListResult, getNextPage func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)) FirewallRuleListResultPage {
1231 return FirewallRuleListResultPage{
1232 fn: getNextPage,
1233 frlr: cur,
1234 }
1235 }
1236
1237
1238 type FirewallRuleProperties struct {
1239
1240 StartIPAddress *string `json:"startIpAddress,omitempty"`
1241
1242 EndIPAddress *string `json:"endIpAddress,omitempty"`
1243 }
1244
1245
1246
1247 type FirewallRulesCreateOrUpdateFuture struct {
1248 azure.FutureAPI
1249
1250
1251 Result func(FirewallRulesClient) (FirewallRule, error)
1252 }
1253
1254
1255 func (future *FirewallRulesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error {
1256 var azFuture azure.Future
1257 if err := json.Unmarshal(body, &azFuture); err != nil {
1258 return err
1259 }
1260 future.FutureAPI = &azFuture
1261 future.Result = future.result
1262 return nil
1263 }
1264
1265
1266 func (future *FirewallRulesCreateOrUpdateFuture) result(client FirewallRulesClient) (fr FirewallRule, err error) {
1267 var done bool
1268 done, err = future.DoneWithContext(context.Background(), client)
1269 if err != nil {
1270 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
1271 return
1272 }
1273 if !done {
1274 fr.Response.Response = future.Response()
1275 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture")
1276 return
1277 }
1278 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1279 if fr.Response.Response, err = future.GetResult(sender); err == nil && fr.Response.Response.StatusCode != http.StatusNoContent {
1280 fr, err = client.CreateOrUpdateResponder(fr.Response.Response)
1281 if err != nil {
1282 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture", "Result", fr.Response.Response, "Failure responding to request")
1283 }
1284 }
1285 return
1286 }
1287
1288
1289
1290 type FirewallRulesDeleteFuture struct {
1291 azure.FutureAPI
1292
1293
1294 Result func(FirewallRulesClient) (autorest.Response, error)
1295 }
1296
1297
1298 func (future *FirewallRulesDeleteFuture) UnmarshalJSON(body []byte) error {
1299 var azFuture azure.Future
1300 if err := json.Unmarshal(body, &azFuture); err != nil {
1301 return err
1302 }
1303 future.FutureAPI = &azFuture
1304 future.Result = future.result
1305 return nil
1306 }
1307
1308
1309 func (future *FirewallRulesDeleteFuture) result(client FirewallRulesClient) (ar autorest.Response, err error) {
1310 var done bool
1311 done, err = future.DoneWithContext(context.Background(), client)
1312 if err != nil {
1313 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesDeleteFuture", "Result", future.Response(), "Polling failure")
1314 return
1315 }
1316 if !done {
1317 ar.Response = future.Response()
1318 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.FirewallRulesDeleteFuture")
1319 return
1320 }
1321 ar.Response = future.Response()
1322 return
1323 }
1324
1325
1326 type FlexibleServerEditionCapability struct {
1327
1328 Name *string `json:"name,omitempty"`
1329
1330 SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"`
1331
1332 SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"`
1333
1334 Status *string `json:"status,omitempty"`
1335 }
1336
1337
1338 func (fsec FlexibleServerEditionCapability) MarshalJSON() ([]byte, error) {
1339 objectMap := make(map[string]interface{})
1340 return json.Marshal(objectMap)
1341 }
1342
1343
1344 type HighAvailability struct {
1345
1346 Mode HighAvailabilityMode `json:"mode,omitempty"`
1347
1348 State ServerHAState `json:"state,omitempty"`
1349
1350 StandbyAvailabilityZone *string `json:"standbyAvailabilityZone,omitempty"`
1351 }
1352
1353
1354 func (ha HighAvailability) MarshalJSON() ([]byte, error) {
1355 objectMap := make(map[string]interface{})
1356 if ha.Mode != "" {
1357 objectMap["mode"] = ha.Mode
1358 }
1359 if ha.StandbyAvailabilityZone != nil {
1360 objectMap["standbyAvailabilityZone"] = ha.StandbyAvailabilityZone
1361 }
1362 return json.Marshal(objectMap)
1363 }
1364
1365
1366 type HyperscaleNodeEditionCapability struct {
1367
1368 Name *string `json:"name,omitempty"`
1369
1370 SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"`
1371
1372 SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"`
1373
1374 SupportedNodeTypes *[]NodeTypeCapability `json:"supportedNodeTypes,omitempty"`
1375
1376 Status *string `json:"status,omitempty"`
1377 }
1378
1379
1380 func (hnec HyperscaleNodeEditionCapability) MarshalJSON() ([]byte, error) {
1381 objectMap := make(map[string]interface{})
1382 return json.Marshal(objectMap)
1383 }
1384
1385
1386 type MaintenanceWindow struct {
1387
1388 CustomWindow *string `json:"customWindow,omitempty"`
1389
1390 StartHour *int32 `json:"startHour,omitempty"`
1391
1392 StartMinute *int32 `json:"startMinute,omitempty"`
1393
1394 DayOfWeek *int32 `json:"dayOfWeek,omitempty"`
1395 }
1396
1397
1398 type NameAvailability struct {
1399 autorest.Response `json:"-"`
1400
1401 Message *string `json:"message,omitempty"`
1402
1403 NameAvailable *bool `json:"nameAvailable,omitempty"`
1404
1405 Name *string `json:"name,omitempty"`
1406
1407 Type *string `json:"type,omitempty"`
1408 }
1409
1410
1411 type NameAvailabilityRequest struct {
1412
1413 Name *string `json:"name,omitempty"`
1414
1415 Type *string `json:"type,omitempty"`
1416 }
1417
1418
1419 type Network struct {
1420
1421 PublicNetworkAccess ServerPublicNetworkAccessState `json:"publicNetworkAccess,omitempty"`
1422
1423 DelegatedSubnetResourceID *string `json:"delegatedSubnetResourceId,omitempty"`
1424
1425 PrivateDNSZoneArmResourceID *string `json:"privateDnsZoneArmResourceId,omitempty"`
1426 }
1427
1428
1429 func (n Network) MarshalJSON() ([]byte, error) {
1430 objectMap := make(map[string]interface{})
1431 if n.DelegatedSubnetResourceID != nil {
1432 objectMap["delegatedSubnetResourceId"] = n.DelegatedSubnetResourceID
1433 }
1434 if n.PrivateDNSZoneArmResourceID != nil {
1435 objectMap["privateDnsZoneArmResourceId"] = n.PrivateDNSZoneArmResourceID
1436 }
1437 return json.Marshal(objectMap)
1438 }
1439
1440
1441 type NodeTypeCapability struct {
1442
1443 Name *string `json:"name,omitempty"`
1444
1445 NodeType *string `json:"nodeType,omitempty"`
1446
1447 Status *string `json:"status,omitempty"`
1448 }
1449
1450
1451 func (ntc NodeTypeCapability) MarshalJSON() ([]byte, error) {
1452 objectMap := make(map[string]interface{})
1453 return json.Marshal(objectMap)
1454 }
1455
1456
1457 type Operation struct {
1458
1459 Name *string `json:"name,omitempty"`
1460
1461 Display *OperationDisplay `json:"display,omitempty"`
1462
1463 IsDataAction *bool `json:"isDataAction,omitempty"`
1464
1465 Origin OperationOrigin `json:"origin,omitempty"`
1466
1467 Properties map[string]interface{} `json:"properties"`
1468 }
1469
1470
1471 func (o Operation) MarshalJSON() ([]byte, error) {
1472 objectMap := make(map[string]interface{})
1473 if o.IsDataAction != nil {
1474 objectMap["isDataAction"] = o.IsDataAction
1475 }
1476 return json.Marshal(objectMap)
1477 }
1478
1479
1480 type OperationDisplay struct {
1481
1482 Provider *string `json:"provider,omitempty"`
1483
1484 Resource *string `json:"resource,omitempty"`
1485
1486 Operation *string `json:"operation,omitempty"`
1487
1488 Description *string `json:"description,omitempty"`
1489 }
1490
1491
1492 func (od OperationDisplay) MarshalJSON() ([]byte, error) {
1493 objectMap := make(map[string]interface{})
1494 return json.Marshal(objectMap)
1495 }
1496
1497
1498 type OperationListResult struct {
1499 autorest.Response `json:"-"`
1500
1501 Value *[]Operation `json:"value,omitempty"`
1502
1503
1504 NextLink *string `json:"nextLink,omitempty"`
1505 }
1506
1507
1508
1509 type ProxyResource struct {
1510
1511 ID *string `json:"id,omitempty"`
1512
1513 Name *string `json:"name,omitempty"`
1514
1515 Type *string `json:"type,omitempty"`
1516 }
1517
1518
1519 func (pr ProxyResource) MarshalJSON() ([]byte, error) {
1520 objectMap := make(map[string]interface{})
1521 return json.Marshal(objectMap)
1522 }
1523
1524
1525 type Resource struct {
1526
1527 ID *string `json:"id,omitempty"`
1528
1529 Name *string `json:"name,omitempty"`
1530
1531 Type *string `json:"type,omitempty"`
1532 }
1533
1534
1535 func (r Resource) MarshalJSON() ([]byte, error) {
1536 objectMap := make(map[string]interface{})
1537 return json.Marshal(objectMap)
1538 }
1539
1540
1541 type RestartParameter struct {
1542
1543 RestartWithFailover *bool `json:"restartWithFailover,omitempty"`
1544
1545 FailoverMode FailoverMode `json:"failoverMode,omitempty"`
1546 }
1547
1548
1549 type Server struct {
1550 autorest.Response `json:"-"`
1551
1552 Sku *Sku `json:"sku,omitempty"`
1553
1554 *ServerProperties `json:"properties,omitempty"`
1555
1556 SystemData *SystemData `json:"systemData,omitempty"`
1557
1558 Tags map[string]*string `json:"tags"`
1559
1560 Location *string `json:"location,omitempty"`
1561
1562 ID *string `json:"id,omitempty"`
1563
1564 Name *string `json:"name,omitempty"`
1565
1566 Type *string `json:"type,omitempty"`
1567 }
1568
1569
1570 func (s Server) MarshalJSON() ([]byte, error) {
1571 objectMap := make(map[string]interface{})
1572 if s.Sku != nil {
1573 objectMap["sku"] = s.Sku
1574 }
1575 if s.ServerProperties != nil {
1576 objectMap["properties"] = s.ServerProperties
1577 }
1578 if s.Tags != nil {
1579 objectMap["tags"] = s.Tags
1580 }
1581 if s.Location != nil {
1582 objectMap["location"] = s.Location
1583 }
1584 return json.Marshal(objectMap)
1585 }
1586
1587
1588 func (s *Server) UnmarshalJSON(body []byte) error {
1589 var m map[string]*json.RawMessage
1590 err := json.Unmarshal(body, &m)
1591 if err != nil {
1592 return err
1593 }
1594 for k, v := range m {
1595 switch k {
1596 case "sku":
1597 if v != nil {
1598 var sku Sku
1599 err = json.Unmarshal(*v, &sku)
1600 if err != nil {
1601 return err
1602 }
1603 s.Sku = &sku
1604 }
1605 case "properties":
1606 if v != nil {
1607 var serverProperties ServerProperties
1608 err = json.Unmarshal(*v, &serverProperties)
1609 if err != nil {
1610 return err
1611 }
1612 s.ServerProperties = &serverProperties
1613 }
1614 case "systemData":
1615 if v != nil {
1616 var systemData SystemData
1617 err = json.Unmarshal(*v, &systemData)
1618 if err != nil {
1619 return err
1620 }
1621 s.SystemData = &systemData
1622 }
1623 case "tags":
1624 if v != nil {
1625 var tags map[string]*string
1626 err = json.Unmarshal(*v, &tags)
1627 if err != nil {
1628 return err
1629 }
1630 s.Tags = tags
1631 }
1632 case "location":
1633 if v != nil {
1634 var location string
1635 err = json.Unmarshal(*v, &location)
1636 if err != nil {
1637 return err
1638 }
1639 s.Location = &location
1640 }
1641 case "id":
1642 if v != nil {
1643 var ID string
1644 err = json.Unmarshal(*v, &ID)
1645 if err != nil {
1646 return err
1647 }
1648 s.ID = &ID
1649 }
1650 case "name":
1651 if v != nil {
1652 var name string
1653 err = json.Unmarshal(*v, &name)
1654 if err != nil {
1655 return err
1656 }
1657 s.Name = &name
1658 }
1659 case "type":
1660 if v != nil {
1661 var typeVar string
1662 err = json.Unmarshal(*v, &typeVar)
1663 if err != nil {
1664 return err
1665 }
1666 s.Type = &typeVar
1667 }
1668 }
1669 }
1670
1671 return nil
1672 }
1673
1674
1675 type ServerForUpdate struct {
1676
1677 Location *string `json:"location,omitempty"`
1678
1679 Sku *Sku `json:"sku,omitempty"`
1680
1681 *ServerPropertiesForUpdate `json:"properties,omitempty"`
1682
1683 Tags map[string]*string `json:"tags"`
1684 }
1685
1686
1687 func (sfu ServerForUpdate) MarshalJSON() ([]byte, error) {
1688 objectMap := make(map[string]interface{})
1689 if sfu.Location != nil {
1690 objectMap["location"] = sfu.Location
1691 }
1692 if sfu.Sku != nil {
1693 objectMap["sku"] = sfu.Sku
1694 }
1695 if sfu.ServerPropertiesForUpdate != nil {
1696 objectMap["properties"] = sfu.ServerPropertiesForUpdate
1697 }
1698 if sfu.Tags != nil {
1699 objectMap["tags"] = sfu.Tags
1700 }
1701 return json.Marshal(objectMap)
1702 }
1703
1704
1705 func (sfu *ServerForUpdate) UnmarshalJSON(body []byte) error {
1706 var m map[string]*json.RawMessage
1707 err := json.Unmarshal(body, &m)
1708 if err != nil {
1709 return err
1710 }
1711 for k, v := range m {
1712 switch k {
1713 case "location":
1714 if v != nil {
1715 var location string
1716 err = json.Unmarshal(*v, &location)
1717 if err != nil {
1718 return err
1719 }
1720 sfu.Location = &location
1721 }
1722 case "sku":
1723 if v != nil {
1724 var sku Sku
1725 err = json.Unmarshal(*v, &sku)
1726 if err != nil {
1727 return err
1728 }
1729 sfu.Sku = &sku
1730 }
1731 case "properties":
1732 if v != nil {
1733 var serverPropertiesForUpdate ServerPropertiesForUpdate
1734 err = json.Unmarshal(*v, &serverPropertiesForUpdate)
1735 if err != nil {
1736 return err
1737 }
1738 sfu.ServerPropertiesForUpdate = &serverPropertiesForUpdate
1739 }
1740 case "tags":
1741 if v != nil {
1742 var tags map[string]*string
1743 err = json.Unmarshal(*v, &tags)
1744 if err != nil {
1745 return err
1746 }
1747 sfu.Tags = tags
1748 }
1749 }
1750 }
1751
1752 return nil
1753 }
1754
1755
1756 type ServerListResult struct {
1757 autorest.Response `json:"-"`
1758
1759 Value *[]Server `json:"value,omitempty"`
1760
1761 NextLink *string `json:"nextLink,omitempty"`
1762 }
1763
1764
1765 type ServerListResultIterator struct {
1766 i int
1767 page ServerListResultPage
1768 }
1769
1770
1771
1772 func (iter *ServerListResultIterator) NextWithContext(ctx context.Context) (err error) {
1773 if tracing.IsEnabled() {
1774 ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultIterator.NextWithContext")
1775 defer func() {
1776 sc := -1
1777 if iter.Response().Response.Response != nil {
1778 sc = iter.Response().Response.Response.StatusCode
1779 }
1780 tracing.EndSpan(ctx, sc, err)
1781 }()
1782 }
1783 iter.i++
1784 if iter.i < len(iter.page.Values()) {
1785 return nil
1786 }
1787 err = iter.page.NextWithContext(ctx)
1788 if err != nil {
1789 iter.i--
1790 return err
1791 }
1792 iter.i = 0
1793 return nil
1794 }
1795
1796
1797
1798
1799 func (iter *ServerListResultIterator) Next() error {
1800 return iter.NextWithContext(context.Background())
1801 }
1802
1803
1804 func (iter ServerListResultIterator) NotDone() bool {
1805 return iter.page.NotDone() && iter.i < len(iter.page.Values())
1806 }
1807
1808
1809 func (iter ServerListResultIterator) Response() ServerListResult {
1810 return iter.page.Response()
1811 }
1812
1813
1814
1815 func (iter ServerListResultIterator) Value() Server {
1816 if !iter.page.NotDone() {
1817 return Server{}
1818 }
1819 return iter.page.Values()[iter.i]
1820 }
1821
1822
1823 func NewServerListResultIterator(page ServerListResultPage) ServerListResultIterator {
1824 return ServerListResultIterator{page: page}
1825 }
1826
1827
1828 func (slr ServerListResult) IsEmpty() bool {
1829 return slr.Value == nil || len(*slr.Value) == 0
1830 }
1831
1832
1833 func (slr ServerListResult) hasNextLink() bool {
1834 return slr.NextLink != nil && len(*slr.NextLink) != 0
1835 }
1836
1837
1838
1839 func (slr ServerListResult) serverListResultPreparer(ctx context.Context) (*http.Request, error) {
1840 if !slr.hasNextLink() {
1841 return nil, nil
1842 }
1843 return autorest.Prepare((&http.Request{}).WithContext(ctx),
1844 autorest.AsJSON(),
1845 autorest.AsGet(),
1846 autorest.WithBaseURL(to.String(slr.NextLink)))
1847 }
1848
1849
1850 type ServerListResultPage struct {
1851 fn func(context.Context, ServerListResult) (ServerListResult, error)
1852 slr ServerListResult
1853 }
1854
1855
1856
1857 func (page *ServerListResultPage) NextWithContext(ctx context.Context) (err error) {
1858 if tracing.IsEnabled() {
1859 ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultPage.NextWithContext")
1860 defer func() {
1861 sc := -1
1862 if page.Response().Response.Response != nil {
1863 sc = page.Response().Response.Response.StatusCode
1864 }
1865 tracing.EndSpan(ctx, sc, err)
1866 }()
1867 }
1868 for {
1869 next, err := page.fn(ctx, page.slr)
1870 if err != nil {
1871 return err
1872 }
1873 page.slr = next
1874 if !next.hasNextLink() || !next.IsEmpty() {
1875 break
1876 }
1877 }
1878 return nil
1879 }
1880
1881
1882
1883
1884 func (page *ServerListResultPage) Next() error {
1885 return page.NextWithContext(context.Background())
1886 }
1887
1888
1889 func (page ServerListResultPage) NotDone() bool {
1890 return !page.slr.IsEmpty()
1891 }
1892
1893
1894 func (page ServerListResultPage) Response() ServerListResult {
1895 return page.slr
1896 }
1897
1898
1899 func (page ServerListResultPage) Values() []Server {
1900 if page.slr.IsEmpty() {
1901 return nil
1902 }
1903 return *page.slr.Value
1904 }
1905
1906
1907 func NewServerListResultPage(cur ServerListResult, getNextPage func(context.Context, ServerListResult) (ServerListResult, error)) ServerListResultPage {
1908 return ServerListResultPage{
1909 fn: getNextPage,
1910 slr: cur,
1911 }
1912 }
1913
1914
1915 type ServerProperties struct {
1916
1917 AdministratorLogin *string `json:"administratorLogin,omitempty"`
1918
1919 AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"`
1920
1921 Version ServerVersion `json:"version,omitempty"`
1922
1923 MinorVersion *string `json:"minorVersion,omitempty"`
1924
1925 State ServerState `json:"state,omitempty"`
1926
1927 FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"`
1928
1929 Storage *Storage `json:"storage,omitempty"`
1930
1931 Backup *Backup `json:"backup,omitempty"`
1932
1933 Network *Network `json:"network,omitempty"`
1934
1935 HighAvailability *HighAvailability `json:"highAvailability,omitempty"`
1936
1937 MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"`
1938
1939 SourceServerResourceID *string `json:"sourceServerResourceId,omitempty"`
1940
1941 PointInTimeUTC *date.Time `json:"pointInTimeUTC,omitempty"`
1942
1943 AvailabilityZone *string `json:"availabilityZone,omitempty"`
1944
1945 CreateMode CreateMode `json:"createMode,omitempty"`
1946
1947 Tags map[string]*string `json:"tags"`
1948 }
1949
1950
1951 func (sp ServerProperties) MarshalJSON() ([]byte, error) {
1952 objectMap := make(map[string]interface{})
1953 if sp.AdministratorLogin != nil {
1954 objectMap["administratorLogin"] = sp.AdministratorLogin
1955 }
1956 if sp.AdministratorLoginPassword != nil {
1957 objectMap["administratorLoginPassword"] = sp.AdministratorLoginPassword
1958 }
1959 if sp.Version != "" {
1960 objectMap["version"] = sp.Version
1961 }
1962 if sp.Storage != nil {
1963 objectMap["storage"] = sp.Storage
1964 }
1965 if sp.Backup != nil {
1966 objectMap["backup"] = sp.Backup
1967 }
1968 if sp.Network != nil {
1969 objectMap["network"] = sp.Network
1970 }
1971 if sp.HighAvailability != nil {
1972 objectMap["highAvailability"] = sp.HighAvailability
1973 }
1974 if sp.MaintenanceWindow != nil {
1975 objectMap["maintenanceWindow"] = sp.MaintenanceWindow
1976 }
1977 if sp.SourceServerResourceID != nil {
1978 objectMap["sourceServerResourceId"] = sp.SourceServerResourceID
1979 }
1980 if sp.PointInTimeUTC != nil {
1981 objectMap["pointInTimeUTC"] = sp.PointInTimeUTC
1982 }
1983 if sp.AvailabilityZone != nil {
1984 objectMap["availabilityZone"] = sp.AvailabilityZone
1985 }
1986 if sp.CreateMode != "" {
1987 objectMap["createMode"] = sp.CreateMode
1988 }
1989 if sp.Tags != nil {
1990 objectMap["tags"] = sp.Tags
1991 }
1992 return json.Marshal(objectMap)
1993 }
1994
1995
1996 type ServerPropertiesForUpdate struct {
1997
1998 AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"`
1999
2000 Storage *Storage `json:"storage,omitempty"`
2001
2002 Backup *Backup `json:"backup,omitempty"`
2003
2004 HighAvailability *HighAvailability `json:"highAvailability,omitempty"`
2005
2006 MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"`
2007
2008 CreateMode CreateModeForUpdate `json:"createMode,omitempty"`
2009 }
2010
2011
2012
2013 type ServersCreateFuture struct {
2014 azure.FutureAPI
2015
2016
2017 Result func(ServersClient) (Server, error)
2018 }
2019
2020
2021 func (future *ServersCreateFuture) UnmarshalJSON(body []byte) error {
2022 var azFuture azure.Future
2023 if err := json.Unmarshal(body, &azFuture); err != nil {
2024 return err
2025 }
2026 future.FutureAPI = &azFuture
2027 future.Result = future.result
2028 return nil
2029 }
2030
2031
2032 func (future *ServersCreateFuture) result(client ServersClient) (s Server, err error) {
2033 var done bool
2034 done, err = future.DoneWithContext(context.Background(), client)
2035 if err != nil {
2036 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersCreateFuture", "Result", future.Response(), "Polling failure")
2037 return
2038 }
2039 if !done {
2040 s.Response.Response = future.Response()
2041 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersCreateFuture")
2042 return
2043 }
2044 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
2045 if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent {
2046 s, err = client.CreateResponder(s.Response.Response)
2047 if err != nil {
2048 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersCreateFuture", "Result", s.Response.Response, "Failure responding to request")
2049 }
2050 }
2051 return
2052 }
2053
2054
2055
2056 type ServersDeleteFuture struct {
2057 azure.FutureAPI
2058
2059
2060 Result func(ServersClient) (autorest.Response, error)
2061 }
2062
2063
2064 func (future *ServersDeleteFuture) UnmarshalJSON(body []byte) error {
2065 var azFuture azure.Future
2066 if err := json.Unmarshal(body, &azFuture); err != nil {
2067 return err
2068 }
2069 future.FutureAPI = &azFuture
2070 future.Result = future.result
2071 return nil
2072 }
2073
2074
2075 func (future *ServersDeleteFuture) result(client ServersClient) (ar autorest.Response, err error) {
2076 var done bool
2077 done, err = future.DoneWithContext(context.Background(), client)
2078 if err != nil {
2079 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersDeleteFuture", "Result", future.Response(), "Polling failure")
2080 return
2081 }
2082 if !done {
2083 ar.Response = future.Response()
2084 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersDeleteFuture")
2085 return
2086 }
2087 ar.Response = future.Response()
2088 return
2089 }
2090
2091
2092
2093 type ServersRestartFuture struct {
2094 azure.FutureAPI
2095
2096
2097 Result func(ServersClient) (autorest.Response, error)
2098 }
2099
2100
2101 func (future *ServersRestartFuture) UnmarshalJSON(body []byte) error {
2102 var azFuture azure.Future
2103 if err := json.Unmarshal(body, &azFuture); err != nil {
2104 return err
2105 }
2106 future.FutureAPI = &azFuture
2107 future.Result = future.result
2108 return nil
2109 }
2110
2111
2112 func (future *ServersRestartFuture) result(client ServersClient) (ar autorest.Response, err error) {
2113 var done bool
2114 done, err = future.DoneWithContext(context.Background(), client)
2115 if err != nil {
2116 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersRestartFuture", "Result", future.Response(), "Polling failure")
2117 return
2118 }
2119 if !done {
2120 ar.Response = future.Response()
2121 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersRestartFuture")
2122 return
2123 }
2124 ar.Response = future.Response()
2125 return
2126 }
2127
2128
2129 type ServersStartFuture struct {
2130 azure.FutureAPI
2131
2132
2133 Result func(ServersClient) (autorest.Response, error)
2134 }
2135
2136
2137 func (future *ServersStartFuture) UnmarshalJSON(body []byte) error {
2138 var azFuture azure.Future
2139 if err := json.Unmarshal(body, &azFuture); err != nil {
2140 return err
2141 }
2142 future.FutureAPI = &azFuture
2143 future.Result = future.result
2144 return nil
2145 }
2146
2147
2148 func (future *ServersStartFuture) result(client ServersClient) (ar autorest.Response, err error) {
2149 var done bool
2150 done, err = future.DoneWithContext(context.Background(), client)
2151 if err != nil {
2152 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersStartFuture", "Result", future.Response(), "Polling failure")
2153 return
2154 }
2155 if !done {
2156 ar.Response = future.Response()
2157 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersStartFuture")
2158 return
2159 }
2160 ar.Response = future.Response()
2161 return
2162 }
2163
2164
2165 type ServersStopFuture struct {
2166 azure.FutureAPI
2167
2168
2169 Result func(ServersClient) (autorest.Response, error)
2170 }
2171
2172
2173 func (future *ServersStopFuture) UnmarshalJSON(body []byte) error {
2174 var azFuture azure.Future
2175 if err := json.Unmarshal(body, &azFuture); err != nil {
2176 return err
2177 }
2178 future.FutureAPI = &azFuture
2179 future.Result = future.result
2180 return nil
2181 }
2182
2183
2184 func (future *ServersStopFuture) result(client ServersClient) (ar autorest.Response, err error) {
2185 var done bool
2186 done, err = future.DoneWithContext(context.Background(), client)
2187 if err != nil {
2188 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersStopFuture", "Result", future.Response(), "Polling failure")
2189 return
2190 }
2191 if !done {
2192 ar.Response = future.Response()
2193 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersStopFuture")
2194 return
2195 }
2196 ar.Response = future.Response()
2197 return
2198 }
2199
2200
2201
2202 type ServersUpdateFuture struct {
2203 azure.FutureAPI
2204
2205
2206 Result func(ServersClient) (Server, error)
2207 }
2208
2209
2210 func (future *ServersUpdateFuture) UnmarshalJSON(body []byte) error {
2211 var azFuture azure.Future
2212 if err := json.Unmarshal(body, &azFuture); err != nil {
2213 return err
2214 }
2215 future.FutureAPI = &azFuture
2216 future.Result = future.result
2217 return nil
2218 }
2219
2220
2221 func (future *ServersUpdateFuture) result(client ServersClient) (s Server, err error) {
2222 var done bool
2223 done, err = future.DoneWithContext(context.Background(), client)
2224 if err != nil {
2225 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersUpdateFuture", "Result", future.Response(), "Polling failure")
2226 return
2227 }
2228 if !done {
2229 s.Response.Response = future.Response()
2230 err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersUpdateFuture")
2231 return
2232 }
2233 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
2234 if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent {
2235 s, err = client.UpdateResponder(s.Response.Response)
2236 if err != nil {
2237 err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request")
2238 }
2239 }
2240 return
2241 }
2242
2243
2244 type ServerVersionCapability struct {
2245
2246 Name *string `json:"name,omitempty"`
2247
2248 SupportedVcores *[]VcoreCapability `json:"supportedVcores,omitempty"`
2249
2250 Status *string `json:"status,omitempty"`
2251 }
2252
2253
2254 func (svc ServerVersionCapability) MarshalJSON() ([]byte, error) {
2255 objectMap := make(map[string]interface{})
2256 return json.Marshal(objectMap)
2257 }
2258
2259
2260 type Sku struct {
2261
2262 Name *string `json:"name,omitempty"`
2263
2264 Tier SkuTier `json:"tier,omitempty"`
2265 }
2266
2267
2268 type Storage struct {
2269
2270 StorageSizeGB *int32 `json:"storageSizeGB,omitempty"`
2271 }
2272
2273
2274 type StorageEditionCapability struct {
2275
2276 Name *string `json:"name,omitempty"`
2277
2278 SupportedStorageMB *[]StorageMBCapability `json:"supportedStorageMB,omitempty"`
2279
2280 Status *string `json:"status,omitempty"`
2281 }
2282
2283
2284 func (sec StorageEditionCapability) MarshalJSON() ([]byte, error) {
2285 objectMap := make(map[string]interface{})
2286 return json.Marshal(objectMap)
2287 }
2288
2289
2290 type StorageMBCapability struct {
2291
2292 Name *string `json:"name,omitempty"`
2293
2294 SupportedIops *int64 `json:"supportedIops,omitempty"`
2295
2296 StorageSizeMB *int64 `json:"storageSizeMB,omitempty"`
2297
2298 Status *string `json:"status,omitempty"`
2299 }
2300
2301
2302 func (smc StorageMBCapability) MarshalJSON() ([]byte, error) {
2303 objectMap := make(map[string]interface{})
2304 return json.Marshal(objectMap)
2305 }
2306
2307
2308 type String struct {
2309 autorest.Response `json:"-"`
2310 Value *string `json:"value,omitempty"`
2311 }
2312
2313
2314 type SystemData struct {
2315
2316 CreatedBy *string `json:"createdBy,omitempty"`
2317
2318 CreatedByType CreatedByType `json:"createdByType,omitempty"`
2319
2320 CreatedAt *date.Time `json:"createdAt,omitempty"`
2321
2322 LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
2323
2324 LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"`
2325
2326 LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
2327 }
2328
2329
2330
2331 type TrackedResource struct {
2332
2333 Tags map[string]*string `json:"tags"`
2334
2335 Location *string `json:"location,omitempty"`
2336
2337 ID *string `json:"id,omitempty"`
2338
2339 Name *string `json:"name,omitempty"`
2340
2341 Type *string `json:"type,omitempty"`
2342 }
2343
2344
2345 func (tr TrackedResource) MarshalJSON() ([]byte, error) {
2346 objectMap := make(map[string]interface{})
2347 if tr.Tags != nil {
2348 objectMap["tags"] = tr.Tags
2349 }
2350 if tr.Location != nil {
2351 objectMap["location"] = tr.Location
2352 }
2353 return json.Marshal(objectMap)
2354 }
2355
2356
2357 type VcoreCapability struct {
2358
2359 Name *string `json:"name,omitempty"`
2360
2361 VCores *int64 `json:"vCores,omitempty"`
2362
2363 SupportedIops *int64 `json:"supportedIops,omitempty"`
2364
2365 SupportedMemoryPerVcoreMB *int64 `json:"supportedMemoryPerVcoreMB,omitempty"`
2366
2367 Status *string `json:"status,omitempty"`
2368 }
2369
2370
2371 func (vc VcoreCapability) MarshalJSON() ([]byte, error) {
2372 objectMap := make(map[string]interface{})
2373 return json.Marshal(objectMap)
2374 }
2375
2376
2377 type VirtualNetworkSubnetUsageParameter struct {
2378
2379 VirtualNetworkArmResourceID *string `json:"virtualNetworkArmResourceId,omitempty"`
2380 }
2381
2382
2383 type VirtualNetworkSubnetUsageResult struct {
2384 autorest.Response `json:"-"`
2385
2386 DelegatedSubnetsUsage *[]DelegatedSubnetUsage `json:"delegatedSubnetsUsage,omitempty"`
2387 }
2388
2389
2390 func (vnsur VirtualNetworkSubnetUsageResult) MarshalJSON() ([]byte, error) {
2391 objectMap := make(map[string]interface{})
2392 return json.Marshal(objectMap)
2393 }
2394
View as plain text