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:v1"
90 const apiName = "firebaseml"
91 const apiVersion = "v1"
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.Operations = NewOperationsService(s)
139 return s, nil
140 }
141
142 type Service struct {
143 client *http.Client
144 BasePath string
145 UserAgent string
146
147 Operations *OperationsService
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 NewOperationsService(s *Service) *OperationsService {
158 rs := &OperationsService{s: s}
159 return rs
160 }
161
162 type OperationsService struct {
163 s *Service
164 }
165
166
167 type CancelOperationRequest struct {
168 }
169
170
171
172
173
174 type Empty struct {
175
176 googleapi.ServerResponse `json:"-"`
177 }
178
179
180 type ListOperationsResponse struct {
181
182 NextPageToken string `json:"nextPageToken,omitempty"`
183
184
185 Operations []*Operation `json:"operations,omitempty"`
186
187
188 googleapi.ServerResponse `json:"-"`
189
190
191
192
193
194 ForceSendFields []string `json:"-"`
195
196
197
198
199 NullFields []string `json:"-"`
200 }
201
202 func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) {
203 type NoMethod ListOperationsResponse
204 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
205 }
206
207
208
209 type ModelOperationMetadata struct {
210
211
212
213
214 BasicOperationStatus string `json:"basicOperationStatus,omitempty"`
215
216
217 Name string `json:"name,omitempty"`
218
219
220
221
222
223 ForceSendFields []string `json:"-"`
224
225
226
227
228 NullFields []string `json:"-"`
229 }
230
231 func (s *ModelOperationMetadata) MarshalJSON() ([]byte, error) {
232 type NoMethod ModelOperationMetadata
233 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
234 }
235
236
237
238 type Operation struct {
239
240
241
242 Done bool `json:"done,omitempty"`
243
244 Error *Status `json:"error,omitempty"`
245
246
247
248
249 Metadata googleapi.RawMessage `json:"metadata,omitempty"`
250
251
252
253 Name string `json:"name,omitempty"`
254
255
256
257
258
259
260
261 Response googleapi.RawMessage `json:"response,omitempty"`
262
263
264
265
266
267 ForceSendFields []string `json:"-"`
268
269
270
271
272 NullFields []string `json:"-"`
273 }
274
275 func (s *Operation) MarshalJSON() ([]byte, error) {
276 type NoMethod Operation
277 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
278 }
279
280
281
282
283
284
285
286 type Status struct {
287
288 Code int64 `json:"code,omitempty"`
289
290
291 Details []googleapi.RawMessage `json:"details,omitempty"`
292
293
294
295 Message string `json:"message,omitempty"`
296
297
298
299
300
301 ForceSendFields []string `json:"-"`
302
303
304
305
306 NullFields []string `json:"-"`
307 }
308
309 func (s *Status) MarshalJSON() ([]byte, error) {
310 type NoMethod Status
311 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
312 }
313
314 type OperationsCancelCall struct {
315 s *Service
316 name string
317 canceloperationrequest *CancelOperationRequest
318 urlParams_ gensupport.URLParams
319 ctx_ context.Context
320 header_ http.Header
321 }
322
323
324
325
326
327
328
329
330
331
332
333
334 func (r *OperationsService) Cancel(name string, canceloperationrequest *CancelOperationRequest) *OperationsCancelCall {
335 c := &OperationsCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)}
336 c.name = name
337 c.canceloperationrequest = canceloperationrequest
338 return c
339 }
340
341
342
343
344 func (c *OperationsCancelCall) Fields(s ...googleapi.Field) *OperationsCancelCall {
345 c.urlParams_.Set("fields", googleapi.CombineFields(s))
346 return c
347 }
348
349
350 func (c *OperationsCancelCall) Context(ctx context.Context) *OperationsCancelCall {
351 c.ctx_ = ctx
352 return c
353 }
354
355
356
357 func (c *OperationsCancelCall) Header() http.Header {
358 if c.header_ == nil {
359 c.header_ = make(http.Header)
360 }
361 return c.header_
362 }
363
364 func (c *OperationsCancelCall) doRequest(alt string) (*http.Response, error) {
365 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
366 var body io.Reader = nil
367 body, err := googleapi.WithoutDataWrapper.JSONReader(c.canceloperationrequest)
368 if err != nil {
369 return nil, err
370 }
371 c.urlParams_.Set("alt", alt)
372 c.urlParams_.Set("prettyPrint", "false")
373 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:cancel")
374 urls += "?" + c.urlParams_.Encode()
375 req, err := http.NewRequest("POST", urls, body)
376 if err != nil {
377 return nil, err
378 }
379 req.Header = reqHeaders
380 googleapi.Expand(req.URL, map[string]string{
381 "name": c.name,
382 })
383 return gensupport.SendRequest(c.ctx_, c.s.client, req)
384 }
385
386
387
388
389
390
391 func (c *OperationsCancelCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
392 gensupport.SetOptions(c.urlParams_, opts...)
393 res, err := c.doRequest("json")
394 if res != nil && res.StatusCode == http.StatusNotModified {
395 if res.Body != nil {
396 res.Body.Close()
397 }
398 return nil, gensupport.WrapError(&googleapi.Error{
399 Code: res.StatusCode,
400 Header: res.Header,
401 })
402 }
403 if err != nil {
404 return nil, err
405 }
406 defer googleapi.CloseBody(res)
407 if err := googleapi.CheckResponse(res); err != nil {
408 return nil, gensupport.WrapError(err)
409 }
410 ret := &Empty{
411 ServerResponse: googleapi.ServerResponse{
412 Header: res.Header,
413 HTTPStatusCode: res.StatusCode,
414 },
415 }
416 target := &ret
417 if err := gensupport.DecodeResponse(target, res); err != nil {
418 return nil, err
419 }
420 return ret, nil
421 }
422
423 type OperationsDeleteCall struct {
424 s *Service
425 name string
426 urlParams_ gensupport.URLParams
427 ctx_ context.Context
428 header_ http.Header
429 }
430
431
432
433
434
435
436
437 func (r *OperationsService) Delete(name string) *OperationsDeleteCall {
438 c := &OperationsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
439 c.name = name
440 return c
441 }
442
443
444
445
446 func (c *OperationsDeleteCall) Fields(s ...googleapi.Field) *OperationsDeleteCall {
447 c.urlParams_.Set("fields", googleapi.CombineFields(s))
448 return c
449 }
450
451
452 func (c *OperationsDeleteCall) Context(ctx context.Context) *OperationsDeleteCall {
453 c.ctx_ = ctx
454 return c
455 }
456
457
458
459 func (c *OperationsDeleteCall) Header() http.Header {
460 if c.header_ == nil {
461 c.header_ = make(http.Header)
462 }
463 return c.header_
464 }
465
466 func (c *OperationsDeleteCall) doRequest(alt string) (*http.Response, error) {
467 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
468 var body io.Reader = nil
469 c.urlParams_.Set("alt", alt)
470 c.urlParams_.Set("prettyPrint", "false")
471 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
472 urls += "?" + c.urlParams_.Encode()
473 req, err := http.NewRequest("DELETE", urls, body)
474 if err != nil {
475 return nil, err
476 }
477 req.Header = reqHeaders
478 googleapi.Expand(req.URL, map[string]string{
479 "name": c.name,
480 })
481 return gensupport.SendRequest(c.ctx_, c.s.client, req)
482 }
483
484
485
486
487
488
489 func (c *OperationsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
490 gensupport.SetOptions(c.urlParams_, opts...)
491 res, err := c.doRequest("json")
492 if res != nil && res.StatusCode == http.StatusNotModified {
493 if res.Body != nil {
494 res.Body.Close()
495 }
496 return nil, gensupport.WrapError(&googleapi.Error{
497 Code: res.StatusCode,
498 Header: res.Header,
499 })
500 }
501 if err != nil {
502 return nil, err
503 }
504 defer googleapi.CloseBody(res)
505 if err := googleapi.CheckResponse(res); err != nil {
506 return nil, gensupport.WrapError(err)
507 }
508 ret := &Empty{
509 ServerResponse: googleapi.ServerResponse{
510 Header: res.Header,
511 HTTPStatusCode: res.StatusCode,
512 },
513 }
514 target := &ret
515 if err := gensupport.DecodeResponse(target, res); err != nil {
516 return nil, err
517 }
518 return ret, nil
519 }
520
521 type OperationsListCall struct {
522 s *Service
523 name string
524 urlParams_ gensupport.URLParams
525 ifNoneMatch_ string
526 ctx_ context.Context
527 header_ http.Header
528 }
529
530
531
532
533
534 func (r *OperationsService) List(name string) *OperationsListCall {
535 c := &OperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
536 c.name = name
537 return c
538 }
539
540
541 func (c *OperationsListCall) Filter(filter string) *OperationsListCall {
542 c.urlParams_.Set("filter", filter)
543 return c
544 }
545
546
547
548 func (c *OperationsListCall) PageSize(pageSize int64) *OperationsListCall {
549 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
550 return c
551 }
552
553
554
555 func (c *OperationsListCall) PageToken(pageToken string) *OperationsListCall {
556 c.urlParams_.Set("pageToken", pageToken)
557 return c
558 }
559
560
561
562
563 func (c *OperationsListCall) Fields(s ...googleapi.Field) *OperationsListCall {
564 c.urlParams_.Set("fields", googleapi.CombineFields(s))
565 return c
566 }
567
568
569
570
571 func (c *OperationsListCall) IfNoneMatch(entityTag string) *OperationsListCall {
572 c.ifNoneMatch_ = entityTag
573 return c
574 }
575
576
577 func (c *OperationsListCall) Context(ctx context.Context) *OperationsListCall {
578 c.ctx_ = ctx
579 return c
580 }
581
582
583
584 func (c *OperationsListCall) Header() http.Header {
585 if c.header_ == nil {
586 c.header_ = make(http.Header)
587 }
588 return c.header_
589 }
590
591 func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) {
592 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
593 if c.ifNoneMatch_ != "" {
594 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
595 }
596 var body io.Reader = nil
597 c.urlParams_.Set("alt", alt)
598 c.urlParams_.Set("prettyPrint", "false")
599 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
600 urls += "?" + c.urlParams_.Encode()
601 req, err := http.NewRequest("GET", urls, body)
602 if err != nil {
603 return nil, err
604 }
605 req.Header = reqHeaders
606 googleapi.Expand(req.URL, map[string]string{
607 "name": c.name,
608 })
609 return gensupport.SendRequest(c.ctx_, c.s.client, req)
610 }
611
612
613
614
615
616
617
618 func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) {
619 gensupport.SetOptions(c.urlParams_, opts...)
620 res, err := c.doRequest("json")
621 if res != nil && res.StatusCode == http.StatusNotModified {
622 if res.Body != nil {
623 res.Body.Close()
624 }
625 return nil, gensupport.WrapError(&googleapi.Error{
626 Code: res.StatusCode,
627 Header: res.Header,
628 })
629 }
630 if err != nil {
631 return nil, err
632 }
633 defer googleapi.CloseBody(res)
634 if err := googleapi.CheckResponse(res); err != nil {
635 return nil, gensupport.WrapError(err)
636 }
637 ret := &ListOperationsResponse{
638 ServerResponse: googleapi.ServerResponse{
639 Header: res.Header,
640 HTTPStatusCode: res.StatusCode,
641 },
642 }
643 target := &ret
644 if err := gensupport.DecodeResponse(target, res); err != nil {
645 return nil, err
646 }
647 return ret, nil
648 }
649
650
651
652
653 func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error {
654 c.ctx_ = ctx
655 defer c.PageToken(c.urlParams_.Get("pageToken"))
656 for {
657 x, err := c.Do()
658 if err != nil {
659 return err
660 }
661 if err := f(x); err != nil {
662 return err
663 }
664 if x.NextPageToken == "" {
665 return nil
666 }
667 c.PageToken(x.NextPageToken)
668 }
669 }
670
View as plain text