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 libraryagent
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 = "libraryagent:v1"
90 const apiName = "libraryagent"
91 const apiVersion = "v1"
92 const basePath = "https://libraryagent.googleapis.com/"
93 const basePathTemplate = "https://libraryagent.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://libraryagent.mtls.googleapis.com/"
95
96
97 const (
98
99
100 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
101 )
102
103
104 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
105 scopesOption := internaloption.WithDefaultScopes(
106 "https://www.googleapis.com/auth/cloud-platform",
107 )
108
109 opts = append([]option.ClientOption{scopesOption}, opts...)
110 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
111 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
112 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
113 opts = append(opts, internaloption.EnableNewAuthLibrary())
114 client, endpoint, err := htransport.NewClient(ctx, opts...)
115 if err != nil {
116 return nil, err
117 }
118 s, err := New(client)
119 if err != nil {
120 return nil, err
121 }
122 if endpoint != "" {
123 s.BasePath = endpoint
124 }
125 return s, nil
126 }
127
128
129
130
131
132
133 func New(client *http.Client) (*Service, error) {
134 if client == nil {
135 return nil, errors.New("client is nil")
136 }
137 s := &Service{client: client, BasePath: basePath}
138 s.Shelves = NewShelvesService(s)
139 return s, nil
140 }
141
142 type Service struct {
143 client *http.Client
144 BasePath string
145 UserAgent string
146
147 Shelves *ShelvesService
148 }
149
150 func (s *Service) userAgent() string {
151 if s.UserAgent == "" {
152 return googleapi.UserAgent
153 }
154 return googleapi.UserAgent + " " + s.UserAgent
155 }
156
157 func NewShelvesService(s *Service) *ShelvesService {
158 rs := &ShelvesService{s: s}
159 rs.Books = NewShelvesBooksService(s)
160 return rs
161 }
162
163 type ShelvesService struct {
164 s *Service
165
166 Books *ShelvesBooksService
167 }
168
169 func NewShelvesBooksService(s *Service) *ShelvesBooksService {
170 rs := &ShelvesBooksService{s: s}
171 return rs
172 }
173
174 type ShelvesBooksService struct {
175 s *Service
176 }
177
178
179 type GoogleExampleLibraryagentV1Book struct {
180
181 Author string `json:"author,omitempty"`
182
183
184
185 Name string `json:"name,omitempty"`
186
187 Read bool `json:"read,omitempty"`
188
189 Title string `json:"title,omitempty"`
190
191
192 googleapi.ServerResponse `json:"-"`
193
194
195
196
197
198 ForceSendFields []string `json:"-"`
199
200
201
202
203 NullFields []string `json:"-"`
204 }
205
206 func (s *GoogleExampleLibraryagentV1Book) MarshalJSON() ([]byte, error) {
207 type NoMethod GoogleExampleLibraryagentV1Book
208 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
209 }
210
211
212
213 type GoogleExampleLibraryagentV1ListBooksResponse struct {
214
215 Books []*GoogleExampleLibraryagentV1Book `json:"books,omitempty"`
216
217
218
219 NextPageToken string `json:"nextPageToken,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 *GoogleExampleLibraryagentV1ListBooksResponse) MarshalJSON() ([]byte, error) {
237 type NoMethod GoogleExampleLibraryagentV1ListBooksResponse
238 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
239 }
240
241
242
243 type GoogleExampleLibraryagentV1ListShelvesResponse struct {
244
245
246
247 NextPageToken string `json:"nextPageToken,omitempty"`
248
249 Shelves []*GoogleExampleLibraryagentV1Shelf `json:"shelves,omitempty"`
250
251
252 googleapi.ServerResponse `json:"-"`
253
254
255
256
257
258 ForceSendFields []string `json:"-"`
259
260
261
262
263 NullFields []string `json:"-"`
264 }
265
266 func (s *GoogleExampleLibraryagentV1ListShelvesResponse) MarshalJSON() ([]byte, error) {
267 type NoMethod GoogleExampleLibraryagentV1ListShelvesResponse
268 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
269 }
270
271
272
273 type GoogleExampleLibraryagentV1Shelf struct {
274
275
276 Name string `json:"name,omitempty"`
277
278 Theme string `json:"theme,omitempty"`
279
280
281 googleapi.ServerResponse `json:"-"`
282
283
284
285
286
287 ForceSendFields []string `json:"-"`
288
289
290
291
292 NullFields []string `json:"-"`
293 }
294
295 func (s *GoogleExampleLibraryagentV1Shelf) MarshalJSON() ([]byte, error) {
296 type NoMethod GoogleExampleLibraryagentV1Shelf
297 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
298 }
299
300 type ShelvesGetCall struct {
301 s *Service
302 name string
303 urlParams_ gensupport.URLParams
304 ifNoneMatch_ string
305 ctx_ context.Context
306 header_ http.Header
307 }
308
309
310
311
312 func (r *ShelvesService) Get(name string) *ShelvesGetCall {
313 c := &ShelvesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
314 c.name = name
315 return c
316 }
317
318
319
320
321 func (c *ShelvesGetCall) Fields(s ...googleapi.Field) *ShelvesGetCall {
322 c.urlParams_.Set("fields", googleapi.CombineFields(s))
323 return c
324 }
325
326
327
328
329 func (c *ShelvesGetCall) IfNoneMatch(entityTag string) *ShelvesGetCall {
330 c.ifNoneMatch_ = entityTag
331 return c
332 }
333
334
335 func (c *ShelvesGetCall) Context(ctx context.Context) *ShelvesGetCall {
336 c.ctx_ = ctx
337 return c
338 }
339
340
341
342 func (c *ShelvesGetCall) Header() http.Header {
343 if c.header_ == nil {
344 c.header_ = make(http.Header)
345 }
346 return c.header_
347 }
348
349 func (c *ShelvesGetCall) doRequest(alt string) (*http.Response, error) {
350 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
351 if c.ifNoneMatch_ != "" {
352 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
353 }
354 var body io.Reader = nil
355 c.urlParams_.Set("alt", alt)
356 c.urlParams_.Set("prettyPrint", "false")
357 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
358 urls += "?" + c.urlParams_.Encode()
359 req, err := http.NewRequest("GET", urls, body)
360 if err != nil {
361 return nil, err
362 }
363 req.Header = reqHeaders
364 googleapi.Expand(req.URL, map[string]string{
365 "name": c.name,
366 })
367 return gensupport.SendRequest(c.ctx_, c.s.client, req)
368 }
369
370
371
372
373
374
375
376 func (c *ShelvesGetCall) Do(opts ...googleapi.CallOption) (*GoogleExampleLibraryagentV1Shelf, error) {
377 gensupport.SetOptions(c.urlParams_, opts...)
378 res, err := c.doRequest("json")
379 if res != nil && res.StatusCode == http.StatusNotModified {
380 if res.Body != nil {
381 res.Body.Close()
382 }
383 return nil, gensupport.WrapError(&googleapi.Error{
384 Code: res.StatusCode,
385 Header: res.Header,
386 })
387 }
388 if err != nil {
389 return nil, err
390 }
391 defer googleapi.CloseBody(res)
392 if err := googleapi.CheckResponse(res); err != nil {
393 return nil, gensupport.WrapError(err)
394 }
395 ret := &GoogleExampleLibraryagentV1Shelf{
396 ServerResponse: googleapi.ServerResponse{
397 Header: res.Header,
398 HTTPStatusCode: res.StatusCode,
399 },
400 }
401 target := &ret
402 if err := gensupport.DecodeResponse(target, res); err != nil {
403 return nil, err
404 }
405 return ret, nil
406 }
407
408 type ShelvesListCall struct {
409 s *Service
410 urlParams_ gensupport.URLParams
411 ifNoneMatch_ string
412 ctx_ context.Context
413 header_ http.Header
414 }
415
416
417
418 func (r *ShelvesService) List() *ShelvesListCall {
419 c := &ShelvesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
420 return c
421 }
422
423
424
425
426 func (c *ShelvesListCall) PageSize(pageSize int64) *ShelvesListCall {
427 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
428 return c
429 }
430
431
432
433
434
435 func (c *ShelvesListCall) PageToken(pageToken string) *ShelvesListCall {
436 c.urlParams_.Set("pageToken", pageToken)
437 return c
438 }
439
440
441
442
443 func (c *ShelvesListCall) Fields(s ...googleapi.Field) *ShelvesListCall {
444 c.urlParams_.Set("fields", googleapi.CombineFields(s))
445 return c
446 }
447
448
449
450
451 func (c *ShelvesListCall) IfNoneMatch(entityTag string) *ShelvesListCall {
452 c.ifNoneMatch_ = entityTag
453 return c
454 }
455
456
457 func (c *ShelvesListCall) Context(ctx context.Context) *ShelvesListCall {
458 c.ctx_ = ctx
459 return c
460 }
461
462
463
464 func (c *ShelvesListCall) Header() http.Header {
465 if c.header_ == nil {
466 c.header_ = make(http.Header)
467 }
468 return c.header_
469 }
470
471 func (c *ShelvesListCall) doRequest(alt string) (*http.Response, error) {
472 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
473 if c.ifNoneMatch_ != "" {
474 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
475 }
476 var body io.Reader = nil
477 c.urlParams_.Set("alt", alt)
478 c.urlParams_.Set("prettyPrint", "false")
479 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/shelves")
480 urls += "?" + c.urlParams_.Encode()
481 req, err := http.NewRequest("GET", urls, body)
482 if err != nil {
483 return nil, err
484 }
485 req.Header = reqHeaders
486 return gensupport.SendRequest(c.ctx_, c.s.client, req)
487 }
488
489
490
491
492
493
494
495 func (c *ShelvesListCall) Do(opts ...googleapi.CallOption) (*GoogleExampleLibraryagentV1ListShelvesResponse, error) {
496 gensupport.SetOptions(c.urlParams_, opts...)
497 res, err := c.doRequest("json")
498 if res != nil && res.StatusCode == http.StatusNotModified {
499 if res.Body != nil {
500 res.Body.Close()
501 }
502 return nil, gensupport.WrapError(&googleapi.Error{
503 Code: res.StatusCode,
504 Header: res.Header,
505 })
506 }
507 if err != nil {
508 return nil, err
509 }
510 defer googleapi.CloseBody(res)
511 if err := googleapi.CheckResponse(res); err != nil {
512 return nil, gensupport.WrapError(err)
513 }
514 ret := &GoogleExampleLibraryagentV1ListShelvesResponse{
515 ServerResponse: googleapi.ServerResponse{
516 Header: res.Header,
517 HTTPStatusCode: res.StatusCode,
518 },
519 }
520 target := &ret
521 if err := gensupport.DecodeResponse(target, res); err != nil {
522 return nil, err
523 }
524 return ret, nil
525 }
526
527
528
529
530 func (c *ShelvesListCall) Pages(ctx context.Context, f func(*GoogleExampleLibraryagentV1ListShelvesResponse) error) error {
531 c.ctx_ = ctx
532 defer c.PageToken(c.urlParams_.Get("pageToken"))
533 for {
534 x, err := c.Do()
535 if err != nil {
536 return err
537 }
538 if err := f(x); err != nil {
539 return err
540 }
541 if x.NextPageToken == "" {
542 return nil
543 }
544 c.PageToken(x.NextPageToken)
545 }
546 }
547
548 type ShelvesBooksBorrowCall struct {
549 s *Service
550 name string
551 urlParams_ gensupport.URLParams
552 ctx_ context.Context
553 header_ http.Header
554 }
555
556
557
558
559
560
561
562 func (r *ShelvesBooksService) Borrow(name string) *ShelvesBooksBorrowCall {
563 c := &ShelvesBooksBorrowCall{s: r.s, urlParams_: make(gensupport.URLParams)}
564 c.name = name
565 return c
566 }
567
568
569
570
571 func (c *ShelvesBooksBorrowCall) Fields(s ...googleapi.Field) *ShelvesBooksBorrowCall {
572 c.urlParams_.Set("fields", googleapi.CombineFields(s))
573 return c
574 }
575
576
577 func (c *ShelvesBooksBorrowCall) Context(ctx context.Context) *ShelvesBooksBorrowCall {
578 c.ctx_ = ctx
579 return c
580 }
581
582
583
584 func (c *ShelvesBooksBorrowCall) Header() http.Header {
585 if c.header_ == nil {
586 c.header_ = make(http.Header)
587 }
588 return c.header_
589 }
590
591 func (c *ShelvesBooksBorrowCall) doRequest(alt string) (*http.Response, error) {
592 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
593 var body io.Reader = nil
594 c.urlParams_.Set("alt", alt)
595 c.urlParams_.Set("prettyPrint", "false")
596 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:borrow")
597 urls += "?" + c.urlParams_.Encode()
598 req, err := http.NewRequest("POST", urls, body)
599 if err != nil {
600 return nil, err
601 }
602 req.Header = reqHeaders
603 googleapi.Expand(req.URL, map[string]string{
604 "name": c.name,
605 })
606 return gensupport.SendRequest(c.ctx_, c.s.client, req)
607 }
608
609
610
611
612
613
614
615 func (c *ShelvesBooksBorrowCall) Do(opts ...googleapi.CallOption) (*GoogleExampleLibraryagentV1Book, error) {
616 gensupport.SetOptions(c.urlParams_, opts...)
617 res, err := c.doRequest("json")
618 if res != nil && res.StatusCode == http.StatusNotModified {
619 if res.Body != nil {
620 res.Body.Close()
621 }
622 return nil, gensupport.WrapError(&googleapi.Error{
623 Code: res.StatusCode,
624 Header: res.Header,
625 })
626 }
627 if err != nil {
628 return nil, err
629 }
630 defer googleapi.CloseBody(res)
631 if err := googleapi.CheckResponse(res); err != nil {
632 return nil, gensupport.WrapError(err)
633 }
634 ret := &GoogleExampleLibraryagentV1Book{
635 ServerResponse: googleapi.ServerResponse{
636 Header: res.Header,
637 HTTPStatusCode: res.StatusCode,
638 },
639 }
640 target := &ret
641 if err := gensupport.DecodeResponse(target, res); err != nil {
642 return nil, err
643 }
644 return ret, nil
645 }
646
647 type ShelvesBooksGetCall struct {
648 s *Service
649 name string
650 urlParams_ gensupport.URLParams
651 ifNoneMatch_ string
652 ctx_ context.Context
653 header_ http.Header
654 }
655
656
657
658
659 func (r *ShelvesBooksService) Get(name string) *ShelvesBooksGetCall {
660 c := &ShelvesBooksGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
661 c.name = name
662 return c
663 }
664
665
666
667
668 func (c *ShelvesBooksGetCall) Fields(s ...googleapi.Field) *ShelvesBooksGetCall {
669 c.urlParams_.Set("fields", googleapi.CombineFields(s))
670 return c
671 }
672
673
674
675
676 func (c *ShelvesBooksGetCall) IfNoneMatch(entityTag string) *ShelvesBooksGetCall {
677 c.ifNoneMatch_ = entityTag
678 return c
679 }
680
681
682 func (c *ShelvesBooksGetCall) Context(ctx context.Context) *ShelvesBooksGetCall {
683 c.ctx_ = ctx
684 return c
685 }
686
687
688
689 func (c *ShelvesBooksGetCall) Header() http.Header {
690 if c.header_ == nil {
691 c.header_ = make(http.Header)
692 }
693 return c.header_
694 }
695
696 func (c *ShelvesBooksGetCall) doRequest(alt string) (*http.Response, error) {
697 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
698 if c.ifNoneMatch_ != "" {
699 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
700 }
701 var body io.Reader = nil
702 c.urlParams_.Set("alt", alt)
703 c.urlParams_.Set("prettyPrint", "false")
704 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
705 urls += "?" + c.urlParams_.Encode()
706 req, err := http.NewRequest("GET", urls, body)
707 if err != nil {
708 return nil, err
709 }
710 req.Header = reqHeaders
711 googleapi.Expand(req.URL, map[string]string{
712 "name": c.name,
713 })
714 return gensupport.SendRequest(c.ctx_, c.s.client, req)
715 }
716
717
718
719
720
721
722
723 func (c *ShelvesBooksGetCall) Do(opts ...googleapi.CallOption) (*GoogleExampleLibraryagentV1Book, error) {
724 gensupport.SetOptions(c.urlParams_, opts...)
725 res, err := c.doRequest("json")
726 if res != nil && res.StatusCode == http.StatusNotModified {
727 if res.Body != nil {
728 res.Body.Close()
729 }
730 return nil, gensupport.WrapError(&googleapi.Error{
731 Code: res.StatusCode,
732 Header: res.Header,
733 })
734 }
735 if err != nil {
736 return nil, err
737 }
738 defer googleapi.CloseBody(res)
739 if err := googleapi.CheckResponse(res); err != nil {
740 return nil, gensupport.WrapError(err)
741 }
742 ret := &GoogleExampleLibraryagentV1Book{
743 ServerResponse: googleapi.ServerResponse{
744 Header: res.Header,
745 HTTPStatusCode: res.StatusCode,
746 },
747 }
748 target := &ret
749 if err := gensupport.DecodeResponse(target, res); err != nil {
750 return nil, err
751 }
752 return ret, nil
753 }
754
755 type ShelvesBooksListCall struct {
756 s *Service
757 parent string
758 urlParams_ gensupport.URLParams
759 ifNoneMatch_ string
760 ctx_ context.Context
761 header_ http.Header
762 }
763
764
765
766
767
768
769 func (r *ShelvesBooksService) List(parent string) *ShelvesBooksListCall {
770 c := &ShelvesBooksListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
771 c.parent = parent
772 return c
773 }
774
775
776
777
778 func (c *ShelvesBooksListCall) PageSize(pageSize int64) *ShelvesBooksListCall {
779 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
780 return c
781 }
782
783
784
785
786
787 func (c *ShelvesBooksListCall) PageToken(pageToken string) *ShelvesBooksListCall {
788 c.urlParams_.Set("pageToken", pageToken)
789 return c
790 }
791
792
793
794
795 func (c *ShelvesBooksListCall) Fields(s ...googleapi.Field) *ShelvesBooksListCall {
796 c.urlParams_.Set("fields", googleapi.CombineFields(s))
797 return c
798 }
799
800
801
802
803 func (c *ShelvesBooksListCall) IfNoneMatch(entityTag string) *ShelvesBooksListCall {
804 c.ifNoneMatch_ = entityTag
805 return c
806 }
807
808
809 func (c *ShelvesBooksListCall) Context(ctx context.Context) *ShelvesBooksListCall {
810 c.ctx_ = ctx
811 return c
812 }
813
814
815
816 func (c *ShelvesBooksListCall) Header() http.Header {
817 if c.header_ == nil {
818 c.header_ = make(http.Header)
819 }
820 return c.header_
821 }
822
823 func (c *ShelvesBooksListCall) doRequest(alt string) (*http.Response, error) {
824 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
825 if c.ifNoneMatch_ != "" {
826 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
827 }
828 var body io.Reader = nil
829 c.urlParams_.Set("alt", alt)
830 c.urlParams_.Set("prettyPrint", "false")
831 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/books")
832 urls += "?" + c.urlParams_.Encode()
833 req, err := http.NewRequest("GET", urls, body)
834 if err != nil {
835 return nil, err
836 }
837 req.Header = reqHeaders
838 googleapi.Expand(req.URL, map[string]string{
839 "parent": c.parent,
840 })
841 return gensupport.SendRequest(c.ctx_, c.s.client, req)
842 }
843
844
845
846
847
848
849
850 func (c *ShelvesBooksListCall) Do(opts ...googleapi.CallOption) (*GoogleExampleLibraryagentV1ListBooksResponse, error) {
851 gensupport.SetOptions(c.urlParams_, opts...)
852 res, err := c.doRequest("json")
853 if res != nil && res.StatusCode == http.StatusNotModified {
854 if res.Body != nil {
855 res.Body.Close()
856 }
857 return nil, gensupport.WrapError(&googleapi.Error{
858 Code: res.StatusCode,
859 Header: res.Header,
860 })
861 }
862 if err != nil {
863 return nil, err
864 }
865 defer googleapi.CloseBody(res)
866 if err := googleapi.CheckResponse(res); err != nil {
867 return nil, gensupport.WrapError(err)
868 }
869 ret := &GoogleExampleLibraryagentV1ListBooksResponse{
870 ServerResponse: googleapi.ServerResponse{
871 Header: res.Header,
872 HTTPStatusCode: res.StatusCode,
873 },
874 }
875 target := &ret
876 if err := gensupport.DecodeResponse(target, res); err != nil {
877 return nil, err
878 }
879 return ret, nil
880 }
881
882
883
884
885 func (c *ShelvesBooksListCall) Pages(ctx context.Context, f func(*GoogleExampleLibraryagentV1ListBooksResponse) error) error {
886 c.ctx_ = ctx
887 defer c.PageToken(c.urlParams_.Get("pageToken"))
888 for {
889 x, err := c.Do()
890 if err != nil {
891 return err
892 }
893 if err := f(x); err != nil {
894 return err
895 }
896 if x.NextPageToken == "" {
897 return nil
898 }
899 c.PageToken(x.NextPageToken)
900 }
901 }
902
903 type ShelvesBooksReturnCall struct {
904 s *Service
905 name string
906 urlParams_ gensupport.URLParams
907 ctx_ context.Context
908 header_ http.Header
909 }
910
911
912
913
914
915
916 func (r *ShelvesBooksService) Return(name string) *ShelvesBooksReturnCall {
917 c := &ShelvesBooksReturnCall{s: r.s, urlParams_: make(gensupport.URLParams)}
918 c.name = name
919 return c
920 }
921
922
923
924
925 func (c *ShelvesBooksReturnCall) Fields(s ...googleapi.Field) *ShelvesBooksReturnCall {
926 c.urlParams_.Set("fields", googleapi.CombineFields(s))
927 return c
928 }
929
930
931 func (c *ShelvesBooksReturnCall) Context(ctx context.Context) *ShelvesBooksReturnCall {
932 c.ctx_ = ctx
933 return c
934 }
935
936
937
938 func (c *ShelvesBooksReturnCall) Header() http.Header {
939 if c.header_ == nil {
940 c.header_ = make(http.Header)
941 }
942 return c.header_
943 }
944
945 func (c *ShelvesBooksReturnCall) doRequest(alt string) (*http.Response, error) {
946 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
947 var body io.Reader = nil
948 c.urlParams_.Set("alt", alt)
949 c.urlParams_.Set("prettyPrint", "false")
950 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:return")
951 urls += "?" + c.urlParams_.Encode()
952 req, err := http.NewRequest("POST", urls, body)
953 if err != nil {
954 return nil, err
955 }
956 req.Header = reqHeaders
957 googleapi.Expand(req.URL, map[string]string{
958 "name": c.name,
959 })
960 return gensupport.SendRequest(c.ctx_, c.s.client, req)
961 }
962
963
964
965
966
967
968
969 func (c *ShelvesBooksReturnCall) Do(opts ...googleapi.CallOption) (*GoogleExampleLibraryagentV1Book, error) {
970 gensupport.SetOptions(c.urlParams_, opts...)
971 res, err := c.doRequest("json")
972 if res != nil && res.StatusCode == http.StatusNotModified {
973 if res.Body != nil {
974 res.Body.Close()
975 }
976 return nil, gensupport.WrapError(&googleapi.Error{
977 Code: res.StatusCode,
978 Header: res.Header,
979 })
980 }
981 if err != nil {
982 return nil, err
983 }
984 defer googleapi.CloseBody(res)
985 if err := googleapi.CheckResponse(res); err != nil {
986 return nil, gensupport.WrapError(err)
987 }
988 ret := &GoogleExampleLibraryagentV1Book{
989 ServerResponse: googleapi.ServerResponse{
990 Header: res.Header,
991 HTTPStatusCode: res.StatusCode,
992 },
993 }
994 target := &ret
995 if err := gensupport.DecodeResponse(target, res); err != nil {
996 return nil, err
997 }
998 return ret, nil
999 }
1000
View as plain text