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 realtimebidding
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 = "realtimebidding:v1alpha"
90 const apiName = "realtimebidding"
91 const apiVersion = "v1alpha"
92 const basePath = "https://realtimebidding.googleapis.com/"
93 const basePathTemplate = "https://realtimebidding.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://realtimebidding.mtls.googleapis.com/"
95
96
97 const (
98
99
100 RealtimeBiddingScope = "https://www.googleapis.com/auth/realtime-bidding"
101 )
102
103
104 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
105 scopesOption := internaloption.WithDefaultScopes(
106 "https://www.googleapis.com/auth/realtime-bidding",
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.Bidders = NewBiddersService(s)
139 return s, nil
140 }
141
142 type Service struct {
143 client *http.Client
144 BasePath string
145 UserAgent string
146
147 Bidders *BiddersService
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 NewBiddersService(s *Service) *BiddersService {
158 rs := &BiddersService{s: s}
159 rs.BiddingFunctions = NewBiddersBiddingFunctionsService(s)
160 return rs
161 }
162
163 type BiddersService struct {
164 s *Service
165
166 BiddingFunctions *BiddersBiddingFunctionsService
167 }
168
169 func NewBiddersBiddingFunctionsService(s *Service) *BiddersBiddingFunctionsService {
170 rs := &BiddersBiddingFunctionsService{s: s}
171 return rs
172 }
173
174 type BiddersBiddingFunctionsService struct {
175 s *Service
176 }
177
178
179 type ActivateBiddingFunctionRequest struct {
180 }
181
182
183 type ArchiveBiddingFunctionRequest struct {
184 }
185
186
187
188 type BiddingFunction struct {
189
190 BiddingFunction string `json:"biddingFunction,omitempty"`
191
192
193 Name string `json:"name,omitempty"`
194
195
196
197
198
199
200
201
202
203
204
205 State string `json:"state,omitempty"`
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304 Type string `json:"type,omitempty"`
305
306
307 googleapi.ServerResponse `json:"-"`
308
309
310
311
312
313 ForceSendFields []string `json:"-"`
314
315
316
317
318 NullFields []string `json:"-"`
319 }
320
321 func (s *BiddingFunction) MarshalJSON() ([]byte, error) {
322 type NoMethod BiddingFunction
323 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
324 }
325
326
327
328 type ListBiddingFunctionsResponse struct {
329
330 BiddingFunctions []*BiddingFunction `json:"biddingFunctions,omitempty"`
331
332
333
334 NextPageToken string `json:"nextPageToken,omitempty"`
335
336
337 googleapi.ServerResponse `json:"-"`
338
339
340
341
342
343 ForceSendFields []string `json:"-"`
344
345
346
347
348 NullFields []string `json:"-"`
349 }
350
351 func (s *ListBiddingFunctionsResponse) MarshalJSON() ([]byte, error) {
352 type NoMethod ListBiddingFunctionsResponse
353 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
354 }
355
356 type BiddersBiddingFunctionsActivateCall struct {
357 s *Service
358 name string
359 activatebiddingfunctionrequest *ActivateBiddingFunctionRequest
360 urlParams_ gensupport.URLParams
361 ctx_ context.Context
362 header_ http.Header
363 }
364
365
366
367
368
369
370 func (r *BiddersBiddingFunctionsService) Activate(name string, activatebiddingfunctionrequest *ActivateBiddingFunctionRequest) *BiddersBiddingFunctionsActivateCall {
371 c := &BiddersBiddingFunctionsActivateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
372 c.name = name
373 c.activatebiddingfunctionrequest = activatebiddingfunctionrequest
374 return c
375 }
376
377
378
379
380 func (c *BiddersBiddingFunctionsActivateCall) Fields(s ...googleapi.Field) *BiddersBiddingFunctionsActivateCall {
381 c.urlParams_.Set("fields", googleapi.CombineFields(s))
382 return c
383 }
384
385
386 func (c *BiddersBiddingFunctionsActivateCall) Context(ctx context.Context) *BiddersBiddingFunctionsActivateCall {
387 c.ctx_ = ctx
388 return c
389 }
390
391
392
393 func (c *BiddersBiddingFunctionsActivateCall) Header() http.Header {
394 if c.header_ == nil {
395 c.header_ = make(http.Header)
396 }
397 return c.header_
398 }
399
400 func (c *BiddersBiddingFunctionsActivateCall) doRequest(alt string) (*http.Response, error) {
401 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
402 var body io.Reader = nil
403 body, err := googleapi.WithoutDataWrapper.JSONReader(c.activatebiddingfunctionrequest)
404 if err != nil {
405 return nil, err
406 }
407 c.urlParams_.Set("alt", alt)
408 c.urlParams_.Set("prettyPrint", "false")
409 urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+name}:activate")
410 urls += "?" + c.urlParams_.Encode()
411 req, err := http.NewRequest("POST", urls, body)
412 if err != nil {
413 return nil, err
414 }
415 req.Header = reqHeaders
416 googleapi.Expand(req.URL, map[string]string{
417 "name": c.name,
418 })
419 return gensupport.SendRequest(c.ctx_, c.s.client, req)
420 }
421
422
423
424
425
426
427
428 func (c *BiddersBiddingFunctionsActivateCall) Do(opts ...googleapi.CallOption) (*BiddingFunction, error) {
429 gensupport.SetOptions(c.urlParams_, opts...)
430 res, err := c.doRequest("json")
431 if res != nil && res.StatusCode == http.StatusNotModified {
432 if res.Body != nil {
433 res.Body.Close()
434 }
435 return nil, gensupport.WrapError(&googleapi.Error{
436 Code: res.StatusCode,
437 Header: res.Header,
438 })
439 }
440 if err != nil {
441 return nil, err
442 }
443 defer googleapi.CloseBody(res)
444 if err := googleapi.CheckResponse(res); err != nil {
445 return nil, gensupport.WrapError(err)
446 }
447 ret := &BiddingFunction{
448 ServerResponse: googleapi.ServerResponse{
449 Header: res.Header,
450 HTTPStatusCode: res.StatusCode,
451 },
452 }
453 target := &ret
454 if err := gensupport.DecodeResponse(target, res); err != nil {
455 return nil, err
456 }
457 return ret, nil
458 }
459
460 type BiddersBiddingFunctionsArchiveCall struct {
461 s *Service
462 name string
463 archivebiddingfunctionrequest *ArchiveBiddingFunctionRequest
464 urlParams_ gensupport.URLParams
465 ctx_ context.Context
466 header_ http.Header
467 }
468
469
470
471
472
473
474
475 func (r *BiddersBiddingFunctionsService) Archive(name string, archivebiddingfunctionrequest *ArchiveBiddingFunctionRequest) *BiddersBiddingFunctionsArchiveCall {
476 c := &BiddersBiddingFunctionsArchiveCall{s: r.s, urlParams_: make(gensupport.URLParams)}
477 c.name = name
478 c.archivebiddingfunctionrequest = archivebiddingfunctionrequest
479 return c
480 }
481
482
483
484
485 func (c *BiddersBiddingFunctionsArchiveCall) Fields(s ...googleapi.Field) *BiddersBiddingFunctionsArchiveCall {
486 c.urlParams_.Set("fields", googleapi.CombineFields(s))
487 return c
488 }
489
490
491 func (c *BiddersBiddingFunctionsArchiveCall) Context(ctx context.Context) *BiddersBiddingFunctionsArchiveCall {
492 c.ctx_ = ctx
493 return c
494 }
495
496
497
498 func (c *BiddersBiddingFunctionsArchiveCall) Header() http.Header {
499 if c.header_ == nil {
500 c.header_ = make(http.Header)
501 }
502 return c.header_
503 }
504
505 func (c *BiddersBiddingFunctionsArchiveCall) doRequest(alt string) (*http.Response, error) {
506 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
507 var body io.Reader = nil
508 body, err := googleapi.WithoutDataWrapper.JSONReader(c.archivebiddingfunctionrequest)
509 if err != nil {
510 return nil, err
511 }
512 c.urlParams_.Set("alt", alt)
513 c.urlParams_.Set("prettyPrint", "false")
514 urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+name}:archive")
515 urls += "?" + c.urlParams_.Encode()
516 req, err := http.NewRequest("POST", urls, body)
517 if err != nil {
518 return nil, err
519 }
520 req.Header = reqHeaders
521 googleapi.Expand(req.URL, map[string]string{
522 "name": c.name,
523 })
524 return gensupport.SendRequest(c.ctx_, c.s.client, req)
525 }
526
527
528
529
530
531
532
533 func (c *BiddersBiddingFunctionsArchiveCall) Do(opts ...googleapi.CallOption) (*BiddingFunction, error) {
534 gensupport.SetOptions(c.urlParams_, opts...)
535 res, err := c.doRequest("json")
536 if res != nil && res.StatusCode == http.StatusNotModified {
537 if res.Body != nil {
538 res.Body.Close()
539 }
540 return nil, gensupport.WrapError(&googleapi.Error{
541 Code: res.StatusCode,
542 Header: res.Header,
543 })
544 }
545 if err != nil {
546 return nil, err
547 }
548 defer googleapi.CloseBody(res)
549 if err := googleapi.CheckResponse(res); err != nil {
550 return nil, gensupport.WrapError(err)
551 }
552 ret := &BiddingFunction{
553 ServerResponse: googleapi.ServerResponse{
554 Header: res.Header,
555 HTTPStatusCode: res.StatusCode,
556 },
557 }
558 target := &ret
559 if err := gensupport.DecodeResponse(target, res); err != nil {
560 return nil, err
561 }
562 return ret, nil
563 }
564
565 type BiddersBiddingFunctionsCreateCall struct {
566 s *Service
567 parent string
568 biddingfunction *BiddingFunction
569 urlParams_ gensupport.URLParams
570 ctx_ context.Context
571 header_ http.Header
572 }
573
574
575
576
577
578 func (r *BiddersBiddingFunctionsService) Create(parent string, biddingfunction *BiddingFunction) *BiddersBiddingFunctionsCreateCall {
579 c := &BiddersBiddingFunctionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
580 c.parent = parent
581 c.biddingfunction = biddingfunction
582 return c
583 }
584
585
586
587
588 func (c *BiddersBiddingFunctionsCreateCall) Fields(s ...googleapi.Field) *BiddersBiddingFunctionsCreateCall {
589 c.urlParams_.Set("fields", googleapi.CombineFields(s))
590 return c
591 }
592
593
594 func (c *BiddersBiddingFunctionsCreateCall) Context(ctx context.Context) *BiddersBiddingFunctionsCreateCall {
595 c.ctx_ = ctx
596 return c
597 }
598
599
600
601 func (c *BiddersBiddingFunctionsCreateCall) Header() http.Header {
602 if c.header_ == nil {
603 c.header_ = make(http.Header)
604 }
605 return c.header_
606 }
607
608 func (c *BiddersBiddingFunctionsCreateCall) doRequest(alt string) (*http.Response, error) {
609 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
610 var body io.Reader = nil
611 body, err := googleapi.WithoutDataWrapper.JSONReader(c.biddingfunction)
612 if err != nil {
613 return nil, err
614 }
615 c.urlParams_.Set("alt", alt)
616 c.urlParams_.Set("prettyPrint", "false")
617 urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+parent}/biddingFunctions")
618 urls += "?" + c.urlParams_.Encode()
619 req, err := http.NewRequest("POST", urls, body)
620 if err != nil {
621 return nil, err
622 }
623 req.Header = reqHeaders
624 googleapi.Expand(req.URL, map[string]string{
625 "parent": c.parent,
626 })
627 return gensupport.SendRequest(c.ctx_, c.s.client, req)
628 }
629
630
631
632
633
634
635
636 func (c *BiddersBiddingFunctionsCreateCall) Do(opts ...googleapi.CallOption) (*BiddingFunction, error) {
637 gensupport.SetOptions(c.urlParams_, opts...)
638 res, err := c.doRequest("json")
639 if res != nil && res.StatusCode == http.StatusNotModified {
640 if res.Body != nil {
641 res.Body.Close()
642 }
643 return nil, gensupport.WrapError(&googleapi.Error{
644 Code: res.StatusCode,
645 Header: res.Header,
646 })
647 }
648 if err != nil {
649 return nil, err
650 }
651 defer googleapi.CloseBody(res)
652 if err := googleapi.CheckResponse(res); err != nil {
653 return nil, gensupport.WrapError(err)
654 }
655 ret := &BiddingFunction{
656 ServerResponse: googleapi.ServerResponse{
657 Header: res.Header,
658 HTTPStatusCode: res.StatusCode,
659 },
660 }
661 target := &ret
662 if err := gensupport.DecodeResponse(target, res); err != nil {
663 return nil, err
664 }
665 return ret, nil
666 }
667
668 type BiddersBiddingFunctionsListCall struct {
669 s *Service
670 parent string
671 urlParams_ gensupport.URLParams
672 ifNoneMatch_ string
673 ctx_ context.Context
674 header_ http.Header
675 }
676
677
678
679
680
681 func (r *BiddersBiddingFunctionsService) List(parent string) *BiddersBiddingFunctionsListCall {
682 c := &BiddersBiddingFunctionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
683 c.parent = parent
684 return c
685 }
686
687
688
689 func (c *BiddersBiddingFunctionsListCall) PageSize(pageSize int64) *BiddersBiddingFunctionsListCall {
690 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
691 return c
692 }
693
694
695
696
697
698 func (c *BiddersBiddingFunctionsListCall) PageToken(pageToken string) *BiddersBiddingFunctionsListCall {
699 c.urlParams_.Set("pageToken", pageToken)
700 return c
701 }
702
703
704
705
706 func (c *BiddersBiddingFunctionsListCall) Fields(s ...googleapi.Field) *BiddersBiddingFunctionsListCall {
707 c.urlParams_.Set("fields", googleapi.CombineFields(s))
708 return c
709 }
710
711
712
713
714 func (c *BiddersBiddingFunctionsListCall) IfNoneMatch(entityTag string) *BiddersBiddingFunctionsListCall {
715 c.ifNoneMatch_ = entityTag
716 return c
717 }
718
719
720 func (c *BiddersBiddingFunctionsListCall) Context(ctx context.Context) *BiddersBiddingFunctionsListCall {
721 c.ctx_ = ctx
722 return c
723 }
724
725
726
727 func (c *BiddersBiddingFunctionsListCall) Header() http.Header {
728 if c.header_ == nil {
729 c.header_ = make(http.Header)
730 }
731 return c.header_
732 }
733
734 func (c *BiddersBiddingFunctionsListCall) doRequest(alt string) (*http.Response, error) {
735 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
736 if c.ifNoneMatch_ != "" {
737 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
738 }
739 var body io.Reader = nil
740 c.urlParams_.Set("alt", alt)
741 c.urlParams_.Set("prettyPrint", "false")
742 urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+parent}/biddingFunctions")
743 urls += "?" + c.urlParams_.Encode()
744 req, err := http.NewRequest("GET", urls, body)
745 if err != nil {
746 return nil, err
747 }
748 req.Header = reqHeaders
749 googleapi.Expand(req.URL, map[string]string{
750 "parent": c.parent,
751 })
752 return gensupport.SendRequest(c.ctx_, c.s.client, req)
753 }
754
755
756
757
758
759
760
761 func (c *BiddersBiddingFunctionsListCall) Do(opts ...googleapi.CallOption) (*ListBiddingFunctionsResponse, error) {
762 gensupport.SetOptions(c.urlParams_, opts...)
763 res, err := c.doRequest("json")
764 if res != nil && res.StatusCode == http.StatusNotModified {
765 if res.Body != nil {
766 res.Body.Close()
767 }
768 return nil, gensupport.WrapError(&googleapi.Error{
769 Code: res.StatusCode,
770 Header: res.Header,
771 })
772 }
773 if err != nil {
774 return nil, err
775 }
776 defer googleapi.CloseBody(res)
777 if err := googleapi.CheckResponse(res); err != nil {
778 return nil, gensupport.WrapError(err)
779 }
780 ret := &ListBiddingFunctionsResponse{
781 ServerResponse: googleapi.ServerResponse{
782 Header: res.Header,
783 HTTPStatusCode: res.StatusCode,
784 },
785 }
786 target := &ret
787 if err := gensupport.DecodeResponse(target, res); err != nil {
788 return nil, err
789 }
790 return ret, nil
791 }
792
793
794
795
796 func (c *BiddersBiddingFunctionsListCall) Pages(ctx context.Context, f func(*ListBiddingFunctionsResponse) error) error {
797 c.ctx_ = ctx
798 defer c.PageToken(c.urlParams_.Get("pageToken"))
799 for {
800 x, err := c.Do()
801 if err != nil {
802 return err
803 }
804 if err := f(x); err != nil {
805 return err
806 }
807 if x.NextPageToken == "" {
808 return nil
809 }
810 c.PageToken(x.NextPageToken)
811 }
812 }
813
View as plain text