1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 package licensing
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "net/http"
61 "net/url"
62 "strconv"
63 "strings"
64
65 googleapi "google.golang.org/api/googleapi"
66 internal "google.golang.org/api/internal"
67 gensupport "google.golang.org/api/internal/gensupport"
68 option "google.golang.org/api/option"
69 internaloption "google.golang.org/api/option/internaloption"
70 htransport "google.golang.org/api/transport/http"
71 )
72
73
74
75 var _ = bytes.NewBuffer
76 var _ = strconv.Itoa
77 var _ = fmt.Sprintf
78 var _ = json.NewDecoder
79 var _ = io.Copy
80 var _ = url.Parse
81 var _ = gensupport.MarshalJSON
82 var _ = googleapi.Version
83 var _ = errors.New
84 var _ = strings.Replace
85 var _ = context.Canceled
86 var _ = internaloption.WithDefaultEndpoint
87 var _ = internal.Version
88
89 const apiId = "licensing:v1"
90 const apiName = "licensing"
91 const apiVersion = "v1"
92 const basePath = "https://licensing.googleapis.com/"
93 const basePathTemplate = "https://licensing.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://licensing.mtls.googleapis.com/"
95
96
97 const (
98
99 AppsLicensingScope = "https://www.googleapis.com/auth/apps.licensing"
100 )
101
102
103 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
104 scopesOption := internaloption.WithDefaultScopes(
105 "https://www.googleapis.com/auth/apps.licensing",
106 )
107
108 opts = append([]option.ClientOption{scopesOption}, opts...)
109 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
110 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
111 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
112 opts = append(opts, internaloption.EnableNewAuthLibrary())
113 client, endpoint, err := htransport.NewClient(ctx, opts...)
114 if err != nil {
115 return nil, err
116 }
117 s, err := New(client)
118 if err != nil {
119 return nil, err
120 }
121 if endpoint != "" {
122 s.BasePath = endpoint
123 }
124 return s, nil
125 }
126
127
128
129
130
131
132 func New(client *http.Client) (*Service, error) {
133 if client == nil {
134 return nil, errors.New("client is nil")
135 }
136 s := &Service{client: client, BasePath: basePath}
137 s.LicenseAssignments = NewLicenseAssignmentsService(s)
138 return s, nil
139 }
140
141 type Service struct {
142 client *http.Client
143 BasePath string
144 UserAgent string
145
146 LicenseAssignments *LicenseAssignmentsService
147 }
148
149 func (s *Service) userAgent() string {
150 if s.UserAgent == "" {
151 return googleapi.UserAgent
152 }
153 return googleapi.UserAgent + " " + s.UserAgent
154 }
155
156 func NewLicenseAssignmentsService(s *Service) *LicenseAssignmentsService {
157 rs := &LicenseAssignmentsService{s: s}
158 return rs
159 }
160
161 type LicenseAssignmentsService struct {
162 s *Service
163 }
164
165
166
167
168
169 type Empty struct {
170
171 googleapi.ServerResponse `json:"-"`
172 }
173
174
175 type LicenseAssignment struct {
176
177 Etags string `json:"etags,omitempty"`
178
179
180 Kind string `json:"kind,omitempty"`
181
182
183 ProductId string `json:"productId,omitempty"`
184
185 ProductName string `json:"productName,omitempty"`
186
187 SelfLink string `json:"selfLink,omitempty"`
188
189
190 SkuId string `json:"skuId,omitempty"`
191
192 SkuName string `json:"skuName,omitempty"`
193
194
195
196
197
198 UserId string `json:"userId,omitempty"`
199
200
201 googleapi.ServerResponse `json:"-"`
202
203
204
205
206
207 ForceSendFields []string `json:"-"`
208
209
210
211
212 NullFields []string `json:"-"`
213 }
214
215 func (s *LicenseAssignment) MarshalJSON() ([]byte, error) {
216 type NoMethod LicenseAssignment
217 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
218 }
219
220
221 type LicenseAssignmentInsert struct {
222
223 UserId string `json:"userId,omitempty"`
224
225
226
227
228
229 ForceSendFields []string `json:"-"`
230
231
232
233
234 NullFields []string `json:"-"`
235 }
236
237 func (s *LicenseAssignmentInsert) MarshalJSON() ([]byte, error) {
238 type NoMethod LicenseAssignmentInsert
239 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
240 }
241
242 type LicenseAssignmentList struct {
243
244 Etag string `json:"etag,omitempty"`
245
246 Items []*LicenseAssignment `json:"items,omitempty"`
247
248 Kind string `json:"kind,omitempty"`
249
250
251
252
253 NextPageToken string `json:"nextPageToken,omitempty"`
254
255
256 googleapi.ServerResponse `json:"-"`
257
258
259
260
261
262 ForceSendFields []string `json:"-"`
263
264
265
266
267 NullFields []string `json:"-"`
268 }
269
270 func (s *LicenseAssignmentList) MarshalJSON() ([]byte, error) {
271 type NoMethod LicenseAssignmentList
272 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
273 }
274
275 type LicenseAssignmentsDeleteCall struct {
276 s *Service
277 productId string
278 skuId string
279 userId string
280 urlParams_ gensupport.URLParams
281 ctx_ context.Context
282 header_ http.Header
283 }
284
285
286
287
288
289
290
291
292
293
294
295
296 func (r *LicenseAssignmentsService) Delete(productId string, skuId string, userId string) *LicenseAssignmentsDeleteCall {
297 c := &LicenseAssignmentsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
298 c.productId = productId
299 c.skuId = skuId
300 c.userId = userId
301 return c
302 }
303
304
305
306
307 func (c *LicenseAssignmentsDeleteCall) Fields(s ...googleapi.Field) *LicenseAssignmentsDeleteCall {
308 c.urlParams_.Set("fields", googleapi.CombineFields(s))
309 return c
310 }
311
312
313 func (c *LicenseAssignmentsDeleteCall) Context(ctx context.Context) *LicenseAssignmentsDeleteCall {
314 c.ctx_ = ctx
315 return c
316 }
317
318
319
320 func (c *LicenseAssignmentsDeleteCall) Header() http.Header {
321 if c.header_ == nil {
322 c.header_ = make(http.Header)
323 }
324 return c.header_
325 }
326
327 func (c *LicenseAssignmentsDeleteCall) doRequest(alt string) (*http.Response, error) {
328 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
329 var body io.Reader = nil
330 c.urlParams_.Set("alt", alt)
331 c.urlParams_.Set("prettyPrint", "false")
332 urls := googleapi.ResolveRelative(c.s.BasePath, "apps/licensing/v1/product/{productId}/sku/{skuId}/user/{userId}")
333 urls += "?" + c.urlParams_.Encode()
334 req, err := http.NewRequest("DELETE", urls, body)
335 if err != nil {
336 return nil, err
337 }
338 req.Header = reqHeaders
339 googleapi.Expand(req.URL, map[string]string{
340 "productId": c.productId,
341 "skuId": c.skuId,
342 "userId": c.userId,
343 })
344 return gensupport.SendRequest(c.ctx_, c.s.client, req)
345 }
346
347
348
349
350
351
352 func (c *LicenseAssignmentsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
353 gensupport.SetOptions(c.urlParams_, opts...)
354 res, err := c.doRequest("json")
355 if res != nil && res.StatusCode == http.StatusNotModified {
356 if res.Body != nil {
357 res.Body.Close()
358 }
359 return nil, gensupport.WrapError(&googleapi.Error{
360 Code: res.StatusCode,
361 Header: res.Header,
362 })
363 }
364 if err != nil {
365 return nil, err
366 }
367 defer googleapi.CloseBody(res)
368 if err := googleapi.CheckResponse(res); err != nil {
369 return nil, gensupport.WrapError(err)
370 }
371 ret := &Empty{
372 ServerResponse: googleapi.ServerResponse{
373 Header: res.Header,
374 HTTPStatusCode: res.StatusCode,
375 },
376 }
377 target := &ret
378 if err := gensupport.DecodeResponse(target, res); err != nil {
379 return nil, err
380 }
381 return ret, nil
382 }
383
384 type LicenseAssignmentsGetCall struct {
385 s *Service
386 productId string
387 skuId string
388 userId string
389 urlParams_ gensupport.URLParams
390 ifNoneMatch_ string
391 ctx_ context.Context
392 header_ http.Header
393 }
394
395
396
397
398
399
400
401
402
403
404
405
406 func (r *LicenseAssignmentsService) Get(productId string, skuId string, userId string) *LicenseAssignmentsGetCall {
407 c := &LicenseAssignmentsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
408 c.productId = productId
409 c.skuId = skuId
410 c.userId = userId
411 return c
412 }
413
414
415
416
417 func (c *LicenseAssignmentsGetCall) Fields(s ...googleapi.Field) *LicenseAssignmentsGetCall {
418 c.urlParams_.Set("fields", googleapi.CombineFields(s))
419 return c
420 }
421
422
423
424
425 func (c *LicenseAssignmentsGetCall) IfNoneMatch(entityTag string) *LicenseAssignmentsGetCall {
426 c.ifNoneMatch_ = entityTag
427 return c
428 }
429
430
431 func (c *LicenseAssignmentsGetCall) Context(ctx context.Context) *LicenseAssignmentsGetCall {
432 c.ctx_ = ctx
433 return c
434 }
435
436
437
438 func (c *LicenseAssignmentsGetCall) Header() http.Header {
439 if c.header_ == nil {
440 c.header_ = make(http.Header)
441 }
442 return c.header_
443 }
444
445 func (c *LicenseAssignmentsGetCall) doRequest(alt string) (*http.Response, error) {
446 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
447 if c.ifNoneMatch_ != "" {
448 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
449 }
450 var body io.Reader = nil
451 c.urlParams_.Set("alt", alt)
452 c.urlParams_.Set("prettyPrint", "false")
453 urls := googleapi.ResolveRelative(c.s.BasePath, "apps/licensing/v1/product/{productId}/sku/{skuId}/user/{userId}")
454 urls += "?" + c.urlParams_.Encode()
455 req, err := http.NewRequest("GET", urls, body)
456 if err != nil {
457 return nil, err
458 }
459 req.Header = reqHeaders
460 googleapi.Expand(req.URL, map[string]string{
461 "productId": c.productId,
462 "skuId": c.skuId,
463 "userId": c.userId,
464 })
465 return gensupport.SendRequest(c.ctx_, c.s.client, req)
466 }
467
468
469
470
471
472
473
474 func (c *LicenseAssignmentsGetCall) Do(opts ...googleapi.CallOption) (*LicenseAssignment, error) {
475 gensupport.SetOptions(c.urlParams_, opts...)
476 res, err := c.doRequest("json")
477 if res != nil && res.StatusCode == http.StatusNotModified {
478 if res.Body != nil {
479 res.Body.Close()
480 }
481 return nil, gensupport.WrapError(&googleapi.Error{
482 Code: res.StatusCode,
483 Header: res.Header,
484 })
485 }
486 if err != nil {
487 return nil, err
488 }
489 defer googleapi.CloseBody(res)
490 if err := googleapi.CheckResponse(res); err != nil {
491 return nil, gensupport.WrapError(err)
492 }
493 ret := &LicenseAssignment{
494 ServerResponse: googleapi.ServerResponse{
495 Header: res.Header,
496 HTTPStatusCode: res.StatusCode,
497 },
498 }
499 target := &ret
500 if err := gensupport.DecodeResponse(target, res); err != nil {
501 return nil, err
502 }
503 return ret, nil
504 }
505
506 type LicenseAssignmentsInsertCall struct {
507 s *Service
508 productId string
509 skuId string
510 licenseassignmentinsert *LicenseAssignmentInsert
511 urlParams_ gensupport.URLParams
512 ctx_ context.Context
513 header_ http.Header
514 }
515
516
517
518
519
520
521
522 func (r *LicenseAssignmentsService) Insert(productId string, skuId string, licenseassignmentinsert *LicenseAssignmentInsert) *LicenseAssignmentsInsertCall {
523 c := &LicenseAssignmentsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
524 c.productId = productId
525 c.skuId = skuId
526 c.licenseassignmentinsert = licenseassignmentinsert
527 return c
528 }
529
530
531
532
533 func (c *LicenseAssignmentsInsertCall) Fields(s ...googleapi.Field) *LicenseAssignmentsInsertCall {
534 c.urlParams_.Set("fields", googleapi.CombineFields(s))
535 return c
536 }
537
538
539 func (c *LicenseAssignmentsInsertCall) Context(ctx context.Context) *LicenseAssignmentsInsertCall {
540 c.ctx_ = ctx
541 return c
542 }
543
544
545
546 func (c *LicenseAssignmentsInsertCall) Header() http.Header {
547 if c.header_ == nil {
548 c.header_ = make(http.Header)
549 }
550 return c.header_
551 }
552
553 func (c *LicenseAssignmentsInsertCall) doRequest(alt string) (*http.Response, error) {
554 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
555 var body io.Reader = nil
556 body, err := googleapi.WithoutDataWrapper.JSONReader(c.licenseassignmentinsert)
557 if err != nil {
558 return nil, err
559 }
560 c.urlParams_.Set("alt", alt)
561 c.urlParams_.Set("prettyPrint", "false")
562 urls := googleapi.ResolveRelative(c.s.BasePath, "apps/licensing/v1/product/{productId}/sku/{skuId}/user")
563 urls += "?" + c.urlParams_.Encode()
564 req, err := http.NewRequest("POST", urls, body)
565 if err != nil {
566 return nil, err
567 }
568 req.Header = reqHeaders
569 googleapi.Expand(req.URL, map[string]string{
570 "productId": c.productId,
571 "skuId": c.skuId,
572 })
573 return gensupport.SendRequest(c.ctx_, c.s.client, req)
574 }
575
576
577
578
579
580
581
582 func (c *LicenseAssignmentsInsertCall) Do(opts ...googleapi.CallOption) (*LicenseAssignment, error) {
583 gensupport.SetOptions(c.urlParams_, opts...)
584 res, err := c.doRequest("json")
585 if res != nil && res.StatusCode == http.StatusNotModified {
586 if res.Body != nil {
587 res.Body.Close()
588 }
589 return nil, gensupport.WrapError(&googleapi.Error{
590 Code: res.StatusCode,
591 Header: res.Header,
592 })
593 }
594 if err != nil {
595 return nil, err
596 }
597 defer googleapi.CloseBody(res)
598 if err := googleapi.CheckResponse(res); err != nil {
599 return nil, gensupport.WrapError(err)
600 }
601 ret := &LicenseAssignment{
602 ServerResponse: googleapi.ServerResponse{
603 Header: res.Header,
604 HTTPStatusCode: res.StatusCode,
605 },
606 }
607 target := &ret
608 if err := gensupport.DecodeResponse(target, res); err != nil {
609 return nil, err
610 }
611 return ret, nil
612 }
613
614 type LicenseAssignmentsListForProductCall struct {
615 s *Service
616 productId string
617 urlParams_ gensupport.URLParams
618 ifNoneMatch_ string
619 ctx_ context.Context
620 header_ http.Header
621 }
622
623
624
625
626
627
628
629 func (r *LicenseAssignmentsService) ListForProduct(productId string, customerId string) *LicenseAssignmentsListForProductCall {
630 c := &LicenseAssignmentsListForProductCall{s: r.s, urlParams_: make(gensupport.URLParams)}
631 c.productId = productId
632 c.urlParams_.Set("customerId", customerId)
633 return c
634 }
635
636
637
638
639
640 func (c *LicenseAssignmentsListForProductCall) MaxResults(maxResults int64) *LicenseAssignmentsListForProductCall {
641 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
642 return c
643 }
644
645
646
647
648
649
650 func (c *LicenseAssignmentsListForProductCall) PageToken(pageToken string) *LicenseAssignmentsListForProductCall {
651 c.urlParams_.Set("pageToken", pageToken)
652 return c
653 }
654
655
656
657
658 func (c *LicenseAssignmentsListForProductCall) Fields(s ...googleapi.Field) *LicenseAssignmentsListForProductCall {
659 c.urlParams_.Set("fields", googleapi.CombineFields(s))
660 return c
661 }
662
663
664
665
666 func (c *LicenseAssignmentsListForProductCall) IfNoneMatch(entityTag string) *LicenseAssignmentsListForProductCall {
667 c.ifNoneMatch_ = entityTag
668 return c
669 }
670
671
672 func (c *LicenseAssignmentsListForProductCall) Context(ctx context.Context) *LicenseAssignmentsListForProductCall {
673 c.ctx_ = ctx
674 return c
675 }
676
677
678
679 func (c *LicenseAssignmentsListForProductCall) Header() http.Header {
680 if c.header_ == nil {
681 c.header_ = make(http.Header)
682 }
683 return c.header_
684 }
685
686 func (c *LicenseAssignmentsListForProductCall) doRequest(alt string) (*http.Response, error) {
687 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
688 if c.ifNoneMatch_ != "" {
689 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
690 }
691 var body io.Reader = nil
692 c.urlParams_.Set("alt", alt)
693 c.urlParams_.Set("prettyPrint", "false")
694 urls := googleapi.ResolveRelative(c.s.BasePath, "apps/licensing/v1/product/{productId}/users")
695 urls += "?" + c.urlParams_.Encode()
696 req, err := http.NewRequest("GET", urls, body)
697 if err != nil {
698 return nil, err
699 }
700 req.Header = reqHeaders
701 googleapi.Expand(req.URL, map[string]string{
702 "productId": c.productId,
703 })
704 return gensupport.SendRequest(c.ctx_, c.s.client, req)
705 }
706
707
708
709
710
711
712
713 func (c *LicenseAssignmentsListForProductCall) Do(opts ...googleapi.CallOption) (*LicenseAssignmentList, error) {
714 gensupport.SetOptions(c.urlParams_, opts...)
715 res, err := c.doRequest("json")
716 if res != nil && res.StatusCode == http.StatusNotModified {
717 if res.Body != nil {
718 res.Body.Close()
719 }
720 return nil, gensupport.WrapError(&googleapi.Error{
721 Code: res.StatusCode,
722 Header: res.Header,
723 })
724 }
725 if err != nil {
726 return nil, err
727 }
728 defer googleapi.CloseBody(res)
729 if err := googleapi.CheckResponse(res); err != nil {
730 return nil, gensupport.WrapError(err)
731 }
732 ret := &LicenseAssignmentList{
733 ServerResponse: googleapi.ServerResponse{
734 Header: res.Header,
735 HTTPStatusCode: res.StatusCode,
736 },
737 }
738 target := &ret
739 if err := gensupport.DecodeResponse(target, res); err != nil {
740 return nil, err
741 }
742 return ret, nil
743 }
744
745
746
747
748 func (c *LicenseAssignmentsListForProductCall) Pages(ctx context.Context, f func(*LicenseAssignmentList) error) error {
749 c.ctx_ = ctx
750 defer c.PageToken(c.urlParams_.Get("pageToken"))
751 for {
752 x, err := c.Do()
753 if err != nil {
754 return err
755 }
756 if err := f(x); err != nil {
757 return err
758 }
759 if x.NextPageToken == "" {
760 return nil
761 }
762 c.PageToken(x.NextPageToken)
763 }
764 }
765
766 type LicenseAssignmentsListForProductAndSkuCall struct {
767 s *Service
768 productId string
769 skuId string
770 urlParams_ gensupport.URLParams
771 ifNoneMatch_ string
772 ctx_ context.Context
773 header_ http.Header
774 }
775
776
777
778
779
780
781
782
783
784
785 func (r *LicenseAssignmentsService) ListForProductAndSku(productId string, skuId string, customerId string) *LicenseAssignmentsListForProductAndSkuCall {
786 c := &LicenseAssignmentsListForProductAndSkuCall{s: r.s, urlParams_: make(gensupport.URLParams)}
787 c.productId = productId
788 c.skuId = skuId
789 c.urlParams_.Set("customerId", customerId)
790 return c
791 }
792
793
794
795
796
797 func (c *LicenseAssignmentsListForProductAndSkuCall) MaxResults(maxResults int64) *LicenseAssignmentsListForProductAndSkuCall {
798 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
799 return c
800 }
801
802
803
804
805
806
807 func (c *LicenseAssignmentsListForProductAndSkuCall) PageToken(pageToken string) *LicenseAssignmentsListForProductAndSkuCall {
808 c.urlParams_.Set("pageToken", pageToken)
809 return c
810 }
811
812
813
814
815 func (c *LicenseAssignmentsListForProductAndSkuCall) Fields(s ...googleapi.Field) *LicenseAssignmentsListForProductAndSkuCall {
816 c.urlParams_.Set("fields", googleapi.CombineFields(s))
817 return c
818 }
819
820
821
822
823 func (c *LicenseAssignmentsListForProductAndSkuCall) IfNoneMatch(entityTag string) *LicenseAssignmentsListForProductAndSkuCall {
824 c.ifNoneMatch_ = entityTag
825 return c
826 }
827
828
829 func (c *LicenseAssignmentsListForProductAndSkuCall) Context(ctx context.Context) *LicenseAssignmentsListForProductAndSkuCall {
830 c.ctx_ = ctx
831 return c
832 }
833
834
835
836 func (c *LicenseAssignmentsListForProductAndSkuCall) Header() http.Header {
837 if c.header_ == nil {
838 c.header_ = make(http.Header)
839 }
840 return c.header_
841 }
842
843 func (c *LicenseAssignmentsListForProductAndSkuCall) doRequest(alt string) (*http.Response, error) {
844 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
845 if c.ifNoneMatch_ != "" {
846 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
847 }
848 var body io.Reader = nil
849 c.urlParams_.Set("alt", alt)
850 c.urlParams_.Set("prettyPrint", "false")
851 urls := googleapi.ResolveRelative(c.s.BasePath, "apps/licensing/v1/product/{productId}/sku/{skuId}/users")
852 urls += "?" + c.urlParams_.Encode()
853 req, err := http.NewRequest("GET", urls, body)
854 if err != nil {
855 return nil, err
856 }
857 req.Header = reqHeaders
858 googleapi.Expand(req.URL, map[string]string{
859 "productId": c.productId,
860 "skuId": c.skuId,
861 })
862 return gensupport.SendRequest(c.ctx_, c.s.client, req)
863 }
864
865
866
867
868
869
870
871 func (c *LicenseAssignmentsListForProductAndSkuCall) Do(opts ...googleapi.CallOption) (*LicenseAssignmentList, error) {
872 gensupport.SetOptions(c.urlParams_, opts...)
873 res, err := c.doRequest("json")
874 if res != nil && res.StatusCode == http.StatusNotModified {
875 if res.Body != nil {
876 res.Body.Close()
877 }
878 return nil, gensupport.WrapError(&googleapi.Error{
879 Code: res.StatusCode,
880 Header: res.Header,
881 })
882 }
883 if err != nil {
884 return nil, err
885 }
886 defer googleapi.CloseBody(res)
887 if err := googleapi.CheckResponse(res); err != nil {
888 return nil, gensupport.WrapError(err)
889 }
890 ret := &LicenseAssignmentList{
891 ServerResponse: googleapi.ServerResponse{
892 Header: res.Header,
893 HTTPStatusCode: res.StatusCode,
894 },
895 }
896 target := &ret
897 if err := gensupport.DecodeResponse(target, res); err != nil {
898 return nil, err
899 }
900 return ret, nil
901 }
902
903
904
905
906 func (c *LicenseAssignmentsListForProductAndSkuCall) Pages(ctx context.Context, f func(*LicenseAssignmentList) error) error {
907 c.ctx_ = ctx
908 defer c.PageToken(c.urlParams_.Get("pageToken"))
909 for {
910 x, err := c.Do()
911 if err != nil {
912 return err
913 }
914 if err := f(x); err != nil {
915 return err
916 }
917 if x.NextPageToken == "" {
918 return nil
919 }
920 c.PageToken(x.NextPageToken)
921 }
922 }
923
924 type LicenseAssignmentsPatchCall struct {
925 s *Service
926 productId string
927 skuId string
928 userId string
929 licenseassignment *LicenseAssignment
930 urlParams_ gensupport.URLParams
931 ctx_ context.Context
932 header_ http.Header
933 }
934
935
936
937
938
939
940
941
942
943
944
945
946
947 func (r *LicenseAssignmentsService) Patch(productId string, skuId string, userId string, licenseassignment *LicenseAssignment) *LicenseAssignmentsPatchCall {
948 c := &LicenseAssignmentsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
949 c.productId = productId
950 c.skuId = skuId
951 c.userId = userId
952 c.licenseassignment = licenseassignment
953 return c
954 }
955
956
957
958
959 func (c *LicenseAssignmentsPatchCall) Fields(s ...googleapi.Field) *LicenseAssignmentsPatchCall {
960 c.urlParams_.Set("fields", googleapi.CombineFields(s))
961 return c
962 }
963
964
965 func (c *LicenseAssignmentsPatchCall) Context(ctx context.Context) *LicenseAssignmentsPatchCall {
966 c.ctx_ = ctx
967 return c
968 }
969
970
971
972 func (c *LicenseAssignmentsPatchCall) Header() http.Header {
973 if c.header_ == nil {
974 c.header_ = make(http.Header)
975 }
976 return c.header_
977 }
978
979 func (c *LicenseAssignmentsPatchCall) doRequest(alt string) (*http.Response, error) {
980 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
981 var body io.Reader = nil
982 body, err := googleapi.WithoutDataWrapper.JSONReader(c.licenseassignment)
983 if err != nil {
984 return nil, err
985 }
986 c.urlParams_.Set("alt", alt)
987 c.urlParams_.Set("prettyPrint", "false")
988 urls := googleapi.ResolveRelative(c.s.BasePath, "apps/licensing/v1/product/{productId}/sku/{skuId}/user/{userId}")
989 urls += "?" + c.urlParams_.Encode()
990 req, err := http.NewRequest("PATCH", urls, body)
991 if err != nil {
992 return nil, err
993 }
994 req.Header = reqHeaders
995 googleapi.Expand(req.URL, map[string]string{
996 "productId": c.productId,
997 "skuId": c.skuId,
998 "userId": c.userId,
999 })
1000 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1001 }
1002
1003
1004
1005
1006
1007
1008
1009 func (c *LicenseAssignmentsPatchCall) Do(opts ...googleapi.CallOption) (*LicenseAssignment, error) {
1010 gensupport.SetOptions(c.urlParams_, opts...)
1011 res, err := c.doRequest("json")
1012 if res != nil && res.StatusCode == http.StatusNotModified {
1013 if res.Body != nil {
1014 res.Body.Close()
1015 }
1016 return nil, gensupport.WrapError(&googleapi.Error{
1017 Code: res.StatusCode,
1018 Header: res.Header,
1019 })
1020 }
1021 if err != nil {
1022 return nil, err
1023 }
1024 defer googleapi.CloseBody(res)
1025 if err := googleapi.CheckResponse(res); err != nil {
1026 return nil, gensupport.WrapError(err)
1027 }
1028 ret := &LicenseAssignment{
1029 ServerResponse: googleapi.ServerResponse{
1030 Header: res.Header,
1031 HTTPStatusCode: res.StatusCode,
1032 },
1033 }
1034 target := &ret
1035 if err := gensupport.DecodeResponse(target, res); err != nil {
1036 return nil, err
1037 }
1038 return ret, nil
1039 }
1040
1041 type LicenseAssignmentsUpdateCall struct {
1042 s *Service
1043 productId string
1044 skuId string
1045 userId string
1046 licenseassignment *LicenseAssignment
1047 urlParams_ gensupport.URLParams
1048 ctx_ context.Context
1049 header_ http.Header
1050 }
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064 func (r *LicenseAssignmentsService) Update(productId string, skuId string, userId string, licenseassignment *LicenseAssignment) *LicenseAssignmentsUpdateCall {
1065 c := &LicenseAssignmentsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1066 c.productId = productId
1067 c.skuId = skuId
1068 c.userId = userId
1069 c.licenseassignment = licenseassignment
1070 return c
1071 }
1072
1073
1074
1075
1076 func (c *LicenseAssignmentsUpdateCall) Fields(s ...googleapi.Field) *LicenseAssignmentsUpdateCall {
1077 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1078 return c
1079 }
1080
1081
1082 func (c *LicenseAssignmentsUpdateCall) Context(ctx context.Context) *LicenseAssignmentsUpdateCall {
1083 c.ctx_ = ctx
1084 return c
1085 }
1086
1087
1088
1089 func (c *LicenseAssignmentsUpdateCall) Header() http.Header {
1090 if c.header_ == nil {
1091 c.header_ = make(http.Header)
1092 }
1093 return c.header_
1094 }
1095
1096 func (c *LicenseAssignmentsUpdateCall) doRequest(alt string) (*http.Response, error) {
1097 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1098 var body io.Reader = nil
1099 body, err := googleapi.WithoutDataWrapper.JSONReader(c.licenseassignment)
1100 if err != nil {
1101 return nil, err
1102 }
1103 c.urlParams_.Set("alt", alt)
1104 c.urlParams_.Set("prettyPrint", "false")
1105 urls := googleapi.ResolveRelative(c.s.BasePath, "apps/licensing/v1/product/{productId}/sku/{skuId}/user/{userId}")
1106 urls += "?" + c.urlParams_.Encode()
1107 req, err := http.NewRequest("PUT", urls, body)
1108 if err != nil {
1109 return nil, err
1110 }
1111 req.Header = reqHeaders
1112 googleapi.Expand(req.URL, map[string]string{
1113 "productId": c.productId,
1114 "skuId": c.skuId,
1115 "userId": c.userId,
1116 })
1117 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1118 }
1119
1120
1121
1122
1123
1124
1125
1126 func (c *LicenseAssignmentsUpdateCall) Do(opts ...googleapi.CallOption) (*LicenseAssignment, error) {
1127 gensupport.SetOptions(c.urlParams_, opts...)
1128 res, err := c.doRequest("json")
1129 if res != nil && res.StatusCode == http.StatusNotModified {
1130 if res.Body != nil {
1131 res.Body.Close()
1132 }
1133 return nil, gensupport.WrapError(&googleapi.Error{
1134 Code: res.StatusCode,
1135 Header: res.Header,
1136 })
1137 }
1138 if err != nil {
1139 return nil, err
1140 }
1141 defer googleapi.CloseBody(res)
1142 if err := googleapi.CheckResponse(res); err != nil {
1143 return nil, gensupport.WrapError(err)
1144 }
1145 ret := &LicenseAssignment{
1146 ServerResponse: googleapi.ServerResponse{
1147 Header: res.Header,
1148 HTTPStatusCode: res.StatusCode,
1149 },
1150 }
1151 target := &ret
1152 if err := gensupport.DecodeResponse(target, res); err != nil {
1153 return nil, err
1154 }
1155 return ret, nil
1156 }
1157
View as plain text