...

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

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

     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/v1"
    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/v1"
    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:v1"
    90  const apiName = "gmailpostmastertools"
    91  const apiVersion = "v1"
    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  	// Reputation: The reputation category this IP reputation represents.
   342  	//
   343  	// Possible values:
   344  	//   "REPUTATION_CATEGORY_UNSPECIFIED" - The default value which should never
   345  	// be used explicitly. This represents the state where no reputation
   346  	// information is available.
   347  	//   "HIGH" - Has a good track record of a very low spam rate, and complies
   348  	// with Gmail's sender guidelines. Mail will rarely be marked by the spam
   349  	// filter.
   350  	//   "MEDIUM" - Known to send good mail, but is prone to sending a low volume
   351  	// of spam intermittently. Most of the email from this entity will have a fair
   352  	// deliverability rate, except when there is a notable increase in spam levels.
   353  	//   "LOW" - Known to send a considerable volume of spam regularly, and mail
   354  	// from this sender will likely be marked as spam.
   355  	//   "BAD" - History of sending an enormously high volume of spam. Mail coming
   356  	// from this entity will almost always be rejected at SMTP level or marked as
   357  	// spam.
   358  	Reputation string `json:"reputation,omitempty"`
   359  	// SampleIps: A sample of IPs in this reputation category.
   360  	SampleIps []string `json:"sampleIps,omitempty"`
   361  	// ForceSendFields is a list of field names (e.g. "IpCount") to unconditionally
   362  	// include in API requests. By default, fields with empty or default values are
   363  	// omitted from API requests. See
   364  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   365  	// details.
   366  	ForceSendFields []string `json:"-"`
   367  	// NullFields is a list of field names (e.g. "IpCount") to include in API
   368  	// requests with the JSON null value. By default, fields with empty values are
   369  	// omitted from API requests. See
   370  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   371  	NullFields []string `json:"-"`
   372  }
   373  
   374  func (s *IpReputation) MarshalJSON() ([]byte, error) {
   375  	type NoMethod IpReputation
   376  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   377  }
   378  
   379  // ListDomainsResponse: Response message for ListDomains.
   380  type ListDomainsResponse struct {
   381  	// Domains: The list of domains.
   382  	Domains []*Domain `json:"domains,omitempty"`
   383  	// NextPageToken: Token to retrieve the next page of results, or empty if there
   384  	// are no more results in the list.
   385  	NextPageToken string `json:"nextPageToken,omitempty"`
   386  
   387  	// ServerResponse contains the HTTP response code and headers from the server.
   388  	googleapi.ServerResponse `json:"-"`
   389  	// ForceSendFields is a list of field names (e.g. "Domains") to unconditionally
   390  	// include in API requests. By default, fields with empty or default values are
   391  	// omitted from API requests. See
   392  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   393  	// details.
   394  	ForceSendFields []string `json:"-"`
   395  	// NullFields is a list of field names (e.g. "Domains") to include in API
   396  	// requests with the JSON null value. By default, fields with empty values are
   397  	// omitted from API requests. See
   398  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   399  	NullFields []string `json:"-"`
   400  }
   401  
   402  func (s *ListDomainsResponse) MarshalJSON() ([]byte, error) {
   403  	type NoMethod ListDomainsResponse
   404  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   405  }
   406  
   407  // ListTrafficStatsResponse: Response message for ListTrafficStats.
   408  type ListTrafficStatsResponse struct {
   409  	// NextPageToken: Token to retrieve the next page of results, or empty if there
   410  	// are no more results in the list.
   411  	NextPageToken string `json:"nextPageToken,omitempty"`
   412  	// TrafficStats: The list of TrafficStats.
   413  	TrafficStats []*TrafficStats `json:"trafficStats,omitempty"`
   414  
   415  	// ServerResponse contains the HTTP response code and headers from the server.
   416  	googleapi.ServerResponse `json:"-"`
   417  	// ForceSendFields is a list of field names (e.g. "NextPageToken") to
   418  	// unconditionally include in API requests. By default, fields with empty or
   419  	// default values are omitted from API requests. See
   420  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   421  	// details.
   422  	ForceSendFields []string `json:"-"`
   423  	// NullFields is a list of field names (e.g. "NextPageToken") to include in API
   424  	// requests with the JSON null value. By default, fields with empty values are
   425  	// omitted from API requests. See
   426  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   427  	NullFields []string `json:"-"`
   428  }
   429  
   430  func (s *ListTrafficStatsResponse) MarshalJSON() ([]byte, error) {
   431  	type NoMethod ListTrafficStatsResponse
   432  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   433  }
   434  
   435  // TrafficStats: Email traffic statistics pertaining to a specific date.
   436  type TrafficStats struct {
   437  	// DeliveryErrors: Delivery errors for the domain. This metric only pertains to
   438  	// traffic that passed SPF (http://www.openspf.org/) or DKIM
   439  	// (http://www.dkim.org/).
   440  	DeliveryErrors []*DeliveryError `json:"deliveryErrors,omitempty"`
   441  	// DkimSuccessRatio: The ratio of mail that successfully authenticated with
   442  	// DKIM vs. all mail that attempted to authenticate with DKIM
   443  	// (http://www.dkim.org/). Spoofed mail is excluded.
   444  	DkimSuccessRatio float64 `json:"dkimSuccessRatio,omitempty"`
   445  	// DmarcSuccessRatio: The ratio of mail that passed DMARC (https://dmarc.org/)
   446  	// alignment checks vs all mail received from the domain that successfully
   447  	// authenticated with either of SPF (http://www.openspf.org/) or DKIM
   448  	// (http://www.dkim.org/).
   449  	DmarcSuccessRatio float64 `json:"dmarcSuccessRatio,omitempty"`
   450  	// DomainReputation: Reputation of the domain.
   451  	//
   452  	// Possible values:
   453  	//   "REPUTATION_CATEGORY_UNSPECIFIED" - The default value which should never
   454  	// be used explicitly. This represents the state where no reputation
   455  	// information is available.
   456  	//   "HIGH" - Has a good track record of a very low spam rate, and complies
   457  	// with Gmail's sender guidelines. Mail will rarely be marked by the spam
   458  	// filter.
   459  	//   "MEDIUM" - Known to send good mail, but is prone to sending a low volume
   460  	// of spam intermittently. Most of the email from this entity will have a fair
   461  	// deliverability rate, except when there is a notable increase in spam levels.
   462  	//   "LOW" - Known to send a considerable volume of spam regularly, and mail
   463  	// from this sender will likely be marked as spam.
   464  	//   "BAD" - History of sending an enormously high volume of spam. Mail coming
   465  	// from this entity will almost always be rejected at SMTP level or marked as
   466  	// spam.
   467  	DomainReputation string `json:"domainReputation,omitempty"`
   468  	// InboundEncryptionRatio: The ratio of incoming mail (to Gmail), that passed
   469  	// secure transport (TLS) vs all mail received from that domain. This metric
   470  	// only pertains to traffic that passed SPF (http://www.openspf.org/) or DKIM
   471  	// (http://www.dkim.org/).
   472  	InboundEncryptionRatio float64 `json:"inboundEncryptionRatio,omitempty"`
   473  	// IpReputations: Reputation information pertaining to the IP addresses of the
   474  	// email servers for the domain. There is exactly one entry for each reputation
   475  	// category except REPUTATION_CATEGORY_UNSPECIFIED.
   476  	IpReputations []*IpReputation `json:"ipReputations,omitempty"`
   477  	// Name: The resource name of the traffic statistics. Traffic statistic names
   478  	// have the form `domains/{domain}/trafficStats/{date}`, where domain_name is
   479  	// the fully qualified domain name (i.e., mymail.mydomain.com) of the domain
   480  	// this traffic statistics pertains to and date is the date in yyyymmdd format
   481  	// that these statistics corresponds to. For example:
   482  	// domains/mymail.mydomain.com/trafficStats/20160807
   483  	Name string `json:"name,omitempty"`
   484  	// OutboundEncryptionRatio: The ratio of outgoing mail (from Gmail) that was
   485  	// accepted over secure transport (TLS).
   486  	OutboundEncryptionRatio float64 `json:"outboundEncryptionRatio,omitempty"`
   487  	// SpammyFeedbackLoops: Spammy [Feedback loop identifiers]
   488  	// (https://support.google.com/mail/answer/6254652) with their individual spam
   489  	// rates. This metric only pertains to traffic that is authenticated by DKIM
   490  	// (http://www.dkim.org/).
   491  	SpammyFeedbackLoops []*FeedbackLoop `json:"spammyFeedbackLoops,omitempty"`
   492  	// SpfSuccessRatio: The ratio of mail that successfully authenticated with SPF
   493  	// vs. all mail that attempted to authenticate with SPF
   494  	// (http://www.openspf.org/). Spoofed mail is excluded.
   495  	SpfSuccessRatio float64 `json:"spfSuccessRatio,omitempty"`
   496  	// UserReportedSpamRatio: The ratio of user-report spam vs. email that was sent
   497  	// to the inbox. This is potentially inexact -- users may want to refer to the
   498  	// description of the interval fields userReportedSpamRatioLowerBound and
   499  	// userReportedSpamRatioUpperBound for more explicit accuracy guarantees. This
   500  	// metric only pertains to emails authenticated by DKIM (http://www.dkim.org/).
   501  	UserReportedSpamRatio float64 `json:"userReportedSpamRatio,omitempty"`
   502  	// UserReportedSpamRatioLowerBound: The lower bound of the confidence interval
   503  	// for the user reported spam ratio. If this field is set, then the value of
   504  	// userReportedSpamRatio is set to the midpoint of this interval and is thus
   505  	// inexact. However, the true ratio is guaranteed to be in between this lower
   506  	// bound and the corresponding upper bound 95% of the time. This metric only
   507  	// pertains to emails authenticated by DKIM (http://www.dkim.org/).
   508  	UserReportedSpamRatioLowerBound float64 `json:"userReportedSpamRatioLowerBound,omitempty"`
   509  	// UserReportedSpamRatioUpperBound: The upper bound of the confidence interval
   510  	// for the user reported spam ratio. If this field is set, then the value of
   511  	// userReportedSpamRatio is set to the midpoint of this interval and is thus
   512  	// inexact. However, the true ratio is guaranteed to be in between this upper
   513  	// bound and the corresponding lower bound 95% of the time. This metric only
   514  	// pertains to emails authenticated by DKIM (http://www.dkim.org/).
   515  	UserReportedSpamRatioUpperBound float64 `json:"userReportedSpamRatioUpperBound,omitempty"`
   516  
   517  	// ServerResponse contains the HTTP response code and headers from the server.
   518  	googleapi.ServerResponse `json:"-"`
   519  	// ForceSendFields is a list of field names (e.g. "DeliveryErrors") to
   520  	// unconditionally include in API requests. By default, fields with empty or
   521  	// default values are omitted from API requests. See
   522  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   523  	// details.
   524  	ForceSendFields []string `json:"-"`
   525  	// NullFields is a list of field names (e.g. "DeliveryErrors") to include in
   526  	// API requests with the JSON null value. By default, fields with empty values
   527  	// are omitted from API requests. See
   528  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   529  	NullFields []string `json:"-"`
   530  }
   531  
   532  func (s *TrafficStats) MarshalJSON() ([]byte, error) {
   533  	type NoMethod TrafficStats
   534  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   535  }
   536  
   537  func (s *TrafficStats) UnmarshalJSON(data []byte) error {
   538  	type NoMethod TrafficStats
   539  	var s1 struct {
   540  		DkimSuccessRatio                gensupport.JSONFloat64 `json:"dkimSuccessRatio"`
   541  		DmarcSuccessRatio               gensupport.JSONFloat64 `json:"dmarcSuccessRatio"`
   542  		InboundEncryptionRatio          gensupport.JSONFloat64 `json:"inboundEncryptionRatio"`
   543  		OutboundEncryptionRatio         gensupport.JSONFloat64 `json:"outboundEncryptionRatio"`
   544  		SpfSuccessRatio                 gensupport.JSONFloat64 `json:"spfSuccessRatio"`
   545  		UserReportedSpamRatio           gensupport.JSONFloat64 `json:"userReportedSpamRatio"`
   546  		UserReportedSpamRatioLowerBound gensupport.JSONFloat64 `json:"userReportedSpamRatioLowerBound"`
   547  		UserReportedSpamRatioUpperBound gensupport.JSONFloat64 `json:"userReportedSpamRatioUpperBound"`
   548  		*NoMethod
   549  	}
   550  	s1.NoMethod = (*NoMethod)(s)
   551  	if err := json.Unmarshal(data, &s1); err != nil {
   552  		return err
   553  	}
   554  	s.DkimSuccessRatio = float64(s1.DkimSuccessRatio)
   555  	s.DmarcSuccessRatio = float64(s1.DmarcSuccessRatio)
   556  	s.InboundEncryptionRatio = float64(s1.InboundEncryptionRatio)
   557  	s.OutboundEncryptionRatio = float64(s1.OutboundEncryptionRatio)
   558  	s.SpfSuccessRatio = float64(s1.SpfSuccessRatio)
   559  	s.UserReportedSpamRatio = float64(s1.UserReportedSpamRatio)
   560  	s.UserReportedSpamRatioLowerBound = float64(s1.UserReportedSpamRatioLowerBound)
   561  	s.UserReportedSpamRatioUpperBound = float64(s1.UserReportedSpamRatioUpperBound)
   562  	return nil
   563  }
   564  
   565  type DomainsGetCall struct {
   566  	s            *Service
   567  	name         string
   568  	urlParams_   gensupport.URLParams
   569  	ifNoneMatch_ string
   570  	ctx_         context.Context
   571  	header_      http.Header
   572  }
   573  
   574  // Get: Gets a specific domain registered by the client. Returns NOT_FOUND if
   575  // the domain does not exist.
   576  //
   577  //   - name: The resource name of the domain. It should have the form
   578  //     `domains/{domain_name}`, where domain_name is the fully qualified domain
   579  //     name.
   580  func (r *DomainsService) Get(name string) *DomainsGetCall {
   581  	c := &DomainsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   582  	c.name = name
   583  	return c
   584  }
   585  
   586  // Fields allows partial responses to be retrieved. See
   587  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   588  // details.
   589  func (c *DomainsGetCall) Fields(s ...googleapi.Field) *DomainsGetCall {
   590  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   591  	return c
   592  }
   593  
   594  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   595  // object's ETag matches the given value. This is useful for getting updates
   596  // only after the object has changed since the last request.
   597  func (c *DomainsGetCall) IfNoneMatch(entityTag string) *DomainsGetCall {
   598  	c.ifNoneMatch_ = entityTag
   599  	return c
   600  }
   601  
   602  // Context sets the context to be used in this call's Do method.
   603  func (c *DomainsGetCall) Context(ctx context.Context) *DomainsGetCall {
   604  	c.ctx_ = ctx
   605  	return c
   606  }
   607  
   608  // Header returns a http.Header that can be modified by the caller to add
   609  // headers to the request.
   610  func (c *DomainsGetCall) Header() http.Header {
   611  	if c.header_ == nil {
   612  		c.header_ = make(http.Header)
   613  	}
   614  	return c.header_
   615  }
   616  
   617  func (c *DomainsGetCall) doRequest(alt string) (*http.Response, error) {
   618  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   619  	if c.ifNoneMatch_ != "" {
   620  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   621  	}
   622  	var body io.Reader = nil
   623  	c.urlParams_.Set("alt", alt)
   624  	c.urlParams_.Set("prettyPrint", "false")
   625  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   626  	urls += "?" + c.urlParams_.Encode()
   627  	req, err := http.NewRequest("GET", urls, body)
   628  	if err != nil {
   629  		return nil, err
   630  	}
   631  	req.Header = reqHeaders
   632  	googleapi.Expand(req.URL, map[string]string{
   633  		"name": c.name,
   634  	})
   635  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   636  }
   637  
   638  // Do executes the "gmailpostmastertools.domains.get" call.
   639  // Any non-2xx status code is an error. Response headers are in either
   640  // *Domain.ServerResponse.Header or (if a response was returned at all) in
   641  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   642  // whether the returned error was because http.StatusNotModified was returned.
   643  func (c *DomainsGetCall) Do(opts ...googleapi.CallOption) (*Domain, error) {
   644  	gensupport.SetOptions(c.urlParams_, opts...)
   645  	res, err := c.doRequest("json")
   646  	if res != nil && res.StatusCode == http.StatusNotModified {
   647  		if res.Body != nil {
   648  			res.Body.Close()
   649  		}
   650  		return nil, gensupport.WrapError(&googleapi.Error{
   651  			Code:   res.StatusCode,
   652  			Header: res.Header,
   653  		})
   654  	}
   655  	if err != nil {
   656  		return nil, err
   657  	}
   658  	defer googleapi.CloseBody(res)
   659  	if err := googleapi.CheckResponse(res); err != nil {
   660  		return nil, gensupport.WrapError(err)
   661  	}
   662  	ret := &Domain{
   663  		ServerResponse: googleapi.ServerResponse{
   664  			Header:         res.Header,
   665  			HTTPStatusCode: res.StatusCode,
   666  		},
   667  	}
   668  	target := &ret
   669  	if err := gensupport.DecodeResponse(target, res); err != nil {
   670  		return nil, err
   671  	}
   672  	return ret, nil
   673  }
   674  
   675  type DomainsListCall struct {
   676  	s            *Service
   677  	urlParams_   gensupport.URLParams
   678  	ifNoneMatch_ string
   679  	ctx_         context.Context
   680  	header_      http.Header
   681  }
   682  
   683  // List: Lists the domains that have been registered by the client. The order
   684  // of domains in the response is unspecified and non-deterministic. Newly
   685  // created domains will not necessarily be added to the end of this list.
   686  func (r *DomainsService) List() *DomainsListCall {
   687  	c := &DomainsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   688  	return c
   689  }
   690  
   691  // PageSize sets the optional parameter "pageSize": Requested page size. Server
   692  // may return fewer domains than requested. If unspecified, server will pick an
   693  // appropriate default.
   694  func (c *DomainsListCall) PageSize(pageSize int64) *DomainsListCall {
   695  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   696  	return c
   697  }
   698  
   699  // PageToken sets the optional parameter "pageToken": The next_page_token value
   700  // returned from a previous List request, if any. This is the value of
   701  // ListDomainsResponse.next_page_token returned from the previous call to
   702  // `ListDomains` method.
   703  func (c *DomainsListCall) PageToken(pageToken string) *DomainsListCall {
   704  	c.urlParams_.Set("pageToken", pageToken)
   705  	return c
   706  }
   707  
   708  // Fields allows partial responses to be retrieved. See
   709  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   710  // details.
   711  func (c *DomainsListCall) Fields(s ...googleapi.Field) *DomainsListCall {
   712  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   713  	return c
   714  }
   715  
   716  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   717  // object's ETag matches the given value. This is useful for getting updates
   718  // only after the object has changed since the last request.
   719  func (c *DomainsListCall) IfNoneMatch(entityTag string) *DomainsListCall {
   720  	c.ifNoneMatch_ = entityTag
   721  	return c
   722  }
   723  
   724  // Context sets the context to be used in this call's Do method.
   725  func (c *DomainsListCall) Context(ctx context.Context) *DomainsListCall {
   726  	c.ctx_ = ctx
   727  	return c
   728  }
   729  
   730  // Header returns a http.Header that can be modified by the caller to add
   731  // headers to the request.
   732  func (c *DomainsListCall) Header() http.Header {
   733  	if c.header_ == nil {
   734  		c.header_ = make(http.Header)
   735  	}
   736  	return c.header_
   737  }
   738  
   739  func (c *DomainsListCall) doRequest(alt string) (*http.Response, error) {
   740  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   741  	if c.ifNoneMatch_ != "" {
   742  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   743  	}
   744  	var body io.Reader = nil
   745  	c.urlParams_.Set("alt", alt)
   746  	c.urlParams_.Set("prettyPrint", "false")
   747  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/domains")
   748  	urls += "?" + c.urlParams_.Encode()
   749  	req, err := http.NewRequest("GET", urls, body)
   750  	if err != nil {
   751  		return nil, err
   752  	}
   753  	req.Header = reqHeaders
   754  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   755  }
   756  
   757  // Do executes the "gmailpostmastertools.domains.list" call.
   758  // Any non-2xx status code is an error. Response headers are in either
   759  // *ListDomainsResponse.ServerResponse.Header or (if a response was returned at
   760  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   761  // check whether the returned error was because http.StatusNotModified was
   762  // returned.
   763  func (c *DomainsListCall) Do(opts ...googleapi.CallOption) (*ListDomainsResponse, error) {
   764  	gensupport.SetOptions(c.urlParams_, opts...)
   765  	res, err := c.doRequest("json")
   766  	if res != nil && res.StatusCode == http.StatusNotModified {
   767  		if res.Body != nil {
   768  			res.Body.Close()
   769  		}
   770  		return nil, gensupport.WrapError(&googleapi.Error{
   771  			Code:   res.StatusCode,
   772  			Header: res.Header,
   773  		})
   774  	}
   775  	if err != nil {
   776  		return nil, err
   777  	}
   778  	defer googleapi.CloseBody(res)
   779  	if err := googleapi.CheckResponse(res); err != nil {
   780  		return nil, gensupport.WrapError(err)
   781  	}
   782  	ret := &ListDomainsResponse{
   783  		ServerResponse: googleapi.ServerResponse{
   784  			Header:         res.Header,
   785  			HTTPStatusCode: res.StatusCode,
   786  		},
   787  	}
   788  	target := &ret
   789  	if err := gensupport.DecodeResponse(target, res); err != nil {
   790  		return nil, err
   791  	}
   792  	return ret, nil
   793  }
   794  
   795  // Pages invokes f for each page of results.
   796  // A non-nil error returned from f will halt the iteration.
   797  // The provided context supersedes any context provided to the Context method.
   798  func (c *DomainsListCall) Pages(ctx context.Context, f func(*ListDomainsResponse) error) error {
   799  	c.ctx_ = ctx
   800  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   801  	for {
   802  		x, err := c.Do()
   803  		if err != nil {
   804  			return err
   805  		}
   806  		if err := f(x); err != nil {
   807  			return err
   808  		}
   809  		if x.NextPageToken == "" {
   810  			return nil
   811  		}
   812  		c.PageToken(x.NextPageToken)
   813  	}
   814  }
   815  
   816  type DomainsTrafficStatsGetCall struct {
   817  	s            *Service
   818  	name         string
   819  	urlParams_   gensupport.URLParams
   820  	ifNoneMatch_ string
   821  	ctx_         context.Context
   822  	header_      http.Header
   823  }
   824  
   825  // Get: Get traffic statistics for a domain on a specific date. Returns
   826  // PERMISSION_DENIED if user does not have permission to access TrafficStats
   827  // for the domain.
   828  //
   829  //   - name: The resource name of the traffic statistics to get. E.g.,
   830  //     domains/mymail.mydomain.com/trafficStats/20160807.
   831  func (r *DomainsTrafficStatsService) Get(name string) *DomainsTrafficStatsGetCall {
   832  	c := &DomainsTrafficStatsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   833  	c.name = name
   834  	return c
   835  }
   836  
   837  // Fields allows partial responses to be retrieved. See
   838  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   839  // details.
   840  func (c *DomainsTrafficStatsGetCall) Fields(s ...googleapi.Field) *DomainsTrafficStatsGetCall {
   841  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   842  	return c
   843  }
   844  
   845  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   846  // object's ETag matches the given value. This is useful for getting updates
   847  // only after the object has changed since the last request.
   848  func (c *DomainsTrafficStatsGetCall) IfNoneMatch(entityTag string) *DomainsTrafficStatsGetCall {
   849  	c.ifNoneMatch_ = entityTag
   850  	return c
   851  }
   852  
   853  // Context sets the context to be used in this call's Do method.
   854  func (c *DomainsTrafficStatsGetCall) Context(ctx context.Context) *DomainsTrafficStatsGetCall {
   855  	c.ctx_ = ctx
   856  	return c
   857  }
   858  
   859  // Header returns a http.Header that can be modified by the caller to add
   860  // headers to the request.
   861  func (c *DomainsTrafficStatsGetCall) Header() http.Header {
   862  	if c.header_ == nil {
   863  		c.header_ = make(http.Header)
   864  	}
   865  	return c.header_
   866  }
   867  
   868  func (c *DomainsTrafficStatsGetCall) doRequest(alt string) (*http.Response, error) {
   869  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   870  	if c.ifNoneMatch_ != "" {
   871  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   872  	}
   873  	var body io.Reader = nil
   874  	c.urlParams_.Set("alt", alt)
   875  	c.urlParams_.Set("prettyPrint", "false")
   876  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   877  	urls += "?" + c.urlParams_.Encode()
   878  	req, err := http.NewRequest("GET", urls, body)
   879  	if err != nil {
   880  		return nil, err
   881  	}
   882  	req.Header = reqHeaders
   883  	googleapi.Expand(req.URL, map[string]string{
   884  		"name": c.name,
   885  	})
   886  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   887  }
   888  
   889  // Do executes the "gmailpostmastertools.domains.trafficStats.get" call.
   890  // Any non-2xx status code is an error. Response headers are in either
   891  // *TrafficStats.ServerResponse.Header or (if a response was returned at all)
   892  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   893  // whether the returned error was because http.StatusNotModified was returned.
   894  func (c *DomainsTrafficStatsGetCall) Do(opts ...googleapi.CallOption) (*TrafficStats, error) {
   895  	gensupport.SetOptions(c.urlParams_, opts...)
   896  	res, err := c.doRequest("json")
   897  	if res != nil && res.StatusCode == http.StatusNotModified {
   898  		if res.Body != nil {
   899  			res.Body.Close()
   900  		}
   901  		return nil, gensupport.WrapError(&googleapi.Error{
   902  			Code:   res.StatusCode,
   903  			Header: res.Header,
   904  		})
   905  	}
   906  	if err != nil {
   907  		return nil, err
   908  	}
   909  	defer googleapi.CloseBody(res)
   910  	if err := googleapi.CheckResponse(res); err != nil {
   911  		return nil, gensupport.WrapError(err)
   912  	}
   913  	ret := &TrafficStats{
   914  		ServerResponse: googleapi.ServerResponse{
   915  			Header:         res.Header,
   916  			HTTPStatusCode: res.StatusCode,
   917  		},
   918  	}
   919  	target := &ret
   920  	if err := gensupport.DecodeResponse(target, res); err != nil {
   921  		return nil, err
   922  	}
   923  	return ret, nil
   924  }
   925  
   926  type DomainsTrafficStatsListCall struct {
   927  	s            *Service
   928  	parent       string
   929  	urlParams_   gensupport.URLParams
   930  	ifNoneMatch_ string
   931  	ctx_         context.Context
   932  	header_      http.Header
   933  }
   934  
   935  // List: List traffic statistics for all available days. Returns
   936  // PERMISSION_DENIED if user does not have permission to access TrafficStats
   937  // for the domain.
   938  //
   939  //   - parent: The resource name of the domain whose traffic statistics we'd like
   940  //     to list. It should have the form `domains/{domain_name}`, where
   941  //     domain_name is the fully qualified domain name.
   942  func (r *DomainsTrafficStatsService) List(parent string) *DomainsTrafficStatsListCall {
   943  	c := &DomainsTrafficStatsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   944  	c.parent = parent
   945  	return c
   946  }
   947  
   948  // EndDateDay sets the optional parameter "endDate.day": Day of a month. Must
   949  // be from 1 to 31 and valid for the year and month, or 0 to specify a year by
   950  // itself or a year and month where the day isn't significant.
   951  func (c *DomainsTrafficStatsListCall) EndDateDay(endDateDay int64) *DomainsTrafficStatsListCall {
   952  	c.urlParams_.Set("endDate.day", fmt.Sprint(endDateDay))
   953  	return c
   954  }
   955  
   956  // EndDateMonth sets the optional parameter "endDate.month": Month of a year.
   957  // Must be from 1 to 12, or 0 to specify a year without a month and day.
   958  func (c *DomainsTrafficStatsListCall) EndDateMonth(endDateMonth int64) *DomainsTrafficStatsListCall {
   959  	c.urlParams_.Set("endDate.month", fmt.Sprint(endDateMonth))
   960  	return c
   961  }
   962  
   963  // EndDateYear sets the optional parameter "endDate.year": Year of the date.
   964  // Must be from 1 to 9999, or 0 to specify a date without a year.
   965  func (c *DomainsTrafficStatsListCall) EndDateYear(endDateYear int64) *DomainsTrafficStatsListCall {
   966  	c.urlParams_.Set("endDate.year", fmt.Sprint(endDateYear))
   967  	return c
   968  }
   969  
   970  // PageSize sets the optional parameter "pageSize": Requested page size. Server
   971  // may return fewer TrafficStats than requested. If unspecified, server will
   972  // pick an appropriate default.
   973  func (c *DomainsTrafficStatsListCall) PageSize(pageSize int64) *DomainsTrafficStatsListCall {
   974  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   975  	return c
   976  }
   977  
   978  // PageToken sets the optional parameter "pageToken": The next_page_token value
   979  // returned from a previous List request, if any. This is the value of
   980  // ListTrafficStatsResponse.next_page_token returned from the previous call to
   981  // `ListTrafficStats` method.
   982  func (c *DomainsTrafficStatsListCall) PageToken(pageToken string) *DomainsTrafficStatsListCall {
   983  	c.urlParams_.Set("pageToken", pageToken)
   984  	return c
   985  }
   986  
   987  // StartDateDay sets the optional parameter "startDate.day": Day of a month.
   988  // Must be from 1 to 31 and valid for the year and month, or 0 to specify a
   989  // year by itself or a year and month where the day isn't significant.
   990  func (c *DomainsTrafficStatsListCall) StartDateDay(startDateDay int64) *DomainsTrafficStatsListCall {
   991  	c.urlParams_.Set("startDate.day", fmt.Sprint(startDateDay))
   992  	return c
   993  }
   994  
   995  // StartDateMonth sets the optional parameter "startDate.month": Month of a
   996  // year. Must be from 1 to 12, or 0 to specify a year without a month and day.
   997  func (c *DomainsTrafficStatsListCall) StartDateMonth(startDateMonth int64) *DomainsTrafficStatsListCall {
   998  	c.urlParams_.Set("startDate.month", fmt.Sprint(startDateMonth))
   999  	return c
  1000  }
  1001  
  1002  // StartDateYear sets the optional parameter "startDate.year": Year of the
  1003  // date. Must be from 1 to 9999, or 0 to specify a date without a year.
  1004  func (c *DomainsTrafficStatsListCall) StartDateYear(startDateYear int64) *DomainsTrafficStatsListCall {
  1005  	c.urlParams_.Set("startDate.year", fmt.Sprint(startDateYear))
  1006  	return c
  1007  }
  1008  
  1009  // Fields allows partial responses to be retrieved. See
  1010  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1011  // details.
  1012  func (c *DomainsTrafficStatsListCall) Fields(s ...googleapi.Field) *DomainsTrafficStatsListCall {
  1013  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1014  	return c
  1015  }
  1016  
  1017  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1018  // object's ETag matches the given value. This is useful for getting updates
  1019  // only after the object has changed since the last request.
  1020  func (c *DomainsTrafficStatsListCall) IfNoneMatch(entityTag string) *DomainsTrafficStatsListCall {
  1021  	c.ifNoneMatch_ = entityTag
  1022  	return c
  1023  }
  1024  
  1025  // Context sets the context to be used in this call's Do method.
  1026  func (c *DomainsTrafficStatsListCall) Context(ctx context.Context) *DomainsTrafficStatsListCall {
  1027  	c.ctx_ = ctx
  1028  	return c
  1029  }
  1030  
  1031  // Header returns a http.Header that can be modified by the caller to add
  1032  // headers to the request.
  1033  func (c *DomainsTrafficStatsListCall) Header() http.Header {
  1034  	if c.header_ == nil {
  1035  		c.header_ = make(http.Header)
  1036  	}
  1037  	return c.header_
  1038  }
  1039  
  1040  func (c *DomainsTrafficStatsListCall) doRequest(alt string) (*http.Response, error) {
  1041  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1042  	if c.ifNoneMatch_ != "" {
  1043  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1044  	}
  1045  	var body io.Reader = nil
  1046  	c.urlParams_.Set("alt", alt)
  1047  	c.urlParams_.Set("prettyPrint", "false")
  1048  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/trafficStats")
  1049  	urls += "?" + c.urlParams_.Encode()
  1050  	req, err := http.NewRequest("GET", urls, body)
  1051  	if err != nil {
  1052  		return nil, err
  1053  	}
  1054  	req.Header = reqHeaders
  1055  	googleapi.Expand(req.URL, map[string]string{
  1056  		"parent": c.parent,
  1057  	})
  1058  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1059  }
  1060  
  1061  // Do executes the "gmailpostmastertools.domains.trafficStats.list" call.
  1062  // Any non-2xx status code is an error. Response headers are in either
  1063  // *ListTrafficStatsResponse.ServerResponse.Header or (if a response was
  1064  // returned at all) in error.(*googleapi.Error).Header. Use
  1065  // googleapi.IsNotModified to check whether the returned error was because
  1066  // http.StatusNotModified was returned.
  1067  func (c *DomainsTrafficStatsListCall) Do(opts ...googleapi.CallOption) (*ListTrafficStatsResponse, error) {
  1068  	gensupport.SetOptions(c.urlParams_, opts...)
  1069  	res, err := c.doRequest("json")
  1070  	if res != nil && res.StatusCode == http.StatusNotModified {
  1071  		if res.Body != nil {
  1072  			res.Body.Close()
  1073  		}
  1074  		return nil, gensupport.WrapError(&googleapi.Error{
  1075  			Code:   res.StatusCode,
  1076  			Header: res.Header,
  1077  		})
  1078  	}
  1079  	if err != nil {
  1080  		return nil, err
  1081  	}
  1082  	defer googleapi.CloseBody(res)
  1083  	if err := googleapi.CheckResponse(res); err != nil {
  1084  		return nil, gensupport.WrapError(err)
  1085  	}
  1086  	ret := &ListTrafficStatsResponse{
  1087  		ServerResponse: googleapi.ServerResponse{
  1088  			Header:         res.Header,
  1089  			HTTPStatusCode: res.StatusCode,
  1090  		},
  1091  	}
  1092  	target := &ret
  1093  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1094  		return nil, err
  1095  	}
  1096  	return ret, nil
  1097  }
  1098  
  1099  // Pages invokes f for each page of results.
  1100  // A non-nil error returned from f will halt the iteration.
  1101  // The provided context supersedes any context provided to the Context method.
  1102  func (c *DomainsTrafficStatsListCall) Pages(ctx context.Context, f func(*ListTrafficStatsResponse) error) error {
  1103  	c.ctx_ = ctx
  1104  	defer c.PageToken(c.urlParams_.Get("pageToken"))
  1105  	for {
  1106  		x, err := c.Do()
  1107  		if err != nil {
  1108  			return err
  1109  		}
  1110  		if err := f(x); err != nil {
  1111  			return err
  1112  		}
  1113  		if x.NextPageToken == "" {
  1114  			return nil
  1115  		}
  1116  		c.PageToken(x.NextPageToken)
  1117  	}
  1118  }
  1119  

View as plain text