1 package windowsesu
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/preview/windowsesu/mgmt/2019-09-16-preview/windowsesu"
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 ErrorDefinition struct {
43
44 Code *string `json:"code,omitempty"`
45
46 Message *string `json:"message,omitempty"`
47
48 Details *[]ErrorDefinition `json:"details,omitempty"`
49 }
50
51
52 func (ed ErrorDefinition) MarshalJSON() ([]byte, error) {
53 objectMap := make(map[string]interface{})
54 return json.Marshal(objectMap)
55 }
56
57
58 type ErrorResponse struct {
59
60 Error *ErrorDefinition `json:"error,omitempty"`
61 }
62
63
64 type MultipleActivationKey struct {
65 autorest.Response `json:"-"`
66
67 *MultipleActivationKeyProperties `json:"properties,omitempty"`
68
69 Tags map[string]*string `json:"tags"`
70
71 Location *string `json:"location,omitempty"`
72
73 ID *string `json:"id,omitempty"`
74
75 Name *string `json:"name,omitempty"`
76
77 Type *string `json:"type,omitempty"`
78 }
79
80
81 func (mak MultipleActivationKey) MarshalJSON() ([]byte, error) {
82 objectMap := make(map[string]interface{})
83 if mak.MultipleActivationKeyProperties != nil {
84 objectMap["properties"] = mak.MultipleActivationKeyProperties
85 }
86 if mak.Tags != nil {
87 objectMap["tags"] = mak.Tags
88 }
89 if mak.Location != nil {
90 objectMap["location"] = mak.Location
91 }
92 return json.Marshal(objectMap)
93 }
94
95
96 func (mak *MultipleActivationKey) UnmarshalJSON(body []byte) error {
97 var m map[string]*json.RawMessage
98 err := json.Unmarshal(body, &m)
99 if err != nil {
100 return err
101 }
102 for k, v := range m {
103 switch k {
104 case "properties":
105 if v != nil {
106 var multipleActivationKeyProperties MultipleActivationKeyProperties
107 err = json.Unmarshal(*v, &multipleActivationKeyProperties)
108 if err != nil {
109 return err
110 }
111 mak.MultipleActivationKeyProperties = &multipleActivationKeyProperties
112 }
113 case "tags":
114 if v != nil {
115 var tags map[string]*string
116 err = json.Unmarshal(*v, &tags)
117 if err != nil {
118 return err
119 }
120 mak.Tags = tags
121 }
122 case "location":
123 if v != nil {
124 var location string
125 err = json.Unmarshal(*v, &location)
126 if err != nil {
127 return err
128 }
129 mak.Location = &location
130 }
131 case "id":
132 if v != nil {
133 var ID string
134 err = json.Unmarshal(*v, &ID)
135 if err != nil {
136 return err
137 }
138 mak.ID = &ID
139 }
140 case "name":
141 if v != nil {
142 var name string
143 err = json.Unmarshal(*v, &name)
144 if err != nil {
145 return err
146 }
147 mak.Name = &name
148 }
149 case "type":
150 if v != nil {
151 var typeVar string
152 err = json.Unmarshal(*v, &typeVar)
153 if err != nil {
154 return err
155 }
156 mak.Type = &typeVar
157 }
158 }
159 }
160
161 return nil
162 }
163
164
165 type MultipleActivationKeyList struct {
166 autorest.Response `json:"-"`
167
168 Value *[]MultipleActivationKey `json:"value,omitempty"`
169
170 NextLink *string `json:"nextLink,omitempty"`
171 }
172
173
174 func (makl MultipleActivationKeyList) MarshalJSON() ([]byte, error) {
175 objectMap := make(map[string]interface{})
176 if makl.Value != nil {
177 objectMap["value"] = makl.Value
178 }
179 return json.Marshal(objectMap)
180 }
181
182
183 type MultipleActivationKeyListIterator struct {
184 i int
185 page MultipleActivationKeyListPage
186 }
187
188
189
190 func (iter *MultipleActivationKeyListIterator) NextWithContext(ctx context.Context) (err error) {
191 if tracing.IsEnabled() {
192 ctx = tracing.StartSpan(ctx, fqdn+"/MultipleActivationKeyListIterator.NextWithContext")
193 defer func() {
194 sc := -1
195 if iter.Response().Response.Response != nil {
196 sc = iter.Response().Response.Response.StatusCode
197 }
198 tracing.EndSpan(ctx, sc, err)
199 }()
200 }
201 iter.i++
202 if iter.i < len(iter.page.Values()) {
203 return nil
204 }
205 err = iter.page.NextWithContext(ctx)
206 if err != nil {
207 iter.i--
208 return err
209 }
210 iter.i = 0
211 return nil
212 }
213
214
215
216
217 func (iter *MultipleActivationKeyListIterator) Next() error {
218 return iter.NextWithContext(context.Background())
219 }
220
221
222 func (iter MultipleActivationKeyListIterator) NotDone() bool {
223 return iter.page.NotDone() && iter.i < len(iter.page.Values())
224 }
225
226
227 func (iter MultipleActivationKeyListIterator) Response() MultipleActivationKeyList {
228 return iter.page.Response()
229 }
230
231
232
233 func (iter MultipleActivationKeyListIterator) Value() MultipleActivationKey {
234 if !iter.page.NotDone() {
235 return MultipleActivationKey{}
236 }
237 return iter.page.Values()[iter.i]
238 }
239
240
241 func NewMultipleActivationKeyListIterator(page MultipleActivationKeyListPage) MultipleActivationKeyListIterator {
242 return MultipleActivationKeyListIterator{page: page}
243 }
244
245
246 func (makl MultipleActivationKeyList) IsEmpty() bool {
247 return makl.Value == nil || len(*makl.Value) == 0
248 }
249
250
251 func (makl MultipleActivationKeyList) hasNextLink() bool {
252 return makl.NextLink != nil && len(*makl.NextLink) != 0
253 }
254
255
256
257 func (makl MultipleActivationKeyList) multipleActivationKeyListPreparer(ctx context.Context) (*http.Request, error) {
258 if !makl.hasNextLink() {
259 return nil, nil
260 }
261 return autorest.Prepare((&http.Request{}).WithContext(ctx),
262 autorest.AsJSON(),
263 autorest.AsGet(),
264 autorest.WithBaseURL(to.String(makl.NextLink)))
265 }
266
267
268 type MultipleActivationKeyListPage struct {
269 fn func(context.Context, MultipleActivationKeyList) (MultipleActivationKeyList, error)
270 makl MultipleActivationKeyList
271 }
272
273
274
275 func (page *MultipleActivationKeyListPage) NextWithContext(ctx context.Context) (err error) {
276 if tracing.IsEnabled() {
277 ctx = tracing.StartSpan(ctx, fqdn+"/MultipleActivationKeyListPage.NextWithContext")
278 defer func() {
279 sc := -1
280 if page.Response().Response.Response != nil {
281 sc = page.Response().Response.Response.StatusCode
282 }
283 tracing.EndSpan(ctx, sc, err)
284 }()
285 }
286 for {
287 next, err := page.fn(ctx, page.makl)
288 if err != nil {
289 return err
290 }
291 page.makl = next
292 if !next.hasNextLink() || !next.IsEmpty() {
293 break
294 }
295 }
296 return nil
297 }
298
299
300
301
302 func (page *MultipleActivationKeyListPage) Next() error {
303 return page.NextWithContext(context.Background())
304 }
305
306
307 func (page MultipleActivationKeyListPage) NotDone() bool {
308 return !page.makl.IsEmpty()
309 }
310
311
312 func (page MultipleActivationKeyListPage) Response() MultipleActivationKeyList {
313 return page.makl
314 }
315
316
317 func (page MultipleActivationKeyListPage) Values() []MultipleActivationKey {
318 if page.makl.IsEmpty() {
319 return nil
320 }
321 return *page.makl.Value
322 }
323
324
325 func NewMultipleActivationKeyListPage(cur MultipleActivationKeyList, getNextPage func(context.Context, MultipleActivationKeyList) (MultipleActivationKeyList, error)) MultipleActivationKeyListPage {
326 return MultipleActivationKeyListPage{
327 fn: getNextPage,
328 makl: cur,
329 }
330 }
331
332
333 type MultipleActivationKeyProperties struct {
334
335 MultipleActivationKey *string `json:"multipleActivationKey,omitempty"`
336
337 ExpirationDate *date.Time `json:"expirationDate,omitempty"`
338
339 OsType OsType `json:"osType,omitempty"`
340
341 SupportType SupportType `json:"supportType,omitempty"`
342
343 InstalledServerNumber *int32 `json:"installedServerNumber,omitempty"`
344
345 AgreementNumber *string `json:"agreementNumber,omitempty"`
346
347 IsEligible *bool `json:"isEligible,omitempty"`
348
349 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
350 }
351
352
353 func (mak MultipleActivationKeyProperties) MarshalJSON() ([]byte, error) {
354 objectMap := make(map[string]interface{})
355 if mak.OsType != "" {
356 objectMap["osType"] = mak.OsType
357 }
358 if mak.SupportType != "" {
359 objectMap["supportType"] = mak.SupportType
360 }
361 if mak.InstalledServerNumber != nil {
362 objectMap["installedServerNumber"] = mak.InstalledServerNumber
363 }
364 if mak.AgreementNumber != nil {
365 objectMap["agreementNumber"] = mak.AgreementNumber
366 }
367 if mak.IsEligible != nil {
368 objectMap["isEligible"] = mak.IsEligible
369 }
370 return json.Marshal(objectMap)
371 }
372
373
374
375 type MultipleActivationKeysCreateFuture struct {
376 azure.FutureAPI
377
378
379 Result func(MultipleActivationKeysClient) (MultipleActivationKey, error)
380 }
381
382
383 func (future *MultipleActivationKeysCreateFuture) UnmarshalJSON(body []byte) error {
384 var azFuture azure.Future
385 if err := json.Unmarshal(body, &azFuture); err != nil {
386 return err
387 }
388 future.FutureAPI = &azFuture
389 future.Result = future.result
390 return nil
391 }
392
393
394 func (future *MultipleActivationKeysCreateFuture) result(client MultipleActivationKeysClient) (mak MultipleActivationKey, err error) {
395 var done bool
396 done, err = future.DoneWithContext(context.Background(), client)
397 if err != nil {
398 err = autorest.NewErrorWithError(err, "windowsesu.MultipleActivationKeysCreateFuture", "Result", future.Response(), "Polling failure")
399 return
400 }
401 if !done {
402 mak.Response.Response = future.Response()
403 err = azure.NewAsyncOpIncompleteError("windowsesu.MultipleActivationKeysCreateFuture")
404 return
405 }
406 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
407 if mak.Response.Response, err = future.GetResult(sender); err == nil && mak.Response.Response.StatusCode != http.StatusNoContent {
408 mak, err = client.CreateResponder(mak.Response.Response)
409 if err != nil {
410 err = autorest.NewErrorWithError(err, "windowsesu.MultipleActivationKeysCreateFuture", "Result", mak.Response.Response, "Failure responding to request")
411 }
412 }
413 return
414 }
415
416
417 type MultipleActivationKeyUpdate struct {
418
419 Tags map[string]*string `json:"tags"`
420 }
421
422
423 func (maku MultipleActivationKeyUpdate) MarshalJSON() ([]byte, error) {
424 objectMap := make(map[string]interface{})
425 if maku.Tags != nil {
426 objectMap["tags"] = maku.Tags
427 }
428 return json.Marshal(objectMap)
429 }
430
431
432 type Operation struct {
433
434 Name *string `json:"name,omitempty"`
435 Display *OperationDisplay `json:"display,omitempty"`
436 }
437
438
439 func (o Operation) MarshalJSON() ([]byte, error) {
440 objectMap := make(map[string]interface{})
441 if o.Display != nil {
442 objectMap["display"] = o.Display
443 }
444 return json.Marshal(objectMap)
445 }
446
447
448 type OperationDisplay struct {
449 Provider *string `json:"provider,omitempty"`
450 Resource *string `json:"resource,omitempty"`
451 Operation *string `json:"operation,omitempty"`
452 Description *string `json:"description,omitempty"`
453 }
454
455
456 type OperationList struct {
457 autorest.Response `json:"-"`
458
459 Value *[]Operation `json:"value,omitempty"`
460
461 NextLink *string `json:"nextLink,omitempty"`
462 }
463
464
465 func (ol OperationList) MarshalJSON() ([]byte, error) {
466 objectMap := make(map[string]interface{})
467 if ol.Value != nil {
468 objectMap["value"] = ol.Value
469 }
470 return json.Marshal(objectMap)
471 }
472
473
474 type OperationListIterator struct {
475 i int
476 page OperationListPage
477 }
478
479
480
481 func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) {
482 if tracing.IsEnabled() {
483 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext")
484 defer func() {
485 sc := -1
486 if iter.Response().Response.Response != nil {
487 sc = iter.Response().Response.Response.StatusCode
488 }
489 tracing.EndSpan(ctx, sc, err)
490 }()
491 }
492 iter.i++
493 if iter.i < len(iter.page.Values()) {
494 return nil
495 }
496 err = iter.page.NextWithContext(ctx)
497 if err != nil {
498 iter.i--
499 return err
500 }
501 iter.i = 0
502 return nil
503 }
504
505
506
507
508 func (iter *OperationListIterator) Next() error {
509 return iter.NextWithContext(context.Background())
510 }
511
512
513 func (iter OperationListIterator) NotDone() bool {
514 return iter.page.NotDone() && iter.i < len(iter.page.Values())
515 }
516
517
518 func (iter OperationListIterator) Response() OperationList {
519 return iter.page.Response()
520 }
521
522
523
524 func (iter OperationListIterator) Value() Operation {
525 if !iter.page.NotDone() {
526 return Operation{}
527 }
528 return iter.page.Values()[iter.i]
529 }
530
531
532 func NewOperationListIterator(page OperationListPage) OperationListIterator {
533 return OperationListIterator{page: page}
534 }
535
536
537 func (ol OperationList) IsEmpty() bool {
538 return ol.Value == nil || len(*ol.Value) == 0
539 }
540
541
542 func (ol OperationList) hasNextLink() bool {
543 return ol.NextLink != nil && len(*ol.NextLink) != 0
544 }
545
546
547
548 func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) {
549 if !ol.hasNextLink() {
550 return nil, nil
551 }
552 return autorest.Prepare((&http.Request{}).WithContext(ctx),
553 autorest.AsJSON(),
554 autorest.AsGet(),
555 autorest.WithBaseURL(to.String(ol.NextLink)))
556 }
557
558
559 type OperationListPage struct {
560 fn func(context.Context, OperationList) (OperationList, error)
561 ol OperationList
562 }
563
564
565
566 func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) {
567 if tracing.IsEnabled() {
568 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext")
569 defer func() {
570 sc := -1
571 if page.Response().Response.Response != nil {
572 sc = page.Response().Response.Response.StatusCode
573 }
574 tracing.EndSpan(ctx, sc, err)
575 }()
576 }
577 for {
578 next, err := page.fn(ctx, page.ol)
579 if err != nil {
580 return err
581 }
582 page.ol = next
583 if !next.hasNextLink() || !next.IsEmpty() {
584 break
585 }
586 }
587 return nil
588 }
589
590
591
592
593 func (page *OperationListPage) Next() error {
594 return page.NextWithContext(context.Background())
595 }
596
597
598 func (page OperationListPage) NotDone() bool {
599 return !page.ol.IsEmpty()
600 }
601
602
603 func (page OperationListPage) Response() OperationList {
604 return page.ol
605 }
606
607
608 func (page OperationListPage) Values() []Operation {
609 if page.ol.IsEmpty() {
610 return nil
611 }
612 return *page.ol.Value
613 }
614
615
616 func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage {
617 return OperationListPage{
618 fn: getNextPage,
619 ol: cur,
620 }
621 }
622
623
624
625 type ProxyResource struct {
626
627 ID *string `json:"id,omitempty"`
628
629 Name *string `json:"name,omitempty"`
630
631 Type *string `json:"type,omitempty"`
632 }
633
634
635 func (pr ProxyResource) MarshalJSON() ([]byte, error) {
636 objectMap := make(map[string]interface{})
637 return json.Marshal(objectMap)
638 }
639
640
641 type Resource struct {
642
643 ID *string `json:"id,omitempty"`
644
645 Name *string `json:"name,omitempty"`
646
647 Type *string `json:"type,omitempty"`
648 }
649
650
651 func (r Resource) MarshalJSON() ([]byte, error) {
652 objectMap := make(map[string]interface{})
653 return json.Marshal(objectMap)
654 }
655
656
657
658 type TrackedResource struct {
659
660 Tags map[string]*string `json:"tags"`
661
662 Location *string `json:"location,omitempty"`
663
664 ID *string `json:"id,omitempty"`
665
666 Name *string `json:"name,omitempty"`
667
668 Type *string `json:"type,omitempty"`
669 }
670
671
672 func (tr TrackedResource) MarshalJSON() ([]byte, error) {
673 objectMap := make(map[string]interface{})
674 if tr.Tags != nil {
675 objectMap["tags"] = tr.Tags
676 }
677 if tr.Location != nil {
678 objectMap["location"] = tr.Location
679 }
680 return json.Marshal(objectMap)
681 }
682
View as plain text