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 firebaseml
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 = "firebaseml:v1beta2"
90 const apiName = "firebaseml"
91 const apiVersion = "v1beta2"
92 const basePath = "https://firebaseml.googleapis.com/"
93 const basePathTemplate = "https://firebaseml.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://firebaseml.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.Projects = NewProjectsService(s)
139 return s, nil
140 }
141
142 type Service struct {
143 client *http.Client
144 BasePath string
145 UserAgent string
146
147 Projects *ProjectsService
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 NewProjectsService(s *Service) *ProjectsService {
158 rs := &ProjectsService{s: s}
159 rs.Models = NewProjectsModelsService(s)
160 rs.Operations = NewProjectsOperationsService(s)
161 return rs
162 }
163
164 type ProjectsService struct {
165 s *Service
166
167 Models *ProjectsModelsService
168
169 Operations *ProjectsOperationsService
170 }
171
172 func NewProjectsModelsService(s *Service) *ProjectsModelsService {
173 rs := &ProjectsModelsService{s: s}
174 return rs
175 }
176
177 type ProjectsModelsService struct {
178 s *Service
179 }
180
181 func NewProjectsOperationsService(s *Service) *ProjectsOperationsService {
182 rs := &ProjectsOperationsService{s: s}
183 return rs
184 }
185
186 type ProjectsOperationsService struct {
187 s *Service
188 }
189
190
191 type DownloadModelResponse struct {
192
193 DownloadUri string `json:"downloadUri,omitempty"`
194
195
196 ExpireTime string `json:"expireTime,omitempty"`
197
198
199
200
201
202 ModelFormat string `json:"modelFormat,omitempty"`
203
204
205 SizeBytes int64 `json:"sizeBytes,omitempty,string"`
206
207
208 googleapi.ServerResponse `json:"-"`
209
210
211
212
213
214 ForceSendFields []string `json:"-"`
215
216
217
218
219 NullFields []string `json:"-"`
220 }
221
222 func (s *DownloadModelResponse) MarshalJSON() ([]byte, error) {
223 type NoMethod DownloadModelResponse
224 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
225 }
226
227
228
229
230
231 type Empty struct {
232
233 googleapi.ServerResponse `json:"-"`
234 }
235
236
237 type ListModelsResponse struct {
238
239 Models []*Model `json:"models,omitempty"`
240
241
242 NextPageToken string `json:"nextPageToken,omitempty"`
243
244
245 googleapi.ServerResponse `json:"-"`
246
247
248
249
250
251 ForceSendFields []string `json:"-"`
252
253
254
255
256 NullFields []string `json:"-"`
257 }
258
259 func (s *ListModelsResponse) MarshalJSON() ([]byte, error) {
260 type NoMethod ListModelsResponse
261 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
262 }
263
264
265 type Model struct {
266
267
268 ActiveOperations []*Operation `json:"activeOperations,omitempty"`
269
270
271 CreateTime string `json:"createTime,omitempty"`
272
273
274
275 DisplayName string `json:"displayName,omitempty"`
276
277
278 Etag string `json:"etag,omitempty"`
279
280
281 ModelHash string `json:"modelHash,omitempty"`
282
283
284
285 Name string `json:"name,omitempty"`
286
287
288 State *ModelState `json:"state,omitempty"`
289
290
291 Tags []string `json:"tags,omitempty"`
292
293 TfliteModel *TfLiteModel `json:"tfliteModel,omitempty"`
294
295
296 UpdateTime string `json:"updateTime,omitempty"`
297
298
299 googleapi.ServerResponse `json:"-"`
300
301
302
303
304
305 ForceSendFields []string `json:"-"`
306
307
308
309
310 NullFields []string `json:"-"`
311 }
312
313 func (s *Model) MarshalJSON() ([]byte, error) {
314 type NoMethod Model
315 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
316 }
317
318
319
320 type ModelOperationMetadata struct {
321
322
323
324
325 BasicOperationStatus string `json:"basicOperationStatus,omitempty"`
326
327
328 Name string `json:"name,omitempty"`
329
330
331
332
333
334 ForceSendFields []string `json:"-"`
335
336
337
338
339 NullFields []string `json:"-"`
340 }
341
342 func (s *ModelOperationMetadata) MarshalJSON() ([]byte, error) {
343 type NoMethod ModelOperationMetadata
344 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
345 }
346
347
348
349 type ModelState struct {
350
351 Published bool `json:"published,omitempty"`
352
353
354
355
356
357 ValidationError *Status `json:"validationError,omitempty"`
358
359
360
361
362
363 ForceSendFields []string `json:"-"`
364
365
366
367
368 NullFields []string `json:"-"`
369 }
370
371 func (s *ModelState) MarshalJSON() ([]byte, error) {
372 type NoMethod ModelState
373 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
374 }
375
376
377
378 type Operation struct {
379
380
381
382 Done bool `json:"done,omitempty"`
383
384 Error *Status `json:"error,omitempty"`
385
386
387
388
389 Metadata googleapi.RawMessage `json:"metadata,omitempty"`
390
391
392
393 Name string `json:"name,omitempty"`
394
395
396
397
398
399
400
401 Response googleapi.RawMessage `json:"response,omitempty"`
402
403
404 googleapi.ServerResponse `json:"-"`
405
406
407
408
409
410 ForceSendFields []string `json:"-"`
411
412
413
414
415 NullFields []string `json:"-"`
416 }
417
418 func (s *Operation) MarshalJSON() ([]byte, error) {
419 type NoMethod Operation
420 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
421 }
422
423
424
425
426
427
428
429 type Status struct {
430
431 Code int64 `json:"code,omitempty"`
432
433
434 Details []googleapi.RawMessage `json:"details,omitempty"`
435
436
437
438 Message string `json:"message,omitempty"`
439
440
441
442
443
444 ForceSendFields []string `json:"-"`
445
446
447
448
449 NullFields []string `json:"-"`
450 }
451
452 func (s *Status) MarshalJSON() ([]byte, error) {
453 type NoMethod Status
454 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
455 }
456
457
458 type TfLiteModel struct {
459
460
461
462 AutomlModel string `json:"automlModel,omitempty"`
463
464
465
466
467
468 GcsTfliteUri string `json:"gcsTfliteUri,omitempty"`
469
470 SizeBytes string `json:"sizeBytes,omitempty"`
471
472
473
474
475
476 ForceSendFields []string `json:"-"`
477
478
479
480
481 NullFields []string `json:"-"`
482 }
483
484 func (s *TfLiteModel) MarshalJSON() ([]byte, error) {
485 type NoMethod TfLiteModel
486 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
487 }
488
489 type ProjectsModelsCreateCall struct {
490 s *Service
491 parent string
492 model *Model
493 urlParams_ gensupport.URLParams
494 ctx_ context.Context
495 header_ http.Header
496 }
497
498
499
500
501
502
503 func (r *ProjectsModelsService) Create(parent string, model *Model) *ProjectsModelsCreateCall {
504 c := &ProjectsModelsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
505 c.parent = parent
506 c.model = model
507 return c
508 }
509
510
511
512
513 func (c *ProjectsModelsCreateCall) Fields(s ...googleapi.Field) *ProjectsModelsCreateCall {
514 c.urlParams_.Set("fields", googleapi.CombineFields(s))
515 return c
516 }
517
518
519 func (c *ProjectsModelsCreateCall) Context(ctx context.Context) *ProjectsModelsCreateCall {
520 c.ctx_ = ctx
521 return c
522 }
523
524
525
526 func (c *ProjectsModelsCreateCall) Header() http.Header {
527 if c.header_ == nil {
528 c.header_ = make(http.Header)
529 }
530 return c.header_
531 }
532
533 func (c *ProjectsModelsCreateCall) doRequest(alt string) (*http.Response, error) {
534 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
535 var body io.Reader = nil
536 body, err := googleapi.WithoutDataWrapper.JSONReader(c.model)
537 if err != nil {
538 return nil, err
539 }
540 c.urlParams_.Set("alt", alt)
541 c.urlParams_.Set("prettyPrint", "false")
542 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+parent}/models")
543 urls += "?" + c.urlParams_.Encode()
544 req, err := http.NewRequest("POST", urls, body)
545 if err != nil {
546 return nil, err
547 }
548 req.Header = reqHeaders
549 googleapi.Expand(req.URL, map[string]string{
550 "parent": c.parent,
551 })
552 return gensupport.SendRequest(c.ctx_, c.s.client, req)
553 }
554
555
556
557
558
559
560 func (c *ProjectsModelsCreateCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
561 gensupport.SetOptions(c.urlParams_, opts...)
562 res, err := c.doRequest("json")
563 if res != nil && res.StatusCode == http.StatusNotModified {
564 if res.Body != nil {
565 res.Body.Close()
566 }
567 return nil, gensupport.WrapError(&googleapi.Error{
568 Code: res.StatusCode,
569 Header: res.Header,
570 })
571 }
572 if err != nil {
573 return nil, err
574 }
575 defer googleapi.CloseBody(res)
576 if err := googleapi.CheckResponse(res); err != nil {
577 return nil, gensupport.WrapError(err)
578 }
579 ret := &Operation{
580 ServerResponse: googleapi.ServerResponse{
581 Header: res.Header,
582 HTTPStatusCode: res.StatusCode,
583 },
584 }
585 target := &ret
586 if err := gensupport.DecodeResponse(target, res); err != nil {
587 return nil, err
588 }
589 return ret, nil
590 }
591
592 type ProjectsModelsDeleteCall struct {
593 s *Service
594 name string
595 urlParams_ gensupport.URLParams
596 ctx_ context.Context
597 header_ http.Header
598 }
599
600
601
602
603
604 func (r *ProjectsModelsService) Delete(name string) *ProjectsModelsDeleteCall {
605 c := &ProjectsModelsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
606 c.name = name
607 return c
608 }
609
610
611
612
613 func (c *ProjectsModelsDeleteCall) Fields(s ...googleapi.Field) *ProjectsModelsDeleteCall {
614 c.urlParams_.Set("fields", googleapi.CombineFields(s))
615 return c
616 }
617
618
619 func (c *ProjectsModelsDeleteCall) Context(ctx context.Context) *ProjectsModelsDeleteCall {
620 c.ctx_ = ctx
621 return c
622 }
623
624
625
626 func (c *ProjectsModelsDeleteCall) Header() http.Header {
627 if c.header_ == nil {
628 c.header_ = make(http.Header)
629 }
630 return c.header_
631 }
632
633 func (c *ProjectsModelsDeleteCall) doRequest(alt string) (*http.Response, error) {
634 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
635 var body io.Reader = nil
636 c.urlParams_.Set("alt", alt)
637 c.urlParams_.Set("prettyPrint", "false")
638 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
639 urls += "?" + c.urlParams_.Encode()
640 req, err := http.NewRequest("DELETE", urls, body)
641 if err != nil {
642 return nil, err
643 }
644 req.Header = reqHeaders
645 googleapi.Expand(req.URL, map[string]string{
646 "name": c.name,
647 })
648 return gensupport.SendRequest(c.ctx_, c.s.client, req)
649 }
650
651
652
653
654
655
656 func (c *ProjectsModelsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
657 gensupport.SetOptions(c.urlParams_, opts...)
658 res, err := c.doRequest("json")
659 if res != nil && res.StatusCode == http.StatusNotModified {
660 if res.Body != nil {
661 res.Body.Close()
662 }
663 return nil, gensupport.WrapError(&googleapi.Error{
664 Code: res.StatusCode,
665 Header: res.Header,
666 })
667 }
668 if err != nil {
669 return nil, err
670 }
671 defer googleapi.CloseBody(res)
672 if err := googleapi.CheckResponse(res); err != nil {
673 return nil, gensupport.WrapError(err)
674 }
675 ret := &Empty{
676 ServerResponse: googleapi.ServerResponse{
677 Header: res.Header,
678 HTTPStatusCode: res.StatusCode,
679 },
680 }
681 target := &ret
682 if err := gensupport.DecodeResponse(target, res); err != nil {
683 return nil, err
684 }
685 return ret, nil
686 }
687
688 type ProjectsModelsDownloadCall struct {
689 s *Service
690 name string
691 urlParams_ gensupport.URLParams
692 ifNoneMatch_ string
693 ctx_ context.Context
694 header_ http.Header
695 }
696
697
698
699
700
701
702
703 func (r *ProjectsModelsService) Download(name string) *ProjectsModelsDownloadCall {
704 c := &ProjectsModelsDownloadCall{s: r.s, urlParams_: make(gensupport.URLParams)}
705 c.name = name
706 return c
707 }
708
709
710
711
712 func (c *ProjectsModelsDownloadCall) Fields(s ...googleapi.Field) *ProjectsModelsDownloadCall {
713 c.urlParams_.Set("fields", googleapi.CombineFields(s))
714 return c
715 }
716
717
718
719
720 func (c *ProjectsModelsDownloadCall) IfNoneMatch(entityTag string) *ProjectsModelsDownloadCall {
721 c.ifNoneMatch_ = entityTag
722 return c
723 }
724
725
726 func (c *ProjectsModelsDownloadCall) Context(ctx context.Context) *ProjectsModelsDownloadCall {
727 c.ctx_ = ctx
728 return c
729 }
730
731
732
733 func (c *ProjectsModelsDownloadCall) Header() http.Header {
734 if c.header_ == nil {
735 c.header_ = make(http.Header)
736 }
737 return c.header_
738 }
739
740 func (c *ProjectsModelsDownloadCall) doRequest(alt string) (*http.Response, error) {
741 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
742 if c.ifNoneMatch_ != "" {
743 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
744 }
745 var body io.Reader = nil
746 c.urlParams_.Set("alt", alt)
747 c.urlParams_.Set("prettyPrint", "false")
748 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}:download")
749 urls += "?" + c.urlParams_.Encode()
750 req, err := http.NewRequest("GET", urls, body)
751 if err != nil {
752 return nil, err
753 }
754 req.Header = reqHeaders
755 googleapi.Expand(req.URL, map[string]string{
756 "name": c.name,
757 })
758 return gensupport.SendRequest(c.ctx_, c.s.client, req)
759 }
760
761
762
763
764
765
766
767 func (c *ProjectsModelsDownloadCall) Do(opts ...googleapi.CallOption) (*DownloadModelResponse, error) {
768 gensupport.SetOptions(c.urlParams_, opts...)
769 res, err := c.doRequest("json")
770 if res != nil && res.StatusCode == http.StatusNotModified {
771 if res.Body != nil {
772 res.Body.Close()
773 }
774 return nil, gensupport.WrapError(&googleapi.Error{
775 Code: res.StatusCode,
776 Header: res.Header,
777 })
778 }
779 if err != nil {
780 return nil, err
781 }
782 defer googleapi.CloseBody(res)
783 if err := googleapi.CheckResponse(res); err != nil {
784 return nil, gensupport.WrapError(err)
785 }
786 ret := &DownloadModelResponse{
787 ServerResponse: googleapi.ServerResponse{
788 Header: res.Header,
789 HTTPStatusCode: res.StatusCode,
790 },
791 }
792 target := &ret
793 if err := gensupport.DecodeResponse(target, res); err != nil {
794 return nil, err
795 }
796 return ret, nil
797 }
798
799 type ProjectsModelsGetCall struct {
800 s *Service
801 name string
802 urlParams_ gensupport.URLParams
803 ifNoneMatch_ string
804 ctx_ context.Context
805 header_ http.Header
806 }
807
808
809
810
811
812 func (r *ProjectsModelsService) Get(name string) *ProjectsModelsGetCall {
813 c := &ProjectsModelsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
814 c.name = name
815 return c
816 }
817
818
819
820
821 func (c *ProjectsModelsGetCall) Fields(s ...googleapi.Field) *ProjectsModelsGetCall {
822 c.urlParams_.Set("fields", googleapi.CombineFields(s))
823 return c
824 }
825
826
827
828
829 func (c *ProjectsModelsGetCall) IfNoneMatch(entityTag string) *ProjectsModelsGetCall {
830 c.ifNoneMatch_ = entityTag
831 return c
832 }
833
834
835 func (c *ProjectsModelsGetCall) Context(ctx context.Context) *ProjectsModelsGetCall {
836 c.ctx_ = ctx
837 return c
838 }
839
840
841
842 func (c *ProjectsModelsGetCall) Header() http.Header {
843 if c.header_ == nil {
844 c.header_ = make(http.Header)
845 }
846 return c.header_
847 }
848
849 func (c *ProjectsModelsGetCall) doRequest(alt string) (*http.Response, error) {
850 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
851 if c.ifNoneMatch_ != "" {
852 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
853 }
854 var body io.Reader = nil
855 c.urlParams_.Set("alt", alt)
856 c.urlParams_.Set("prettyPrint", "false")
857 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
858 urls += "?" + c.urlParams_.Encode()
859 req, err := http.NewRequest("GET", urls, body)
860 if err != nil {
861 return nil, err
862 }
863 req.Header = reqHeaders
864 googleapi.Expand(req.URL, map[string]string{
865 "name": c.name,
866 })
867 return gensupport.SendRequest(c.ctx_, c.s.client, req)
868 }
869
870
871
872
873
874
875 func (c *ProjectsModelsGetCall) Do(opts ...googleapi.CallOption) (*Model, error) {
876 gensupport.SetOptions(c.urlParams_, opts...)
877 res, err := c.doRequest("json")
878 if res != nil && res.StatusCode == http.StatusNotModified {
879 if res.Body != nil {
880 res.Body.Close()
881 }
882 return nil, gensupport.WrapError(&googleapi.Error{
883 Code: res.StatusCode,
884 Header: res.Header,
885 })
886 }
887 if err != nil {
888 return nil, err
889 }
890 defer googleapi.CloseBody(res)
891 if err := googleapi.CheckResponse(res); err != nil {
892 return nil, gensupport.WrapError(err)
893 }
894 ret := &Model{
895 ServerResponse: googleapi.ServerResponse{
896 Header: res.Header,
897 HTTPStatusCode: res.StatusCode,
898 },
899 }
900 target := &ret
901 if err := gensupport.DecodeResponse(target, res); err != nil {
902 return nil, err
903 }
904 return ret, nil
905 }
906
907 type ProjectsModelsListCall struct {
908 s *Service
909 parent string
910 urlParams_ gensupport.URLParams
911 ifNoneMatch_ string
912 ctx_ context.Context
913 header_ http.Header
914 }
915
916
917
918
919
920 func (r *ProjectsModelsService) List(parent string) *ProjectsModelsListCall {
921 c := &ProjectsModelsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
922 c.parent = parent
923 return c
924 }
925
926
927
928 func (c *ProjectsModelsListCall) Filter(filter string) *ProjectsModelsListCall {
929 c.urlParams_.Set("filter", filter)
930 return c
931 }
932
933
934
935 func (c *ProjectsModelsListCall) PageSize(pageSize int64) *ProjectsModelsListCall {
936 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
937 return c
938 }
939
940
941
942 func (c *ProjectsModelsListCall) PageToken(pageToken string) *ProjectsModelsListCall {
943 c.urlParams_.Set("pageToken", pageToken)
944 return c
945 }
946
947
948
949
950 func (c *ProjectsModelsListCall) Fields(s ...googleapi.Field) *ProjectsModelsListCall {
951 c.urlParams_.Set("fields", googleapi.CombineFields(s))
952 return c
953 }
954
955
956
957
958 func (c *ProjectsModelsListCall) IfNoneMatch(entityTag string) *ProjectsModelsListCall {
959 c.ifNoneMatch_ = entityTag
960 return c
961 }
962
963
964 func (c *ProjectsModelsListCall) Context(ctx context.Context) *ProjectsModelsListCall {
965 c.ctx_ = ctx
966 return c
967 }
968
969
970
971 func (c *ProjectsModelsListCall) Header() http.Header {
972 if c.header_ == nil {
973 c.header_ = make(http.Header)
974 }
975 return c.header_
976 }
977
978 func (c *ProjectsModelsListCall) doRequest(alt string) (*http.Response, error) {
979 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
980 if c.ifNoneMatch_ != "" {
981 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
982 }
983 var body io.Reader = nil
984 c.urlParams_.Set("alt", alt)
985 c.urlParams_.Set("prettyPrint", "false")
986 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+parent}/models")
987 urls += "?" + c.urlParams_.Encode()
988 req, err := http.NewRequest("GET", urls, body)
989 if err != nil {
990 return nil, err
991 }
992 req.Header = reqHeaders
993 googleapi.Expand(req.URL, map[string]string{
994 "parent": c.parent,
995 })
996 return gensupport.SendRequest(c.ctx_, c.s.client, req)
997 }
998
999
1000
1001
1002
1003
1004
1005 func (c *ProjectsModelsListCall) Do(opts ...googleapi.CallOption) (*ListModelsResponse, error) {
1006 gensupport.SetOptions(c.urlParams_, opts...)
1007 res, err := c.doRequest("json")
1008 if res != nil && res.StatusCode == http.StatusNotModified {
1009 if res.Body != nil {
1010 res.Body.Close()
1011 }
1012 return nil, gensupport.WrapError(&googleapi.Error{
1013 Code: res.StatusCode,
1014 Header: res.Header,
1015 })
1016 }
1017 if err != nil {
1018 return nil, err
1019 }
1020 defer googleapi.CloseBody(res)
1021 if err := googleapi.CheckResponse(res); err != nil {
1022 return nil, gensupport.WrapError(err)
1023 }
1024 ret := &ListModelsResponse{
1025 ServerResponse: googleapi.ServerResponse{
1026 Header: res.Header,
1027 HTTPStatusCode: res.StatusCode,
1028 },
1029 }
1030 target := &ret
1031 if err := gensupport.DecodeResponse(target, res); err != nil {
1032 return nil, err
1033 }
1034 return ret, nil
1035 }
1036
1037
1038
1039
1040 func (c *ProjectsModelsListCall) Pages(ctx context.Context, f func(*ListModelsResponse) error) error {
1041 c.ctx_ = ctx
1042 defer c.PageToken(c.urlParams_.Get("pageToken"))
1043 for {
1044 x, err := c.Do()
1045 if err != nil {
1046 return err
1047 }
1048 if err := f(x); err != nil {
1049 return err
1050 }
1051 if x.NextPageToken == "" {
1052 return nil
1053 }
1054 c.PageToken(x.NextPageToken)
1055 }
1056 }
1057
1058 type ProjectsModelsPatchCall struct {
1059 s *Service
1060 name string
1061 model *Model
1062 urlParams_ gensupport.URLParams
1063 ctx_ context.Context
1064 header_ http.Header
1065 }
1066
1067
1068
1069
1070
1071
1072
1073 func (r *ProjectsModelsService) Patch(name string, model *Model) *ProjectsModelsPatchCall {
1074 c := &ProjectsModelsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1075 c.name = name
1076 c.model = model
1077 return c
1078 }
1079
1080
1081 func (c *ProjectsModelsPatchCall) UpdateMask(updateMask string) *ProjectsModelsPatchCall {
1082 c.urlParams_.Set("updateMask", updateMask)
1083 return c
1084 }
1085
1086
1087
1088
1089 func (c *ProjectsModelsPatchCall) Fields(s ...googleapi.Field) *ProjectsModelsPatchCall {
1090 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1091 return c
1092 }
1093
1094
1095 func (c *ProjectsModelsPatchCall) Context(ctx context.Context) *ProjectsModelsPatchCall {
1096 c.ctx_ = ctx
1097 return c
1098 }
1099
1100
1101
1102 func (c *ProjectsModelsPatchCall) Header() http.Header {
1103 if c.header_ == nil {
1104 c.header_ = make(http.Header)
1105 }
1106 return c.header_
1107 }
1108
1109 func (c *ProjectsModelsPatchCall) doRequest(alt string) (*http.Response, error) {
1110 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1111 var body io.Reader = nil
1112 body, err := googleapi.WithoutDataWrapper.JSONReader(c.model)
1113 if err != nil {
1114 return nil, err
1115 }
1116 c.urlParams_.Set("alt", alt)
1117 c.urlParams_.Set("prettyPrint", "false")
1118 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
1119 urls += "?" + c.urlParams_.Encode()
1120 req, err := http.NewRequest("PATCH", urls, body)
1121 if err != nil {
1122 return nil, err
1123 }
1124 req.Header = reqHeaders
1125 googleapi.Expand(req.URL, map[string]string{
1126 "name": c.name,
1127 })
1128 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1129 }
1130
1131
1132
1133
1134
1135
1136 func (c *ProjectsModelsPatchCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
1137 gensupport.SetOptions(c.urlParams_, opts...)
1138 res, err := c.doRequest("json")
1139 if res != nil && res.StatusCode == http.StatusNotModified {
1140 if res.Body != nil {
1141 res.Body.Close()
1142 }
1143 return nil, gensupport.WrapError(&googleapi.Error{
1144 Code: res.StatusCode,
1145 Header: res.Header,
1146 })
1147 }
1148 if err != nil {
1149 return nil, err
1150 }
1151 defer googleapi.CloseBody(res)
1152 if err := googleapi.CheckResponse(res); err != nil {
1153 return nil, gensupport.WrapError(err)
1154 }
1155 ret := &Operation{
1156 ServerResponse: googleapi.ServerResponse{
1157 Header: res.Header,
1158 HTTPStatusCode: res.StatusCode,
1159 },
1160 }
1161 target := &ret
1162 if err := gensupport.DecodeResponse(target, res); err != nil {
1163 return nil, err
1164 }
1165 return ret, nil
1166 }
1167
1168 type ProjectsOperationsGetCall struct {
1169 s *Service
1170 name string
1171 urlParams_ gensupport.URLParams
1172 ifNoneMatch_ string
1173 ctx_ context.Context
1174 header_ http.Header
1175 }
1176
1177
1178
1179
1180
1181
1182 func (r *ProjectsOperationsService) Get(name string) *ProjectsOperationsGetCall {
1183 c := &ProjectsOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1184 c.name = name
1185 return c
1186 }
1187
1188
1189
1190
1191 func (c *ProjectsOperationsGetCall) Fields(s ...googleapi.Field) *ProjectsOperationsGetCall {
1192 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1193 return c
1194 }
1195
1196
1197
1198
1199 func (c *ProjectsOperationsGetCall) IfNoneMatch(entityTag string) *ProjectsOperationsGetCall {
1200 c.ifNoneMatch_ = entityTag
1201 return c
1202 }
1203
1204
1205 func (c *ProjectsOperationsGetCall) Context(ctx context.Context) *ProjectsOperationsGetCall {
1206 c.ctx_ = ctx
1207 return c
1208 }
1209
1210
1211
1212 func (c *ProjectsOperationsGetCall) Header() http.Header {
1213 if c.header_ == nil {
1214 c.header_ = make(http.Header)
1215 }
1216 return c.header_
1217 }
1218
1219 func (c *ProjectsOperationsGetCall) doRequest(alt string) (*http.Response, error) {
1220 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1221 if c.ifNoneMatch_ != "" {
1222 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1223 }
1224 var body io.Reader = nil
1225 c.urlParams_.Set("alt", alt)
1226 c.urlParams_.Set("prettyPrint", "false")
1227 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
1228 urls += "?" + c.urlParams_.Encode()
1229 req, err := http.NewRequest("GET", urls, body)
1230 if err != nil {
1231 return nil, err
1232 }
1233 req.Header = reqHeaders
1234 googleapi.Expand(req.URL, map[string]string{
1235 "name": c.name,
1236 })
1237 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1238 }
1239
1240
1241
1242
1243
1244
1245 func (c *ProjectsOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
1246 gensupport.SetOptions(c.urlParams_, opts...)
1247 res, err := c.doRequest("json")
1248 if res != nil && res.StatusCode == http.StatusNotModified {
1249 if res.Body != nil {
1250 res.Body.Close()
1251 }
1252 return nil, gensupport.WrapError(&googleapi.Error{
1253 Code: res.StatusCode,
1254 Header: res.Header,
1255 })
1256 }
1257 if err != nil {
1258 return nil, err
1259 }
1260 defer googleapi.CloseBody(res)
1261 if err := googleapi.CheckResponse(res); err != nil {
1262 return nil, gensupport.WrapError(err)
1263 }
1264 ret := &Operation{
1265 ServerResponse: googleapi.ServerResponse{
1266 Header: res.Header,
1267 HTTPStatusCode: res.StatusCode,
1268 },
1269 }
1270 target := &ret
1271 if err := gensupport.DecodeResponse(target, res); err != nil {
1272 return nil, err
1273 }
1274 return ret, nil
1275 }
1276
View as plain text