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 youtubeanalytics
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 = "youtubeAnalytics:v2"
95 const apiName = "youtubeAnalytics"
96 const apiVersion = "v2"
97 const basePath = "https://youtubeanalytics.googleapis.com/"
98 const basePathTemplate = "https://youtubeanalytics.UNIVERSE_DOMAIN/"
99 const mtlsBasePath = "https://youtubeanalytics.mtls.googleapis.com/"
100
101
102 const (
103
104 YoutubeScope = "https://www.googleapis.com/auth/youtube"
105
106
107 YoutubeReadonlyScope = "https://www.googleapis.com/auth/youtube.readonly"
108
109
110 YoutubepartnerScope = "https://www.googleapis.com/auth/youtubepartner"
111
112
113
114 YtAnalyticsMonetaryReadonlyScope = "https://www.googleapis.com/auth/yt-analytics-monetary.readonly"
115
116
117 YtAnalyticsReadonlyScope = "https://www.googleapis.com/auth/yt-analytics.readonly"
118 )
119
120
121 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
122 scopesOption := internaloption.WithDefaultScopes(
123 "https://www.googleapis.com/auth/youtube",
124 "https://www.googleapis.com/auth/youtube.readonly",
125 "https://www.googleapis.com/auth/youtubepartner",
126 "https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
127 "https://www.googleapis.com/auth/yt-analytics.readonly",
128 )
129
130 opts = append([]option.ClientOption{scopesOption}, opts...)
131 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
132 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
133 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
134 opts = append(opts, internaloption.EnableNewAuthLibrary())
135 client, endpoint, err := htransport.NewClient(ctx, opts...)
136 if err != nil {
137 return nil, err
138 }
139 s, err := New(client)
140 if err != nil {
141 return nil, err
142 }
143 if endpoint != "" {
144 s.BasePath = endpoint
145 }
146 return s, nil
147 }
148
149
150
151
152
153
154 func New(client *http.Client) (*Service, error) {
155 if client == nil {
156 return nil, errors.New("client is nil")
157 }
158 s := &Service{client: client, BasePath: basePath}
159 s.GroupItems = NewGroupItemsService(s)
160 s.Groups = NewGroupsService(s)
161 s.Reports = NewReportsService(s)
162 return s, nil
163 }
164
165 type Service struct {
166 client *http.Client
167 BasePath string
168 UserAgent string
169
170 GroupItems *GroupItemsService
171
172 Groups *GroupsService
173
174 Reports *ReportsService
175 }
176
177 func (s *Service) userAgent() string {
178 if s.UserAgent == "" {
179 return googleapi.UserAgent
180 }
181 return googleapi.UserAgent + " " + s.UserAgent
182 }
183
184 func NewGroupItemsService(s *Service) *GroupItemsService {
185 rs := &GroupItemsService{s: s}
186 return rs
187 }
188
189 type GroupItemsService struct {
190 s *Service
191 }
192
193 func NewGroupsService(s *Service) *GroupsService {
194 rs := &GroupsService{s: s}
195 return rs
196 }
197
198 type GroupsService struct {
199 s *Service
200 }
201
202 func NewReportsService(s *Service) *ReportsService {
203 rs := &ReportsService{s: s}
204 return rs
205 }
206
207 type ReportsService struct {
208 s *Service
209 }
210
211
212 type EmptyResponse struct {
213
214 Errors *Errors `json:"errors,omitempty"`
215
216
217 googleapi.ServerResponse `json:"-"`
218
219
220
221
222
223 ForceSendFields []string `json:"-"`
224
225
226
227
228 NullFields []string `json:"-"`
229 }
230
231 func (s *EmptyResponse) MarshalJSON() ([]byte, error) {
232 type NoMethod EmptyResponse
233 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
234 }
235
236
237 type ErrorProto struct {
238
239
240
241 Argument []string `json:"argument,omitempty"`
242
243
244
245 Code string `json:"code,omitempty"`
246
247 DebugInfo string `json:"debugInfo,omitempty"`
248
249
250
251 Domain string `json:"domain,omitempty"`
252
253
254
255
256
257
258
259 ExternalErrorMessage string `json:"externalErrorMessage,omitempty"`
260
261
262
263
264 Location string `json:"location,omitempty"`
265
266
267
268
269
270
271 LocationType string `json:"locationType,omitempty"`
272
273
274
275
276
277 ForceSendFields []string `json:"-"`
278
279
280
281
282 NullFields []string `json:"-"`
283 }
284
285 func (s *ErrorProto) MarshalJSON() ([]byte, error) {
286 type NoMethod ErrorProto
287 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
288 }
289
290
291
292 type Errors struct {
293
294
295
296
297
298
299
300
301
302
303
304
305 Code string `json:"code,omitempty"`
306
307 Error []*ErrorProto `json:"error,omitempty"`
308
309
310 RequestId string `json:"requestId,omitempty"`
311
312
313
314
315
316 ForceSendFields []string `json:"-"`
317
318
319
320
321 NullFields []string `json:"-"`
322 }
323
324 func (s *Errors) MarshalJSON() ([]byte, error) {
325 type NoMethod Errors
326 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
327 }
328
329
330 type Group struct {
331
332
333 ContentDetails *GroupContentDetails `json:"contentDetails,omitempty"`
334
335 Errors *Errors `json:"errors,omitempty"`
336
337 Etag string `json:"etag,omitempty"`
338
339 Id string `json:"id,omitempty"`
340
341 Kind string `json:"kind,omitempty"`
342
343
344 Snippet *GroupSnippet `json:"snippet,omitempty"`
345
346
347 googleapi.ServerResponse `json:"-"`
348
349
350
351
352
353 ForceSendFields []string `json:"-"`
354
355
356
357
358 NullFields []string `json:"-"`
359 }
360
361 func (s *Group) MarshalJSON() ([]byte, error) {
362 type NoMethod Group
363 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
364 }
365
366
367 type GroupContentDetails struct {
368
369 ItemCount uint64 `json:"itemCount,omitempty,string"`
370
371
372
373 ItemType string `json:"itemType,omitempty"`
374
375
376
377
378
379 ForceSendFields []string `json:"-"`
380
381
382
383
384 NullFields []string `json:"-"`
385 }
386
387 func (s *GroupContentDetails) MarshalJSON() ([]byte, error) {
388 type NoMethod GroupContentDetails
389 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
390 }
391
392
393 type GroupItem struct {
394
395 Errors *Errors `json:"errors,omitempty"`
396
397 Etag string `json:"etag,omitempty"`
398
399
400 GroupId string `json:"groupId,omitempty"`
401
402
403
404
405
406
407
408 Id string `json:"id,omitempty"`
409
410
411 Kind string `json:"kind,omitempty"`
412
413
414 Resource *GroupItemResource `json:"resource,omitempty"`
415
416
417 googleapi.ServerResponse `json:"-"`
418
419
420
421
422
423 ForceSendFields []string `json:"-"`
424
425
426
427
428 NullFields []string `json:"-"`
429 }
430
431 func (s *GroupItem) MarshalJSON() ([]byte, error) {
432 type NoMethod GroupItem
433 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
434 }
435
436 type GroupItemResource struct {
437
438
439 Id string `json:"id,omitempty"`
440
441
442
443 Kind string `json:"kind,omitempty"`
444
445
446
447
448
449 ForceSendFields []string `json:"-"`
450
451
452
453
454 NullFields []string `json:"-"`
455 }
456
457 func (s *GroupItemResource) MarshalJSON() ([]byte, error) {
458 type NoMethod GroupItemResource
459 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
460 }
461
462
463 type GroupSnippet struct {
464
465
466 PublishedAt string `json:"publishedAt,omitempty"`
467
468 Title string `json:"title,omitempty"`
469
470
471
472
473
474 ForceSendFields []string `json:"-"`
475
476
477
478
479 NullFields []string `json:"-"`
480 }
481
482 func (s *GroupSnippet) MarshalJSON() ([]byte, error) {
483 type NoMethod GroupSnippet
484 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
485 }
486
487
488 type ListGroupItemsResponse struct {
489
490 Errors *Errors `json:"errors,omitempty"`
491
492 Etag string `json:"etag,omitempty"`
493
494
495 Items []*GroupItem `json:"items,omitempty"`
496
497
498 Kind string `json:"kind,omitempty"`
499
500
501 googleapi.ServerResponse `json:"-"`
502
503
504
505
506
507 ForceSendFields []string `json:"-"`
508
509
510
511
512 NullFields []string `json:"-"`
513 }
514
515 func (s *ListGroupItemsResponse) MarshalJSON() ([]byte, error) {
516 type NoMethod ListGroupItemsResponse
517 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
518 }
519
520
521 type ListGroupsResponse struct {
522
523 Errors *Errors `json:"errors,omitempty"`
524
525 Etag string `json:"etag,omitempty"`
526
527
528 Items []*Group `json:"items,omitempty"`
529
530
531 Kind string `json:"kind,omitempty"`
532
533
534 NextPageToken string `json:"nextPageToken,omitempty"`
535
536
537 googleapi.ServerResponse `json:"-"`
538
539
540
541
542
543 ForceSendFields []string `json:"-"`
544
545
546
547
548 NullFields []string `json:"-"`
549 }
550
551 func (s *ListGroupsResponse) MarshalJSON() ([]byte, error) {
552 type NoMethod ListGroupsResponse
553 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
554 }
555
556
557 type QueryResponse struct {
558
559
560
561
562
563
564
565
566
567 ColumnHeaders []*ResultTableColumnHeader `json:"columnHeaders,omitempty"`
568
569 Errors *Errors `json:"errors,omitempty"`
570
571
572
573 Kind string `json:"kind,omitempty"`
574
575
576
577
578
579
580
581 Rows [][]interface{} `json:"rows,omitempty"`
582
583
584 googleapi.ServerResponse `json:"-"`
585
586
587
588
589
590 ForceSendFields []string `json:"-"`
591
592
593
594
595 NullFields []string `json:"-"`
596 }
597
598 func (s *QueryResponse) MarshalJSON() ([]byte, error) {
599 type NoMethod QueryResponse
600 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
601 }
602
603
604 type ResultTableColumnHeader struct {
605
606 ColumnType string `json:"columnType,omitempty"`
607
608
609 DataType string `json:"dataType,omitempty"`
610
611 Name string `json:"name,omitempty"`
612
613
614
615
616
617 ForceSendFields []string `json:"-"`
618
619
620
621
622 NullFields []string `json:"-"`
623 }
624
625 func (s *ResultTableColumnHeader) MarshalJSON() ([]byte, error) {
626 type NoMethod ResultTableColumnHeader
627 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
628 }
629
630 type GroupItemsDeleteCall struct {
631 s *Service
632 urlParams_ gensupport.URLParams
633 ctx_ context.Context
634 header_ http.Header
635 }
636
637
638 func (r *GroupItemsService) Delete() *GroupItemsDeleteCall {
639 c := &GroupItemsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
640 return c
641 }
642
643
644
645 func (c *GroupItemsDeleteCall) Id(id string) *GroupItemsDeleteCall {
646 c.urlParams_.Set("id", id)
647 return c
648 }
649
650
651
652
653
654
655
656
657
658
659
660
661 func (c *GroupItemsDeleteCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupItemsDeleteCall {
662 c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
663 return c
664 }
665
666
667
668
669 func (c *GroupItemsDeleteCall) Fields(s ...googleapi.Field) *GroupItemsDeleteCall {
670 c.urlParams_.Set("fields", googleapi.CombineFields(s))
671 return c
672 }
673
674
675 func (c *GroupItemsDeleteCall) Context(ctx context.Context) *GroupItemsDeleteCall {
676 c.ctx_ = ctx
677 return c
678 }
679
680
681
682 func (c *GroupItemsDeleteCall) Header() http.Header {
683 if c.header_ == nil {
684 c.header_ = make(http.Header)
685 }
686 return c.header_
687 }
688
689 func (c *GroupItemsDeleteCall) doRequest(alt string) (*http.Response, error) {
690 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
691 var body io.Reader = nil
692 c.urlParams_.Set("alt", alt)
693 c.urlParams_.Set("prettyPrint", "false")
694 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groupItems")
695 urls += "?" + c.urlParams_.Encode()
696 req, err := http.NewRequest("DELETE", urls, body)
697 if err != nil {
698 return nil, err
699 }
700 req.Header = reqHeaders
701 return gensupport.SendRequest(c.ctx_, c.s.client, req)
702 }
703
704
705
706
707
708
709 func (c *GroupItemsDeleteCall) Do(opts ...googleapi.CallOption) (*EmptyResponse, error) {
710 gensupport.SetOptions(c.urlParams_, opts...)
711 res, err := c.doRequest("json")
712 if res != nil && res.StatusCode == http.StatusNotModified {
713 if res.Body != nil {
714 res.Body.Close()
715 }
716 return nil, gensupport.WrapError(&googleapi.Error{
717 Code: res.StatusCode,
718 Header: res.Header,
719 })
720 }
721 if err != nil {
722 return nil, err
723 }
724 defer googleapi.CloseBody(res)
725 if err := googleapi.CheckResponse(res); err != nil {
726 return nil, gensupport.WrapError(err)
727 }
728 ret := &EmptyResponse{
729 ServerResponse: googleapi.ServerResponse{
730 Header: res.Header,
731 HTTPStatusCode: res.StatusCode,
732 },
733 }
734 target := &ret
735 if err := gensupport.DecodeResponse(target, res); err != nil {
736 return nil, err
737 }
738 return ret, nil
739 }
740
741 type GroupItemsInsertCall struct {
742 s *Service
743 groupitem *GroupItem
744 urlParams_ gensupport.URLParams
745 ctx_ context.Context
746 header_ http.Header
747 }
748
749
750 func (r *GroupItemsService) Insert(groupitem *GroupItem) *GroupItemsInsertCall {
751 c := &GroupItemsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
752 c.groupitem = groupitem
753 return c
754 }
755
756
757
758
759
760
761
762
763
764
765
766
767 func (c *GroupItemsInsertCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupItemsInsertCall {
768 c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
769 return c
770 }
771
772
773
774
775 func (c *GroupItemsInsertCall) Fields(s ...googleapi.Field) *GroupItemsInsertCall {
776 c.urlParams_.Set("fields", googleapi.CombineFields(s))
777 return c
778 }
779
780
781 func (c *GroupItemsInsertCall) Context(ctx context.Context) *GroupItemsInsertCall {
782 c.ctx_ = ctx
783 return c
784 }
785
786
787
788 func (c *GroupItemsInsertCall) Header() http.Header {
789 if c.header_ == nil {
790 c.header_ = make(http.Header)
791 }
792 return c.header_
793 }
794
795 func (c *GroupItemsInsertCall) doRequest(alt string) (*http.Response, error) {
796 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
797 var body io.Reader = nil
798 body, err := googleapi.WithoutDataWrapper.JSONReader(c.groupitem)
799 if err != nil {
800 return nil, err
801 }
802 c.urlParams_.Set("alt", alt)
803 c.urlParams_.Set("prettyPrint", "false")
804 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groupItems")
805 urls += "?" + c.urlParams_.Encode()
806 req, err := http.NewRequest("POST", urls, body)
807 if err != nil {
808 return nil, err
809 }
810 req.Header = reqHeaders
811 return gensupport.SendRequest(c.ctx_, c.s.client, req)
812 }
813
814
815
816
817
818
819 func (c *GroupItemsInsertCall) Do(opts ...googleapi.CallOption) (*GroupItem, error) {
820 gensupport.SetOptions(c.urlParams_, opts...)
821 res, err := c.doRequest("json")
822 if res != nil && res.StatusCode == http.StatusNotModified {
823 if res.Body != nil {
824 res.Body.Close()
825 }
826 return nil, gensupport.WrapError(&googleapi.Error{
827 Code: res.StatusCode,
828 Header: res.Header,
829 })
830 }
831 if err != nil {
832 return nil, err
833 }
834 defer googleapi.CloseBody(res)
835 if err := googleapi.CheckResponse(res); err != nil {
836 return nil, gensupport.WrapError(err)
837 }
838 ret := &GroupItem{
839 ServerResponse: googleapi.ServerResponse{
840 Header: res.Header,
841 HTTPStatusCode: res.StatusCode,
842 },
843 }
844 target := &ret
845 if err := gensupport.DecodeResponse(target, res); err != nil {
846 return nil, err
847 }
848 return ret, nil
849 }
850
851 type GroupItemsListCall struct {
852 s *Service
853 urlParams_ gensupport.URLParams
854 ifNoneMatch_ string
855 ctx_ context.Context
856 header_ http.Header
857 }
858
859
860
861 func (r *GroupItemsService) List() *GroupItemsListCall {
862 c := &GroupItemsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
863 return c
864 }
865
866
867
868
869 func (c *GroupItemsListCall) GroupId(groupId string) *GroupItemsListCall {
870 c.urlParams_.Set("groupId", groupId)
871 return c
872 }
873
874
875
876
877
878
879
880
881
882
883
884
885 func (c *GroupItemsListCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupItemsListCall {
886 c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
887 return c
888 }
889
890
891
892
893 func (c *GroupItemsListCall) Fields(s ...googleapi.Field) *GroupItemsListCall {
894 c.urlParams_.Set("fields", googleapi.CombineFields(s))
895 return c
896 }
897
898
899
900
901 func (c *GroupItemsListCall) IfNoneMatch(entityTag string) *GroupItemsListCall {
902 c.ifNoneMatch_ = entityTag
903 return c
904 }
905
906
907 func (c *GroupItemsListCall) Context(ctx context.Context) *GroupItemsListCall {
908 c.ctx_ = ctx
909 return c
910 }
911
912
913
914 func (c *GroupItemsListCall) Header() http.Header {
915 if c.header_ == nil {
916 c.header_ = make(http.Header)
917 }
918 return c.header_
919 }
920
921 func (c *GroupItemsListCall) doRequest(alt string) (*http.Response, error) {
922 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
923 if c.ifNoneMatch_ != "" {
924 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
925 }
926 var body io.Reader = nil
927 c.urlParams_.Set("alt", alt)
928 c.urlParams_.Set("prettyPrint", "false")
929 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groupItems")
930 urls += "?" + c.urlParams_.Encode()
931 req, err := http.NewRequest("GET", urls, body)
932 if err != nil {
933 return nil, err
934 }
935 req.Header = reqHeaders
936 return gensupport.SendRequest(c.ctx_, c.s.client, req)
937 }
938
939
940
941
942
943
944
945 func (c *GroupItemsListCall) Do(opts ...googleapi.CallOption) (*ListGroupItemsResponse, error) {
946 gensupport.SetOptions(c.urlParams_, opts...)
947 res, err := c.doRequest("json")
948 if res != nil && res.StatusCode == http.StatusNotModified {
949 if res.Body != nil {
950 res.Body.Close()
951 }
952 return nil, gensupport.WrapError(&googleapi.Error{
953 Code: res.StatusCode,
954 Header: res.Header,
955 })
956 }
957 if err != nil {
958 return nil, err
959 }
960 defer googleapi.CloseBody(res)
961 if err := googleapi.CheckResponse(res); err != nil {
962 return nil, gensupport.WrapError(err)
963 }
964 ret := &ListGroupItemsResponse{
965 ServerResponse: googleapi.ServerResponse{
966 Header: res.Header,
967 HTTPStatusCode: res.StatusCode,
968 },
969 }
970 target := &ret
971 if err := gensupport.DecodeResponse(target, res); err != nil {
972 return nil, err
973 }
974 return ret, nil
975 }
976
977 type GroupsDeleteCall struct {
978 s *Service
979 urlParams_ gensupport.URLParams
980 ctx_ context.Context
981 header_ http.Header
982 }
983
984
985 func (r *GroupsService) Delete() *GroupsDeleteCall {
986 c := &GroupsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
987 return c
988 }
989
990
991
992 func (c *GroupsDeleteCall) Id(id string) *GroupsDeleteCall {
993 c.urlParams_.Set("id", id)
994 return c
995 }
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008 func (c *GroupsDeleteCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupsDeleteCall {
1009 c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
1010 return c
1011 }
1012
1013
1014
1015
1016 func (c *GroupsDeleteCall) Fields(s ...googleapi.Field) *GroupsDeleteCall {
1017 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1018 return c
1019 }
1020
1021
1022 func (c *GroupsDeleteCall) Context(ctx context.Context) *GroupsDeleteCall {
1023 c.ctx_ = ctx
1024 return c
1025 }
1026
1027
1028
1029 func (c *GroupsDeleteCall) Header() http.Header {
1030 if c.header_ == nil {
1031 c.header_ = make(http.Header)
1032 }
1033 return c.header_
1034 }
1035
1036 func (c *GroupsDeleteCall) doRequest(alt string) (*http.Response, error) {
1037 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1038 var body io.Reader = nil
1039 c.urlParams_.Set("alt", alt)
1040 c.urlParams_.Set("prettyPrint", "false")
1041 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groups")
1042 urls += "?" + c.urlParams_.Encode()
1043 req, err := http.NewRequest("DELETE", urls, body)
1044 if err != nil {
1045 return nil, err
1046 }
1047 req.Header = reqHeaders
1048 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1049 }
1050
1051
1052
1053
1054
1055
1056 func (c *GroupsDeleteCall) Do(opts ...googleapi.CallOption) (*EmptyResponse, error) {
1057 gensupport.SetOptions(c.urlParams_, opts...)
1058 res, err := c.doRequest("json")
1059 if res != nil && res.StatusCode == http.StatusNotModified {
1060 if res.Body != nil {
1061 res.Body.Close()
1062 }
1063 return nil, gensupport.WrapError(&googleapi.Error{
1064 Code: res.StatusCode,
1065 Header: res.Header,
1066 })
1067 }
1068 if err != nil {
1069 return nil, err
1070 }
1071 defer googleapi.CloseBody(res)
1072 if err := googleapi.CheckResponse(res); err != nil {
1073 return nil, gensupport.WrapError(err)
1074 }
1075 ret := &EmptyResponse{
1076 ServerResponse: googleapi.ServerResponse{
1077 Header: res.Header,
1078 HTTPStatusCode: res.StatusCode,
1079 },
1080 }
1081 target := &ret
1082 if err := gensupport.DecodeResponse(target, res); err != nil {
1083 return nil, err
1084 }
1085 return ret, nil
1086 }
1087
1088 type GroupsInsertCall struct {
1089 s *Service
1090 group *Group
1091 urlParams_ gensupport.URLParams
1092 ctx_ context.Context
1093 header_ http.Header
1094 }
1095
1096
1097 func (r *GroupsService) Insert(group *Group) *GroupsInsertCall {
1098 c := &GroupsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1099 c.group = group
1100 return c
1101 }
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114 func (c *GroupsInsertCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupsInsertCall {
1115 c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
1116 return c
1117 }
1118
1119
1120
1121
1122 func (c *GroupsInsertCall) Fields(s ...googleapi.Field) *GroupsInsertCall {
1123 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1124 return c
1125 }
1126
1127
1128 func (c *GroupsInsertCall) Context(ctx context.Context) *GroupsInsertCall {
1129 c.ctx_ = ctx
1130 return c
1131 }
1132
1133
1134
1135 func (c *GroupsInsertCall) Header() http.Header {
1136 if c.header_ == nil {
1137 c.header_ = make(http.Header)
1138 }
1139 return c.header_
1140 }
1141
1142 func (c *GroupsInsertCall) doRequest(alt string) (*http.Response, error) {
1143 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1144 var body io.Reader = nil
1145 body, err := googleapi.WithoutDataWrapper.JSONReader(c.group)
1146 if err != nil {
1147 return nil, err
1148 }
1149 c.urlParams_.Set("alt", alt)
1150 c.urlParams_.Set("prettyPrint", "false")
1151 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groups")
1152 urls += "?" + c.urlParams_.Encode()
1153 req, err := http.NewRequest("POST", urls, body)
1154 if err != nil {
1155 return nil, err
1156 }
1157 req.Header = reqHeaders
1158 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1159 }
1160
1161
1162
1163
1164
1165
1166 func (c *GroupsInsertCall) Do(opts ...googleapi.CallOption) (*Group, error) {
1167 gensupport.SetOptions(c.urlParams_, opts...)
1168 res, err := c.doRequest("json")
1169 if res != nil && res.StatusCode == http.StatusNotModified {
1170 if res.Body != nil {
1171 res.Body.Close()
1172 }
1173 return nil, gensupport.WrapError(&googleapi.Error{
1174 Code: res.StatusCode,
1175 Header: res.Header,
1176 })
1177 }
1178 if err != nil {
1179 return nil, err
1180 }
1181 defer googleapi.CloseBody(res)
1182 if err := googleapi.CheckResponse(res); err != nil {
1183 return nil, gensupport.WrapError(err)
1184 }
1185 ret := &Group{
1186 ServerResponse: googleapi.ServerResponse{
1187 Header: res.Header,
1188 HTTPStatusCode: res.StatusCode,
1189 },
1190 }
1191 target := &ret
1192 if err := gensupport.DecodeResponse(target, res); err != nil {
1193 return nil, err
1194 }
1195 return ret, nil
1196 }
1197
1198 type GroupsListCall struct {
1199 s *Service
1200 urlParams_ gensupport.URLParams
1201 ifNoneMatch_ string
1202 ctx_ context.Context
1203 header_ http.Header
1204 }
1205
1206
1207
1208
1209 func (r *GroupsService) List() *GroupsListCall {
1210 c := &GroupsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1211 return c
1212 }
1213
1214
1215
1216
1217
1218
1219
1220 func (c *GroupsListCall) Id(id string) *GroupsListCall {
1221 c.urlParams_.Set("id", id)
1222 return c
1223 }
1224
1225
1226
1227
1228 func (c *GroupsListCall) Mine(mine bool) *GroupsListCall {
1229 c.urlParams_.Set("mine", fmt.Sprint(mine))
1230 return c
1231 }
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244 func (c *GroupsListCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupsListCall {
1245 c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
1246 return c
1247 }
1248
1249
1250
1251
1252
1253 func (c *GroupsListCall) PageToken(pageToken string) *GroupsListCall {
1254 c.urlParams_.Set("pageToken", pageToken)
1255 return c
1256 }
1257
1258
1259
1260
1261 func (c *GroupsListCall) Fields(s ...googleapi.Field) *GroupsListCall {
1262 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1263 return c
1264 }
1265
1266
1267
1268
1269 func (c *GroupsListCall) IfNoneMatch(entityTag string) *GroupsListCall {
1270 c.ifNoneMatch_ = entityTag
1271 return c
1272 }
1273
1274
1275 func (c *GroupsListCall) Context(ctx context.Context) *GroupsListCall {
1276 c.ctx_ = ctx
1277 return c
1278 }
1279
1280
1281
1282 func (c *GroupsListCall) Header() http.Header {
1283 if c.header_ == nil {
1284 c.header_ = make(http.Header)
1285 }
1286 return c.header_
1287 }
1288
1289 func (c *GroupsListCall) doRequest(alt string) (*http.Response, error) {
1290 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1291 if c.ifNoneMatch_ != "" {
1292 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1293 }
1294 var body io.Reader = nil
1295 c.urlParams_.Set("alt", alt)
1296 c.urlParams_.Set("prettyPrint", "false")
1297 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groups")
1298 urls += "?" + c.urlParams_.Encode()
1299 req, err := http.NewRequest("GET", urls, body)
1300 if err != nil {
1301 return nil, err
1302 }
1303 req.Header = reqHeaders
1304 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1305 }
1306
1307
1308
1309
1310
1311
1312
1313 func (c *GroupsListCall) Do(opts ...googleapi.CallOption) (*ListGroupsResponse, error) {
1314 gensupport.SetOptions(c.urlParams_, opts...)
1315 res, err := c.doRequest("json")
1316 if res != nil && res.StatusCode == http.StatusNotModified {
1317 if res.Body != nil {
1318 res.Body.Close()
1319 }
1320 return nil, gensupport.WrapError(&googleapi.Error{
1321 Code: res.StatusCode,
1322 Header: res.Header,
1323 })
1324 }
1325 if err != nil {
1326 return nil, err
1327 }
1328 defer googleapi.CloseBody(res)
1329 if err := googleapi.CheckResponse(res); err != nil {
1330 return nil, gensupport.WrapError(err)
1331 }
1332 ret := &ListGroupsResponse{
1333 ServerResponse: googleapi.ServerResponse{
1334 Header: res.Header,
1335 HTTPStatusCode: res.StatusCode,
1336 },
1337 }
1338 target := &ret
1339 if err := gensupport.DecodeResponse(target, res); err != nil {
1340 return nil, err
1341 }
1342 return ret, nil
1343 }
1344
1345
1346
1347
1348 func (c *GroupsListCall) Pages(ctx context.Context, f func(*ListGroupsResponse) error) error {
1349 c.ctx_ = ctx
1350 defer c.PageToken(c.urlParams_.Get("pageToken"))
1351 for {
1352 x, err := c.Do()
1353 if err != nil {
1354 return err
1355 }
1356 if err := f(x); err != nil {
1357 return err
1358 }
1359 if x.NextPageToken == "" {
1360 return nil
1361 }
1362 c.PageToken(x.NextPageToken)
1363 }
1364 }
1365
1366 type GroupsUpdateCall struct {
1367 s *Service
1368 group *Group
1369 urlParams_ gensupport.URLParams
1370 ctx_ context.Context
1371 header_ http.Header
1372 }
1373
1374
1375 func (r *GroupsService) Update(group *Group) *GroupsUpdateCall {
1376 c := &GroupsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1377 c.group = group
1378 return c
1379 }
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392 func (c *GroupsUpdateCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupsUpdateCall {
1393 c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
1394 return c
1395 }
1396
1397
1398
1399
1400 func (c *GroupsUpdateCall) Fields(s ...googleapi.Field) *GroupsUpdateCall {
1401 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1402 return c
1403 }
1404
1405
1406 func (c *GroupsUpdateCall) Context(ctx context.Context) *GroupsUpdateCall {
1407 c.ctx_ = ctx
1408 return c
1409 }
1410
1411
1412
1413 func (c *GroupsUpdateCall) Header() http.Header {
1414 if c.header_ == nil {
1415 c.header_ = make(http.Header)
1416 }
1417 return c.header_
1418 }
1419
1420 func (c *GroupsUpdateCall) doRequest(alt string) (*http.Response, error) {
1421 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1422 var body io.Reader = nil
1423 body, err := googleapi.WithoutDataWrapper.JSONReader(c.group)
1424 if err != nil {
1425 return nil, err
1426 }
1427 c.urlParams_.Set("alt", alt)
1428 c.urlParams_.Set("prettyPrint", "false")
1429 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groups")
1430 urls += "?" + c.urlParams_.Encode()
1431 req, err := http.NewRequest("PUT", urls, body)
1432 if err != nil {
1433 return nil, err
1434 }
1435 req.Header = reqHeaders
1436 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1437 }
1438
1439
1440
1441
1442
1443
1444 func (c *GroupsUpdateCall) Do(opts ...googleapi.CallOption) (*Group, error) {
1445 gensupport.SetOptions(c.urlParams_, opts...)
1446 res, err := c.doRequest("json")
1447 if res != nil && res.StatusCode == http.StatusNotModified {
1448 if res.Body != nil {
1449 res.Body.Close()
1450 }
1451 return nil, gensupport.WrapError(&googleapi.Error{
1452 Code: res.StatusCode,
1453 Header: res.Header,
1454 })
1455 }
1456 if err != nil {
1457 return nil, err
1458 }
1459 defer googleapi.CloseBody(res)
1460 if err := googleapi.CheckResponse(res); err != nil {
1461 return nil, gensupport.WrapError(err)
1462 }
1463 ret := &Group{
1464 ServerResponse: googleapi.ServerResponse{
1465 Header: res.Header,
1466 HTTPStatusCode: res.StatusCode,
1467 },
1468 }
1469 target := &ret
1470 if err := gensupport.DecodeResponse(target, res); err != nil {
1471 return nil, err
1472 }
1473 return ret, nil
1474 }
1475
1476 type ReportsQueryCall struct {
1477 s *Service
1478 urlParams_ gensupport.URLParams
1479 ifNoneMatch_ string
1480 ctx_ context.Context
1481 header_ http.Header
1482 }
1483
1484
1485 func (r *ReportsService) Query() *ReportsQueryCall {
1486 c := &ReportsQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1487 return c
1488 }
1489
1490
1491
1492
1493
1494
1495 func (c *ReportsQueryCall) Currency(currency string) *ReportsQueryCall {
1496 c.urlParams_.Set("currency", currency)
1497 return c
1498 }
1499
1500
1501
1502
1503
1504
1505
1506 func (c *ReportsQueryCall) Dimensions(dimensions string) *ReportsQueryCall {
1507 c.urlParams_.Set("dimensions", dimensions)
1508 return c
1509 }
1510
1511
1512
1513
1514 func (c *ReportsQueryCall) EndDate(endDate string) *ReportsQueryCall {
1515 c.urlParams_.Set("endDate", endDate)
1516 return c
1517 }
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528 func (c *ReportsQueryCall) Filters(filters string) *ReportsQueryCall {
1529 c.urlParams_.Set("filters", filters)
1530 return c
1531 }
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541 func (c *ReportsQueryCall) Ids(ids string) *ReportsQueryCall {
1542 c.urlParams_.Set("ids", ids)
1543 return c
1544 }
1545
1546
1547
1548
1549
1550 func (c *ReportsQueryCall) IncludeHistoricalChannelData(includeHistoricalChannelData bool) *ReportsQueryCall {
1551 c.urlParams_.Set("includeHistoricalChannelData", fmt.Sprint(includeHistoricalChannelData))
1552 return c
1553 }
1554
1555
1556
1557 func (c *ReportsQueryCall) MaxResults(maxResults int64) *ReportsQueryCall {
1558 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
1559 return c
1560 }
1561
1562
1563
1564
1565
1566
1567
1568 func (c *ReportsQueryCall) Metrics(metrics string) *ReportsQueryCall {
1569 c.urlParams_.Set("metrics", metrics)
1570 return c
1571 }
1572
1573
1574
1575
1576
1577 func (c *ReportsQueryCall) Sort(sort string) *ReportsQueryCall {
1578 c.urlParams_.Set("sort", sort)
1579 return c
1580 }
1581
1582
1583
1584
1585 func (c *ReportsQueryCall) StartDate(startDate string) *ReportsQueryCall {
1586 c.urlParams_.Set("startDate", startDate)
1587 return c
1588 }
1589
1590
1591
1592
1593 func (c *ReportsQueryCall) StartIndex(startIndex int64) *ReportsQueryCall {
1594 c.urlParams_.Set("startIndex", fmt.Sprint(startIndex))
1595 return c
1596 }
1597
1598
1599
1600
1601 func (c *ReportsQueryCall) Fields(s ...googleapi.Field) *ReportsQueryCall {
1602 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1603 return c
1604 }
1605
1606
1607
1608
1609 func (c *ReportsQueryCall) IfNoneMatch(entityTag string) *ReportsQueryCall {
1610 c.ifNoneMatch_ = entityTag
1611 return c
1612 }
1613
1614
1615 func (c *ReportsQueryCall) Context(ctx context.Context) *ReportsQueryCall {
1616 c.ctx_ = ctx
1617 return c
1618 }
1619
1620
1621
1622 func (c *ReportsQueryCall) Header() http.Header {
1623 if c.header_ == nil {
1624 c.header_ = make(http.Header)
1625 }
1626 return c.header_
1627 }
1628
1629 func (c *ReportsQueryCall) doRequest(alt string) (*http.Response, error) {
1630 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1631 if c.ifNoneMatch_ != "" {
1632 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1633 }
1634 var body io.Reader = nil
1635 c.urlParams_.Set("alt", alt)
1636 c.urlParams_.Set("prettyPrint", "false")
1637 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/reports")
1638 urls += "?" + c.urlParams_.Encode()
1639 req, err := http.NewRequest("GET", urls, body)
1640 if err != nil {
1641 return nil, err
1642 }
1643 req.Header = reqHeaders
1644 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1645 }
1646
1647
1648
1649
1650
1651
1652 func (c *ReportsQueryCall) Do(opts ...googleapi.CallOption) (*QueryResponse, error) {
1653 gensupport.SetOptions(c.urlParams_, opts...)
1654 res, err := c.doRequest("json")
1655 if res != nil && res.StatusCode == http.StatusNotModified {
1656 if res.Body != nil {
1657 res.Body.Close()
1658 }
1659 return nil, gensupport.WrapError(&googleapi.Error{
1660 Code: res.StatusCode,
1661 Header: res.Header,
1662 })
1663 }
1664 if err != nil {
1665 return nil, err
1666 }
1667 defer googleapi.CloseBody(res)
1668 if err := googleapi.CheckResponse(res); err != nil {
1669 return nil, gensupport.WrapError(err)
1670 }
1671 ret := &QueryResponse{
1672 ServerResponse: googleapi.ServerResponse{
1673 Header: res.Header,
1674 HTTPStatusCode: res.StatusCode,
1675 },
1676 }
1677 target := &ret
1678 if err := gensupport.DecodeResponse(target, res); err != nil {
1679 return nil, err
1680 }
1681 return ret, nil
1682 }
1683
View as plain text