...

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

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

     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/v4/getting-started
    10  //
    11  // # Creating a client
    12  //
    13  // Usage example:
    14  //
    15  //	import "google.golang.org/api/pagespeedonline/v4"
    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/v4"
    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:v4"
    75  const apiName = "pagespeedonline"
    76  const apiVersion = "v4"
    77  const basePath = "https://www.googleapis.com/pagespeedonline/v4/"
    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 PagespeedApiFormatStringV4 struct {
   135  	// Args: List of arguments for the format string.
   136  	Args []*PagespeedApiFormatStringV4Args `json:"args,omitempty"`
   137  
   138  	// Format: A localized format string with {{FOO}} placeholders, where
   139  	// 'FOO' is the key of the argument whose value should be substituted.
   140  	// For HYPERLINK arguments, the format string will instead contain
   141  	// {{BEGIN_FOO}} and {{END_FOO}} for the argument with key 'FOO'.
   142  	Format string `json:"format,omitempty"`
   143  
   144  	// ForceSendFields is a list of field names (e.g. "Args") to
   145  	// unconditionally include in API requests. By default, fields with
   146  	// empty values are omitted from API requests. However, any non-pointer,
   147  	// non-interface field appearing in ForceSendFields will be sent to the
   148  	// server regardless of whether the field is empty or not. This may be
   149  	// used to include empty fields in Patch requests.
   150  	ForceSendFields []string `json:"-"`
   151  
   152  	// NullFields is a list of field names (e.g. "Args") to include in API
   153  	// requests with the JSON null value. By default, fields with empty
   154  	// values are omitted from API requests. However, any field with an
   155  	// empty value appearing in NullFields will be sent to the server as
   156  	// null. It is an error if a field in this list has a non-empty value.
   157  	// This may be used to include null fields in Patch requests.
   158  	NullFields []string `json:"-"`
   159  }
   160  
   161  func (s *PagespeedApiFormatStringV4) MarshalJSON() ([]byte, error) {
   162  	type NoMethod PagespeedApiFormatStringV4
   163  	raw := NoMethod(*s)
   164  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   165  }
   166  
   167  type PagespeedApiFormatStringV4Args struct {
   168  	// Key: The placeholder key for this arg, as a string.
   169  	Key string `json:"key,omitempty"`
   170  
   171  	// Rects: The screen rectangles being referred to, with dimensions
   172  	// measured in CSS pixels. This is only ever used for SNAPSHOT_RECT
   173  	// arguments. If this is absent for a SNAPSHOT_RECT argument, it means
   174  	// that that argument refers to the entire snapshot.
   175  	Rects []*PagespeedApiFormatStringV4ArgsRects `json:"rects,omitempty"`
   176  
   177  	// SecondaryRects: Secondary screen rectangles being referred to, with
   178  	// dimensions measured in CSS pixels. This is only ever used for
   179  	// SNAPSHOT_RECT arguments.
   180  	SecondaryRects []*PagespeedApiFormatStringV4ArgsSecondaryRects `json:"secondary_rects,omitempty"`
   181  
   182  	// Type: Type of argument. One of URL, STRING_LITERAL, INT_LITERAL,
   183  	// BYTES, DURATION, VERBATIM_STRING, PERCENTAGE, HYPERLINK, or
   184  	// SNAPSHOT_RECT.
   185  	Type string `json:"type,omitempty"`
   186  
   187  	// Value: Argument value, as a localized string.
   188  	Value string `json:"value,omitempty"`
   189  
   190  	// ForceSendFields is a list of field names (e.g. "Key") to
   191  	// unconditionally include in API requests. By default, fields with
   192  	// empty values are omitted from API requests. However, any non-pointer,
   193  	// non-interface field appearing in ForceSendFields will be sent to the
   194  	// server regardless of whether the field is empty or not. This may be
   195  	// used to include empty fields in Patch requests.
   196  	ForceSendFields []string `json:"-"`
   197  
   198  	// NullFields is a list of field names (e.g. "Key") to include in API
   199  	// requests with the JSON null value. By default, fields with empty
   200  	// values are omitted from API requests. However, any field with an
   201  	// empty value appearing in NullFields will be sent to the server as
   202  	// null. It is an error if a field in this list has a non-empty value.
   203  	// This may be used to include null fields in Patch requests.
   204  	NullFields []string `json:"-"`
   205  }
   206  
   207  func (s *PagespeedApiFormatStringV4Args) MarshalJSON() ([]byte, error) {
   208  	type NoMethod PagespeedApiFormatStringV4Args
   209  	raw := NoMethod(*s)
   210  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   211  }
   212  
   213  type PagespeedApiFormatStringV4ArgsRects struct {
   214  	Height int64 `json:"height,omitempty"`
   215  
   216  	Left int64 `json:"left,omitempty"`
   217  
   218  	Top int64 `json:"top,omitempty"`
   219  
   220  	Width int64 `json:"width,omitempty"`
   221  
   222  	// ForceSendFields is a list of field names (e.g. "Height") to
   223  	// unconditionally include in API requests. By default, fields with
   224  	// empty values are omitted from API requests. However, any non-pointer,
   225  	// non-interface field appearing in ForceSendFields will be sent to the
   226  	// server regardless of whether the field is empty or not. This may be
   227  	// used to include empty fields in Patch requests.
   228  	ForceSendFields []string `json:"-"`
   229  
   230  	// NullFields is a list of field names (e.g. "Height") to include in API
   231  	// requests with the JSON null value. By default, fields with empty
   232  	// values are omitted from API requests. However, any field with an
   233  	// empty value appearing in NullFields will be sent to the server as
   234  	// null. It is an error if a field in this list has a non-empty value.
   235  	// This may be used to include null fields in Patch requests.
   236  	NullFields []string `json:"-"`
   237  }
   238  
   239  func (s *PagespeedApiFormatStringV4ArgsRects) MarshalJSON() ([]byte, error) {
   240  	type NoMethod PagespeedApiFormatStringV4ArgsRects
   241  	raw := NoMethod(*s)
   242  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   243  }
   244  
   245  type PagespeedApiFormatStringV4ArgsSecondaryRects struct {
   246  	Height int64 `json:"height,omitempty"`
   247  
   248  	Left int64 `json:"left,omitempty"`
   249  
   250  	Top int64 `json:"top,omitempty"`
   251  
   252  	Width int64 `json:"width,omitempty"`
   253  
   254  	// ForceSendFields is a list of field names (e.g. "Height") to
   255  	// unconditionally include in API requests. By default, fields with
   256  	// empty values are omitted from API requests. However, any non-pointer,
   257  	// non-interface field appearing in ForceSendFields will be sent to the
   258  	// server regardless of whether the field is empty or not. This may be
   259  	// used to include empty fields in Patch requests.
   260  	ForceSendFields []string `json:"-"`
   261  
   262  	// NullFields is a list of field names (e.g. "Height") to include in API
   263  	// requests with the JSON null value. By default, fields with empty
   264  	// values are omitted from API requests. However, any field with an
   265  	// empty value appearing in NullFields will be sent to the server as
   266  	// null. It is an error if a field in this list has a non-empty value.
   267  	// This may be used to include null fields in Patch requests.
   268  	NullFields []string `json:"-"`
   269  }
   270  
   271  func (s *PagespeedApiFormatStringV4ArgsSecondaryRects) MarshalJSON() ([]byte, error) {
   272  	type NoMethod PagespeedApiFormatStringV4ArgsSecondaryRects
   273  	raw := NoMethod(*s)
   274  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   275  }
   276  
   277  type PagespeedApiImageV4 struct {
   278  	// Data: Image data base64 encoded.
   279  	Data string `json:"data,omitempty"`
   280  
   281  	// Height: Height of screenshot in pixels.
   282  	Height int64 `json:"height,omitempty"`
   283  
   284  	// Key: Unique string key, if any, identifying this image.
   285  	Key string `json:"key,omitempty"`
   286  
   287  	// MimeType: Mime type of image data (e.g. "image/jpeg").
   288  	MimeType string `json:"mime_type,omitempty"`
   289  
   290  	PageRect *PagespeedApiImageV4PageRect `json:"page_rect,omitempty"`
   291  
   292  	// Width: Width of screenshot in pixels.
   293  	Width int64 `json:"width,omitempty"`
   294  
   295  	// ForceSendFields is a list of field names (e.g. "Data") to
   296  	// unconditionally include in API requests. By default, fields with
   297  	// empty values are omitted from API requests. However, any non-pointer,
   298  	// non-interface field appearing in ForceSendFields will be sent to the
   299  	// server regardless of whether the field is empty or not. This may be
   300  	// used to include empty fields in Patch requests.
   301  	ForceSendFields []string `json:"-"`
   302  
   303  	// NullFields is a list of field names (e.g. "Data") to include in API
   304  	// requests with the JSON null value. By default, fields with empty
   305  	// values are omitted from API requests. However, any field with an
   306  	// empty value appearing in NullFields will be sent to the server as
   307  	// null. It is an error if a field in this list has a non-empty value.
   308  	// This may be used to include null fields in Patch requests.
   309  	NullFields []string `json:"-"`
   310  }
   311  
   312  func (s *PagespeedApiImageV4) MarshalJSON() ([]byte, error) {
   313  	type NoMethod PagespeedApiImageV4
   314  	raw := NoMethod(*s)
   315  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   316  }
   317  
   318  type PagespeedApiImageV4PageRect struct {
   319  	Height int64 `json:"height,omitempty"`
   320  
   321  	Left int64 `json:"left,omitempty"`
   322  
   323  	Top int64 `json:"top,omitempty"`
   324  
   325  	Width int64 `json:"width,omitempty"`
   326  
   327  	// ForceSendFields is a list of field names (e.g. "Height") to
   328  	// unconditionally include in API requests. By default, fields with
   329  	// empty values are omitted from API requests. However, any non-pointer,
   330  	// non-interface field appearing in ForceSendFields will be sent to the
   331  	// server regardless of whether the field is empty or not. This may be
   332  	// used to include empty fields in Patch requests.
   333  	ForceSendFields []string `json:"-"`
   334  
   335  	// NullFields is a list of field names (e.g. "Height") to include in API
   336  	// requests with the JSON null value. By default, fields with empty
   337  	// values are omitted from API requests. However, any field with an
   338  	// empty value appearing in NullFields will be sent to the server as
   339  	// null. It is an error if a field in this list has a non-empty value.
   340  	// This may be used to include null fields in Patch requests.
   341  	NullFields []string `json:"-"`
   342  }
   343  
   344  func (s *PagespeedApiImageV4PageRect) MarshalJSON() ([]byte, error) {
   345  	type NoMethod PagespeedApiImageV4PageRect
   346  	raw := NoMethod(*s)
   347  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   348  }
   349  
   350  type PagespeedApiPagespeedResponseV4 struct {
   351  	// CaptchaResult: The captcha verify result
   352  	CaptchaResult string `json:"captchaResult,omitempty"`
   353  
   354  	// FormattedResults: Localized PageSpeed results. Contains a ruleResults
   355  	// entry for each PageSpeed rule instantiated and run by the server.
   356  	FormattedResults *PagespeedApiPagespeedResponseV4FormattedResults `json:"formattedResults,omitempty"`
   357  
   358  	// Id: Canonicalized and final URL for the document, after following
   359  	// page redirects (if any).
   360  	Id string `json:"id,omitempty"`
   361  
   362  	// InvalidRules: List of rules that were specified in the request, but
   363  	// which the server did not know how to instantiate.
   364  	InvalidRules []string `json:"invalidRules,omitempty"`
   365  
   366  	// Kind: Kind of result.
   367  	Kind string `json:"kind,omitempty"`
   368  
   369  	// LoadingExperience: Metrics of end users' page loading experience.
   370  	LoadingExperience *PagespeedApiPagespeedResponseV4LoadingExperience `json:"loadingExperience,omitempty"`
   371  
   372  	// PageStats: Summary statistics for the page, such as number of
   373  	// JavaScript bytes, number of HTML bytes, etc.
   374  	PageStats *PagespeedApiPagespeedResponseV4PageStats `json:"pageStats,omitempty"`
   375  
   376  	// ResponseCode: Response code for the document. 200 indicates a normal
   377  	// page load. 4xx/5xx indicates an error.
   378  	ResponseCode int64 `json:"responseCode,omitempty"`
   379  
   380  	// RuleGroups: A map with one entry for each rule group in these
   381  	// results.
   382  	RuleGroups map[string]PagespeedApiPagespeedResponseV4RuleGroups `json:"ruleGroups,omitempty"`
   383  
   384  	// Screenshot: Base64-encoded screenshot of the page that was analyzed.
   385  	Screenshot *PagespeedApiImageV4 `json:"screenshot,omitempty"`
   386  
   387  	// Snapshots: Additional base64-encoded screenshots of the page, in
   388  	// various partial render states.
   389  	Snapshots []*PagespeedApiImageV4 `json:"snapshots,omitempty"`
   390  
   391  	// Title: Title of the page, as displayed in the browser's title bar.
   392  	Title string `json:"title,omitempty"`
   393  
   394  	// Version: The version of PageSpeed used to generate these results.
   395  	Version *PagespeedApiPagespeedResponseV4Version `json:"version,omitempty"`
   396  
   397  	// ServerResponse contains the HTTP response code and headers from the
   398  	// server.
   399  	googleapi.ServerResponse `json:"-"`
   400  
   401  	// ForceSendFields is a list of field names (e.g. "CaptchaResult") to
   402  	// unconditionally include in API requests. By default, fields with
   403  	// empty values are omitted from API requests. However, any non-pointer,
   404  	// non-interface field appearing in ForceSendFields will be sent to the
   405  	// server regardless of whether the field is empty or not. This may be
   406  	// used to include empty fields in Patch requests.
   407  	ForceSendFields []string `json:"-"`
   408  
   409  	// NullFields is a list of field names (e.g. "CaptchaResult") to include
   410  	// in API requests with the JSON null value. By default, fields with
   411  	// empty values are omitted from API requests. However, any field with
   412  	// an empty value appearing in NullFields will be sent to the server as
   413  	// null. It is an error if a field in this list has a non-empty value.
   414  	// This may be used to include null fields in Patch requests.
   415  	NullFields []string `json:"-"`
   416  }
   417  
   418  func (s *PagespeedApiPagespeedResponseV4) MarshalJSON() ([]byte, error) {
   419  	type NoMethod PagespeedApiPagespeedResponseV4
   420  	raw := NoMethod(*s)
   421  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   422  }
   423  
   424  // PagespeedApiPagespeedResponseV4FormattedResults: Localized PageSpeed
   425  // results. Contains a ruleResults entry for each PageSpeed rule
   426  // instantiated and run by the server.
   427  type PagespeedApiPagespeedResponseV4FormattedResults struct {
   428  	// Locale: The locale of the formattedResults, e.g. "en_US".
   429  	Locale string `json:"locale,omitempty"`
   430  
   431  	// RuleResults: Dictionary of formatted rule results, with one entry for
   432  	// each PageSpeed rule instantiated and run by the server.
   433  	RuleResults map[string]PagespeedApiPagespeedResponseV4FormattedResultsRuleResults `json:"ruleResults,omitempty"`
   434  
   435  	// ForceSendFields is a list of field names (e.g. "Locale") to
   436  	// unconditionally include in API requests. By default, fields with
   437  	// empty values are omitted from API requests. However, any non-pointer,
   438  	// non-interface field appearing in ForceSendFields will be sent to the
   439  	// server regardless of whether the field is empty or not. This may be
   440  	// used to include empty fields in Patch requests.
   441  	ForceSendFields []string `json:"-"`
   442  
   443  	// NullFields is a list of field names (e.g. "Locale") to include in API
   444  	// requests with the JSON null value. By default, fields with empty
   445  	// values are omitted from API requests. However, any field with an
   446  	// empty value appearing in NullFields will be sent to the server as
   447  	// null. It is an error if a field in this list has a non-empty value.
   448  	// This may be used to include null fields in Patch requests.
   449  	NullFields []string `json:"-"`
   450  }
   451  
   452  func (s *PagespeedApiPagespeedResponseV4FormattedResults) MarshalJSON() ([]byte, error) {
   453  	type NoMethod PagespeedApiPagespeedResponseV4FormattedResults
   454  	raw := NoMethod(*s)
   455  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   456  }
   457  
   458  // PagespeedApiPagespeedResponseV4FormattedResultsRuleResults: The
   459  // enum-like identifier for this rule. For instance "EnableKeepAlive" or
   460  // "AvoidCssImport". Not localized.
   461  type PagespeedApiPagespeedResponseV4FormattedResultsRuleResults struct {
   462  	// Beta: Whether this rule is in 'beta'. Rules in beta are new rules
   463  	// that are being tested, which do not impact the overall score.
   464  	Beta bool `json:"beta,omitempty"`
   465  
   466  	// Groups: List of rule groups that this rule belongs to. Each entry in
   467  	// the list is one of "SPEED", "USABILITY", or "SECURITY".
   468  	Groups []string `json:"groups,omitempty"`
   469  
   470  	// LocalizedRuleName: Localized name of the rule, intended for
   471  	// presentation to a user.
   472  	LocalizedRuleName string `json:"localizedRuleName,omitempty"`
   473  
   474  	// RuleImpact: The impact (unbounded floating point value) that
   475  	// implementing the suggestions for this rule would have on making the
   476  	// page faster. Impact is comparable between rules to determine which
   477  	// rule's suggestions would have a higher or lower impact on making a
   478  	// page faster. For instance, if enabling compression would save 1MB,
   479  	// while optimizing images would save 500kB, the enable compression rule
   480  	// would have 2x the impact of the image optimization rule, all other
   481  	// things being equal.
   482  	RuleImpact float64 `json:"ruleImpact,omitempty"`
   483  
   484  	// Summary: A brief summary description for the rule, indicating at a
   485  	// high level what should be done to follow the rule and what benefit
   486  	// can be gained by doing so.
   487  	Summary *PagespeedApiFormatStringV4 `json:"summary,omitempty"`
   488  
   489  	// UrlBlocks: List of blocks of URLs. Each block may contain a heading
   490  	// and a list of URLs. Each URL may optionally include additional
   491  	// details.
   492  	UrlBlocks []*PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocks `json:"urlBlocks,omitempty"`
   493  
   494  	// ForceSendFields is a list of field names (e.g. "Beta") to
   495  	// unconditionally include in API requests. By default, fields with
   496  	// empty values are omitted from API requests. However, any non-pointer,
   497  	// non-interface field appearing in ForceSendFields will be sent to the
   498  	// server regardless of whether the field is empty or not. This may be
   499  	// used to include empty fields in Patch requests.
   500  	ForceSendFields []string `json:"-"`
   501  
   502  	// NullFields is a list of field names (e.g. "Beta") to include in API
   503  	// requests with the JSON null value. By default, fields with empty
   504  	// values are omitted from API requests. However, any field with an
   505  	// empty value appearing in NullFields will be sent to the server as
   506  	// null. It is an error if a field in this list has a non-empty value.
   507  	// This may be used to include null fields in Patch requests.
   508  	NullFields []string `json:"-"`
   509  }
   510  
   511  func (s *PagespeedApiPagespeedResponseV4FormattedResultsRuleResults) MarshalJSON() ([]byte, error) {
   512  	type NoMethod PagespeedApiPagespeedResponseV4FormattedResultsRuleResults
   513  	raw := NoMethod(*s)
   514  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   515  }
   516  
   517  func (s *PagespeedApiPagespeedResponseV4FormattedResultsRuleResults) UnmarshalJSON(data []byte) error {
   518  	type NoMethod PagespeedApiPagespeedResponseV4FormattedResultsRuleResults
   519  	var s1 struct {
   520  		RuleImpact gensupport.JSONFloat64 `json:"ruleImpact"`
   521  		*NoMethod
   522  	}
   523  	s1.NoMethod = (*NoMethod)(s)
   524  	if err := json.Unmarshal(data, &s1); err != nil {
   525  		return err
   526  	}
   527  	s.RuleImpact = float64(s1.RuleImpact)
   528  	return nil
   529  }
   530  
   531  type PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocks struct {
   532  	// Header: Heading to be displayed with the list of URLs.
   533  	Header *PagespeedApiFormatStringV4 `json:"header,omitempty"`
   534  
   535  	// Urls: List of entries that provide information about URLs in the url
   536  	// block. Optional.
   537  	Urls []*PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocksUrls `json:"urls,omitempty"`
   538  
   539  	// ForceSendFields is a list of field names (e.g. "Header") to
   540  	// unconditionally include in API requests. By default, fields with
   541  	// empty values are omitted from API requests. However, any non-pointer,
   542  	// non-interface field appearing in ForceSendFields will be sent to the
   543  	// server regardless of whether the field is empty or not. This may be
   544  	// used to include empty fields in Patch requests.
   545  	ForceSendFields []string `json:"-"`
   546  
   547  	// NullFields is a list of field names (e.g. "Header") to include in API
   548  	// requests with the JSON null value. By default, fields with empty
   549  	// values are omitted from API requests. However, any field with an
   550  	// empty value appearing in NullFields will be sent to the server as
   551  	// null. It is an error if a field in this list has a non-empty value.
   552  	// This may be used to include null fields in Patch requests.
   553  	NullFields []string `json:"-"`
   554  }
   555  
   556  func (s *PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocks) MarshalJSON() ([]byte, error) {
   557  	type NoMethod PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocks
   558  	raw := NoMethod(*s)
   559  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   560  }
   561  
   562  type PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocksUrls struct {
   563  	// Details: List of entries that provide additional details about a
   564  	// single URL. Optional.
   565  	Details []*PagespeedApiFormatStringV4 `json:"details,omitempty"`
   566  
   567  	// Result: A format string that gives information about the URL, and a
   568  	// list of arguments for that format string.
   569  	Result *PagespeedApiFormatStringV4 `json:"result,omitempty"`
   570  
   571  	// ForceSendFields is a list of field names (e.g. "Details") to
   572  	// unconditionally include in API requests. By default, fields with
   573  	// empty values are omitted from API requests. However, any non-pointer,
   574  	// non-interface field appearing in ForceSendFields will be sent to the
   575  	// server regardless of whether the field is empty or not. This may be
   576  	// used to include empty fields in Patch requests.
   577  	ForceSendFields []string `json:"-"`
   578  
   579  	// NullFields is a list of field names (e.g. "Details") to include in
   580  	// API requests with the JSON null value. By default, fields with empty
   581  	// values are omitted from API requests. However, any field with an
   582  	// empty value appearing in NullFields will be sent to the server as
   583  	// null. It is an error if a field in this list has a non-empty value.
   584  	// This may be used to include null fields in Patch requests.
   585  	NullFields []string `json:"-"`
   586  }
   587  
   588  func (s *PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocksUrls) MarshalJSON() ([]byte, error) {
   589  	type NoMethod PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocksUrls
   590  	raw := NoMethod(*s)
   591  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   592  }
   593  
   594  // PagespeedApiPagespeedResponseV4LoadingExperience: Metrics of end
   595  // users' page loading experience.
   596  type PagespeedApiPagespeedResponseV4LoadingExperience struct {
   597  	// Id: The url, pattern or origin which the metrics are on.
   598  	Id string `json:"id,omitempty"`
   599  
   600  	InitialUrl string `json:"initial_url,omitempty"`
   601  
   602  	Metrics map[string]PagespeedApiPagespeedResponseV4LoadingExperienceMetrics `json:"metrics,omitempty"`
   603  
   604  	OverallCategory string `json:"overall_category,omitempty"`
   605  
   606  	// ForceSendFields is a list of field names (e.g. "Id") 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. "Id") to include in API
   615  	// requests with the JSON null value. By default, fields with empty
   616  	// values are omitted from API requests. However, any field with an
   617  	// empty value appearing in NullFields will be sent to the server as
   618  	// null. It is an error if a field in this list has a non-empty value.
   619  	// This may be used to include null fields in Patch requests.
   620  	NullFields []string `json:"-"`
   621  }
   622  
   623  func (s *PagespeedApiPagespeedResponseV4LoadingExperience) MarshalJSON() ([]byte, error) {
   624  	type NoMethod PagespeedApiPagespeedResponseV4LoadingExperience
   625  	raw := NoMethod(*s)
   626  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   627  }
   628  
   629  // PagespeedApiPagespeedResponseV4LoadingExperienceMetrics: The type of
   630  // the metric.
   631  type PagespeedApiPagespeedResponseV4LoadingExperienceMetrics struct {
   632  	Category string `json:"category,omitempty"`
   633  
   634  	Distributions []*PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions `json:"distributions,omitempty"`
   635  
   636  	Median int64 `json:"median,omitempty"`
   637  
   638  	// ForceSendFields is a list of field names (e.g. "Category") to
   639  	// unconditionally include in API requests. By default, fields with
   640  	// empty values are omitted from API requests. However, any non-pointer,
   641  	// non-interface field appearing in ForceSendFields will be sent to the
   642  	// server regardless of whether the field is empty or not. This may be
   643  	// used to include empty fields in Patch requests.
   644  	ForceSendFields []string `json:"-"`
   645  
   646  	// NullFields is a list of field names (e.g. "Category") to include in
   647  	// API requests with the JSON null value. By default, fields with empty
   648  	// values are omitted from API requests. However, any field with an
   649  	// empty value appearing in NullFields will be sent to the server as
   650  	// null. It is an error if a field in this list has a non-empty value.
   651  	// This may be used to include null fields in Patch requests.
   652  	NullFields []string `json:"-"`
   653  }
   654  
   655  func (s *PagespeedApiPagespeedResponseV4LoadingExperienceMetrics) MarshalJSON() ([]byte, error) {
   656  	type NoMethod PagespeedApiPagespeedResponseV4LoadingExperienceMetrics
   657  	raw := NoMethod(*s)
   658  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   659  }
   660  
   661  type PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions struct {
   662  	Max int64 `json:"max,omitempty"`
   663  
   664  	Min int64 `json:"min,omitempty"`
   665  
   666  	Proportion float64 `json:"proportion,omitempty"`
   667  
   668  	// ForceSendFields is a list of field names (e.g. "Max") to
   669  	// unconditionally include in API requests. By default, fields with
   670  	// empty values are omitted from API requests. However, any non-pointer,
   671  	// non-interface field appearing in ForceSendFields will be sent to the
   672  	// server regardless of whether the field is empty or not. This may be
   673  	// used to include empty fields in Patch requests.
   674  	ForceSendFields []string `json:"-"`
   675  
   676  	// NullFields is a list of field names (e.g. "Max") to include in API
   677  	// requests with the JSON null value. By default, fields with empty
   678  	// values are omitted from API requests. However, any field with an
   679  	// empty value appearing in NullFields will be sent to the server as
   680  	// null. It is an error if a field in this list has a non-empty value.
   681  	// This may be used to include null fields in Patch requests.
   682  	NullFields []string `json:"-"`
   683  }
   684  
   685  func (s *PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions) MarshalJSON() ([]byte, error) {
   686  	type NoMethod PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions
   687  	raw := NoMethod(*s)
   688  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   689  }
   690  
   691  func (s *PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions) UnmarshalJSON(data []byte) error {
   692  	type NoMethod PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions
   693  	var s1 struct {
   694  		Proportion gensupport.JSONFloat64 `json:"proportion"`
   695  		*NoMethod
   696  	}
   697  	s1.NoMethod = (*NoMethod)(s)
   698  	if err := json.Unmarshal(data, &s1); err != nil {
   699  		return err
   700  	}
   701  	s.Proportion = float64(s1.Proportion)
   702  	return nil
   703  }
   704  
   705  // PagespeedApiPagespeedResponseV4PageStats: Summary statistics for the
   706  // page, such as number of JavaScript bytes, number of HTML bytes, etc.
   707  type PagespeedApiPagespeedResponseV4PageStats struct {
   708  	// Cms: Content management system (CMS) used for the page.
   709  	Cms string `json:"cms,omitempty"`
   710  
   711  	// CssResponseBytes: Number of uncompressed response bytes for CSS
   712  	// resources on the page.
   713  	CssResponseBytes int64 `json:"cssResponseBytes,omitempty,string"`
   714  
   715  	// FlashResponseBytes: Number of response bytes for flash resources on
   716  	// the page.
   717  	FlashResponseBytes int64 `json:"flashResponseBytes,omitempty,string"`
   718  
   719  	// HtmlResponseBytes: Number of uncompressed response bytes for the main
   720  	// HTML document and all iframes on the page.
   721  	HtmlResponseBytes int64 `json:"htmlResponseBytes,omitempty,string"`
   722  
   723  	// ImageResponseBytes: Number of response bytes for image resources on
   724  	// the page.
   725  	ImageResponseBytes int64 `json:"imageResponseBytes,omitempty,string"`
   726  
   727  	// JavascriptResponseBytes: Number of uncompressed response bytes for JS
   728  	// resources on the page.
   729  	JavascriptResponseBytes int64 `json:"javascriptResponseBytes,omitempty,string"`
   730  
   731  	// NumRenderBlockingRoundTrips: The needed round trips to load render
   732  	// blocking resources
   733  	NumRenderBlockingRoundTrips int64 `json:"numRenderBlockingRoundTrips,omitempty"`
   734  
   735  	// NumTotalRoundTrips: The needed round trips to load the full page
   736  	NumTotalRoundTrips int64 `json:"numTotalRoundTrips,omitempty"`
   737  
   738  	// NumberCssResources: Number of CSS resources referenced by the page.
   739  	NumberCssResources int64 `json:"numberCssResources,omitempty"`
   740  
   741  	// NumberHosts: Number of unique hosts referenced by the page.
   742  	NumberHosts int64 `json:"numberHosts,omitempty"`
   743  
   744  	// NumberJsResources: Number of JavaScript resources referenced by the
   745  	// page.
   746  	NumberJsResources int64 `json:"numberJsResources,omitempty"`
   747  
   748  	// NumberResources: Number of HTTP resources loaded by the page.
   749  	NumberResources int64 `json:"numberResources,omitempty"`
   750  
   751  	// NumberRobotedResources: Number of roboted resources.
   752  	NumberRobotedResources int64 `json:"numberRobotedResources,omitempty"`
   753  
   754  	// NumberStaticResources: Number of static (i.e. cacheable) resources on
   755  	// the page.
   756  	NumberStaticResources int64 `json:"numberStaticResources,omitempty"`
   757  
   758  	// NumberTransientFetchFailureResources: Number of transient-failed
   759  	// resources.
   760  	NumberTransientFetchFailureResources int64 `json:"numberTransientFetchFailureResources,omitempty"`
   761  
   762  	// OtherResponseBytes: Number of response bytes for other resources on
   763  	// the page.
   764  	OtherResponseBytes int64 `json:"otherResponseBytes,omitempty,string"`
   765  
   766  	// OverTheWireResponseBytes: Number of over-the-wire bytes, uses the
   767  	// default gzip compression strategy as an estimation.
   768  	OverTheWireResponseBytes int64 `json:"overTheWireResponseBytes,omitempty,string"`
   769  
   770  	// RobotedUrls: List of roboted urls.
   771  	RobotedUrls []string `json:"robotedUrls,omitempty"`
   772  
   773  	// TextResponseBytes: Number of uncompressed response bytes for text
   774  	// resources not covered by other statistics (i.e non-HTML, non-script,
   775  	// non-CSS resources) on the page.
   776  	TextResponseBytes int64 `json:"textResponseBytes,omitempty,string"`
   777  
   778  	// TotalRequestBytes: Total size of all request bytes sent by the page.
   779  	TotalRequestBytes int64 `json:"totalRequestBytes,omitempty,string"`
   780  
   781  	// TransientFetchFailureUrls: List of transient fetch failure urls.
   782  	TransientFetchFailureUrls []string `json:"transientFetchFailureUrls,omitempty"`
   783  
   784  	// ForceSendFields is a list of field names (e.g. "Cms") to
   785  	// unconditionally include in API requests. By default, fields with
   786  	// empty values are omitted from API requests. However, any non-pointer,
   787  	// non-interface field appearing in ForceSendFields will be sent to the
   788  	// server regardless of whether the field is empty or not. This may be
   789  	// used to include empty fields in Patch requests.
   790  	ForceSendFields []string `json:"-"`
   791  
   792  	// NullFields is a list of field names (e.g. "Cms") to include in API
   793  	// requests with the JSON null value. By default, fields with empty
   794  	// values are omitted from API requests. However, any field with an
   795  	// empty value appearing in NullFields will be sent to the server as
   796  	// null. It is an error if a field in this list has a non-empty value.
   797  	// This may be used to include null fields in Patch requests.
   798  	NullFields []string `json:"-"`
   799  }
   800  
   801  func (s *PagespeedApiPagespeedResponseV4PageStats) MarshalJSON() ([]byte, error) {
   802  	type NoMethod PagespeedApiPagespeedResponseV4PageStats
   803  	raw := NoMethod(*s)
   804  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   805  }
   806  
   807  // PagespeedApiPagespeedResponseV4RuleGroups: The name of this rule
   808  // group: one of "SPEED", "USABILITY", or "SECURITY".
   809  type PagespeedApiPagespeedResponseV4RuleGroups struct {
   810  	Pass bool `json:"pass,omitempty"`
   811  
   812  	// Score: The score (0-100) for this rule group, which indicates how
   813  	// much better a page could be in that category (e.g. how much faster,
   814  	// or how much more usable, or how much more secure). A high score
   815  	// indicates little room for improvement, while a lower score indicates
   816  	// more room for improvement.
   817  	Score int64 `json:"score,omitempty"`
   818  
   819  	// ForceSendFields is a list of field names (e.g. "Pass") to
   820  	// unconditionally include in API requests. By default, fields with
   821  	// empty values are omitted from API requests. However, any non-pointer,
   822  	// non-interface field appearing in ForceSendFields will be sent to the
   823  	// server regardless of whether the field is empty or not. This may be
   824  	// used to include empty fields in Patch requests.
   825  	ForceSendFields []string `json:"-"`
   826  
   827  	// NullFields is a list of field names (e.g. "Pass") to include in API
   828  	// requests with the JSON null value. By default, fields with empty
   829  	// values are omitted from API requests. However, any field with an
   830  	// empty value appearing in NullFields will be sent to the server as
   831  	// null. It is an error if a field in this list has a non-empty value.
   832  	// This may be used to include null fields in Patch requests.
   833  	NullFields []string `json:"-"`
   834  }
   835  
   836  func (s *PagespeedApiPagespeedResponseV4RuleGroups) MarshalJSON() ([]byte, error) {
   837  	type NoMethod PagespeedApiPagespeedResponseV4RuleGroups
   838  	raw := NoMethod(*s)
   839  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   840  }
   841  
   842  // PagespeedApiPagespeedResponseV4Version: The version of PageSpeed used
   843  // to generate these results.
   844  type PagespeedApiPagespeedResponseV4Version struct {
   845  	// Major: The major version number of PageSpeed used to generate these
   846  	// results.
   847  	Major int64 `json:"major,omitempty"`
   848  
   849  	// Minor: The minor version number of PageSpeed used to generate these
   850  	// results.
   851  	Minor int64 `json:"minor,omitempty"`
   852  
   853  	// ForceSendFields is a list of field names (e.g. "Major") to
   854  	// unconditionally include in API requests. By default, fields with
   855  	// empty values are omitted from API requests. However, any non-pointer,
   856  	// non-interface field appearing in ForceSendFields will be sent to the
   857  	// server regardless of whether the field is empty or not. This may be
   858  	// used to include empty fields in Patch requests.
   859  	ForceSendFields []string `json:"-"`
   860  
   861  	// NullFields is a list of field names (e.g. "Major") to include in API
   862  	// requests with the JSON null value. By default, fields with empty
   863  	// values are omitted from API requests. However, any field with an
   864  	// empty value appearing in NullFields will be sent to the server as
   865  	// null. It is an error if a field in this list has a non-empty value.
   866  	// This may be used to include null fields in Patch requests.
   867  	NullFields []string `json:"-"`
   868  }
   869  
   870  func (s *PagespeedApiPagespeedResponseV4Version) MarshalJSON() ([]byte, error) {
   871  	type NoMethod PagespeedApiPagespeedResponseV4Version
   872  	raw := NoMethod(*s)
   873  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   874  }
   875  
   876  // method id "pagespeedonline.pagespeedapi.runpagespeed":
   877  
   878  type PagespeedapiRunpagespeedCall struct {
   879  	s            *Service
   880  	urlParams_   gensupport.URLParams
   881  	ifNoneMatch_ string
   882  	ctx_         context.Context
   883  	header_      http.Header
   884  }
   885  
   886  // Runpagespeed: Runs PageSpeed analysis on the page at the specified
   887  // URL, and returns PageSpeed scores, a list of suggestions to make that
   888  // page faster, and other information.
   889  func (r *PagespeedapiService) Runpagespeed(url string) *PagespeedapiRunpagespeedCall {
   890  	c := &PagespeedapiRunpagespeedCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   891  	c.urlParams_.Set("url", url)
   892  	return c
   893  }
   894  
   895  // FilterThirdPartyResources sets the optional parameter
   896  // "filter_third_party_resources": Indicates if third party resources
   897  // should be filtered out before PageSpeed analysis.
   898  func (c *PagespeedapiRunpagespeedCall) FilterThirdPartyResources(filterThirdPartyResources bool) *PagespeedapiRunpagespeedCall {
   899  	c.urlParams_.Set("filter_third_party_resources", fmt.Sprint(filterThirdPartyResources))
   900  	return c
   901  }
   902  
   903  // Locale sets the optional parameter "locale": The locale used to
   904  // localize formatted results
   905  func (c *PagespeedapiRunpagespeedCall) Locale(locale string) *PagespeedapiRunpagespeedCall {
   906  	c.urlParams_.Set("locale", locale)
   907  	return c
   908  }
   909  
   910  // Rule sets the optional parameter "rule": A PageSpeed rule to run; if
   911  // none are given, all rules are run
   912  func (c *PagespeedapiRunpagespeedCall) Rule(rule ...string) *PagespeedapiRunpagespeedCall {
   913  	c.urlParams_.SetMulti("rule", append([]string{}, rule...))
   914  	return c
   915  }
   916  
   917  // Screenshot sets the optional parameter "screenshot": Indicates if
   918  // binary data containing a screenshot should be included
   919  func (c *PagespeedapiRunpagespeedCall) Screenshot(screenshot bool) *PagespeedapiRunpagespeedCall {
   920  	c.urlParams_.Set("screenshot", fmt.Sprint(screenshot))
   921  	return c
   922  }
   923  
   924  // Snapshots sets the optional parameter "snapshots": Indicates if
   925  // binary data containing snapshot images should be included
   926  func (c *PagespeedapiRunpagespeedCall) Snapshots(snapshots bool) *PagespeedapiRunpagespeedCall {
   927  	c.urlParams_.Set("snapshots", fmt.Sprint(snapshots))
   928  	return c
   929  }
   930  
   931  // Strategy sets the optional parameter "strategy": The analysis
   932  // strategy (desktop or mobile) to use, and desktop is the default
   933  //
   934  // Possible values:
   935  //
   936  //	"desktop" - Fetch and analyze the URL for desktop browsers
   937  //	"mobile" - Fetch and analyze the URL for mobile devices
   938  func (c *PagespeedapiRunpagespeedCall) Strategy(strategy string) *PagespeedapiRunpagespeedCall {
   939  	c.urlParams_.Set("strategy", strategy)
   940  	return c
   941  }
   942  
   943  // UtmCampaign sets the optional parameter "utm_campaign": Campaign name
   944  // for analytics.
   945  func (c *PagespeedapiRunpagespeedCall) UtmCampaign(utmCampaign string) *PagespeedapiRunpagespeedCall {
   946  	c.urlParams_.Set("utm_campaign", utmCampaign)
   947  	return c
   948  }
   949  
   950  // UtmSource sets the optional parameter "utm_source": Campaign source
   951  // for analytics.
   952  func (c *PagespeedapiRunpagespeedCall) UtmSource(utmSource string) *PagespeedapiRunpagespeedCall {
   953  	c.urlParams_.Set("utm_source", utmSource)
   954  	return c
   955  }
   956  
   957  // Fields allows partial responses to be retrieved. See
   958  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   959  // for more information.
   960  func (c *PagespeedapiRunpagespeedCall) Fields(s ...googleapi.Field) *PagespeedapiRunpagespeedCall {
   961  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   962  	return c
   963  }
   964  
   965  // IfNoneMatch sets the optional parameter which makes the operation
   966  // fail if the object's ETag matches the given value. This is useful for
   967  // getting updates only after the object has changed since the last
   968  // request. Use googleapi.IsNotModified to check whether the response
   969  // error from Do is the result of In-None-Match.
   970  func (c *PagespeedapiRunpagespeedCall) IfNoneMatch(entityTag string) *PagespeedapiRunpagespeedCall {
   971  	c.ifNoneMatch_ = entityTag
   972  	return c
   973  }
   974  
   975  // Context sets the context to be used in this call's Do method. Any
   976  // pending HTTP request will be aborted if the provided context is
   977  // canceled.
   978  func (c *PagespeedapiRunpagespeedCall) Context(ctx context.Context) *PagespeedapiRunpagespeedCall {
   979  	c.ctx_ = ctx
   980  	return c
   981  }
   982  
   983  // Header returns an http.Header that can be modified by the caller to
   984  // add HTTP headers to the request.
   985  func (c *PagespeedapiRunpagespeedCall) Header() http.Header {
   986  	if c.header_ == nil {
   987  		c.header_ = make(http.Header)
   988  	}
   989  	return c.header_
   990  }
   991  
   992  func (c *PagespeedapiRunpagespeedCall) doRequest(alt string) (*http.Response, error) {
   993  	reqHeaders := make(http.Header)
   994  	reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200514")
   995  	for k, v := range c.header_ {
   996  		reqHeaders[k] = v
   997  	}
   998  	reqHeaders.Set("User-Agent", c.s.userAgent())
   999  	if c.ifNoneMatch_ != "" {
  1000  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1001  	}
  1002  	var body io.Reader = nil
  1003  	c.urlParams_.Set("alt", alt)
  1004  	c.urlParams_.Set("prettyPrint", "false")
  1005  	urls := googleapi.ResolveRelative(c.s.BasePath, "runPagespeed")
  1006  	urls += "?" + c.urlParams_.Encode()
  1007  	req, err := http.NewRequest("GET", urls, body)
  1008  	if err != nil {
  1009  		return nil, err
  1010  	}
  1011  	req.Header = reqHeaders
  1012  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1013  }
  1014  
  1015  // Do executes the "pagespeedonline.pagespeedapi.runpagespeed" call.
  1016  // Exactly one of *PagespeedApiPagespeedResponseV4 or error will be
  1017  // non-nil. Any non-2xx status code is an error. Response headers are in
  1018  // either *PagespeedApiPagespeedResponseV4.ServerResponse.Header or (if
  1019  // a response was returned at all) in error.(*googleapi.Error).Header.
  1020  // Use googleapi.IsNotModified to check whether the returned error was
  1021  // because http.StatusNotModified was returned.
  1022  func (c *PagespeedapiRunpagespeedCall) Do(opts ...googleapi.CallOption) (*PagespeedApiPagespeedResponseV4, error) {
  1023  	gensupport.SetOptions(c.urlParams_, opts...)
  1024  	res, err := c.doRequest("json")
  1025  	if res != nil && res.StatusCode == http.StatusNotModified {
  1026  		if res.Body != nil {
  1027  			res.Body.Close()
  1028  		}
  1029  		return nil, &googleapi.Error{
  1030  			Code:   res.StatusCode,
  1031  			Header: res.Header,
  1032  		}
  1033  	}
  1034  	if err != nil {
  1035  		return nil, err
  1036  	}
  1037  	defer googleapi.CloseBody(res)
  1038  	if err := googleapi.CheckResponse(res); err != nil {
  1039  		return nil, err
  1040  	}
  1041  	ret := &PagespeedApiPagespeedResponseV4{
  1042  		ServerResponse: googleapi.ServerResponse{
  1043  			Header:         res.Header,
  1044  			HTTPStatusCode: res.StatusCode,
  1045  		},
  1046  	}
  1047  	target := &ret
  1048  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1049  		return nil, err
  1050  	}
  1051  	return ret, nil
  1052  	// {
  1053  	//   "description": "Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information.",
  1054  	//   "httpMethod": "GET",
  1055  	//   "id": "pagespeedonline.pagespeedapi.runpagespeed",
  1056  	//   "parameterOrder": [
  1057  	//     "url"
  1058  	//   ],
  1059  	//   "parameters": {
  1060  	//     "filter_third_party_resources": {
  1061  	//       "default": "false",
  1062  	//       "description": "Indicates if third party resources should be filtered out before PageSpeed analysis.",
  1063  	//       "location": "query",
  1064  	//       "type": "boolean"
  1065  	//     },
  1066  	//     "locale": {
  1067  	//       "description": "The locale used to localize formatted results",
  1068  	//       "location": "query",
  1069  	//       "pattern": "[a-zA-Z]+(_[a-zA-Z]+)?",
  1070  	//       "type": "string"
  1071  	//     },
  1072  	//     "rule": {
  1073  	//       "description": "A PageSpeed rule to run; if none are given, all rules are run",
  1074  	//       "location": "query",
  1075  	//       "pattern": "[a-zA-Z]+",
  1076  	//       "repeated": true,
  1077  	//       "type": "string"
  1078  	//     },
  1079  	//     "screenshot": {
  1080  	//       "default": "false",
  1081  	//       "description": "Indicates if binary data containing a screenshot should be included",
  1082  	//       "location": "query",
  1083  	//       "type": "boolean"
  1084  	//     },
  1085  	//     "snapshots": {
  1086  	//       "default": "false",
  1087  	//       "description": "Indicates if binary data containing snapshot images should be included",
  1088  	//       "location": "query",
  1089  	//       "type": "boolean"
  1090  	//     },
  1091  	//     "strategy": {
  1092  	//       "description": "The analysis strategy (desktop or mobile) to use, and desktop is the default",
  1093  	//       "enum": [
  1094  	//         "desktop",
  1095  	//         "mobile"
  1096  	//       ],
  1097  	//       "enumDescriptions": [
  1098  	//         "Fetch and analyze the URL for desktop browsers",
  1099  	//         "Fetch and analyze the URL for mobile devices"
  1100  	//       ],
  1101  	//       "location": "query",
  1102  	//       "type": "string"
  1103  	//     },
  1104  	//     "url": {
  1105  	//       "description": "The URL to fetch and analyze",
  1106  	//       "location": "query",
  1107  	//       "pattern": "(?i)(site:|origin:)?http(s)?://.*",
  1108  	//       "required": true,
  1109  	//       "type": "string"
  1110  	//     },
  1111  	//     "utm_campaign": {
  1112  	//       "description": "Campaign name for analytics.",
  1113  	//       "location": "query",
  1114  	//       "type": "string"
  1115  	//     },
  1116  	//     "utm_source": {
  1117  	//       "description": "Campaign source for analytics.",
  1118  	//       "location": "query",
  1119  	//       "type": "string"
  1120  	//     }
  1121  	//   },
  1122  	//   "path": "runPagespeed",
  1123  	//   "response": {
  1124  	//     "$ref": "PagespeedApiPagespeedResponseV4"
  1125  	//   }
  1126  	// }
  1127  
  1128  }
  1129  

View as plain text