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