1 package experimentation
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/date"
14 "github.com/Azure/go-autorest/autorest/to"
15 "github.com/Azure/go-autorest/tracing"
16 "net/http"
17 )
18
19
20 const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/machinelearning/mgmt/2017-05-01-preview/experimentation"
21
22
23 type Account struct {
24 autorest.Response `json:"-"`
25
26 *AccountProperties `json:"properties,omitempty"`
27
28 ID *string `json:"id,omitempty"`
29
30 Name *string `json:"name,omitempty"`
31
32 Type *string `json:"type,omitempty"`
33
34 Location *string `json:"location,omitempty"`
35
36 Tags map[string]*string `json:"tags"`
37 }
38
39
40 func (a Account) MarshalJSON() ([]byte, error) {
41 objectMap := make(map[string]interface{})
42 if a.AccountProperties != nil {
43 objectMap["properties"] = a.AccountProperties
44 }
45 if a.Location != nil {
46 objectMap["location"] = a.Location
47 }
48 if a.Tags != nil {
49 objectMap["tags"] = a.Tags
50 }
51 return json.Marshal(objectMap)
52 }
53
54
55 func (a *Account) UnmarshalJSON(body []byte) error {
56 var m map[string]*json.RawMessage
57 err := json.Unmarshal(body, &m)
58 if err != nil {
59 return err
60 }
61 for k, v := range m {
62 switch k {
63 case "properties":
64 if v != nil {
65 var accountProperties AccountProperties
66 err = json.Unmarshal(*v, &accountProperties)
67 if err != nil {
68 return err
69 }
70 a.AccountProperties = &accountProperties
71 }
72 case "id":
73 if v != nil {
74 var ID string
75 err = json.Unmarshal(*v, &ID)
76 if err != nil {
77 return err
78 }
79 a.ID = &ID
80 }
81 case "name":
82 if v != nil {
83 var name string
84 err = json.Unmarshal(*v, &name)
85 if err != nil {
86 return err
87 }
88 a.Name = &name
89 }
90 case "type":
91 if v != nil {
92 var typeVar string
93 err = json.Unmarshal(*v, &typeVar)
94 if err != nil {
95 return err
96 }
97 a.Type = &typeVar
98 }
99 case "location":
100 if v != nil {
101 var location string
102 err = json.Unmarshal(*v, &location)
103 if err != nil {
104 return err
105 }
106 a.Location = &location
107 }
108 case "tags":
109 if v != nil {
110 var tags map[string]*string
111 err = json.Unmarshal(*v, &tags)
112 if err != nil {
113 return err
114 }
115 a.Tags = tags
116 }
117 }
118 }
119
120 return nil
121 }
122
123
124 type AccountListResult struct {
125 autorest.Response `json:"-"`
126
127 Value *[]Account `json:"value,omitempty"`
128
129 NextLink *string `json:"nextLink,omitempty"`
130 }
131
132
133 type AccountListResultIterator struct {
134 i int
135 page AccountListResultPage
136 }
137
138
139
140 func (iter *AccountListResultIterator) NextWithContext(ctx context.Context) (err error) {
141 if tracing.IsEnabled() {
142 ctx = tracing.StartSpan(ctx, fqdn+"/AccountListResultIterator.NextWithContext")
143 defer func() {
144 sc := -1
145 if iter.Response().Response.Response != nil {
146 sc = iter.Response().Response.Response.StatusCode
147 }
148 tracing.EndSpan(ctx, sc, err)
149 }()
150 }
151 iter.i++
152 if iter.i < len(iter.page.Values()) {
153 return nil
154 }
155 err = iter.page.NextWithContext(ctx)
156 if err != nil {
157 iter.i--
158 return err
159 }
160 iter.i = 0
161 return nil
162 }
163
164
165
166
167 func (iter *AccountListResultIterator) Next() error {
168 return iter.NextWithContext(context.Background())
169 }
170
171
172 func (iter AccountListResultIterator) NotDone() bool {
173 return iter.page.NotDone() && iter.i < len(iter.page.Values())
174 }
175
176
177 func (iter AccountListResultIterator) Response() AccountListResult {
178 return iter.page.Response()
179 }
180
181
182
183 func (iter AccountListResultIterator) Value() Account {
184 if !iter.page.NotDone() {
185 return Account{}
186 }
187 return iter.page.Values()[iter.i]
188 }
189
190
191 func NewAccountListResultIterator(page AccountListResultPage) AccountListResultIterator {
192 return AccountListResultIterator{page: page}
193 }
194
195
196 func (alr AccountListResult) IsEmpty() bool {
197 return alr.Value == nil || len(*alr.Value) == 0
198 }
199
200
201 func (alr AccountListResult) hasNextLink() bool {
202 return alr.NextLink != nil && len(*alr.NextLink) != 0
203 }
204
205
206
207 func (alr AccountListResult) accountListResultPreparer(ctx context.Context) (*http.Request, error) {
208 if !alr.hasNextLink() {
209 return nil, nil
210 }
211 return autorest.Prepare((&http.Request{}).WithContext(ctx),
212 autorest.AsJSON(),
213 autorest.AsGet(),
214 autorest.WithBaseURL(to.String(alr.NextLink)))
215 }
216
217
218 type AccountListResultPage struct {
219 fn func(context.Context, AccountListResult) (AccountListResult, error)
220 alr AccountListResult
221 }
222
223
224
225 func (page *AccountListResultPage) NextWithContext(ctx context.Context) (err error) {
226 if tracing.IsEnabled() {
227 ctx = tracing.StartSpan(ctx, fqdn+"/AccountListResultPage.NextWithContext")
228 defer func() {
229 sc := -1
230 if page.Response().Response.Response != nil {
231 sc = page.Response().Response.Response.StatusCode
232 }
233 tracing.EndSpan(ctx, sc, err)
234 }()
235 }
236 for {
237 next, err := page.fn(ctx, page.alr)
238 if err != nil {
239 return err
240 }
241 page.alr = next
242 if !next.hasNextLink() || !next.IsEmpty() {
243 break
244 }
245 }
246 return nil
247 }
248
249
250
251
252 func (page *AccountListResultPage) Next() error {
253 return page.NextWithContext(context.Background())
254 }
255
256
257 func (page AccountListResultPage) NotDone() bool {
258 return !page.alr.IsEmpty()
259 }
260
261
262 func (page AccountListResultPage) Response() AccountListResult {
263 return page.alr
264 }
265
266
267 func (page AccountListResultPage) Values() []Account {
268 if page.alr.IsEmpty() {
269 return nil
270 }
271 return *page.alr.Value
272 }
273
274
275 func NewAccountListResultPage(cur AccountListResult, getNextPage func(context.Context, AccountListResult) (AccountListResult, error)) AccountListResultPage {
276 return AccountListResultPage{
277 fn: getNextPage,
278 alr: cur,
279 }
280 }
281
282
283 type AccountProperties struct {
284
285 VsoAccountID *string `json:"vsoAccountId,omitempty"`
286
287 AccountID *string `json:"accountId,omitempty"`
288
289 Description *string `json:"description,omitempty"`
290
291 FriendlyName *string `json:"friendlyName,omitempty"`
292
293 KeyVaultID *string `json:"keyVaultId,omitempty"`
294
295 Seats *string `json:"seats,omitempty"`
296
297 DiscoveryURI *string `json:"discoveryUri,omitempty"`
298
299 CreationDate *date.Time `json:"creationDate,omitempty"`
300
301 StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"`
302
303 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
304 }
305
306
307 func (ap AccountProperties) MarshalJSON() ([]byte, error) {
308 objectMap := make(map[string]interface{})
309 if ap.VsoAccountID != nil {
310 objectMap["vsoAccountId"] = ap.VsoAccountID
311 }
312 if ap.Description != nil {
313 objectMap["description"] = ap.Description
314 }
315 if ap.FriendlyName != nil {
316 objectMap["friendlyName"] = ap.FriendlyName
317 }
318 if ap.KeyVaultID != nil {
319 objectMap["keyVaultId"] = ap.KeyVaultID
320 }
321 if ap.Seats != nil {
322 objectMap["seats"] = ap.Seats
323 }
324 if ap.StorageAccount != nil {
325 objectMap["storageAccount"] = ap.StorageAccount
326 }
327 return json.Marshal(objectMap)
328 }
329
330
331
332 type AccountPropertiesUpdateParameters struct {
333
334 Description *string `json:"description,omitempty"`
335
336 FriendlyName *string `json:"friendlyName,omitempty"`
337
338 Seats *string `json:"seats,omitempty"`
339
340 StorageAccountKey *string `json:"storageAccountKey,omitempty"`
341 }
342
343
344 type AccountUpdateParameters struct {
345
346 Tags map[string]*string `json:"tags"`
347
348 *AccountPropertiesUpdateParameters `json:"properties,omitempty"`
349 }
350
351
352 func (aup AccountUpdateParameters) MarshalJSON() ([]byte, error) {
353 objectMap := make(map[string]interface{})
354 if aup.Tags != nil {
355 objectMap["tags"] = aup.Tags
356 }
357 if aup.AccountPropertiesUpdateParameters != nil {
358 objectMap["properties"] = aup.AccountPropertiesUpdateParameters
359 }
360 return json.Marshal(objectMap)
361 }
362
363
364 func (aup *AccountUpdateParameters) UnmarshalJSON(body []byte) error {
365 var m map[string]*json.RawMessage
366 err := json.Unmarshal(body, &m)
367 if err != nil {
368 return err
369 }
370 for k, v := range m {
371 switch k {
372 case "tags":
373 if v != nil {
374 var tags map[string]*string
375 err = json.Unmarshal(*v, &tags)
376 if err != nil {
377 return err
378 }
379 aup.Tags = tags
380 }
381 case "properties":
382 if v != nil {
383 var accountPropertiesUpdateParameters AccountPropertiesUpdateParameters
384 err = json.Unmarshal(*v, &accountPropertiesUpdateParameters)
385 if err != nil {
386 return err
387 }
388 aup.AccountPropertiesUpdateParameters = &accountPropertiesUpdateParameters
389 }
390 }
391 }
392
393 return nil
394 }
395
396
397 type ErrorResponse struct {
398
399 Code *string `json:"code,omitempty"`
400
401 Message *string `json:"message,omitempty"`
402 }
403
404
405 type Operation struct {
406
407 Name *string `json:"name,omitempty"`
408
409 Display *OperationDisplay `json:"display,omitempty"`
410 }
411
412
413 type OperationDisplay struct {
414
415 Provider *string `json:"provider,omitempty"`
416
417 Resource *string `json:"resource,omitempty"`
418
419 Operation *string `json:"operation,omitempty"`
420
421 Description *string `json:"description,omitempty"`
422 }
423
424
425 type OperationListResult struct {
426 autorest.Response `json:"-"`
427
428 Value *[]Operation `json:"value,omitempty"`
429 }
430
431
432 type Project struct {
433 autorest.Response `json:"-"`
434
435 *ProjectProperties `json:"properties,omitempty"`
436
437 ID *string `json:"id,omitempty"`
438
439 Name *string `json:"name,omitempty"`
440
441 Type *string `json:"type,omitempty"`
442
443 Location *string `json:"location,omitempty"`
444
445 Tags map[string]*string `json:"tags"`
446 }
447
448
449 func (p Project) MarshalJSON() ([]byte, error) {
450 objectMap := make(map[string]interface{})
451 if p.ProjectProperties != nil {
452 objectMap["properties"] = p.ProjectProperties
453 }
454 if p.Location != nil {
455 objectMap["location"] = p.Location
456 }
457 if p.Tags != nil {
458 objectMap["tags"] = p.Tags
459 }
460 return json.Marshal(objectMap)
461 }
462
463
464 func (p *Project) UnmarshalJSON(body []byte) error {
465 var m map[string]*json.RawMessage
466 err := json.Unmarshal(body, &m)
467 if err != nil {
468 return err
469 }
470 for k, v := range m {
471 switch k {
472 case "properties":
473 if v != nil {
474 var projectProperties ProjectProperties
475 err = json.Unmarshal(*v, &projectProperties)
476 if err != nil {
477 return err
478 }
479 p.ProjectProperties = &projectProperties
480 }
481 case "id":
482 if v != nil {
483 var ID string
484 err = json.Unmarshal(*v, &ID)
485 if err != nil {
486 return err
487 }
488 p.ID = &ID
489 }
490 case "name":
491 if v != nil {
492 var name string
493 err = json.Unmarshal(*v, &name)
494 if err != nil {
495 return err
496 }
497 p.Name = &name
498 }
499 case "type":
500 if v != nil {
501 var typeVar string
502 err = json.Unmarshal(*v, &typeVar)
503 if err != nil {
504 return err
505 }
506 p.Type = &typeVar
507 }
508 case "location":
509 if v != nil {
510 var location string
511 err = json.Unmarshal(*v, &location)
512 if err != nil {
513 return err
514 }
515 p.Location = &location
516 }
517 case "tags":
518 if v != nil {
519 var tags map[string]*string
520 err = json.Unmarshal(*v, &tags)
521 if err != nil {
522 return err
523 }
524 p.Tags = tags
525 }
526 }
527 }
528
529 return nil
530 }
531
532
533 type ProjectListResult struct {
534 autorest.Response `json:"-"`
535
536 Value *[]Project `json:"value,omitempty"`
537
538 NextLink *string `json:"nextLink,omitempty"`
539 }
540
541
542 type ProjectListResultIterator struct {
543 i int
544 page ProjectListResultPage
545 }
546
547
548
549 func (iter *ProjectListResultIterator) NextWithContext(ctx context.Context) (err error) {
550 if tracing.IsEnabled() {
551 ctx = tracing.StartSpan(ctx, fqdn+"/ProjectListResultIterator.NextWithContext")
552 defer func() {
553 sc := -1
554 if iter.Response().Response.Response != nil {
555 sc = iter.Response().Response.Response.StatusCode
556 }
557 tracing.EndSpan(ctx, sc, err)
558 }()
559 }
560 iter.i++
561 if iter.i < len(iter.page.Values()) {
562 return nil
563 }
564 err = iter.page.NextWithContext(ctx)
565 if err != nil {
566 iter.i--
567 return err
568 }
569 iter.i = 0
570 return nil
571 }
572
573
574
575
576 func (iter *ProjectListResultIterator) Next() error {
577 return iter.NextWithContext(context.Background())
578 }
579
580
581 func (iter ProjectListResultIterator) NotDone() bool {
582 return iter.page.NotDone() && iter.i < len(iter.page.Values())
583 }
584
585
586 func (iter ProjectListResultIterator) Response() ProjectListResult {
587 return iter.page.Response()
588 }
589
590
591
592 func (iter ProjectListResultIterator) Value() Project {
593 if !iter.page.NotDone() {
594 return Project{}
595 }
596 return iter.page.Values()[iter.i]
597 }
598
599
600 func NewProjectListResultIterator(page ProjectListResultPage) ProjectListResultIterator {
601 return ProjectListResultIterator{page: page}
602 }
603
604
605 func (plr ProjectListResult) IsEmpty() bool {
606 return plr.Value == nil || len(*plr.Value) == 0
607 }
608
609
610 func (plr ProjectListResult) hasNextLink() bool {
611 return plr.NextLink != nil && len(*plr.NextLink) != 0
612 }
613
614
615
616 func (plr ProjectListResult) projectListResultPreparer(ctx context.Context) (*http.Request, error) {
617 if !plr.hasNextLink() {
618 return nil, nil
619 }
620 return autorest.Prepare((&http.Request{}).WithContext(ctx),
621 autorest.AsJSON(),
622 autorest.AsGet(),
623 autorest.WithBaseURL(to.String(plr.NextLink)))
624 }
625
626
627 type ProjectListResultPage struct {
628 fn func(context.Context, ProjectListResult) (ProjectListResult, error)
629 plr ProjectListResult
630 }
631
632
633
634 func (page *ProjectListResultPage) NextWithContext(ctx context.Context) (err error) {
635 if tracing.IsEnabled() {
636 ctx = tracing.StartSpan(ctx, fqdn+"/ProjectListResultPage.NextWithContext")
637 defer func() {
638 sc := -1
639 if page.Response().Response.Response != nil {
640 sc = page.Response().Response.Response.StatusCode
641 }
642 tracing.EndSpan(ctx, sc, err)
643 }()
644 }
645 for {
646 next, err := page.fn(ctx, page.plr)
647 if err != nil {
648 return err
649 }
650 page.plr = next
651 if !next.hasNextLink() || !next.IsEmpty() {
652 break
653 }
654 }
655 return nil
656 }
657
658
659
660
661 func (page *ProjectListResultPage) Next() error {
662 return page.NextWithContext(context.Background())
663 }
664
665
666 func (page ProjectListResultPage) NotDone() bool {
667 return !page.plr.IsEmpty()
668 }
669
670
671 func (page ProjectListResultPage) Response() ProjectListResult {
672 return page.plr
673 }
674
675
676 func (page ProjectListResultPage) Values() []Project {
677 if page.plr.IsEmpty() {
678 return nil
679 }
680 return *page.plr.Value
681 }
682
683
684 func NewProjectListResultPage(cur ProjectListResult, getNextPage func(context.Context, ProjectListResult) (ProjectListResult, error)) ProjectListResultPage {
685 return ProjectListResultPage{
686 fn: getNextPage,
687 plr: cur,
688 }
689 }
690
691
692 type ProjectProperties struct {
693
694 Description *string `json:"description,omitempty"`
695
696 AccountID *string `json:"accountId,omitempty"`
697
698 WorkspaceID *string `json:"workspaceId,omitempty"`
699
700 ProjectID *string `json:"projectId,omitempty"`
701
702 Gitrepo *string `json:"gitrepo,omitempty"`
703
704 FriendlyName *string `json:"friendlyName,omitempty"`
705
706 CreationDate *date.Time `json:"creationDate,omitempty"`
707
708 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
709 }
710
711
712 func (pp ProjectProperties) MarshalJSON() ([]byte, error) {
713 objectMap := make(map[string]interface{})
714 if pp.Description != nil {
715 objectMap["description"] = pp.Description
716 }
717 if pp.Gitrepo != nil {
718 objectMap["gitrepo"] = pp.Gitrepo
719 }
720 if pp.FriendlyName != nil {
721 objectMap["friendlyName"] = pp.FriendlyName
722 }
723 return json.Marshal(objectMap)
724 }
725
726
727 type ProjectPropertiesUpdateParameters struct {
728
729 FriendlyName *string `json:"friendlyName,omitempty"`
730
731 Description *string `json:"description,omitempty"`
732
733 Gitrepo *string `json:"gitrepo,omitempty"`
734 }
735
736
737 type ProjectUpdateParameters struct {
738
739 Tags map[string]*string `json:"tags"`
740
741 *ProjectPropertiesUpdateParameters `json:"properties,omitempty"`
742 }
743
744
745 func (pup ProjectUpdateParameters) MarshalJSON() ([]byte, error) {
746 objectMap := make(map[string]interface{})
747 if pup.Tags != nil {
748 objectMap["tags"] = pup.Tags
749 }
750 if pup.ProjectPropertiesUpdateParameters != nil {
751 objectMap["properties"] = pup.ProjectPropertiesUpdateParameters
752 }
753 return json.Marshal(objectMap)
754 }
755
756
757 func (pup *ProjectUpdateParameters) UnmarshalJSON(body []byte) error {
758 var m map[string]*json.RawMessage
759 err := json.Unmarshal(body, &m)
760 if err != nil {
761 return err
762 }
763 for k, v := range m {
764 switch k {
765 case "tags":
766 if v != nil {
767 var tags map[string]*string
768 err = json.Unmarshal(*v, &tags)
769 if err != nil {
770 return err
771 }
772 pup.Tags = tags
773 }
774 case "properties":
775 if v != nil {
776 var projectPropertiesUpdateParameters ProjectPropertiesUpdateParameters
777 err = json.Unmarshal(*v, &projectPropertiesUpdateParameters)
778 if err != nil {
779 return err
780 }
781 pup.ProjectPropertiesUpdateParameters = &projectPropertiesUpdateParameters
782 }
783 }
784 }
785
786 return nil
787 }
788
789
790 type Resource struct {
791
792 ID *string `json:"id,omitempty"`
793
794 Name *string `json:"name,omitempty"`
795
796 Type *string `json:"type,omitempty"`
797
798 Location *string `json:"location,omitempty"`
799
800 Tags map[string]*string `json:"tags"`
801 }
802
803
804 func (r Resource) MarshalJSON() ([]byte, error) {
805 objectMap := make(map[string]interface{})
806 if r.Location != nil {
807 objectMap["location"] = r.Location
808 }
809 if r.Tags != nil {
810 objectMap["tags"] = r.Tags
811 }
812 return json.Marshal(objectMap)
813 }
814
815
816 type StorageAccountProperties struct {
817
818 StorageAccountID *string `json:"storageAccountId,omitempty"`
819
820 AccessKey *string `json:"accessKey,omitempty"`
821 }
822
823
824 type Workspace struct {
825 autorest.Response `json:"-"`
826
827 *WorkspaceProperties `json:"properties,omitempty"`
828
829 ID *string `json:"id,omitempty"`
830
831 Name *string `json:"name,omitempty"`
832
833 Type *string `json:"type,omitempty"`
834
835 Location *string `json:"location,omitempty"`
836
837 Tags map[string]*string `json:"tags"`
838 }
839
840
841 func (w Workspace) MarshalJSON() ([]byte, error) {
842 objectMap := make(map[string]interface{})
843 if w.WorkspaceProperties != nil {
844 objectMap["properties"] = w.WorkspaceProperties
845 }
846 if w.Location != nil {
847 objectMap["location"] = w.Location
848 }
849 if w.Tags != nil {
850 objectMap["tags"] = w.Tags
851 }
852 return json.Marshal(objectMap)
853 }
854
855
856 func (w *Workspace) UnmarshalJSON(body []byte) error {
857 var m map[string]*json.RawMessage
858 err := json.Unmarshal(body, &m)
859 if err != nil {
860 return err
861 }
862 for k, v := range m {
863 switch k {
864 case "properties":
865 if v != nil {
866 var workspaceProperties WorkspaceProperties
867 err = json.Unmarshal(*v, &workspaceProperties)
868 if err != nil {
869 return err
870 }
871 w.WorkspaceProperties = &workspaceProperties
872 }
873 case "id":
874 if v != nil {
875 var ID string
876 err = json.Unmarshal(*v, &ID)
877 if err != nil {
878 return err
879 }
880 w.ID = &ID
881 }
882 case "name":
883 if v != nil {
884 var name string
885 err = json.Unmarshal(*v, &name)
886 if err != nil {
887 return err
888 }
889 w.Name = &name
890 }
891 case "type":
892 if v != nil {
893 var typeVar string
894 err = json.Unmarshal(*v, &typeVar)
895 if err != nil {
896 return err
897 }
898 w.Type = &typeVar
899 }
900 case "location":
901 if v != nil {
902 var location string
903 err = json.Unmarshal(*v, &location)
904 if err != nil {
905 return err
906 }
907 w.Location = &location
908 }
909 case "tags":
910 if v != nil {
911 var tags map[string]*string
912 err = json.Unmarshal(*v, &tags)
913 if err != nil {
914 return err
915 }
916 w.Tags = tags
917 }
918 }
919 }
920
921 return nil
922 }
923
924
925 type WorkspaceListResult struct {
926 autorest.Response `json:"-"`
927
928 Value *[]Workspace `json:"value,omitempty"`
929
930 NextLink *string `json:"nextLink,omitempty"`
931 }
932
933
934 type WorkspaceListResultIterator struct {
935 i int
936 page WorkspaceListResultPage
937 }
938
939
940
941 func (iter *WorkspaceListResultIterator) NextWithContext(ctx context.Context) (err error) {
942 if tracing.IsEnabled() {
943 ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceListResultIterator.NextWithContext")
944 defer func() {
945 sc := -1
946 if iter.Response().Response.Response != nil {
947 sc = iter.Response().Response.Response.StatusCode
948 }
949 tracing.EndSpan(ctx, sc, err)
950 }()
951 }
952 iter.i++
953 if iter.i < len(iter.page.Values()) {
954 return nil
955 }
956 err = iter.page.NextWithContext(ctx)
957 if err != nil {
958 iter.i--
959 return err
960 }
961 iter.i = 0
962 return nil
963 }
964
965
966
967
968 func (iter *WorkspaceListResultIterator) Next() error {
969 return iter.NextWithContext(context.Background())
970 }
971
972
973 func (iter WorkspaceListResultIterator) NotDone() bool {
974 return iter.page.NotDone() && iter.i < len(iter.page.Values())
975 }
976
977
978 func (iter WorkspaceListResultIterator) Response() WorkspaceListResult {
979 return iter.page.Response()
980 }
981
982
983
984 func (iter WorkspaceListResultIterator) Value() Workspace {
985 if !iter.page.NotDone() {
986 return Workspace{}
987 }
988 return iter.page.Values()[iter.i]
989 }
990
991
992 func NewWorkspaceListResultIterator(page WorkspaceListResultPage) WorkspaceListResultIterator {
993 return WorkspaceListResultIterator{page: page}
994 }
995
996
997 func (wlr WorkspaceListResult) IsEmpty() bool {
998 return wlr.Value == nil || len(*wlr.Value) == 0
999 }
1000
1001
1002 func (wlr WorkspaceListResult) hasNextLink() bool {
1003 return wlr.NextLink != nil && len(*wlr.NextLink) != 0
1004 }
1005
1006
1007
1008 func (wlr WorkspaceListResult) workspaceListResultPreparer(ctx context.Context) (*http.Request, error) {
1009 if !wlr.hasNextLink() {
1010 return nil, nil
1011 }
1012 return autorest.Prepare((&http.Request{}).WithContext(ctx),
1013 autorest.AsJSON(),
1014 autorest.AsGet(),
1015 autorest.WithBaseURL(to.String(wlr.NextLink)))
1016 }
1017
1018
1019 type WorkspaceListResultPage struct {
1020 fn func(context.Context, WorkspaceListResult) (WorkspaceListResult, error)
1021 wlr WorkspaceListResult
1022 }
1023
1024
1025
1026 func (page *WorkspaceListResultPage) NextWithContext(ctx context.Context) (err error) {
1027 if tracing.IsEnabled() {
1028 ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceListResultPage.NextWithContext")
1029 defer func() {
1030 sc := -1
1031 if page.Response().Response.Response != nil {
1032 sc = page.Response().Response.Response.StatusCode
1033 }
1034 tracing.EndSpan(ctx, sc, err)
1035 }()
1036 }
1037 for {
1038 next, err := page.fn(ctx, page.wlr)
1039 if err != nil {
1040 return err
1041 }
1042 page.wlr = next
1043 if !next.hasNextLink() || !next.IsEmpty() {
1044 break
1045 }
1046 }
1047 return nil
1048 }
1049
1050
1051
1052
1053 func (page *WorkspaceListResultPage) Next() error {
1054 return page.NextWithContext(context.Background())
1055 }
1056
1057
1058 func (page WorkspaceListResultPage) NotDone() bool {
1059 return !page.wlr.IsEmpty()
1060 }
1061
1062
1063 func (page WorkspaceListResultPage) Response() WorkspaceListResult {
1064 return page.wlr
1065 }
1066
1067
1068 func (page WorkspaceListResultPage) Values() []Workspace {
1069 if page.wlr.IsEmpty() {
1070 return nil
1071 }
1072 return *page.wlr.Value
1073 }
1074
1075
1076 func NewWorkspaceListResultPage(cur WorkspaceListResult, getNextPage func(context.Context, WorkspaceListResult) (WorkspaceListResult, error)) WorkspaceListResultPage {
1077 return WorkspaceListResultPage{
1078 fn: getNextPage,
1079 wlr: cur,
1080 }
1081 }
1082
1083
1084 type WorkspaceProperties struct {
1085
1086 Description *string `json:"description,omitempty"`
1087
1088 AccountID *string `json:"accountId,omitempty"`
1089
1090 WorkspaceID *string `json:"workspaceId,omitempty"`
1091
1092 FriendlyName *string `json:"friendlyName,omitempty"`
1093
1094 CreationDate *date.Time `json:"creationDate,omitempty"`
1095
1096 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
1097 }
1098
1099
1100 func (wp WorkspaceProperties) MarshalJSON() ([]byte, error) {
1101 objectMap := make(map[string]interface{})
1102 if wp.Description != nil {
1103 objectMap["description"] = wp.Description
1104 }
1105 if wp.FriendlyName != nil {
1106 objectMap["friendlyName"] = wp.FriendlyName
1107 }
1108 return json.Marshal(objectMap)
1109 }
1110
1111
1112
1113 type WorkspacePropertiesUpdateParameters struct {
1114
1115 FriendlyName *string `json:"friendlyName,omitempty"`
1116
1117 Description *string `json:"description,omitempty"`
1118 }
1119
1120
1121 type WorkspaceUpdateParameters struct {
1122
1123 Tags map[string]*string `json:"tags"`
1124
1125 *WorkspacePropertiesUpdateParameters `json:"properties,omitempty"`
1126 }
1127
1128
1129 func (wup WorkspaceUpdateParameters) MarshalJSON() ([]byte, error) {
1130 objectMap := make(map[string]interface{})
1131 if wup.Tags != nil {
1132 objectMap["tags"] = wup.Tags
1133 }
1134 if wup.WorkspacePropertiesUpdateParameters != nil {
1135 objectMap["properties"] = wup.WorkspacePropertiesUpdateParameters
1136 }
1137 return json.Marshal(objectMap)
1138 }
1139
1140
1141 func (wup *WorkspaceUpdateParameters) UnmarshalJSON(body []byte) error {
1142 var m map[string]*json.RawMessage
1143 err := json.Unmarshal(body, &m)
1144 if err != nil {
1145 return err
1146 }
1147 for k, v := range m {
1148 switch k {
1149 case "tags":
1150 if v != nil {
1151 var tags map[string]*string
1152 err = json.Unmarshal(*v, &tags)
1153 if err != nil {
1154 return err
1155 }
1156 wup.Tags = tags
1157 }
1158 case "properties":
1159 if v != nil {
1160 var workspacePropertiesUpdateParameters WorkspacePropertiesUpdateParameters
1161 err = json.Unmarshal(*v, &workspacePropertiesUpdateParameters)
1162 if err != nil {
1163 return err
1164 }
1165 wup.WorkspacePropertiesUpdateParameters = &workspacePropertiesUpdateParameters
1166 }
1167 }
1168 }
1169
1170 return nil
1171 }
1172
View as plain text