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 gmailpostmastertools
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 = "gmailpostmastertools:v1beta1"
90 const apiName = "gmailpostmastertools"
91 const apiVersion = "v1beta1"
92 const basePath = "https://gmailpostmastertools.googleapis.com/"
93 const basePathTemplate = "https://gmailpostmastertools.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://gmailpostmastertools.mtls.googleapis.com/"
95
96
97 const (
98
99
100 PostmasterReadonlyScope = "https://www.googleapis.com/auth/postmaster.readonly"
101 )
102
103
104 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
105 scopesOption := internaloption.WithDefaultScopes(
106 "https://www.googleapis.com/auth/postmaster.readonly",
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.Domains = NewDomainsService(s)
139 return s, nil
140 }
141
142 type Service struct {
143 client *http.Client
144 BasePath string
145 UserAgent string
146
147 Domains *DomainsService
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 NewDomainsService(s *Service) *DomainsService {
158 rs := &DomainsService{s: s}
159 rs.TrafficStats = NewDomainsTrafficStatsService(s)
160 return rs
161 }
162
163 type DomainsService struct {
164 s *Service
165
166 TrafficStats *DomainsTrafficStatsService
167 }
168
169 func NewDomainsTrafficStatsService(s *Service) *DomainsTrafficStatsService {
170 rs := &DomainsTrafficStatsService{s: s}
171 return rs
172 }
173
174 type DomainsTrafficStatsService struct {
175 s *Service
176 }
177
178
179 type DeliveryError struct {
180
181
182
183
184
185
186
187
188 ErrorClass string `json:"errorClass,omitempty"`
189
190
191 ErrorRatio float64 `json:"errorRatio,omitempty"`
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219 ErrorType string `json:"errorType,omitempty"`
220
221
222
223
224
225 ForceSendFields []string `json:"-"`
226
227
228
229
230 NullFields []string `json:"-"`
231 }
232
233 func (s *DeliveryError) MarshalJSON() ([]byte, error) {
234 type NoMethod DeliveryError
235 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
236 }
237
238 func (s *DeliveryError) UnmarshalJSON(data []byte) error {
239 type NoMethod DeliveryError
240 var s1 struct {
241 ErrorRatio gensupport.JSONFloat64 `json:"errorRatio"`
242 *NoMethod
243 }
244 s1.NoMethod = (*NoMethod)(s)
245 if err := json.Unmarshal(data, &s1); err != nil {
246 return err
247 }
248 s.ErrorRatio = float64(s1.ErrorRatio)
249 return nil
250 }
251
252
253 type Domain struct {
254
255
256 CreateTime string `json:"createTime,omitempty"`
257
258
259
260 Name string `json:"name,omitempty"`
261
262
263
264
265
266
267
268
269
270
271
272 Permission string `json:"permission,omitempty"`
273
274
275 googleapi.ServerResponse `json:"-"`
276
277
278
279
280
281 ForceSendFields []string `json:"-"`
282
283
284
285
286 NullFields []string `json:"-"`
287 }
288
289 func (s *Domain) MarshalJSON() ([]byte, error) {
290 type NoMethod Domain
291 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
292 }
293
294
295
296 type FeedbackLoop struct {
297
298 Id string `json:"id,omitempty"`
299
300
301 SpamRatio float64 `json:"spamRatio,omitempty"`
302
303
304
305
306
307 ForceSendFields []string `json:"-"`
308
309
310
311
312 NullFields []string `json:"-"`
313 }
314
315 func (s *FeedbackLoop) MarshalJSON() ([]byte, error) {
316 type NoMethod FeedbackLoop
317 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
318 }
319
320 func (s *FeedbackLoop) UnmarshalJSON(data []byte) error {
321 type NoMethod FeedbackLoop
322 var s1 struct {
323 SpamRatio gensupport.JSONFloat64 `json:"spamRatio"`
324 *NoMethod
325 }
326 s1.NoMethod = (*NoMethod)(s)
327 if err := json.Unmarshal(data, &s1); err != nil {
328 return err
329 }
330 s.SpamRatio = float64(s1.SpamRatio)
331 return nil
332 }
333
334
335
336 type IpReputation struct {
337
338
339
340 IpCount int64 `json:"ipCount,omitempty,string"`
341
342
343
344
345 NumIps int64 `json:"numIps,omitempty,string"`
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363 Reputation string `json:"reputation,omitempty"`
364
365 SampleIps []string `json:"sampleIps,omitempty"`
366
367
368
369
370
371 ForceSendFields []string `json:"-"`
372
373
374
375
376 NullFields []string `json:"-"`
377 }
378
379 func (s *IpReputation) MarshalJSON() ([]byte, error) {
380 type NoMethod IpReputation
381 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
382 }
383
384
385 type ListDomainsResponse struct {
386
387 Domains []*Domain `json:"domains,omitempty"`
388
389
390 NextPageToken string `json:"nextPageToken,omitempty"`
391
392
393 googleapi.ServerResponse `json:"-"`
394
395
396
397
398
399 ForceSendFields []string `json:"-"`
400
401
402
403
404 NullFields []string `json:"-"`
405 }
406
407 func (s *ListDomainsResponse) MarshalJSON() ([]byte, error) {
408 type NoMethod ListDomainsResponse
409 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
410 }
411
412
413 type ListTrafficStatsResponse struct {
414
415
416 NextPageToken string `json:"nextPageToken,omitempty"`
417
418 TrafficStats []*TrafficStats `json:"trafficStats,omitempty"`
419
420
421 googleapi.ServerResponse `json:"-"`
422
423
424
425
426
427 ForceSendFields []string `json:"-"`
428
429
430
431
432 NullFields []string `json:"-"`
433 }
434
435 func (s *ListTrafficStatsResponse) MarshalJSON() ([]byte, error) {
436 type NoMethod ListTrafficStatsResponse
437 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
438 }
439
440
441 type TrafficStats struct {
442
443
444
445 DeliveryErrors []*DeliveryError `json:"deliveryErrors,omitempty"`
446
447
448
449 DkimSuccessRatio float64 `json:"dkimSuccessRatio,omitempty"`
450
451
452
453
454 DmarcSuccessRatio float64 `json:"dmarcSuccessRatio,omitempty"`
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472 DomainReputation string `json:"domainReputation,omitempty"`
473
474
475
476
477 InboundEncryptionRatio float64 `json:"inboundEncryptionRatio,omitempty"`
478
479
480
481 IpReputations []*IpReputation `json:"ipReputations,omitempty"`
482
483
484
485
486
487
488 Name string `json:"name,omitempty"`
489
490
491 OutboundEncryptionRatio float64 `json:"outboundEncryptionRatio,omitempty"`
492
493
494
495
496 SpammyFeedbackLoops []*FeedbackLoop `json:"spammyFeedbackLoops,omitempty"`
497
498
499
500 SpfSuccessRatio float64 `json:"spfSuccessRatio,omitempty"`
501
502
503
504
505
506 UserReportedSpamRatio float64 `json:"userReportedSpamRatio,omitempty"`
507
508
509
510
511
512
513 UserReportedSpamRatioLowerBound float64 `json:"userReportedSpamRatioLowerBound,omitempty"`
514
515
516
517
518
519
520 UserReportedSpamRatioUpperBound float64 `json:"userReportedSpamRatioUpperBound,omitempty"`
521
522
523 googleapi.ServerResponse `json:"-"`
524
525
526
527
528
529 ForceSendFields []string `json:"-"`
530
531
532
533
534 NullFields []string `json:"-"`
535 }
536
537 func (s *TrafficStats) MarshalJSON() ([]byte, error) {
538 type NoMethod TrafficStats
539 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
540 }
541
542 func (s *TrafficStats) UnmarshalJSON(data []byte) error {
543 type NoMethod TrafficStats
544 var s1 struct {
545 DkimSuccessRatio gensupport.JSONFloat64 `json:"dkimSuccessRatio"`
546 DmarcSuccessRatio gensupport.JSONFloat64 `json:"dmarcSuccessRatio"`
547 InboundEncryptionRatio gensupport.JSONFloat64 `json:"inboundEncryptionRatio"`
548 OutboundEncryptionRatio gensupport.JSONFloat64 `json:"outboundEncryptionRatio"`
549 SpfSuccessRatio gensupport.JSONFloat64 `json:"spfSuccessRatio"`
550 UserReportedSpamRatio gensupport.JSONFloat64 `json:"userReportedSpamRatio"`
551 UserReportedSpamRatioLowerBound gensupport.JSONFloat64 `json:"userReportedSpamRatioLowerBound"`
552 UserReportedSpamRatioUpperBound gensupport.JSONFloat64 `json:"userReportedSpamRatioUpperBound"`
553 *NoMethod
554 }
555 s1.NoMethod = (*NoMethod)(s)
556 if err := json.Unmarshal(data, &s1); err != nil {
557 return err
558 }
559 s.DkimSuccessRatio = float64(s1.DkimSuccessRatio)
560 s.DmarcSuccessRatio = float64(s1.DmarcSuccessRatio)
561 s.InboundEncryptionRatio = float64(s1.InboundEncryptionRatio)
562 s.OutboundEncryptionRatio = float64(s1.OutboundEncryptionRatio)
563 s.SpfSuccessRatio = float64(s1.SpfSuccessRatio)
564 s.UserReportedSpamRatio = float64(s1.UserReportedSpamRatio)
565 s.UserReportedSpamRatioLowerBound = float64(s1.UserReportedSpamRatioLowerBound)
566 s.UserReportedSpamRatioUpperBound = float64(s1.UserReportedSpamRatioUpperBound)
567 return nil
568 }
569
570 type DomainsGetCall struct {
571 s *Service
572 name string
573 urlParams_ gensupport.URLParams
574 ifNoneMatch_ string
575 ctx_ context.Context
576 header_ http.Header
577 }
578
579
580
581
582
583
584
585 func (r *DomainsService) Get(name string) *DomainsGetCall {
586 c := &DomainsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
587 c.name = name
588 return c
589 }
590
591
592
593
594 func (c *DomainsGetCall) Fields(s ...googleapi.Field) *DomainsGetCall {
595 c.urlParams_.Set("fields", googleapi.CombineFields(s))
596 return c
597 }
598
599
600
601
602 func (c *DomainsGetCall) IfNoneMatch(entityTag string) *DomainsGetCall {
603 c.ifNoneMatch_ = entityTag
604 return c
605 }
606
607
608 func (c *DomainsGetCall) Context(ctx context.Context) *DomainsGetCall {
609 c.ctx_ = ctx
610 return c
611 }
612
613
614
615 func (c *DomainsGetCall) Header() http.Header {
616 if c.header_ == nil {
617 c.header_ = make(http.Header)
618 }
619 return c.header_
620 }
621
622 func (c *DomainsGetCall) doRequest(alt string) (*http.Response, error) {
623 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
624 if c.ifNoneMatch_ != "" {
625 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
626 }
627 var body io.Reader = nil
628 c.urlParams_.Set("alt", alt)
629 c.urlParams_.Set("prettyPrint", "false")
630 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+name}")
631 urls += "?" + c.urlParams_.Encode()
632 req, err := http.NewRequest("GET", urls, body)
633 if err != nil {
634 return nil, err
635 }
636 req.Header = reqHeaders
637 googleapi.Expand(req.URL, map[string]string{
638 "name": c.name,
639 })
640 return gensupport.SendRequest(c.ctx_, c.s.client, req)
641 }
642
643
644
645
646
647
648 func (c *DomainsGetCall) Do(opts ...googleapi.CallOption) (*Domain, error) {
649 gensupport.SetOptions(c.urlParams_, opts...)
650 res, err := c.doRequest("json")
651 if res != nil && res.StatusCode == http.StatusNotModified {
652 if res.Body != nil {
653 res.Body.Close()
654 }
655 return nil, gensupport.WrapError(&googleapi.Error{
656 Code: res.StatusCode,
657 Header: res.Header,
658 })
659 }
660 if err != nil {
661 return nil, err
662 }
663 defer googleapi.CloseBody(res)
664 if err := googleapi.CheckResponse(res); err != nil {
665 return nil, gensupport.WrapError(err)
666 }
667 ret := &Domain{
668 ServerResponse: googleapi.ServerResponse{
669 Header: res.Header,
670 HTTPStatusCode: res.StatusCode,
671 },
672 }
673 target := &ret
674 if err := gensupport.DecodeResponse(target, res); err != nil {
675 return nil, err
676 }
677 return ret, nil
678 }
679
680 type DomainsListCall struct {
681 s *Service
682 urlParams_ gensupport.URLParams
683 ifNoneMatch_ string
684 ctx_ context.Context
685 header_ http.Header
686 }
687
688
689
690
691 func (r *DomainsService) List() *DomainsListCall {
692 c := &DomainsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
693 return c
694 }
695
696
697
698
699 func (c *DomainsListCall) PageSize(pageSize int64) *DomainsListCall {
700 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
701 return c
702 }
703
704
705
706
707
708 func (c *DomainsListCall) PageToken(pageToken string) *DomainsListCall {
709 c.urlParams_.Set("pageToken", pageToken)
710 return c
711 }
712
713
714
715
716 func (c *DomainsListCall) Fields(s ...googleapi.Field) *DomainsListCall {
717 c.urlParams_.Set("fields", googleapi.CombineFields(s))
718 return c
719 }
720
721
722
723
724 func (c *DomainsListCall) IfNoneMatch(entityTag string) *DomainsListCall {
725 c.ifNoneMatch_ = entityTag
726 return c
727 }
728
729
730 func (c *DomainsListCall) Context(ctx context.Context) *DomainsListCall {
731 c.ctx_ = ctx
732 return c
733 }
734
735
736
737 func (c *DomainsListCall) Header() http.Header {
738 if c.header_ == nil {
739 c.header_ = make(http.Header)
740 }
741 return c.header_
742 }
743
744 func (c *DomainsListCall) doRequest(alt string) (*http.Response, error) {
745 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
746 if c.ifNoneMatch_ != "" {
747 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
748 }
749 var body io.Reader = nil
750 c.urlParams_.Set("alt", alt)
751 c.urlParams_.Set("prettyPrint", "false")
752 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/domains")
753 urls += "?" + c.urlParams_.Encode()
754 req, err := http.NewRequest("GET", urls, body)
755 if err != nil {
756 return nil, err
757 }
758 req.Header = reqHeaders
759 return gensupport.SendRequest(c.ctx_, c.s.client, req)
760 }
761
762
763
764
765
766
767
768 func (c *DomainsListCall) Do(opts ...googleapi.CallOption) (*ListDomainsResponse, error) {
769 gensupport.SetOptions(c.urlParams_, opts...)
770 res, err := c.doRequest("json")
771 if res != nil && res.StatusCode == http.StatusNotModified {
772 if res.Body != nil {
773 res.Body.Close()
774 }
775 return nil, gensupport.WrapError(&googleapi.Error{
776 Code: res.StatusCode,
777 Header: res.Header,
778 })
779 }
780 if err != nil {
781 return nil, err
782 }
783 defer googleapi.CloseBody(res)
784 if err := googleapi.CheckResponse(res); err != nil {
785 return nil, gensupport.WrapError(err)
786 }
787 ret := &ListDomainsResponse{
788 ServerResponse: googleapi.ServerResponse{
789 Header: res.Header,
790 HTTPStatusCode: res.StatusCode,
791 },
792 }
793 target := &ret
794 if err := gensupport.DecodeResponse(target, res); err != nil {
795 return nil, err
796 }
797 return ret, nil
798 }
799
800
801
802
803 func (c *DomainsListCall) Pages(ctx context.Context, f func(*ListDomainsResponse) error) error {
804 c.ctx_ = ctx
805 defer c.PageToken(c.urlParams_.Get("pageToken"))
806 for {
807 x, err := c.Do()
808 if err != nil {
809 return err
810 }
811 if err := f(x); err != nil {
812 return err
813 }
814 if x.NextPageToken == "" {
815 return nil
816 }
817 c.PageToken(x.NextPageToken)
818 }
819 }
820
821 type DomainsTrafficStatsGetCall struct {
822 s *Service
823 name string
824 urlParams_ gensupport.URLParams
825 ifNoneMatch_ string
826 ctx_ context.Context
827 header_ http.Header
828 }
829
830
831
832
833
834
835
836 func (r *DomainsTrafficStatsService) Get(name string) *DomainsTrafficStatsGetCall {
837 c := &DomainsTrafficStatsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
838 c.name = name
839 return c
840 }
841
842
843
844
845 func (c *DomainsTrafficStatsGetCall) Fields(s ...googleapi.Field) *DomainsTrafficStatsGetCall {
846 c.urlParams_.Set("fields", googleapi.CombineFields(s))
847 return c
848 }
849
850
851
852
853 func (c *DomainsTrafficStatsGetCall) IfNoneMatch(entityTag string) *DomainsTrafficStatsGetCall {
854 c.ifNoneMatch_ = entityTag
855 return c
856 }
857
858
859 func (c *DomainsTrafficStatsGetCall) Context(ctx context.Context) *DomainsTrafficStatsGetCall {
860 c.ctx_ = ctx
861 return c
862 }
863
864
865
866 func (c *DomainsTrafficStatsGetCall) Header() http.Header {
867 if c.header_ == nil {
868 c.header_ = make(http.Header)
869 }
870 return c.header_
871 }
872
873 func (c *DomainsTrafficStatsGetCall) doRequest(alt string) (*http.Response, error) {
874 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
875 if c.ifNoneMatch_ != "" {
876 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
877 }
878 var body io.Reader = nil
879 c.urlParams_.Set("alt", alt)
880 c.urlParams_.Set("prettyPrint", "false")
881 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+name}")
882 urls += "?" + c.urlParams_.Encode()
883 req, err := http.NewRequest("GET", urls, body)
884 if err != nil {
885 return nil, err
886 }
887 req.Header = reqHeaders
888 googleapi.Expand(req.URL, map[string]string{
889 "name": c.name,
890 })
891 return gensupport.SendRequest(c.ctx_, c.s.client, req)
892 }
893
894
895
896
897
898
899 func (c *DomainsTrafficStatsGetCall) Do(opts ...googleapi.CallOption) (*TrafficStats, error) {
900 gensupport.SetOptions(c.urlParams_, opts...)
901 res, err := c.doRequest("json")
902 if res != nil && res.StatusCode == http.StatusNotModified {
903 if res.Body != nil {
904 res.Body.Close()
905 }
906 return nil, gensupport.WrapError(&googleapi.Error{
907 Code: res.StatusCode,
908 Header: res.Header,
909 })
910 }
911 if err != nil {
912 return nil, err
913 }
914 defer googleapi.CloseBody(res)
915 if err := googleapi.CheckResponse(res); err != nil {
916 return nil, gensupport.WrapError(err)
917 }
918 ret := &TrafficStats{
919 ServerResponse: googleapi.ServerResponse{
920 Header: res.Header,
921 HTTPStatusCode: res.StatusCode,
922 },
923 }
924 target := &ret
925 if err := gensupport.DecodeResponse(target, res); err != nil {
926 return nil, err
927 }
928 return ret, nil
929 }
930
931 type DomainsTrafficStatsListCall struct {
932 s *Service
933 parent string
934 urlParams_ gensupport.URLParams
935 ifNoneMatch_ string
936 ctx_ context.Context
937 header_ http.Header
938 }
939
940
941
942
943
944
945
946
947 func (r *DomainsTrafficStatsService) List(parent string) *DomainsTrafficStatsListCall {
948 c := &DomainsTrafficStatsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
949 c.parent = parent
950 return c
951 }
952
953
954
955
956 func (c *DomainsTrafficStatsListCall) EndDateDay(endDateDay int64) *DomainsTrafficStatsListCall {
957 c.urlParams_.Set("endDate.day", fmt.Sprint(endDateDay))
958 return c
959 }
960
961
962
963 func (c *DomainsTrafficStatsListCall) EndDateMonth(endDateMonth int64) *DomainsTrafficStatsListCall {
964 c.urlParams_.Set("endDate.month", fmt.Sprint(endDateMonth))
965 return c
966 }
967
968
969
970 func (c *DomainsTrafficStatsListCall) EndDateYear(endDateYear int64) *DomainsTrafficStatsListCall {
971 c.urlParams_.Set("endDate.year", fmt.Sprint(endDateYear))
972 return c
973 }
974
975
976
977
978 func (c *DomainsTrafficStatsListCall) PageSize(pageSize int64) *DomainsTrafficStatsListCall {
979 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
980 return c
981 }
982
983
984
985
986
987 func (c *DomainsTrafficStatsListCall) PageToken(pageToken string) *DomainsTrafficStatsListCall {
988 c.urlParams_.Set("pageToken", pageToken)
989 return c
990 }
991
992
993
994
995 func (c *DomainsTrafficStatsListCall) StartDateDay(startDateDay int64) *DomainsTrafficStatsListCall {
996 c.urlParams_.Set("startDate.day", fmt.Sprint(startDateDay))
997 return c
998 }
999
1000
1001
1002 func (c *DomainsTrafficStatsListCall) StartDateMonth(startDateMonth int64) *DomainsTrafficStatsListCall {
1003 c.urlParams_.Set("startDate.month", fmt.Sprint(startDateMonth))
1004 return c
1005 }
1006
1007
1008
1009 func (c *DomainsTrafficStatsListCall) StartDateYear(startDateYear int64) *DomainsTrafficStatsListCall {
1010 c.urlParams_.Set("startDate.year", fmt.Sprint(startDateYear))
1011 return c
1012 }
1013
1014
1015
1016
1017 func (c *DomainsTrafficStatsListCall) Fields(s ...googleapi.Field) *DomainsTrafficStatsListCall {
1018 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1019 return c
1020 }
1021
1022
1023
1024
1025 func (c *DomainsTrafficStatsListCall) IfNoneMatch(entityTag string) *DomainsTrafficStatsListCall {
1026 c.ifNoneMatch_ = entityTag
1027 return c
1028 }
1029
1030
1031 func (c *DomainsTrafficStatsListCall) Context(ctx context.Context) *DomainsTrafficStatsListCall {
1032 c.ctx_ = ctx
1033 return c
1034 }
1035
1036
1037
1038 func (c *DomainsTrafficStatsListCall) Header() http.Header {
1039 if c.header_ == nil {
1040 c.header_ = make(http.Header)
1041 }
1042 return c.header_
1043 }
1044
1045 func (c *DomainsTrafficStatsListCall) doRequest(alt string) (*http.Response, error) {
1046 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1047 if c.ifNoneMatch_ != "" {
1048 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1049 }
1050 var body io.Reader = nil
1051 c.urlParams_.Set("alt", alt)
1052 c.urlParams_.Set("prettyPrint", "false")
1053 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+parent}/trafficStats")
1054 urls += "?" + c.urlParams_.Encode()
1055 req, err := http.NewRequest("GET", urls, body)
1056 if err != nil {
1057 return nil, err
1058 }
1059 req.Header = reqHeaders
1060 googleapi.Expand(req.URL, map[string]string{
1061 "parent": c.parent,
1062 })
1063 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1064 }
1065
1066
1067
1068
1069
1070
1071
1072 func (c *DomainsTrafficStatsListCall) Do(opts ...googleapi.CallOption) (*ListTrafficStatsResponse, error) {
1073 gensupport.SetOptions(c.urlParams_, opts...)
1074 res, err := c.doRequest("json")
1075 if res != nil && res.StatusCode == http.StatusNotModified {
1076 if res.Body != nil {
1077 res.Body.Close()
1078 }
1079 return nil, gensupport.WrapError(&googleapi.Error{
1080 Code: res.StatusCode,
1081 Header: res.Header,
1082 })
1083 }
1084 if err != nil {
1085 return nil, err
1086 }
1087 defer googleapi.CloseBody(res)
1088 if err := googleapi.CheckResponse(res); err != nil {
1089 return nil, gensupport.WrapError(err)
1090 }
1091 ret := &ListTrafficStatsResponse{
1092 ServerResponse: googleapi.ServerResponse{
1093 Header: res.Header,
1094 HTTPStatusCode: res.StatusCode,
1095 },
1096 }
1097 target := &ret
1098 if err := gensupport.DecodeResponse(target, res); err != nil {
1099 return nil, err
1100 }
1101 return ret, nil
1102 }
1103
1104
1105
1106
1107 func (c *DomainsTrafficStatsListCall) Pages(ctx context.Context, f func(*ListTrafficStatsResponse) error) error {
1108 c.ctx_ = ctx
1109 defer c.PageToken(c.urlParams_.Get("pageToken"))
1110 for {
1111 x, err := c.Do()
1112 if err != nil {
1113 return err
1114 }
1115 if err := f(x); err != nil {
1116 return err
1117 }
1118 if x.NextPageToken == "" {
1119 return nil
1120 }
1121 c.PageToken(x.NextPageToken)
1122 }
1123 }
1124
View as plain text