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 package displayvideo
43
44 import (
45 "bytes"
46 "context"
47 "encoding/json"
48 "errors"
49 "fmt"
50 "io"
51 "net/http"
52 "net/url"
53 "strconv"
54 "strings"
55
56 googleapi "google.golang.org/api/googleapi"
57 gensupport "google.golang.org/api/internal/gensupport"
58 option "google.golang.org/api/option"
59 internaloption "google.golang.org/api/option/internaloption"
60 htransport "google.golang.org/api/transport/http"
61 )
62
63
64
65 var _ = bytes.NewBuffer
66 var _ = strconv.Itoa
67 var _ = fmt.Sprintf
68 var _ = json.NewDecoder
69 var _ = io.Copy
70 var _ = url.Parse
71 var _ = gensupport.MarshalJSON
72 var _ = googleapi.Version
73 var _ = errors.New
74 var _ = strings.Replace
75 var _ = context.Canceled
76 var _ = internaloption.WithDefaultEndpoint
77
78 const apiId = "displayvideo:v1beta"
79 const apiName = "displayvideo"
80 const apiVersion = "v1beta"
81 const basePath = "https://displayvideo.googleapis.com/"
82 const mtlsBasePath = "https://displayvideo.mtls.googleapis.com/"
83
84
85 const (
86
87
88 DisplayVideoScope = "https://www.googleapis.com/auth/display-video"
89
90
91 DoubleclickbidmanagerScope = "https://www.googleapis.com/auth/doubleclickbidmanager"
92 )
93
94
95 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
96 scopesOption := option.WithScopes(
97 "https://www.googleapis.com/auth/display-video",
98 "https://www.googleapis.com/auth/doubleclickbidmanager",
99 )
100
101 opts = append([]option.ClientOption{scopesOption}, opts...)
102 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
103 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
104 client, endpoint, err := htransport.NewClient(ctx, opts...)
105 if err != nil {
106 return nil, err
107 }
108 s, err := New(client)
109 if err != nil {
110 return nil, err
111 }
112 if endpoint != "" {
113 s.BasePath = endpoint
114 }
115 return s, nil
116 }
117
118
119
120
121
122
123 func New(client *http.Client) (*Service, error) {
124 if client == nil {
125 return nil, errors.New("client is nil")
126 }
127 s := &Service{client: client, BasePath: basePath}
128 s.Media = NewMediaService(s)
129 s.Sdfdownloadtask = NewSdfdownloadtaskService(s)
130 s.Sdfdownloadtasks = NewSdfdownloadtasksService(s)
131 return s, nil
132 }
133
134 type Service struct {
135 client *http.Client
136 BasePath string
137 UserAgent string
138
139 Media *MediaService
140
141 Sdfdownloadtask *SdfdownloadtaskService
142
143 Sdfdownloadtasks *SdfdownloadtasksService
144 }
145
146 func (s *Service) userAgent() string {
147 if s.UserAgent == "" {
148 return googleapi.UserAgent
149 }
150 return googleapi.UserAgent + " " + s.UserAgent
151 }
152
153 func NewMediaService(s *Service) *MediaService {
154 rs := &MediaService{s: s}
155 return rs
156 }
157
158 type MediaService struct {
159 s *Service
160 }
161
162 func NewSdfdownloadtaskService(s *Service) *SdfdownloadtaskService {
163 rs := &SdfdownloadtaskService{s: s}
164 rs.Operations = NewSdfdownloadtaskOperationsService(s)
165 return rs
166 }
167
168 type SdfdownloadtaskService struct {
169 s *Service
170
171 Operations *SdfdownloadtaskOperationsService
172 }
173
174 func NewSdfdownloadtaskOperationsService(s *Service) *SdfdownloadtaskOperationsService {
175 rs := &SdfdownloadtaskOperationsService{s: s}
176 return rs
177 }
178
179 type SdfdownloadtaskOperationsService struct {
180 s *Service
181 }
182
183 func NewSdfdownloadtasksService(s *Service) *SdfdownloadtasksService {
184 rs := &SdfdownloadtasksService{s: s}
185 rs.Operations = NewSdfdownloadtasksOperationsService(s)
186 return rs
187 }
188
189 type SdfdownloadtasksService struct {
190 s *Service
191
192 Operations *SdfdownloadtasksOperationsService
193 }
194
195 func NewSdfdownloadtasksOperationsService(s *Service) *SdfdownloadtasksOperationsService {
196 rs := &SdfdownloadtasksOperationsService{s: s}
197 return rs
198 }
199
200 type SdfdownloadtasksOperationsService struct {
201 s *Service
202 }
203
204
205 type GoogleBytestreamMedia struct {
206
207 ResourceName string `json:"resourceName,omitempty"`
208
209
210
211 googleapi.ServerResponse `json:"-"`
212
213
214
215
216
217
218
219 ForceSendFields []string `json:"-"`
220
221
222
223
224
225
226
227 NullFields []string `json:"-"`
228 }
229
230 func (s *GoogleBytestreamMedia) MarshalJSON() ([]byte, error) {
231 type NoMethod GoogleBytestreamMedia
232 raw := NoMethod(*s)
233 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
234 }
235
236
237
238 type Operation struct {
239
240
241
242 Done bool `json:"done,omitempty"`
243
244
245
246 Error *Status `json:"error,omitempty"`
247
248
249
250
251
252
253 Metadata googleapi.RawMessage `json:"metadata,omitempty"`
254
255
256
257
258
259 Name string `json:"name,omitempty"`
260
261
262
263
264
265
266
267
268
269 Response googleapi.RawMessage `json:"response,omitempty"`
270
271
272
273 googleapi.ServerResponse `json:"-"`
274
275
276
277
278
279
280
281 ForceSendFields []string `json:"-"`
282
283
284
285
286
287
288
289 NullFields []string `json:"-"`
290 }
291
292 func (s *Operation) MarshalJSON() ([]byte, error) {
293 type NoMethod Operation
294 raw := NoMethod(*s)
295 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
296 }
297
298
299
300
301
302
303
304
305 type Status struct {
306
307
308 Code int64 `json:"code,omitempty"`
309
310
311
312 Details []googleapi.RawMessage `json:"details,omitempty"`
313
314
315
316
317 Message string `json:"message,omitempty"`
318
319
320
321
322
323
324
325 ForceSendFields []string `json:"-"`
326
327
328
329
330
331
332
333 NullFields []string `json:"-"`
334 }
335
336 func (s *Status) MarshalJSON() ([]byte, error) {
337 type NoMethod Status
338 raw := NoMethod(*s)
339 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
340 }
341
342
343
344 type MediaDownloadCall struct {
345 s *Service
346 resourceName string
347 urlParams_ gensupport.URLParams
348 ifNoneMatch_ string
349 ctx_ context.Context
350 header_ http.Header
351 }
352
353
354
355
356 func (r *MediaService) Download(resourceName string) *MediaDownloadCall {
357 c := &MediaDownloadCall{s: r.s, urlParams_: make(gensupport.URLParams)}
358 c.resourceName = resourceName
359 return c
360 }
361
362
363
364
365 func (c *MediaDownloadCall) Fields(s ...googleapi.Field) *MediaDownloadCall {
366 c.urlParams_.Set("fields", googleapi.CombineFields(s))
367 return c
368 }
369
370
371
372
373
374
375 func (c *MediaDownloadCall) IfNoneMatch(entityTag string) *MediaDownloadCall {
376 c.ifNoneMatch_ = entityTag
377 return c
378 }
379
380
381
382
383 func (c *MediaDownloadCall) Context(ctx context.Context) *MediaDownloadCall {
384 c.ctx_ = ctx
385 return c
386 }
387
388
389
390 func (c *MediaDownloadCall) Header() http.Header {
391 if c.header_ == nil {
392 c.header_ = make(http.Header)
393 }
394 return c.header_
395 }
396
397 func (c *MediaDownloadCall) doRequest(alt string) (*http.Response, error) {
398 reqHeaders := make(http.Header)
399 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20201104")
400 for k, v := range c.header_ {
401 reqHeaders[k] = v
402 }
403 reqHeaders.Set("User-Agent", c.s.userAgent())
404 if c.ifNoneMatch_ != "" {
405 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
406 }
407 var body io.Reader = nil
408 c.urlParams_.Set("alt", alt)
409 c.urlParams_.Set("prettyPrint", "false")
410 urls := googleapi.ResolveRelative(c.s.BasePath, "download/{+resourceName}")
411 urls += "?" + c.urlParams_.Encode()
412 req, err := http.NewRequest("GET", urls, body)
413 if err != nil {
414 return nil, err
415 }
416 req.Header = reqHeaders
417 googleapi.Expand(req.URL, map[string]string{
418 "resourceName": c.resourceName,
419 })
420 return gensupport.SendRequest(c.ctx_, c.s.client, req)
421 }
422
423
424
425
426 func (c *MediaDownloadCall) Download(opts ...googleapi.CallOption) (*http.Response, error) {
427 gensupport.SetOptions(c.urlParams_, opts...)
428 res, err := c.doRequest("media")
429 if err != nil {
430 return nil, err
431 }
432 if err := googleapi.CheckMediaResponse(res); err != nil {
433 res.Body.Close()
434 return nil, err
435 }
436 return res, nil
437 }
438
439
440
441
442
443
444
445
446 func (c *MediaDownloadCall) Do(opts ...googleapi.CallOption) (*GoogleBytestreamMedia, error) {
447 gensupport.SetOptions(c.urlParams_, opts...)
448 res, err := c.doRequest("json")
449 if res != nil && res.StatusCode == http.StatusNotModified {
450 if res.Body != nil {
451 res.Body.Close()
452 }
453 return nil, &googleapi.Error{
454 Code: res.StatusCode,
455 Header: res.Header,
456 }
457 }
458 if err != nil {
459 return nil, err
460 }
461 defer googleapi.CloseBody(res)
462 if err := googleapi.CheckResponse(res); err != nil {
463 return nil, err
464 }
465 ret := &GoogleBytestreamMedia{
466 ServerResponse: googleapi.ServerResponse{
467 Header: res.Header,
468 HTTPStatusCode: res.StatusCode,
469 },
470 }
471 target := &ret
472 if err := gensupport.DecodeResponse(target, res); err != nil {
473 return nil, err
474 }
475 return ret, nil
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504 }
505
506
507
508 type SdfdownloadtaskOperationsGetCall struct {
509 s *Service
510 name string
511 urlParams_ gensupport.URLParams
512 ifNoneMatch_ string
513 ctx_ context.Context
514 header_ http.Header
515 }
516
517
518
519
520 func (r *SdfdownloadtaskOperationsService) Get(name string) *SdfdownloadtaskOperationsGetCall {
521 c := &SdfdownloadtaskOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
522 c.name = name
523 return c
524 }
525
526
527
528
529 func (c *SdfdownloadtaskOperationsGetCall) Fields(s ...googleapi.Field) *SdfdownloadtaskOperationsGetCall {
530 c.urlParams_.Set("fields", googleapi.CombineFields(s))
531 return c
532 }
533
534
535
536
537
538
539 func (c *SdfdownloadtaskOperationsGetCall) IfNoneMatch(entityTag string) *SdfdownloadtaskOperationsGetCall {
540 c.ifNoneMatch_ = entityTag
541 return c
542 }
543
544
545
546
547 func (c *SdfdownloadtaskOperationsGetCall) Context(ctx context.Context) *SdfdownloadtaskOperationsGetCall {
548 c.ctx_ = ctx
549 return c
550 }
551
552
553
554 func (c *SdfdownloadtaskOperationsGetCall) Header() http.Header {
555 if c.header_ == nil {
556 c.header_ = make(http.Header)
557 }
558 return c.header_
559 }
560
561 func (c *SdfdownloadtaskOperationsGetCall) doRequest(alt string) (*http.Response, error) {
562 reqHeaders := make(http.Header)
563 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20201104")
564 for k, v := range c.header_ {
565 reqHeaders[k] = v
566 }
567 reqHeaders.Set("User-Agent", c.s.userAgent())
568 if c.ifNoneMatch_ != "" {
569 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
570 }
571 var body io.Reader = nil
572 c.urlParams_.Set("alt", alt)
573 c.urlParams_.Set("prettyPrint", "false")
574 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}")
575 urls += "?" + c.urlParams_.Encode()
576 req, err := http.NewRequest("GET", urls, body)
577 if err != nil {
578 return nil, err
579 }
580 req.Header = reqHeaders
581 googleapi.Expand(req.URL, map[string]string{
582 "name": c.name,
583 })
584 return gensupport.SendRequest(c.ctx_, c.s.client, req)
585 }
586
587
588
589
590
591
592
593
594 func (c *SdfdownloadtaskOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
595 gensupport.SetOptions(c.urlParams_, opts...)
596 res, err := c.doRequest("json")
597 if res != nil && res.StatusCode == http.StatusNotModified {
598 if res.Body != nil {
599 res.Body.Close()
600 }
601 return nil, &googleapi.Error{
602 Code: res.StatusCode,
603 Header: res.Header,
604 }
605 }
606 if err != nil {
607 return nil, err
608 }
609 defer googleapi.CloseBody(res)
610 if err := googleapi.CheckResponse(res); err != nil {
611 return nil, err
612 }
613 ret := &Operation{
614 ServerResponse: googleapi.ServerResponse{
615 Header: res.Header,
616 HTTPStatusCode: res.StatusCode,
617 },
618 }
619 target := &ret
620 if err := gensupport.DecodeResponse(target, res); err != nil {
621 return nil, err
622 }
623 return ret, nil
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651 }
652
653
654
655 type SdfdownloadtasksOperationsGetCall struct {
656 s *Service
657 name string
658 urlParams_ gensupport.URLParams
659 ifNoneMatch_ string
660 ctx_ context.Context
661 header_ http.Header
662 }
663
664
665
666
667 func (r *SdfdownloadtasksOperationsService) Get(name string) *SdfdownloadtasksOperationsGetCall {
668 c := &SdfdownloadtasksOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
669 c.name = name
670 return c
671 }
672
673
674
675
676 func (c *SdfdownloadtasksOperationsGetCall) Fields(s ...googleapi.Field) *SdfdownloadtasksOperationsGetCall {
677 c.urlParams_.Set("fields", googleapi.CombineFields(s))
678 return c
679 }
680
681
682
683
684
685
686 func (c *SdfdownloadtasksOperationsGetCall) IfNoneMatch(entityTag string) *SdfdownloadtasksOperationsGetCall {
687 c.ifNoneMatch_ = entityTag
688 return c
689 }
690
691
692
693
694 func (c *SdfdownloadtasksOperationsGetCall) Context(ctx context.Context) *SdfdownloadtasksOperationsGetCall {
695 c.ctx_ = ctx
696 return c
697 }
698
699
700
701 func (c *SdfdownloadtasksOperationsGetCall) Header() http.Header {
702 if c.header_ == nil {
703 c.header_ = make(http.Header)
704 }
705 return c.header_
706 }
707
708 func (c *SdfdownloadtasksOperationsGetCall) doRequest(alt string) (*http.Response, error) {
709 reqHeaders := make(http.Header)
710 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20201104")
711 for k, v := range c.header_ {
712 reqHeaders[k] = v
713 }
714 reqHeaders.Set("User-Agent", c.s.userAgent())
715 if c.ifNoneMatch_ != "" {
716 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
717 }
718 var body io.Reader = nil
719 c.urlParams_.Set("alt", alt)
720 c.urlParams_.Set("prettyPrint", "false")
721 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}")
722 urls += "?" + c.urlParams_.Encode()
723 req, err := http.NewRequest("GET", urls, body)
724 if err != nil {
725 return nil, err
726 }
727 req.Header = reqHeaders
728 googleapi.Expand(req.URL, map[string]string{
729 "name": c.name,
730 })
731 return gensupport.SendRequest(c.ctx_, c.s.client, req)
732 }
733
734
735
736
737
738
739
740
741 func (c *SdfdownloadtasksOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
742 gensupport.SetOptions(c.urlParams_, opts...)
743 res, err := c.doRequest("json")
744 if res != nil && res.StatusCode == http.StatusNotModified {
745 if res.Body != nil {
746 res.Body.Close()
747 }
748 return nil, &googleapi.Error{
749 Code: res.StatusCode,
750 Header: res.Header,
751 }
752 }
753 if err != nil {
754 return nil, err
755 }
756 defer googleapi.CloseBody(res)
757 if err := googleapi.CheckResponse(res); err != nil {
758 return nil, err
759 }
760 ret := &Operation{
761 ServerResponse: googleapi.ServerResponse{
762 Header: res.Header,
763 HTTPStatusCode: res.StatusCode,
764 },
765 }
766 target := &ret
767 if err := gensupport.DecodeResponse(target, res); err != nil {
768 return nil, err
769 }
770 return ret, nil
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798 }
799
View as plain text