...

Source file src/google.golang.org/api/gmailpostmastertools/v1beta1/gmailpostmastertools-gen.go

Documentation: google.golang.org/api/gmailpostmastertools/v1beta1

     1  // Copyright 2024 Google LLC.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Code generated file. DO NOT EDIT.
     6  
     7  // Package gmailpostmastertools provides access to the Gmail Postmaster Tools API.
     8  //
     9  // For product documentation, see: https://developers.google.com/gmail/postmaster
    10  //
    11  // # Library status
    12  //
    13  // These client libraries are officially supported by Google. However, this
    14  // library is considered complete and is in maintenance mode. This means
    15  // that we will address critical bugs and security issues but will not add
    16  // any new features.
    17  //
    18  // When possible, we recommend using our newer
    19  // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
    20  // that are still actively being worked and iterated on.
    21  //
    22  // # Creating a client
    23  //
    24  // Usage example:
    25  //
    26  //	import "google.golang.org/api/gmailpostmastertools/v1beta1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	gmailpostmastertoolsService, err := gmailpostmastertools.NewService(ctx)
    30  //
    31  // In this example, Google Application Default Credentials are used for
    32  // authentication. For information on how to create and obtain Application
    33  // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    34  //
    35  // # Other authentication options
    36  //
    37  // To use an API key for authentication (note: some APIs do not support API
    38  // keys), use [google.golang.org/api/option.WithAPIKey]:
    39  //
    40  //	gmailpostmastertoolsService, err := gmailpostmastertools.NewService(ctx, option.WithAPIKey("AIza..."))
    41  //
    42  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    43  // flow, use [google.golang.org/api/option.WithTokenSource]:
    44  //
    45  //	config := &oauth2.Config{...}
    46  //	// ...
    47  //	token, err := config.Exchange(ctx, ...)
    48  //	gmailpostmastertoolsService, err := gmailpostmastertools.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49  //
    50  // See [google.golang.org/api/option.ClientOption] for details on options.
    51  package gmailpostmastertools // import "google.golang.org/api/gmailpostmastertools/v1beta1"
    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  // Always reference these packages, just in case the auto-generated code
    74  // below doesn't.
    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  // OAuth2 scopes used by this API.
    97  const (
    98  	// See email traffic metrics for the domains you have registered in Gmail
    99  	// Postmaster Tools
   100  	PostmasterReadonlyScope = "https://www.googleapis.com/auth/postmaster.readonly"
   101  )
   102  
   103  // NewService creates a new Service.
   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  	// NOTE: prepend, so we don't override user-specified scopes.
   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  // New creates a new Service. It uses the provided http.Client for requests.
   129  //
   130  // Deprecated: please use NewService instead.
   131  // To provide a custom HTTP client, use option.WithHTTPClient.
   132  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   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 // API endpoint base URL
   145  	UserAgent string // optional additional User-Agent fragment
   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  // DeliveryError: Metric on a particular delivery error type.
   179  type DeliveryError struct {
   180  	// ErrorClass: The class of delivery error.
   181  	//
   182  	// Possible values:
   183  	//   "DELIVERY_ERROR_CLASS_UNSPECIFIED" - The default value which should never
   184  	// be used explicitly.
   185  	//   "PERMANENT_ERROR" - Delivery of message has been rejected.
   186  	//   "TEMPORARY_ERROR" - Temporary failure of message delivery to the
   187  	// recipient.
   188  	ErrorClass string `json:"errorClass,omitempty"`
   189  	// ErrorRatio: The ratio of messages where the error occurred vs all
   190  	// authenticated traffic.
   191  	ErrorRatio float64 `json:"errorRatio,omitempty"`
   192  	// ErrorType: The type of delivery error.
   193  	//
   194  	// Possible values:
   195  	//   "DELIVERY_ERROR_TYPE_UNSPECIFIED" - The default value which should never
   196  	// be used explicitly.
   197  	//   "RATE_LIMIT_EXCEEDED" - The Domain or IP is sending traffic at a
   198  	// suspiciously high rate, due to which temporary rate limits have been
   199  	// imposed. The limit will be lifted when Gmail is confident enough of the
   200  	// nature of the traffic.
   201  	//   "SUSPECTED_SPAM" - The traffic is suspected to be spam, by Gmail, for
   202  	// various reasons.
   203  	//   "CONTENT_SPAMMY" - The traffic is suspected to be spammy, specific to the
   204  	// content.
   205  	//   "BAD_ATTACHMENT" - Traffic contains attachments not supported by Gmail.
   206  	//   "BAD_DMARC_POLICY" - The sender domain has set up a DMARC rejection
   207  	// policy.
   208  	//   "LOW_IP_REPUTATION" - The IP reputation of the sending IP is very low.
   209  	//   "LOW_DOMAIN_REPUTATION" - The Domain reputation of the sending domain is
   210  	// very low.
   211  	//   "IP_IN_RBL" - The IP is listed in one or more public [Real-time Blackhole
   212  	// Lists](http://en.wikipedia.org/wiki/DNSBL). Work with the RBL to get your IP
   213  	// delisted.
   214  	//   "DOMAIN_IN_RBL" - The Domain is listed in one or more public [Real-time
   215  	// Blackhole Lists](http://en.wikipedia.org/wiki/DNSBL). Work with the RBL to
   216  	// get your domain delisted.
   217  	//   "BAD_PTR_RECORD" - The sending IP is missing a [PTR
   218  	// record](https://support.google.com/domains/answer/3251147#ptr).
   219  	ErrorType string `json:"errorType,omitempty"`
   220  	// ForceSendFields is a list of field names (e.g. "ErrorClass") to
   221  	// unconditionally include in API requests. By default, fields with empty or
   222  	// default values are omitted from API requests. See
   223  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   224  	// details.
   225  	ForceSendFields []string `json:"-"`
   226  	// NullFields is a list of field names (e.g. "ErrorClass") to include in API
   227  	// requests with the JSON null value. By default, fields with empty values are
   228  	// omitted from API requests. See
   229  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // Domain: A registered domain resource in the Postmaster API.
   253  type Domain struct {
   254  	// CreateTime: Timestamp when the user registered this domain. Assigned by the
   255  	// server.
   256  	CreateTime string `json:"createTime,omitempty"`
   257  	// Name: The resource name of the Domain. Domain names have the form
   258  	// `domains/{domain_name}`, where domain_name is the fully qualified domain
   259  	// name (i.e., mymail.mydomain.com).
   260  	Name string `json:"name,omitempty"`
   261  	// Permission: User’s permission for this domain. Assigned by the server.
   262  	//
   263  	// Possible values:
   264  	//   "PERMISSION_UNSPECIFIED" - The default value and should never be used
   265  	// explicitly.
   266  	//   "OWNER" - User has read access to the domain and can share access with
   267  	// others.
   268  	//   "READER" - User has read access to the domain.
   269  	//   "NONE" - User doesn't have permission to access information about the
   270  	// domain. User did not verify ownership of domain nor was access granted by
   271  	// other domain owners.
   272  	Permission string `json:"permission,omitempty"`
   273  
   274  	// ServerResponse contains the HTTP response code and headers from the server.
   275  	googleapi.ServerResponse `json:"-"`
   276  	// ForceSendFields is a list of field names (e.g. "CreateTime") to
   277  	// unconditionally include in API requests. By default, fields with empty or
   278  	// default values are omitted from API requests. See
   279  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   280  	// details.
   281  	ForceSendFields []string `json:"-"`
   282  	// NullFields is a list of field names (e.g. "CreateTime") to include in API
   283  	// requests with the JSON null value. By default, fields with empty values are
   284  	// omitted from API requests. See
   285  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // FeedbackLoop: Feedback loop (https://support.google.com/mail/answer/6254652)
   295  // identifier information.
   296  type FeedbackLoop struct {
   297  	// Id: Feedback loop identifier that uniquely identifies individual campaigns.
   298  	Id string `json:"id,omitempty"`
   299  	// SpamRatio: The ratio of user marked spam messages with the identifier vs the
   300  	// total number of inboxed messages with that identifier.
   301  	SpamRatio float64 `json:"spamRatio,omitempty"`
   302  	// ForceSendFields is a list of field names (e.g. "Id") to unconditionally
   303  	// include in API requests. By default, fields with empty or default values are
   304  	// omitted from API requests. See
   305  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   306  	// details.
   307  	ForceSendFields []string `json:"-"`
   308  	// NullFields is a list of field names (e.g. "Id") to include in API requests
   309  	// with the JSON null value. By default, fields with empty values are omitted
   310  	// from API requests. See
   311  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // IpReputation: IP Reputation information for a set of IPs in a specific
   335  // reputation category.
   336  type IpReputation struct {
   337  	// IpCount: Total number of unique IPs in this reputation category. This metric
   338  	// only pertains to traffic that passed SPF (http://www.openspf.org/) or DKIM
   339  	// (http://www.dkim.org/).
   340  	IpCount int64 `json:"ipCount,omitempty,string"`
   341  	// NumIps: Total number of unique IPs in this reputation category. This metric
   342  	// only pertains to traffic that passed SPF (http://www.openspf.org/) or DKIM
   343  	// (http://www.dkim.org/). Deprecated to be complied with ApiLinter for
   344  	// Quantities. Use ip_count instead.
   345  	NumIps int64 `json:"numIps,omitempty,string"`
   346  	// Reputation: The reputation category this IP reputation represents.
   347  	//
   348  	// Possible values:
   349  	//   "REPUTATION_CATEGORY_UNSPECIFIED" - The default value which should never
   350  	// be used explicitly. This represents the state where no reputation
   351  	// information is available.
   352  	//   "HIGH" - Has a good track record of a very low spam rate, and complies
   353  	// with Gmail's sender guidelines. Mail will rarely be marked by the spam
   354  	// filter.
   355  	//   "MEDIUM" - Known to send good mail, but is prone to sending a low volume
   356  	// of spam intermittently. Most of the email from this entity will have a fair
   357  	// deliverability rate, except when there is a notable increase in spam levels.
   358  	//   "LOW" - Known to send a considerable volume of spam regularly, and mail
   359  	// from this sender will likely be marked as spam.
   360  	//   "BAD" - History of sending an enormously high volume of spam. Mail coming
   361  	// from this entity will almost always be rejected at SMTP level or marked as
   362  	// spam.
   363  	Reputation string `json:"reputation,omitempty"`
   364  	// SampleIps: A sample of IPs in this reputation category.
   365  	SampleIps []string `json:"sampleIps,omitempty"`
   366  	// ForceSendFields is a list of field names (e.g. "IpCount") to unconditionally
   367  	// include in API requests. By default, fields with empty or default values are
   368  	// omitted from API requests. See
   369  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   370  	// details.
   371  	ForceSendFields []string `json:"-"`
   372  	// NullFields is a list of field names (e.g. "IpCount") to include in API
   373  	// requests with the JSON null value. By default, fields with empty values are
   374  	// omitted from API requests. See
   375  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // ListDomainsResponse: Response message for ListDomains.
   385  type ListDomainsResponse struct {
   386  	// Domains: The list of domains.
   387  	Domains []*Domain `json:"domains,omitempty"`
   388  	// NextPageToken: Token to retrieve the next page of results, or empty if there
   389  	// are no more results in the list.
   390  	NextPageToken string `json:"nextPageToken,omitempty"`
   391  
   392  	// ServerResponse contains the HTTP response code and headers from the server.
   393  	googleapi.ServerResponse `json:"-"`
   394  	// ForceSendFields is a list of field names (e.g. "Domains") to unconditionally
   395  	// include in API requests. By default, fields with empty or default values are
   396  	// omitted from API requests. See
   397  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   398  	// details.
   399  	ForceSendFields []string `json:"-"`
   400  	// NullFields is a list of field names (e.g. "Domains") to include in API
   401  	// requests with the JSON null value. By default, fields with empty values are
   402  	// omitted from API requests. See
   403  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // ListTrafficStatsResponse: Response message for ListTrafficStats.
   413  type ListTrafficStatsResponse struct {
   414  	// NextPageToken: Token to retrieve the next page of results, or empty if there
   415  	// are no more results in the list.
   416  	NextPageToken string `json:"nextPageToken,omitempty"`
   417  	// TrafficStats: The list of TrafficStats.
   418  	TrafficStats []*TrafficStats `json:"trafficStats,omitempty"`
   419  
   420  	// ServerResponse contains the HTTP response code and headers from the server.
   421  	googleapi.ServerResponse `json:"-"`
   422  	// ForceSendFields is a list of field names (e.g. "NextPageToken") to
   423  	// unconditionally include in API requests. By default, fields with empty or
   424  	// default values are omitted from API requests. See
   425  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   426  	// details.
   427  	ForceSendFields []string `json:"-"`
   428  	// NullFields is a list of field names (e.g. "NextPageToken") to include in API
   429  	// requests with the JSON null value. By default, fields with empty values are
   430  	// omitted from API requests. See
   431  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // TrafficStats: Email traffic statistics pertaining to a specific date.
   441  type TrafficStats struct {
   442  	// DeliveryErrors: Delivery errors for the domain. This metric only pertains to
   443  	// traffic that passed SPF (http://www.openspf.org/) or DKIM
   444  	// (http://www.dkim.org/).
   445  	DeliveryErrors []*DeliveryError `json:"deliveryErrors,omitempty"`
   446  	// DkimSuccessRatio: The ratio of mail that successfully authenticated with
   447  	// DKIM vs. all mail that attempted to authenticate with DKIM
   448  	// (http://www.dkim.org/). Spoofed mail is excluded.
   449  	DkimSuccessRatio float64 `json:"dkimSuccessRatio,omitempty"`
   450  	// DmarcSuccessRatio: The ratio of mail that passed DMARC (https://dmarc.org/)
   451  	// alignment checks vs all mail received from the domain that successfully
   452  	// authenticated with either of SPF (http://www.openspf.org/) or DKIM
   453  	// (http://www.dkim.org/).
   454  	DmarcSuccessRatio float64 `json:"dmarcSuccessRatio,omitempty"`
   455  	// DomainReputation: Reputation of the domain.
   456  	//
   457  	// Possible values:
   458  	//   "REPUTATION_CATEGORY_UNSPECIFIED" - The default value which should never
   459  	// be used explicitly. This represents the state where no reputation
   460  	// information is available.
   461  	//   "HIGH" - Has a good track record of a very low spam rate, and complies
   462  	// with Gmail's sender guidelines. Mail will rarely be marked by the spam
   463  	// filter.
   464  	//   "MEDIUM" - Known to send good mail, but is prone to sending a low volume
   465  	// of spam intermittently. Most of the email from this entity will have a fair
   466  	// deliverability rate, except when there is a notable increase in spam levels.
   467  	//   "LOW" - Known to send a considerable volume of spam regularly, and mail
   468  	// from this sender will likely be marked as spam.
   469  	//   "BAD" - History of sending an enormously high volume of spam. Mail coming
   470  	// from this entity will almost always be rejected at SMTP level or marked as
   471  	// spam.
   472  	DomainReputation string `json:"domainReputation,omitempty"`
   473  	// InboundEncryptionRatio: The ratio of incoming mail (to Gmail), that passed
   474  	// secure transport (TLS) vs all mail received from that domain. This metric
   475  	// only pertains to traffic that passed SPF (http://www.openspf.org/) or DKIM
   476  	// (http://www.dkim.org/).
   477  	InboundEncryptionRatio float64 `json:"inboundEncryptionRatio,omitempty"`
   478  	// IpReputations: Reputation information pertaining to the IP addresses of the
   479  	// email servers for the domain. There is exactly one entry for each reputation
   480  	// category except REPUTATION_CATEGORY_UNSPECIFIED.
   481  	IpReputations []*IpReputation `json:"ipReputations,omitempty"`
   482  	// Name: The resource name of the traffic statistics. Traffic statistic names
   483  	// have the form `domains/{domain}/trafficStats/{date}`, where domain_name is
   484  	// the fully qualified domain name (i.e., mymail.mydomain.com) of the domain
   485  	// this traffic statistics pertains to and date is the date in yyyymmdd format
   486  	// that these statistics corresponds to. For example:
   487  	// domains/mymail.mydomain.com/trafficStats/20160807
   488  	Name string `json:"name,omitempty"`
   489  	// OutboundEncryptionRatio: The ratio of outgoing mail (from Gmail) that was
   490  	// accepted over secure transport (TLS).
   491  	OutboundEncryptionRatio float64 `json:"outboundEncryptionRatio,omitempty"`
   492  	// SpammyFeedbackLoops: Spammy [Feedback loop identifiers]
   493  	// (https://support.google.com/mail/answer/6254652) with their individual spam
   494  	// rates. This metric only pertains to traffic that is authenticated by DKIM
   495  	// (http://www.dkim.org/).
   496  	SpammyFeedbackLoops []*FeedbackLoop `json:"spammyFeedbackLoops,omitempty"`
   497  	// SpfSuccessRatio: The ratio of mail that successfully authenticated with SPF
   498  	// vs. all mail that attempted to authenticate with SPF
   499  	// (http://www.openspf.org/). Spoofed mail is excluded.
   500  	SpfSuccessRatio float64 `json:"spfSuccessRatio,omitempty"`
   501  	// UserReportedSpamRatio: The ratio of user-report spam vs. email that was sent
   502  	// to the inbox. This is potentially inexact -- users may want to refer to the
   503  	// description of the interval fields userReportedSpamRatioLowerBound and
   504  	// userReportedSpamRatioUpperBound for more explicit accuracy guarantees. This
   505  	// metric only pertains to emails authenticated by DKIM (http://www.dkim.org/).
   506  	UserReportedSpamRatio float64 `json:"userReportedSpamRatio,omitempty"`
   507  	// UserReportedSpamRatioLowerBound: The lower bound of the confidence interval
   508  	// for the user reported spam ratio. If this field is set, then the value of
   509  	// userReportedSpamRatio is set to the midpoint of this interval and is thus
   510  	// inexact. However, the true ratio is guaranteed to be in between this lower
   511  	// bound and the corresponding upper bound 95% of the time. This metric only
   512  	// pertains to emails authenticated by DKIM (http://www.dkim.org/).
   513  	UserReportedSpamRatioLowerBound float64 `json:"userReportedSpamRatioLowerBound,omitempty"`
   514  	// UserReportedSpamRatioUpperBound: The upper bound of the confidence interval
   515  	// for the user reported spam ratio. If this field is set, then the value of
   516  	// userReportedSpamRatio is set to the midpoint of this interval and is thus
   517  	// inexact. However, the true ratio is guaranteed to be in between this upper
   518  	// bound and the corresponding lower bound 95% of the time. This metric only
   519  	// pertains to emails authenticated by DKIM (http://www.dkim.org/).
   520  	UserReportedSpamRatioUpperBound float64 `json:"userReportedSpamRatioUpperBound,omitempty"`
   521  
   522  	// ServerResponse contains the HTTP response code and headers from the server.
   523  	googleapi.ServerResponse `json:"-"`
   524  	// ForceSendFields is a list of field names (e.g. "DeliveryErrors") to
   525  	// unconditionally include in API requests. By default, fields with empty or
   526  	// default values are omitted from API requests. See
   527  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   528  	// details.
   529  	ForceSendFields []string `json:"-"`
   530  	// NullFields is a list of field names (e.g. "DeliveryErrors") to include in
   531  	// API requests with the JSON null value. By default, fields with empty values
   532  	// are omitted from API requests. See
   533  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // Get: Gets a specific domain registered by the client. Returns NOT_FOUND if
   580  // the domain does not exist.
   581  //
   582  //   - name: The resource name of the domain. It should have the form
   583  //     `domains/{domain_name}`, where domain_name is the fully qualified domain
   584  //     name.
   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  // Fields allows partial responses to be retrieved. See
   592  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   593  // details.
   594  func (c *DomainsGetCall) Fields(s ...googleapi.Field) *DomainsGetCall {
   595  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   596  	return c
   597  }
   598  
   599  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   600  // object's ETag matches the given value. This is useful for getting updates
   601  // only after the object has changed since the last request.
   602  func (c *DomainsGetCall) IfNoneMatch(entityTag string) *DomainsGetCall {
   603  	c.ifNoneMatch_ = entityTag
   604  	return c
   605  }
   606  
   607  // Context sets the context to be used in this call's Do method.
   608  func (c *DomainsGetCall) Context(ctx context.Context) *DomainsGetCall {
   609  	c.ctx_ = ctx
   610  	return c
   611  }
   612  
   613  // Header returns a http.Header that can be modified by the caller to add
   614  // headers to the request.
   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  // Do executes the "gmailpostmastertools.domains.get" call.
   644  // Any non-2xx status code is an error. Response headers are in either
   645  // *Domain.ServerResponse.Header or (if a response was returned at all) in
   646  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   647  // whether the returned error was because http.StatusNotModified was returned.
   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  // List: Lists the domains that have been registered by the client. The order
   689  // of domains in the response is unspecified and non-deterministic. Newly
   690  // created domains will not necessarily be added to the end of this list.
   691  func (r *DomainsService) List() *DomainsListCall {
   692  	c := &DomainsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   693  	return c
   694  }
   695  
   696  // PageSize sets the optional parameter "pageSize": Requested page size. Server
   697  // may return fewer domains than requested. If unspecified, server will pick an
   698  // appropriate default.
   699  func (c *DomainsListCall) PageSize(pageSize int64) *DomainsListCall {
   700  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   701  	return c
   702  }
   703  
   704  // PageToken sets the optional parameter "pageToken": The next_page_token value
   705  // returned from a previous List request, if any. This is the value of
   706  // ListDomainsResponse.next_page_token returned from the previous call to
   707  // `ListDomains` method.
   708  func (c *DomainsListCall) PageToken(pageToken string) *DomainsListCall {
   709  	c.urlParams_.Set("pageToken", pageToken)
   710  	return c
   711  }
   712  
   713  // Fields allows partial responses to be retrieved. See
   714  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   715  // details.
   716  func (c *DomainsListCall) Fields(s ...googleapi.Field) *DomainsListCall {
   717  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   718  	return c
   719  }
   720  
   721  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   722  // object's ETag matches the given value. This is useful for getting updates
   723  // only after the object has changed since the last request.
   724  func (c *DomainsListCall) IfNoneMatch(entityTag string) *DomainsListCall {
   725  	c.ifNoneMatch_ = entityTag
   726  	return c
   727  }
   728  
   729  // Context sets the context to be used in this call's Do method.
   730  func (c *DomainsListCall) Context(ctx context.Context) *DomainsListCall {
   731  	c.ctx_ = ctx
   732  	return c
   733  }
   734  
   735  // Header returns a http.Header that can be modified by the caller to add
   736  // headers to the request.
   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  // Do executes the "gmailpostmastertools.domains.list" call.
   763  // Any non-2xx status code is an error. Response headers are in either
   764  // *ListDomainsResponse.ServerResponse.Header or (if a response was returned at
   765  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   766  // check whether the returned error was because http.StatusNotModified was
   767  // returned.
   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  // Pages invokes f for each page of results.
   801  // A non-nil error returned from f will halt the iteration.
   802  // The provided context supersedes any context provided to the Context method.
   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  // Get: Get traffic statistics for a domain on a specific date. Returns
   831  // PERMISSION_DENIED if user does not have permission to access TrafficStats
   832  // for the domain.
   833  //
   834  //   - name: The resource name of the traffic statistics to get. E.g.,
   835  //     domains/mymail.mydomain.com/trafficStats/20160807.
   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  // Fields allows partial responses to be retrieved. See
   843  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   844  // details.
   845  func (c *DomainsTrafficStatsGetCall) Fields(s ...googleapi.Field) *DomainsTrafficStatsGetCall {
   846  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   847  	return c
   848  }
   849  
   850  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   851  // object's ETag matches the given value. This is useful for getting updates
   852  // only after the object has changed since the last request.
   853  func (c *DomainsTrafficStatsGetCall) IfNoneMatch(entityTag string) *DomainsTrafficStatsGetCall {
   854  	c.ifNoneMatch_ = entityTag
   855  	return c
   856  }
   857  
   858  // Context sets the context to be used in this call's Do method.
   859  func (c *DomainsTrafficStatsGetCall) Context(ctx context.Context) *DomainsTrafficStatsGetCall {
   860  	c.ctx_ = ctx
   861  	return c
   862  }
   863  
   864  // Header returns a http.Header that can be modified by the caller to add
   865  // headers to the request.
   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  // Do executes the "gmailpostmastertools.domains.trafficStats.get" call.
   895  // Any non-2xx status code is an error. Response headers are in either
   896  // *TrafficStats.ServerResponse.Header or (if a response was returned at all)
   897  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   898  // whether the returned error was because http.StatusNotModified was returned.
   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  // List: List traffic statistics for all available days. Returns
   941  // PERMISSION_DENIED if user does not have permission to access TrafficStats
   942  // for the domain.
   943  //
   944  //   - parent: The resource name of the domain whose traffic statistics we'd like
   945  //     to list. It should have the form `domains/{domain_name}`, where
   946  //     domain_name is the fully qualified domain name.
   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  // EndDateDay sets the optional parameter "endDate.day": Day of a month. Must
   954  // be from 1 to 31 and valid for the year and month, or 0 to specify a year by
   955  // itself or a year and month where the day isn't significant.
   956  func (c *DomainsTrafficStatsListCall) EndDateDay(endDateDay int64) *DomainsTrafficStatsListCall {
   957  	c.urlParams_.Set("endDate.day", fmt.Sprint(endDateDay))
   958  	return c
   959  }
   960  
   961  // EndDateMonth sets the optional parameter "endDate.month": Month of a year.
   962  // Must be from 1 to 12, or 0 to specify a year without a month and day.
   963  func (c *DomainsTrafficStatsListCall) EndDateMonth(endDateMonth int64) *DomainsTrafficStatsListCall {
   964  	c.urlParams_.Set("endDate.month", fmt.Sprint(endDateMonth))
   965  	return c
   966  }
   967  
   968  // EndDateYear sets the optional parameter "endDate.year": Year of the date.
   969  // Must be from 1 to 9999, or 0 to specify a date without a year.
   970  func (c *DomainsTrafficStatsListCall) EndDateYear(endDateYear int64) *DomainsTrafficStatsListCall {
   971  	c.urlParams_.Set("endDate.year", fmt.Sprint(endDateYear))
   972  	return c
   973  }
   974  
   975  // PageSize sets the optional parameter "pageSize": Requested page size. Server
   976  // may return fewer TrafficStats than requested. If unspecified, server will
   977  // pick an appropriate default.
   978  func (c *DomainsTrafficStatsListCall) PageSize(pageSize int64) *DomainsTrafficStatsListCall {
   979  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   980  	return c
   981  }
   982  
   983  // PageToken sets the optional parameter "pageToken": The next_page_token value
   984  // returned from a previous List request, if any. This is the value of
   985  // ListTrafficStatsResponse.next_page_token returned from the previous call to
   986  // `ListTrafficStats` method.
   987  func (c *DomainsTrafficStatsListCall) PageToken(pageToken string) *DomainsTrafficStatsListCall {
   988  	c.urlParams_.Set("pageToken", pageToken)
   989  	return c
   990  }
   991  
   992  // StartDateDay sets the optional parameter "startDate.day": Day of a month.
   993  // Must be from 1 to 31 and valid for the year and month, or 0 to specify a
   994  // year by itself or a year and month where the day isn't significant.
   995  func (c *DomainsTrafficStatsListCall) StartDateDay(startDateDay int64) *DomainsTrafficStatsListCall {
   996  	c.urlParams_.Set("startDate.day", fmt.Sprint(startDateDay))
   997  	return c
   998  }
   999  
  1000  // StartDateMonth sets the optional parameter "startDate.month": Month of a
  1001  // year. Must be from 1 to 12, or 0 to specify a year without a month and day.
  1002  func (c *DomainsTrafficStatsListCall) StartDateMonth(startDateMonth int64) *DomainsTrafficStatsListCall {
  1003  	c.urlParams_.Set("startDate.month", fmt.Sprint(startDateMonth))
  1004  	return c
  1005  }
  1006  
  1007  // StartDateYear sets the optional parameter "startDate.year": Year of the
  1008  // date. Must be from 1 to 9999, or 0 to specify a date without a year.
  1009  func (c *DomainsTrafficStatsListCall) StartDateYear(startDateYear int64) *DomainsTrafficStatsListCall {
  1010  	c.urlParams_.Set("startDate.year", fmt.Sprint(startDateYear))
  1011  	return c
  1012  }
  1013  
  1014  // Fields allows partial responses to be retrieved. See
  1015  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1016  // details.
  1017  func (c *DomainsTrafficStatsListCall) Fields(s ...googleapi.Field) *DomainsTrafficStatsListCall {
  1018  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1019  	return c
  1020  }
  1021  
  1022  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1023  // object's ETag matches the given value. This is useful for getting updates
  1024  // only after the object has changed since the last request.
  1025  func (c *DomainsTrafficStatsListCall) IfNoneMatch(entityTag string) *DomainsTrafficStatsListCall {
  1026  	c.ifNoneMatch_ = entityTag
  1027  	return c
  1028  }
  1029  
  1030  // Context sets the context to be used in this call's Do method.
  1031  func (c *DomainsTrafficStatsListCall) Context(ctx context.Context) *DomainsTrafficStatsListCall {
  1032  	c.ctx_ = ctx
  1033  	return c
  1034  }
  1035  
  1036  // Header returns a http.Header that can be modified by the caller to add
  1037  // headers to the request.
  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  // Do executes the "gmailpostmastertools.domains.trafficStats.list" call.
  1067  // Any non-2xx status code is an error. Response headers are in either
  1068  // *ListTrafficStatsResponse.ServerResponse.Header or (if a response was
  1069  // returned at all) in error.(*googleapi.Error).Header. Use
  1070  // googleapi.IsNotModified to check whether the returned error was because
  1071  // http.StatusNotModified was returned.
  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  // Pages invokes f for each page of results.
  1105  // A non-nil error returned from f will halt the iteration.
  1106  // The provided context supersedes any context provided to the Context method.
  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