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 readerrevenuesubscriptionlinking
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 = "readerrevenuesubscriptionlinking:v1"
90 const apiName = "readerrevenuesubscriptionlinking"
91 const apiVersion = "v1"
92 const basePath = "https://readerrevenuesubscriptionlinking.googleapis.com/"
93 const basePathTemplate = "https://readerrevenuesubscriptionlinking.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://readerrevenuesubscriptionlinking.mtls.googleapis.com/"
95
96
97 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
98 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
99 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
100 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
101 opts = append(opts, internaloption.EnableNewAuthLibrary())
102 client, endpoint, err := htransport.NewClient(ctx, opts...)
103 if err != nil {
104 return nil, err
105 }
106 s, err := New(client)
107 if err != nil {
108 return nil, err
109 }
110 if endpoint != "" {
111 s.BasePath = endpoint
112 }
113 return s, nil
114 }
115
116
117
118
119
120
121 func New(client *http.Client) (*Service, error) {
122 if client == nil {
123 return nil, errors.New("client is nil")
124 }
125 s := &Service{client: client, BasePath: basePath}
126 s.Publications = NewPublicationsService(s)
127 return s, nil
128 }
129
130 type Service struct {
131 client *http.Client
132 BasePath string
133 UserAgent string
134
135 Publications *PublicationsService
136 }
137
138 func (s *Service) userAgent() string {
139 if s.UserAgent == "" {
140 return googleapi.UserAgent
141 }
142 return googleapi.UserAgent + " " + s.UserAgent
143 }
144
145 func NewPublicationsService(s *Service) *PublicationsService {
146 rs := &PublicationsService{s: s}
147 rs.Readers = NewPublicationsReadersService(s)
148 return rs
149 }
150
151 type PublicationsService struct {
152 s *Service
153
154 Readers *PublicationsReadersService
155 }
156
157 func NewPublicationsReadersService(s *Service) *PublicationsReadersService {
158 rs := &PublicationsReadersService{s: s}
159 return rs
160 }
161
162 type PublicationsReadersService struct {
163 s *Service
164 }
165
166
167 type DeleteReaderResponse struct {
168
169 googleapi.ServerResponse `json:"-"`
170 }
171
172
173 type Entitlement struct {
174
175
176
177
178
179 Detail string `json:"detail,omitempty"`
180
181
182
183
184
185 ExpireTime string `json:"expireTime,omitempty"`
186
187
188
189 ProductId string `json:"productId,omitempty"`
190
191
192
193 SubscriptionToken string `json:"subscriptionToken,omitempty"`
194
195
196
197
198
199 ForceSendFields []string `json:"-"`
200
201
202
203
204 NullFields []string `json:"-"`
205 }
206
207 func (s *Entitlement) MarshalJSON() ([]byte, error) {
208 type NoMethod Entitlement
209 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
210 }
211
212
213 type Reader struct {
214
215
216 CreateTime string `json:"createTime,omitempty"`
217
218
219 Name string `json:"name,omitempty"`
220
221
222 googleapi.ServerResponse `json:"-"`
223
224
225
226
227
228 ForceSendFields []string `json:"-"`
229
230
231
232
233 NullFields []string `json:"-"`
234 }
235
236 func (s *Reader) MarshalJSON() ([]byte, error) {
237 type NoMethod Reader
238 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
239 }
240
241
242
243 type ReaderEntitlements struct {
244
245 Entitlements []*Entitlement `json:"entitlements,omitempty"`
246
247 Name string `json:"name,omitempty"`
248
249
250 googleapi.ServerResponse `json:"-"`
251
252
253
254
255
256 ForceSendFields []string `json:"-"`
257
258
259
260
261 NullFields []string `json:"-"`
262 }
263
264 func (s *ReaderEntitlements) MarshalJSON() ([]byte, error) {
265 type NoMethod ReaderEntitlements
266 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
267 }
268
269 type PublicationsReadersDeleteCall struct {
270 s *Service
271 name string
272 urlParams_ gensupport.URLParams
273 ctx_ context.Context
274 header_ http.Header
275 }
276
277
278
279
280
281
282
283
284
285
286 func (r *PublicationsReadersService) Delete(name string) *PublicationsReadersDeleteCall {
287 c := &PublicationsReadersDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
288 c.name = name
289 return c
290 }
291
292
293
294 func (c *PublicationsReadersDeleteCall) Force(force bool) *PublicationsReadersDeleteCall {
295 c.urlParams_.Set("force", fmt.Sprint(force))
296 return c
297 }
298
299
300
301
302 func (c *PublicationsReadersDeleteCall) Fields(s ...googleapi.Field) *PublicationsReadersDeleteCall {
303 c.urlParams_.Set("fields", googleapi.CombineFields(s))
304 return c
305 }
306
307
308 func (c *PublicationsReadersDeleteCall) Context(ctx context.Context) *PublicationsReadersDeleteCall {
309 c.ctx_ = ctx
310 return c
311 }
312
313
314
315 func (c *PublicationsReadersDeleteCall) Header() http.Header {
316 if c.header_ == nil {
317 c.header_ = make(http.Header)
318 }
319 return c.header_
320 }
321
322 func (c *PublicationsReadersDeleteCall) doRequest(alt string) (*http.Response, error) {
323 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
324 var body io.Reader = nil
325 c.urlParams_.Set("alt", alt)
326 c.urlParams_.Set("prettyPrint", "false")
327 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
328 urls += "?" + c.urlParams_.Encode()
329 req, err := http.NewRequest("DELETE", urls, body)
330 if err != nil {
331 return nil, err
332 }
333 req.Header = reqHeaders
334 googleapi.Expand(req.URL, map[string]string{
335 "name": c.name,
336 })
337 return gensupport.SendRequest(c.ctx_, c.s.client, req)
338 }
339
340
341
342
343
344
345
346 func (c *PublicationsReadersDeleteCall) Do(opts ...googleapi.CallOption) (*DeleteReaderResponse, error) {
347 gensupport.SetOptions(c.urlParams_, opts...)
348 res, err := c.doRequest("json")
349 if res != nil && res.StatusCode == http.StatusNotModified {
350 if res.Body != nil {
351 res.Body.Close()
352 }
353 return nil, gensupport.WrapError(&googleapi.Error{
354 Code: res.StatusCode,
355 Header: res.Header,
356 })
357 }
358 if err != nil {
359 return nil, err
360 }
361 defer googleapi.CloseBody(res)
362 if err := googleapi.CheckResponse(res); err != nil {
363 return nil, gensupport.WrapError(err)
364 }
365 ret := &DeleteReaderResponse{
366 ServerResponse: googleapi.ServerResponse{
367 Header: res.Header,
368 HTTPStatusCode: res.StatusCode,
369 },
370 }
371 target := &ret
372 if err := gensupport.DecodeResponse(target, res); err != nil {
373 return nil, err
374 }
375 return ret, nil
376 }
377
378 type PublicationsReadersGetCall struct {
379 s *Service
380 name string
381 urlParams_ gensupport.URLParams
382 ifNoneMatch_ string
383 ctx_ context.Context
384 header_ http.Header
385 }
386
387
388
389
390
391
392 func (r *PublicationsReadersService) Get(name string) *PublicationsReadersGetCall {
393 c := &PublicationsReadersGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
394 c.name = name
395 return c
396 }
397
398
399
400
401 func (c *PublicationsReadersGetCall) Fields(s ...googleapi.Field) *PublicationsReadersGetCall {
402 c.urlParams_.Set("fields", googleapi.CombineFields(s))
403 return c
404 }
405
406
407
408
409 func (c *PublicationsReadersGetCall) IfNoneMatch(entityTag string) *PublicationsReadersGetCall {
410 c.ifNoneMatch_ = entityTag
411 return c
412 }
413
414
415 func (c *PublicationsReadersGetCall) Context(ctx context.Context) *PublicationsReadersGetCall {
416 c.ctx_ = ctx
417 return c
418 }
419
420
421
422 func (c *PublicationsReadersGetCall) Header() http.Header {
423 if c.header_ == nil {
424 c.header_ = make(http.Header)
425 }
426 return c.header_
427 }
428
429 func (c *PublicationsReadersGetCall) doRequest(alt string) (*http.Response, error) {
430 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
431 if c.ifNoneMatch_ != "" {
432 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
433 }
434 var body io.Reader = nil
435 c.urlParams_.Set("alt", alt)
436 c.urlParams_.Set("prettyPrint", "false")
437 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
438 urls += "?" + c.urlParams_.Encode()
439 req, err := http.NewRequest("GET", urls, body)
440 if err != nil {
441 return nil, err
442 }
443 req.Header = reqHeaders
444 googleapi.Expand(req.URL, map[string]string{
445 "name": c.name,
446 })
447 return gensupport.SendRequest(c.ctx_, c.s.client, req)
448 }
449
450
451
452
453
454
455 func (c *PublicationsReadersGetCall) Do(opts ...googleapi.CallOption) (*Reader, error) {
456 gensupport.SetOptions(c.urlParams_, opts...)
457 res, err := c.doRequest("json")
458 if res != nil && res.StatusCode == http.StatusNotModified {
459 if res.Body != nil {
460 res.Body.Close()
461 }
462 return nil, gensupport.WrapError(&googleapi.Error{
463 Code: res.StatusCode,
464 Header: res.Header,
465 })
466 }
467 if err != nil {
468 return nil, err
469 }
470 defer googleapi.CloseBody(res)
471 if err := googleapi.CheckResponse(res); err != nil {
472 return nil, gensupport.WrapError(err)
473 }
474 ret := &Reader{
475 ServerResponse: googleapi.ServerResponse{
476 Header: res.Header,
477 HTTPStatusCode: res.StatusCode,
478 },
479 }
480 target := &ret
481 if err := gensupport.DecodeResponse(target, res); err != nil {
482 return nil, err
483 }
484 return ret, nil
485 }
486
487 type PublicationsReadersGetEntitlementsCall struct {
488 s *Service
489 name string
490 urlParams_ gensupport.URLParams
491 ifNoneMatch_ string
492 ctx_ context.Context
493 header_ http.Header
494 }
495
496
497
498
499
500
501
502 func (r *PublicationsReadersService) GetEntitlements(name string) *PublicationsReadersGetEntitlementsCall {
503 c := &PublicationsReadersGetEntitlementsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
504 c.name = name
505 return c
506 }
507
508
509
510
511 func (c *PublicationsReadersGetEntitlementsCall) Fields(s ...googleapi.Field) *PublicationsReadersGetEntitlementsCall {
512 c.urlParams_.Set("fields", googleapi.CombineFields(s))
513 return c
514 }
515
516
517
518
519 func (c *PublicationsReadersGetEntitlementsCall) IfNoneMatch(entityTag string) *PublicationsReadersGetEntitlementsCall {
520 c.ifNoneMatch_ = entityTag
521 return c
522 }
523
524
525 func (c *PublicationsReadersGetEntitlementsCall) Context(ctx context.Context) *PublicationsReadersGetEntitlementsCall {
526 c.ctx_ = ctx
527 return c
528 }
529
530
531
532 func (c *PublicationsReadersGetEntitlementsCall) Header() http.Header {
533 if c.header_ == nil {
534 c.header_ = make(http.Header)
535 }
536 return c.header_
537 }
538
539 func (c *PublicationsReadersGetEntitlementsCall) doRequest(alt string) (*http.Response, error) {
540 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
541 if c.ifNoneMatch_ != "" {
542 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
543 }
544 var body io.Reader = nil
545 c.urlParams_.Set("alt", alt)
546 c.urlParams_.Set("prettyPrint", "false")
547 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
548 urls += "?" + c.urlParams_.Encode()
549 req, err := http.NewRequest("GET", urls, body)
550 if err != nil {
551 return nil, err
552 }
553 req.Header = reqHeaders
554 googleapi.Expand(req.URL, map[string]string{
555 "name": c.name,
556 })
557 return gensupport.SendRequest(c.ctx_, c.s.client, req)
558 }
559
560
561
562
563
564
565
566 func (c *PublicationsReadersGetEntitlementsCall) Do(opts ...googleapi.CallOption) (*ReaderEntitlements, error) {
567 gensupport.SetOptions(c.urlParams_, opts...)
568 res, err := c.doRequest("json")
569 if res != nil && res.StatusCode == http.StatusNotModified {
570 if res.Body != nil {
571 res.Body.Close()
572 }
573 return nil, gensupport.WrapError(&googleapi.Error{
574 Code: res.StatusCode,
575 Header: res.Header,
576 })
577 }
578 if err != nil {
579 return nil, err
580 }
581 defer googleapi.CloseBody(res)
582 if err := googleapi.CheckResponse(res); err != nil {
583 return nil, gensupport.WrapError(err)
584 }
585 ret := &ReaderEntitlements{
586 ServerResponse: googleapi.ServerResponse{
587 Header: res.Header,
588 HTTPStatusCode: res.StatusCode,
589 },
590 }
591 target := &ret
592 if err := gensupport.DecodeResponse(target, res); err != nil {
593 return nil, err
594 }
595 return ret, nil
596 }
597
598 type PublicationsReadersUpdateEntitlementsCall struct {
599 s *Service
600 name string
601 readerentitlements *ReaderEntitlements
602 urlParams_ gensupport.URLParams
603 ctx_ context.Context
604 header_ http.Header
605 }
606
607
608
609
610
611
612
613
614 func (r *PublicationsReadersService) UpdateEntitlements(name string, readerentitlements *ReaderEntitlements) *PublicationsReadersUpdateEntitlementsCall {
615 c := &PublicationsReadersUpdateEntitlementsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
616 c.name = name
617 c.readerentitlements = readerentitlements
618 return c
619 }
620
621
622
623 func (c *PublicationsReadersUpdateEntitlementsCall) UpdateMask(updateMask string) *PublicationsReadersUpdateEntitlementsCall {
624 c.urlParams_.Set("updateMask", updateMask)
625 return c
626 }
627
628
629
630
631 func (c *PublicationsReadersUpdateEntitlementsCall) Fields(s ...googleapi.Field) *PublicationsReadersUpdateEntitlementsCall {
632 c.urlParams_.Set("fields", googleapi.CombineFields(s))
633 return c
634 }
635
636
637 func (c *PublicationsReadersUpdateEntitlementsCall) Context(ctx context.Context) *PublicationsReadersUpdateEntitlementsCall {
638 c.ctx_ = ctx
639 return c
640 }
641
642
643
644 func (c *PublicationsReadersUpdateEntitlementsCall) Header() http.Header {
645 if c.header_ == nil {
646 c.header_ = make(http.Header)
647 }
648 return c.header_
649 }
650
651 func (c *PublicationsReadersUpdateEntitlementsCall) doRequest(alt string) (*http.Response, error) {
652 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
653 var body io.Reader = nil
654 body, err := googleapi.WithoutDataWrapper.JSONReader(c.readerentitlements)
655 if err != nil {
656 return nil, err
657 }
658 c.urlParams_.Set("alt", alt)
659 c.urlParams_.Set("prettyPrint", "false")
660 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
661 urls += "?" + c.urlParams_.Encode()
662 req, err := http.NewRequest("PATCH", urls, body)
663 if err != nil {
664 return nil, err
665 }
666 req.Header = reqHeaders
667 googleapi.Expand(req.URL, map[string]string{
668 "name": c.name,
669 })
670 return gensupport.SendRequest(c.ctx_, c.s.client, req)
671 }
672
673
674
675
676
677
678
679 func (c *PublicationsReadersUpdateEntitlementsCall) Do(opts ...googleapi.CallOption) (*ReaderEntitlements, error) {
680 gensupport.SetOptions(c.urlParams_, opts...)
681 res, err := c.doRequest("json")
682 if res != nil && res.StatusCode == http.StatusNotModified {
683 if res.Body != nil {
684 res.Body.Close()
685 }
686 return nil, gensupport.WrapError(&googleapi.Error{
687 Code: res.StatusCode,
688 Header: res.Header,
689 })
690 }
691 if err != nil {
692 return nil, err
693 }
694 defer googleapi.CloseBody(res)
695 if err := googleapi.CheckResponse(res); err != nil {
696 return nil, gensupport.WrapError(err)
697 }
698 ret := &ReaderEntitlements{
699 ServerResponse: googleapi.ServerResponse{
700 Header: res.Header,
701 HTTPStatusCode: res.StatusCode,
702 },
703 }
704 target := &ret
705 if err := gensupport.DecodeResponse(target, res); err != nil {
706 return nil, err
707 }
708 return ret, nil
709 }
710
View as plain text