...

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

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

     1  // Copyright 2020 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 pagespeedonline provides access to the PageSpeed Insights API.
     8  //
     9  // For product documentation, see: https://developers.google.com/speed/docs/insights/v1/getting_started
    10  //
    11  // # Creating a client
    12  //
    13  // Usage example:
    14  //
    15  //	import "google.golang.org/api/pagespeedonline/v1"
    16  //	...
    17  //	ctx := context.Background()
    18  //	pagespeedonlineService, err := pagespeedonline.NewService(ctx)
    19  //
    20  // In this example, Google Application Default Credentials are used for authentication.
    21  //
    22  // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    23  //
    24  // # Other authentication options
    25  //
    26  // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
    27  //
    28  //	pagespeedonlineService, err := pagespeedonline.NewService(ctx, option.WithAPIKey("AIza..."))
    29  //
    30  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
    31  //
    32  //	config := &oauth2.Config{...}
    33  //	// ...
    34  //	token, err := config.Exchange(ctx, ...)
    35  //	pagespeedonlineService, err := pagespeedonline.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    36  //
    37  // See https://godoc.org/google.golang.org/api/option/ for details on options.
    38  package pagespeedonline // import "google.golang.org/api/pagespeedonline/v1"
    39  
    40  import (
    41  	"bytes"
    42  	"context"
    43  	"encoding/json"
    44  	"errors"
    45  	"fmt"
    46  	"io"
    47  	"net/http"
    48  	"net/url"
    49  	"strconv"
    50  	"strings"
    51  
    52  	googleapi "google.golang.org/api/googleapi"
    53  	gensupport "google.golang.org/api/internal/gensupport"
    54  	option "google.golang.org/api/option"
    55  	internaloption "google.golang.org/api/option/internaloption"
    56  	htransport "google.golang.org/api/transport/http"
    57  )
    58  
    59  // Always reference these packages, just in case the auto-generated code
    60  // below doesn't.
    61  var _ = bytes.NewBuffer
    62  var _ = strconv.Itoa
    63  var _ = fmt.Sprintf
    64  var _ = json.NewDecoder
    65  var _ = io.Copy
    66  var _ = url.Parse
    67  var _ = gensupport.MarshalJSON
    68  var _ = googleapi.Version
    69  var _ = errors.New
    70  var _ = strings.Replace
    71  var _ = context.Canceled
    72  var _ = internaloption.WithDefaultEndpoint
    73  
    74  const apiId = "pagespeedonline:v1"
    75  const apiName = "pagespeedonline"
    76  const apiVersion = "v1"
    77  const basePath = "https://www.googleapis.com/pagespeedonline/v1/"
    78  
    79  // NewService creates a new Service.
    80  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
    81  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
    82  	client, endpoint, err := htransport.NewClient(ctx, opts...)
    83  	if err != nil {
    84  		return nil, err
    85  	}
    86  	s, err := New(client)
    87  	if err != nil {
    88  		return nil, err
    89  	}
    90  	if endpoint != "" {
    91  		s.BasePath = endpoint
    92  	}
    93  	return s, nil
    94  }
    95  
    96  // New creates a new Service. It uses the provided http.Client for requests.
    97  //
    98  // Deprecated: please use NewService instead.
    99  // To provide a custom HTTP client, use option.WithHTTPClient.
   100  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   101  func New(client *http.Client) (*Service, error) {
   102  	if client == nil {
   103  		return nil, errors.New("client is nil")
   104  	}
   105  	s := &Service{client: client, BasePath: basePath}
   106  	s.Pagespeedapi = NewPagespeedapiService(s)
   107  	return s, nil
   108  }
   109  
   110  type Service struct {
   111  	client    *http.Client
   112  	BasePath  string // API endpoint base URL
   113  	UserAgent string // optional additional User-Agent fragment
   114  
   115  	Pagespeedapi *PagespeedapiService
   116  }
   117  
   118  func (s *Service) userAgent() string {
   119  	if s.UserAgent == "" {
   120  		return googleapi.UserAgent
   121  	}
   122  	return googleapi.UserAgent + " " + s.UserAgent
   123  }
   124  
   125  func NewPagespeedapiService(s *Service) *PagespeedapiService {
   126  	rs := &PagespeedapiService{s: s}
   127  	return rs
   128  }
   129  
   130  type PagespeedapiService struct {
   131  	s *Service
   132  }
   133  
   134  type Result struct {
   135  	// CaptchaResult: The captcha verify result
   136  	CaptchaResult string `json:"captchaResult,omitempty"`
   137  
   138  	// FormattedResults: Localized PageSpeed results. Contains a ruleResults
   139  	// entry for each PageSpeed rule instantiated and run by the server.
   140  	FormattedResults *ResultFormattedResults `json:"formattedResults,omitempty"`
   141  
   142  	// Id: Canonicalized and final URL for the document, after following
   143  	// page redirects (if any).
   144  	Id string `json:"id,omitempty"`
   145  
   146  	// InvalidRules: List of rules that were specified in the request, but
   147  	// which the server did not know how to instantiate.
   148  	InvalidRules []string `json:"invalidRules,omitempty"`
   149  
   150  	// Kind: Kind of result.
   151  	Kind string `json:"kind,omitempty"`
   152  
   153  	// PageStats: Summary statistics for the page, such as number of
   154  	// JavaScript bytes, number of HTML bytes, etc.
   155  	PageStats *ResultPageStats `json:"pageStats,omitempty"`
   156  
   157  	// ResponseCode: Response code for the document. 200 indicates a normal
   158  	// page load. 4xx/5xx indicates an error.
   159  	ResponseCode int64 `json:"responseCode,omitempty"`
   160  
   161  	// Score: The PageSpeed Score (0-100), which indicates how much faster a
   162  	// page could be. A high score indicates little room for improvement,
   163  	// while a lower score indicates more room for improvement.
   164  	Score int64 `json:"score,omitempty"`
   165  
   166  	// Screenshot: Base64-encoded screenshot of the page that was analyzed.
   167  	Screenshot *ResultScreenshot `json:"screenshot,omitempty"`
   168  
   169  	// Title: Title of the page, as displayed in the browser's title bar.
   170  	Title string `json:"title,omitempty"`
   171  
   172  	// Version: The version of PageSpeed used to generate these results.
   173  	Version *ResultVersion `json:"version,omitempty"`
   174  
   175  	// ServerResponse contains the HTTP response code and headers from the
   176  	// server.
   177  	googleapi.ServerResponse `json:"-"`
   178  
   179  	// ForceSendFields is a list of field names (e.g. "CaptchaResult") to
   180  	// unconditionally include in API requests. By default, fields with
   181  	// empty values are omitted from API requests. However, any non-pointer,
   182  	// non-interface field appearing in ForceSendFields will be sent to the
   183  	// server regardless of whether the field is empty or not. This may be
   184  	// used to include empty fields in Patch requests.
   185  	ForceSendFields []string `json:"-"`
   186  
   187  	// NullFields is a list of field names (e.g. "CaptchaResult") to include
   188  	// in API requests with the JSON null value. By default, fields with
   189  	// empty values are omitted from API requests. However, any field with
   190  	// an empty value appearing in NullFields will be sent to the server as
   191  	// null. It is an error if a field in this list has a non-empty value.
   192  	// This may be used to include null fields in Patch requests.
   193  	NullFields []string `json:"-"`
   194  }
   195  
   196  func (s *Result) MarshalJSON() ([]byte, error) {
   197  	type NoMethod Result
   198  	raw := NoMethod(*s)
   199  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   200  }
   201  
   202  // ResultFormattedResults: Localized PageSpeed results. Contains a
   203  // ruleResults entry for each PageSpeed rule instantiated and run by the
   204  // server.
   205  type ResultFormattedResults struct {
   206  	// Locale: The locale of the formattedResults, e.g. "en_US".
   207  	Locale string `json:"locale,omitempty"`
   208  
   209  	// RuleResults: Dictionary of formatted rule results, with one entry for
   210  	// each PageSpeed rule instantiated and run by the server.
   211  	RuleResults map[string]ResultFormattedResultsRuleResults `json:"ruleResults,omitempty"`
   212  
   213  	// ForceSendFields is a list of field names (e.g. "Locale") to
   214  	// unconditionally include in API requests. By default, fields with
   215  	// empty values are omitted from API requests. However, any non-pointer,
   216  	// non-interface field appearing in ForceSendFields will be sent to the
   217  	// server regardless of whether the field is empty or not. This may be
   218  	// used to include empty fields in Patch requests.
   219  	ForceSendFields []string `json:"-"`
   220  
   221  	// NullFields is a list of field names (e.g. "Locale") to include in API
   222  	// requests with the JSON null value. By default, fields with empty
   223  	// values are omitted from API requests. However, any field with an
   224  	// empty value appearing in NullFields will be sent to the server as
   225  	// null. It is an error if a field in this list has a non-empty value.
   226  	// This may be used to include null fields in Patch requests.
   227  	NullFields []string `json:"-"`
   228  }
   229  
   230  func (s *ResultFormattedResults) MarshalJSON() ([]byte, error) {
   231  	type NoMethod ResultFormattedResults
   232  	raw := NoMethod(*s)
   233  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   234  }
   235  
   236  // ResultFormattedResultsRuleResults: The enum-like identifier for this
   237  // rule. For instance "EnableKeepAlive" or "AvoidCssImport". Not
   238  // localized.
   239  type ResultFormattedResultsRuleResults struct {
   240  	// LocalizedRuleName: Localized name of the rule, intended for
   241  	// presentation to a user.
   242  	LocalizedRuleName string `json:"localizedRuleName,omitempty"`
   243  
   244  	// RuleImpact: The impact (unbounded floating point value) that
   245  	// implementing the suggestions for this rule would have on making the
   246  	// page faster. Impact is comparable between rules to determine which
   247  	// rule's suggestions would have a higher or lower impact on making a
   248  	// page faster. For instance, if enabling compression would save 1MB,
   249  	// while optimizing images would save 500kB, the enable compression rule
   250  	// would have 2x the impact of the image optimization rule, all other
   251  	// things being equal.
   252  	RuleImpact float64 `json:"ruleImpact,omitempty"`
   253  
   254  	// UrlBlocks: List of blocks of URLs. Each block may contain a heading
   255  	// and a list of URLs. Each URL may optionally include additional
   256  	// details.
   257  	UrlBlocks []*ResultFormattedResultsRuleResultsUrlBlocks `json:"urlBlocks,omitempty"`
   258  
   259  	// ForceSendFields is a list of field names (e.g. "LocalizedRuleName")
   260  	// to unconditionally include in API requests. By default, fields with
   261  	// empty values are omitted from API requests. However, any non-pointer,
   262  	// non-interface field appearing in ForceSendFields will be sent to the
   263  	// server regardless of whether the field is empty or not. This may be
   264  	// used to include empty fields in Patch requests.
   265  	ForceSendFields []string `json:"-"`
   266  
   267  	// NullFields is a list of field names (e.g. "LocalizedRuleName") to
   268  	// include in API requests with the JSON null value. By default, fields
   269  	// with empty values are omitted from API requests. However, any field
   270  	// with an empty value appearing in NullFields will be sent to the
   271  	// server as null. It is an error if a field in this list has a
   272  	// non-empty value. This may be used to include null fields in Patch
   273  	// requests.
   274  	NullFields []string `json:"-"`
   275  }
   276  
   277  func (s *ResultFormattedResultsRuleResults) MarshalJSON() ([]byte, error) {
   278  	type NoMethod ResultFormattedResultsRuleResults
   279  	raw := NoMethod(*s)
   280  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   281  }
   282  
   283  func (s *ResultFormattedResultsRuleResults) UnmarshalJSON(data []byte) error {
   284  	type NoMethod ResultFormattedResultsRuleResults
   285  	var s1 struct {
   286  		RuleImpact gensupport.JSONFloat64 `json:"ruleImpact"`
   287  		*NoMethod
   288  	}
   289  	s1.NoMethod = (*NoMethod)(s)
   290  	if err := json.Unmarshal(data, &s1); err != nil {
   291  		return err
   292  	}
   293  	s.RuleImpact = float64(s1.RuleImpact)
   294  	return nil
   295  }
   296  
   297  type ResultFormattedResultsRuleResultsUrlBlocks struct {
   298  	// Header: Heading to be displayed with the list of URLs.
   299  	Header *ResultFormattedResultsRuleResultsUrlBlocksHeader `json:"header,omitempty"`
   300  
   301  	// Urls: List of entries that provide information about URLs in the url
   302  	// block. Optional.
   303  	Urls []*ResultFormattedResultsRuleResultsUrlBlocksUrls `json:"urls,omitempty"`
   304  
   305  	// ForceSendFields is a list of field names (e.g. "Header") to
   306  	// unconditionally include in API requests. By default, fields with
   307  	// empty values are omitted from API requests. However, any non-pointer,
   308  	// non-interface field appearing in ForceSendFields will be sent to the
   309  	// server regardless of whether the field is empty or not. This may be
   310  	// used to include empty fields in Patch requests.
   311  	ForceSendFields []string `json:"-"`
   312  
   313  	// NullFields is a list of field names (e.g. "Header") to include in API
   314  	// requests with the JSON null value. By default, fields with empty
   315  	// values are omitted from API requests. However, any field with an
   316  	// empty value appearing in NullFields will be sent to the server as
   317  	// null. It is an error if a field in this list has a non-empty value.
   318  	// This may be used to include null fields in Patch requests.
   319  	NullFields []string `json:"-"`
   320  }
   321  
   322  func (s *ResultFormattedResultsRuleResultsUrlBlocks) MarshalJSON() ([]byte, error) {
   323  	type NoMethod ResultFormattedResultsRuleResultsUrlBlocks
   324  	raw := NoMethod(*s)
   325  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   326  }
   327  
   328  // ResultFormattedResultsRuleResultsUrlBlocksHeader: Heading to be
   329  // displayed with the list of URLs.
   330  type ResultFormattedResultsRuleResultsUrlBlocksHeader struct {
   331  	// Args: List of arguments for the format string.
   332  	Args []*ResultFormattedResultsRuleResultsUrlBlocksHeaderArgs `json:"args,omitempty"`
   333  
   334  	// Format: A localized format string with $N placeholders, where N is
   335  	// the 1-indexed argument number, e.g. 'Minifying the following $1
   336  	// resources would save a total of $2 bytes'.
   337  	Format string `json:"format,omitempty"`
   338  
   339  	// ForceSendFields is a list of field names (e.g. "Args") to
   340  	// unconditionally include in API requests. By default, fields with
   341  	// empty values are omitted from API requests. However, any non-pointer,
   342  	// non-interface field appearing in ForceSendFields will be sent to the
   343  	// server regardless of whether the field is empty or not. This may be
   344  	// used to include empty fields in Patch requests.
   345  	ForceSendFields []string `json:"-"`
   346  
   347  	// NullFields is a list of field names (e.g. "Args") to include in API
   348  	// requests with the JSON null value. By default, fields with empty
   349  	// values are omitted from API requests. However, any field with an
   350  	// empty value appearing in NullFields will be sent to the server as
   351  	// null. It is an error if a field in this list has a non-empty value.
   352  	// This may be used to include null fields in Patch requests.
   353  	NullFields []string `json:"-"`
   354  }
   355  
   356  func (s *ResultFormattedResultsRuleResultsUrlBlocksHeader) MarshalJSON() ([]byte, error) {
   357  	type NoMethod ResultFormattedResultsRuleResultsUrlBlocksHeader
   358  	raw := NoMethod(*s)
   359  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   360  }
   361  
   362  type ResultFormattedResultsRuleResultsUrlBlocksHeaderArgs struct {
   363  	// Type: Type of argument. One of URL, STRING_LITERAL, INT_LITERAL,
   364  	// BYTES, or DURATION.
   365  	Type string `json:"type,omitempty"`
   366  
   367  	// Value: Argument value, as a localized string.
   368  	Value string `json:"value,omitempty"`
   369  
   370  	// ForceSendFields is a list of field names (e.g. "Type") to
   371  	// unconditionally include in API requests. By default, fields with
   372  	// empty values are omitted from API requests. However, any non-pointer,
   373  	// non-interface field appearing in ForceSendFields will be sent to the
   374  	// server regardless of whether the field is empty or not. This may be
   375  	// used to include empty fields in Patch requests.
   376  	ForceSendFields []string `json:"-"`
   377  
   378  	// NullFields is a list of field names (e.g. "Type") to include in API
   379  	// requests with the JSON null value. By default, fields with empty
   380  	// values are omitted from API requests. However, any field with an
   381  	// empty value appearing in NullFields will be sent to the server as
   382  	// null. It is an error if a field in this list has a non-empty value.
   383  	// This may be used to include null fields in Patch requests.
   384  	NullFields []string `json:"-"`
   385  }
   386  
   387  func (s *ResultFormattedResultsRuleResultsUrlBlocksHeaderArgs) MarshalJSON() ([]byte, error) {
   388  	type NoMethod ResultFormattedResultsRuleResultsUrlBlocksHeaderArgs
   389  	raw := NoMethod(*s)
   390  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   391  }
   392  
   393  type ResultFormattedResultsRuleResultsUrlBlocksUrls struct {
   394  	// Details: List of entries that provide additional details about a
   395  	// single URL. Optional.
   396  	Details []*ResultFormattedResultsRuleResultsUrlBlocksUrlsDetails `json:"details,omitempty"`
   397  
   398  	// Result: A format string that gives information about the URL, and a
   399  	// list of arguments for that format string.
   400  	Result *ResultFormattedResultsRuleResultsUrlBlocksUrlsResult `json:"result,omitempty"`
   401  
   402  	// ForceSendFields is a list of field names (e.g. "Details") to
   403  	// unconditionally include in API requests. By default, fields with
   404  	// empty values are omitted from API requests. However, any non-pointer,
   405  	// non-interface field appearing in ForceSendFields will be sent to the
   406  	// server regardless of whether the field is empty or not. This may be
   407  	// used to include empty fields in Patch requests.
   408  	ForceSendFields []string `json:"-"`
   409  
   410  	// NullFields is a list of field names (e.g. "Details") to include in
   411  	// API requests with the JSON null value. By default, fields with empty
   412  	// values are omitted from API requests. However, any field with an
   413  	// empty value appearing in NullFields will be sent to the server as
   414  	// null. It is an error if a field in this list has a non-empty value.
   415  	// This may be used to include null fields in Patch requests.
   416  	NullFields []string `json:"-"`
   417  }
   418  
   419  func (s *ResultFormattedResultsRuleResultsUrlBlocksUrls) MarshalJSON() ([]byte, error) {
   420  	type NoMethod ResultFormattedResultsRuleResultsUrlBlocksUrls
   421  	raw := NoMethod(*s)
   422  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   423  }
   424  
   425  type ResultFormattedResultsRuleResultsUrlBlocksUrlsDetails struct {
   426  	// Args: List of arguments for the format string.
   427  	Args []*ResultFormattedResultsRuleResultsUrlBlocksUrlsDetailsArgs `json:"args,omitempty"`
   428  
   429  	// Format: A localized format string with $N placeholders, where N is
   430  	// the 1-indexed argument number, e.g. 'Unnecessary metadata for this
   431  	// resource adds an additional $1 bytes to its download size'.
   432  	Format string `json:"format,omitempty"`
   433  
   434  	// ForceSendFields is a list of field names (e.g. "Args") to
   435  	// unconditionally include in API requests. By default, fields with
   436  	// empty values are omitted from API requests. However, any non-pointer,
   437  	// non-interface field appearing in ForceSendFields will be sent to the
   438  	// server regardless of whether the field is empty or not. This may be
   439  	// used to include empty fields in Patch requests.
   440  	ForceSendFields []string `json:"-"`
   441  
   442  	// NullFields is a list of field names (e.g. "Args") to include in API
   443  	// requests with the JSON null value. By default, fields with empty
   444  	// values are omitted from API requests. However, any field with an
   445  	// empty value appearing in NullFields will be sent to the server as
   446  	// null. It is an error if a field in this list has a non-empty value.
   447  	// This may be used to include null fields in Patch requests.
   448  	NullFields []string `json:"-"`
   449  }
   450  
   451  func (s *ResultFormattedResultsRuleResultsUrlBlocksUrlsDetails) MarshalJSON() ([]byte, error) {
   452  	type NoMethod ResultFormattedResultsRuleResultsUrlBlocksUrlsDetails
   453  	raw := NoMethod(*s)
   454  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   455  }
   456  
   457  type ResultFormattedResultsRuleResultsUrlBlocksUrlsDetailsArgs struct {
   458  	// Type: Type of argument. One of URL, STRING_LITERAL, INT_LITERAL,
   459  	// BYTES, or DURATION.
   460  	Type string `json:"type,omitempty"`
   461  
   462  	// Value: Argument value, as a localized string.
   463  	Value string `json:"value,omitempty"`
   464  
   465  	// ForceSendFields is a list of field names (e.g. "Type") to
   466  	// unconditionally include in API requests. By default, fields with
   467  	// empty values are omitted from API requests. However, any non-pointer,
   468  	// non-interface field appearing in ForceSendFields will be sent to the
   469  	// server regardless of whether the field is empty or not. This may be
   470  	// used to include empty fields in Patch requests.
   471  	ForceSendFields []string `json:"-"`
   472  
   473  	// NullFields is a list of field names (e.g. "Type") to include in API
   474  	// requests with the JSON null value. By default, fields with empty
   475  	// values are omitted from API requests. However, any field with an
   476  	// empty value appearing in NullFields will be sent to the server as
   477  	// null. It is an error if a field in this list has a non-empty value.
   478  	// This may be used to include null fields in Patch requests.
   479  	NullFields []string `json:"-"`
   480  }
   481  
   482  func (s *ResultFormattedResultsRuleResultsUrlBlocksUrlsDetailsArgs) MarshalJSON() ([]byte, error) {
   483  	type NoMethod ResultFormattedResultsRuleResultsUrlBlocksUrlsDetailsArgs
   484  	raw := NoMethod(*s)
   485  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   486  }
   487  
   488  // ResultFormattedResultsRuleResultsUrlBlocksUrlsResult: A format string
   489  // that gives information about the URL, and a list of arguments for
   490  // that format string.
   491  type ResultFormattedResultsRuleResultsUrlBlocksUrlsResult struct {
   492  	// Args: List of arguments for the format string.
   493  	Args []*ResultFormattedResultsRuleResultsUrlBlocksUrlsResultArgs `json:"args,omitempty"`
   494  
   495  	// Format: A localized format string with $N placeholders, where N is
   496  	// the 1-indexed argument number, e.g. 'Minifying the resource at URL $1
   497  	// can save $2 bytes'.
   498  	Format string `json:"format,omitempty"`
   499  
   500  	// ForceSendFields is a list of field names (e.g. "Args") to
   501  	// unconditionally include in API requests. By default, fields with
   502  	// empty values are omitted from API requests. However, any non-pointer,
   503  	// non-interface field appearing in ForceSendFields will be sent to the
   504  	// server regardless of whether the field is empty or not. This may be
   505  	// used to include empty fields in Patch requests.
   506  	ForceSendFields []string `json:"-"`
   507  
   508  	// NullFields is a list of field names (e.g. "Args") to include in API
   509  	// requests with the JSON null value. By default, fields with empty
   510  	// values are omitted from API requests. However, any field with an
   511  	// empty value appearing in NullFields will be sent to the server as
   512  	// null. It is an error if a field in this list has a non-empty value.
   513  	// This may be used to include null fields in Patch requests.
   514  	NullFields []string `json:"-"`
   515  }
   516  
   517  func (s *ResultFormattedResultsRuleResultsUrlBlocksUrlsResult) MarshalJSON() ([]byte, error) {
   518  	type NoMethod ResultFormattedResultsRuleResultsUrlBlocksUrlsResult
   519  	raw := NoMethod(*s)
   520  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   521  }
   522  
   523  type ResultFormattedResultsRuleResultsUrlBlocksUrlsResultArgs struct {
   524  	// Type: Type of argument. One of URL, STRING_LITERAL, INT_LITERAL,
   525  	// BYTES, or DURATION.
   526  	Type string `json:"type,omitempty"`
   527  
   528  	// Value: Argument value, as a localized string.
   529  	Value string `json:"value,omitempty"`
   530  
   531  	// ForceSendFields is a list of field names (e.g. "Type") to
   532  	// unconditionally include in API requests. By default, fields with
   533  	// empty values are omitted from API requests. However, any non-pointer,
   534  	// non-interface field appearing in ForceSendFields will be sent to the
   535  	// server regardless of whether the field is empty or not. This may be
   536  	// used to include empty fields in Patch requests.
   537  	ForceSendFields []string `json:"-"`
   538  
   539  	// NullFields is a list of field names (e.g. "Type") to include in API
   540  	// requests with the JSON null value. By default, fields with empty
   541  	// values are omitted from API requests. However, any field with an
   542  	// empty value appearing in NullFields will be sent to the server as
   543  	// null. It is an error if a field in this list has a non-empty value.
   544  	// This may be used to include null fields in Patch requests.
   545  	NullFields []string `json:"-"`
   546  }
   547  
   548  func (s *ResultFormattedResultsRuleResultsUrlBlocksUrlsResultArgs) MarshalJSON() ([]byte, error) {
   549  	type NoMethod ResultFormattedResultsRuleResultsUrlBlocksUrlsResultArgs
   550  	raw := NoMethod(*s)
   551  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   552  }
   553  
   554  // ResultPageStats: Summary statistics for the page, such as number of
   555  // JavaScript bytes, number of HTML bytes, etc.
   556  type ResultPageStats struct {
   557  	// CssResponseBytes: Number of uncompressed response bytes for CSS
   558  	// resources on the page.
   559  	CssResponseBytes int64 `json:"cssResponseBytes,omitempty,string"`
   560  
   561  	// FlashResponseBytes: Number of response bytes for flash resources on
   562  	// the page.
   563  	FlashResponseBytes int64 `json:"flashResponseBytes,omitempty,string"`
   564  
   565  	// HtmlResponseBytes: Number of uncompressed response bytes for the main
   566  	// HTML document and all iframes on the page.
   567  	HtmlResponseBytes int64 `json:"htmlResponseBytes,omitempty,string"`
   568  
   569  	// ImageResponseBytes: Number of response bytes for image resources on
   570  	// the page.
   571  	ImageResponseBytes int64 `json:"imageResponseBytes,omitempty,string"`
   572  
   573  	// JavascriptResponseBytes: Number of uncompressed response bytes for JS
   574  	// resources on the page.
   575  	JavascriptResponseBytes int64 `json:"javascriptResponseBytes,omitempty,string"`
   576  
   577  	// NumberCssResources: Number of CSS resources referenced by the page.
   578  	NumberCssResources int64 `json:"numberCssResources,omitempty"`
   579  
   580  	// NumberHosts: Number of unique hosts referenced by the page.
   581  	NumberHosts int64 `json:"numberHosts,omitempty"`
   582  
   583  	// NumberJsResources: Number of JavaScript resources referenced by the
   584  	// page.
   585  	NumberJsResources int64 `json:"numberJsResources,omitempty"`
   586  
   587  	// NumberResources: Number of HTTP resources loaded by the page.
   588  	NumberResources int64 `json:"numberResources,omitempty"`
   589  
   590  	// NumberStaticResources: Number of static (i.e. cacheable) resources on
   591  	// the page.
   592  	NumberStaticResources int64 `json:"numberStaticResources,omitempty"`
   593  
   594  	// OtherResponseBytes: Number of response bytes for other resources on
   595  	// the page.
   596  	OtherResponseBytes int64 `json:"otherResponseBytes,omitempty,string"`
   597  
   598  	// TextResponseBytes: Number of uncompressed response bytes for text
   599  	// resources not covered by other statistics (i.e non-HTML, non-script,
   600  	// non-CSS resources) on the page.
   601  	TextResponseBytes int64 `json:"textResponseBytes,omitempty,string"`
   602  
   603  	// TotalRequestBytes: Total size of all request bytes sent by the page.
   604  	TotalRequestBytes int64 `json:"totalRequestBytes,omitempty,string"`
   605  
   606  	// ForceSendFields is a list of field names (e.g. "CssResponseBytes") to
   607  	// unconditionally include in API requests. By default, fields with
   608  	// empty values are omitted from API requests. However, any non-pointer,
   609  	// non-interface field appearing in ForceSendFields will be sent to the
   610  	// server regardless of whether the field is empty or not. This may be
   611  	// used to include empty fields in Patch requests.
   612  	ForceSendFields []string `json:"-"`
   613  
   614  	// NullFields is a list of field names (e.g. "CssResponseBytes") to
   615  	// include in API requests with the JSON null value. By default, fields
   616  	// with empty values are omitted from API requests. However, any field
   617  	// with an empty value appearing in NullFields will be sent to the
   618  	// server as null. It is an error if a field in this list has a
   619  	// non-empty value. This may be used to include null fields in Patch
   620  	// requests.
   621  	NullFields []string `json:"-"`
   622  }
   623  
   624  func (s *ResultPageStats) MarshalJSON() ([]byte, error) {
   625  	type NoMethod ResultPageStats
   626  	raw := NoMethod(*s)
   627  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   628  }
   629  
   630  // ResultScreenshot: Base64-encoded screenshot of the page that was
   631  // analyzed.
   632  type ResultScreenshot struct {
   633  	// Data: Image data base64 encoded.
   634  	Data string `json:"data,omitempty"`
   635  
   636  	// Height: Height of screenshot in pixels.
   637  	Height int64 `json:"height,omitempty"`
   638  
   639  	// MimeType: Mime type of image data. E.g. "image/jpeg".
   640  	MimeType string `json:"mime_type,omitempty"`
   641  
   642  	// Width: Width of screenshot in pixels.
   643  	Width int64 `json:"width,omitempty"`
   644  
   645  	// ForceSendFields is a list of field names (e.g. "Data") to
   646  	// unconditionally include in API requests. By default, fields with
   647  	// empty values are omitted from API requests. However, any non-pointer,
   648  	// non-interface field appearing in ForceSendFields will be sent to the
   649  	// server regardless of whether the field is empty or not. This may be
   650  	// used to include empty fields in Patch requests.
   651  	ForceSendFields []string `json:"-"`
   652  
   653  	// NullFields is a list of field names (e.g. "Data") to include in API
   654  	// requests with the JSON null value. By default, fields with empty
   655  	// values are omitted from API requests. However, any field with an
   656  	// empty value appearing in NullFields will be sent to the server as
   657  	// null. It is an error if a field in this list has a non-empty value.
   658  	// This may be used to include null fields in Patch requests.
   659  	NullFields []string `json:"-"`
   660  }
   661  
   662  func (s *ResultScreenshot) MarshalJSON() ([]byte, error) {
   663  	type NoMethod ResultScreenshot
   664  	raw := NoMethod(*s)
   665  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   666  }
   667  
   668  // ResultVersion: The version of PageSpeed used to generate these
   669  // results.
   670  type ResultVersion struct {
   671  	// Major: The major version number of PageSpeed used to generate these
   672  	// results.
   673  	Major int64 `json:"major,omitempty"`
   674  
   675  	// Minor: The minor version number of PageSpeed used to generate these
   676  	// results.
   677  	Minor int64 `json:"minor,omitempty"`
   678  
   679  	// ForceSendFields is a list of field names (e.g. "Major") to
   680  	// unconditionally include in API requests. By default, fields with
   681  	// empty values are omitted from API requests. However, any non-pointer,
   682  	// non-interface field appearing in ForceSendFields will be sent to the
   683  	// server regardless of whether the field is empty or not. This may be
   684  	// used to include empty fields in Patch requests.
   685  	ForceSendFields []string `json:"-"`
   686  
   687  	// NullFields is a list of field names (e.g. "Major") to include in API
   688  	// requests with the JSON null value. By default, fields with empty
   689  	// values are omitted from API requests. However, any field with an
   690  	// empty value appearing in NullFields will be sent to the server as
   691  	// null. It is an error if a field in this list has a non-empty value.
   692  	// This may be used to include null fields in Patch requests.
   693  	NullFields []string `json:"-"`
   694  }
   695  
   696  func (s *ResultVersion) MarshalJSON() ([]byte, error) {
   697  	type NoMethod ResultVersion
   698  	raw := NoMethod(*s)
   699  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   700  }
   701  
   702  // method id "pagespeedonline.pagespeedapi.runpagespeed":
   703  
   704  type PagespeedapiRunpagespeedCall struct {
   705  	s            *Service
   706  	urlParams_   gensupport.URLParams
   707  	ifNoneMatch_ string
   708  	ctx_         context.Context
   709  	header_      http.Header
   710  }
   711  
   712  // Runpagespeed: Runs PageSpeed analysis on the page at the specified
   713  // URL, and returns a PageSpeed score, a list of suggestions to make
   714  // that page faster, and other information.
   715  func (r *PagespeedapiService) Runpagespeed(url string) *PagespeedapiRunpagespeedCall {
   716  	c := &PagespeedapiRunpagespeedCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   717  	c.urlParams_.Set("url", url)
   718  	return c
   719  }
   720  
   721  // FilterThirdPartyResources sets the optional parameter
   722  // "filter_third_party_resources": Indicates if third party resources
   723  // should be filtered out before PageSpeed analysis.
   724  func (c *PagespeedapiRunpagespeedCall) FilterThirdPartyResources(filterThirdPartyResources bool) *PagespeedapiRunpagespeedCall {
   725  	c.urlParams_.Set("filter_third_party_resources", fmt.Sprint(filterThirdPartyResources))
   726  	return c
   727  }
   728  
   729  // Locale sets the optional parameter "locale": The locale used to
   730  // localize formatted results
   731  func (c *PagespeedapiRunpagespeedCall) Locale(locale string) *PagespeedapiRunpagespeedCall {
   732  	c.urlParams_.Set("locale", locale)
   733  	return c
   734  }
   735  
   736  // Rule sets the optional parameter "rule": A PageSpeed rule to run; if
   737  // none are given, all rules are run
   738  func (c *PagespeedapiRunpagespeedCall) Rule(rule ...string) *PagespeedapiRunpagespeedCall {
   739  	c.urlParams_.SetMulti("rule", append([]string{}, rule...))
   740  	return c
   741  }
   742  
   743  // Screenshot sets the optional parameter "screenshot": Indicates if
   744  // binary data containing a screenshot should be included
   745  func (c *PagespeedapiRunpagespeedCall) Screenshot(screenshot bool) *PagespeedapiRunpagespeedCall {
   746  	c.urlParams_.Set("screenshot", fmt.Sprint(screenshot))
   747  	return c
   748  }
   749  
   750  // Strategy sets the optional parameter "strategy": The analysis
   751  // strategy to use
   752  //
   753  // Possible values:
   754  //
   755  //	"desktop" - Fetch and analyze the URL for desktop browsers
   756  //	"mobile" - Fetch and analyze the URL for mobile devices
   757  func (c *PagespeedapiRunpagespeedCall) Strategy(strategy string) *PagespeedapiRunpagespeedCall {
   758  	c.urlParams_.Set("strategy", strategy)
   759  	return c
   760  }
   761  
   762  // Fields allows partial responses to be retrieved. See
   763  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   764  // for more information.
   765  func (c *PagespeedapiRunpagespeedCall) Fields(s ...googleapi.Field) *PagespeedapiRunpagespeedCall {
   766  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   767  	return c
   768  }
   769  
   770  // IfNoneMatch sets the optional parameter which makes the operation
   771  // fail if the object's ETag matches the given value. This is useful for
   772  // getting updates only after the object has changed since the last
   773  // request. Use googleapi.IsNotModified to check whether the response
   774  // error from Do is the result of In-None-Match.
   775  func (c *PagespeedapiRunpagespeedCall) IfNoneMatch(entityTag string) *PagespeedapiRunpagespeedCall {
   776  	c.ifNoneMatch_ = entityTag
   777  	return c
   778  }
   779  
   780  // Context sets the context to be used in this call's Do method. Any
   781  // pending HTTP request will be aborted if the provided context is
   782  // canceled.
   783  func (c *PagespeedapiRunpagespeedCall) Context(ctx context.Context) *PagespeedapiRunpagespeedCall {
   784  	c.ctx_ = ctx
   785  	return c
   786  }
   787  
   788  // Header returns an http.Header that can be modified by the caller to
   789  // add HTTP headers to the request.
   790  func (c *PagespeedapiRunpagespeedCall) Header() http.Header {
   791  	if c.header_ == nil {
   792  		c.header_ = make(http.Header)
   793  	}
   794  	return c.header_
   795  }
   796  
   797  func (c *PagespeedapiRunpagespeedCall) doRequest(alt string) (*http.Response, error) {
   798  	reqHeaders := make(http.Header)
   799  	reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200512")
   800  	for k, v := range c.header_ {
   801  		reqHeaders[k] = v
   802  	}
   803  	reqHeaders.Set("User-Agent", c.s.userAgent())
   804  	if c.ifNoneMatch_ != "" {
   805  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   806  	}
   807  	var body io.Reader = nil
   808  	c.urlParams_.Set("alt", alt)
   809  	c.urlParams_.Set("prettyPrint", "false")
   810  	urls := googleapi.ResolveRelative(c.s.BasePath, "runPagespeed")
   811  	urls += "?" + c.urlParams_.Encode()
   812  	req, err := http.NewRequest("GET", urls, body)
   813  	if err != nil {
   814  		return nil, err
   815  	}
   816  	req.Header = reqHeaders
   817  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   818  }
   819  
   820  // Do executes the "pagespeedonline.pagespeedapi.runpagespeed" call.
   821  // Exactly one of *Result or error will be non-nil. Any non-2xx status
   822  // code is an error. Response headers are in either
   823  // *Result.ServerResponse.Header or (if a response was returned at all)
   824  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   825  // check whether the returned error was because http.StatusNotModified
   826  // was returned.
   827  func (c *PagespeedapiRunpagespeedCall) Do(opts ...googleapi.CallOption) (*Result, error) {
   828  	gensupport.SetOptions(c.urlParams_, opts...)
   829  	res, err := c.doRequest("json")
   830  	if res != nil && res.StatusCode == http.StatusNotModified {
   831  		if res.Body != nil {
   832  			res.Body.Close()
   833  		}
   834  		return nil, &googleapi.Error{
   835  			Code:   res.StatusCode,
   836  			Header: res.Header,
   837  		}
   838  	}
   839  	if err != nil {
   840  		return nil, err
   841  	}
   842  	defer googleapi.CloseBody(res)
   843  	if err := googleapi.CheckResponse(res); err != nil {
   844  		return nil, err
   845  	}
   846  	ret := &Result{
   847  		ServerResponse: googleapi.ServerResponse{
   848  			Header:         res.Header,
   849  			HTTPStatusCode: res.StatusCode,
   850  		},
   851  	}
   852  	target := &ret
   853  	if err := gensupport.DecodeResponse(target, res); err != nil {
   854  		return nil, err
   855  	}
   856  	return ret, nil
   857  	// {
   858  	//   "description": "Runs PageSpeed analysis on the page at the specified URL, and returns a PageSpeed score, a list of suggestions to make that page faster, and other information.",
   859  	//   "httpMethod": "GET",
   860  	//   "id": "pagespeedonline.pagespeedapi.runpagespeed",
   861  	//   "parameterOrder": [
   862  	//     "url"
   863  	//   ],
   864  	//   "parameters": {
   865  	//     "filter_third_party_resources": {
   866  	//       "default": "false",
   867  	//       "description": "Indicates if third party resources should be filtered out before PageSpeed analysis.",
   868  	//       "location": "query",
   869  	//       "type": "boolean"
   870  	//     },
   871  	//     "locale": {
   872  	//       "description": "The locale used to localize formatted results",
   873  	//       "location": "query",
   874  	//       "pattern": "[a-zA-Z]+(_[a-zA-Z]+)?",
   875  	//       "type": "string"
   876  	//     },
   877  	//     "rule": {
   878  	//       "description": "A PageSpeed rule to run; if none are given, all rules are run",
   879  	//       "location": "query",
   880  	//       "pattern": "[a-zA-Z]+",
   881  	//       "repeated": true,
   882  	//       "type": "string"
   883  	//     },
   884  	//     "screenshot": {
   885  	//       "default": "false",
   886  	//       "description": "Indicates if binary data containing a screenshot should be included",
   887  	//       "location": "query",
   888  	//       "type": "boolean"
   889  	//     },
   890  	//     "strategy": {
   891  	//       "description": "The analysis strategy to use",
   892  	//       "enum": [
   893  	//         "desktop",
   894  	//         "mobile"
   895  	//       ],
   896  	//       "enumDescriptions": [
   897  	//         "Fetch and analyze the URL for desktop browsers",
   898  	//         "Fetch and analyze the URL for mobile devices"
   899  	//       ],
   900  	//       "location": "query",
   901  	//       "type": "string"
   902  	//     },
   903  	//     "url": {
   904  	//       "description": "The URL to fetch and analyze",
   905  	//       "location": "query",
   906  	//       "pattern": "(?i)http(s)?://.*",
   907  	//       "required": true,
   908  	//       "type": "string"
   909  	//     }
   910  	//   },
   911  	//   "path": "runPagespeed",
   912  	//   "response": {
   913  	//     "$ref": "Result"
   914  	//   }
   915  	// }
   916  
   917  }
   918  

View as plain text