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/v2/getting-started
10//
11// Creating a client
12//
13// Usage example:
14//
15//   import "google.golang.org/api/pagespeedonline/v2"
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.
38package pagespeedonline // import "google.golang.org/api/pagespeedonline/v2"
39
40import (
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.
61var _ = bytes.NewBuffer
62var _ = strconv.Itoa
63var _ = fmt.Sprintf
64var _ = json.NewDecoder
65var _ = io.Copy
66var _ = url.Parse
67var _ = gensupport.MarshalJSON
68var _ = googleapi.Version
69var _ = errors.New
70var _ = strings.Replace
71var _ = context.Canceled
72var _ = internaloption.WithDefaultEndpoint
73
74const apiId = "pagespeedonline:v2"
75const apiName = "pagespeedonline"
76const apiVersion = "v2"
77const basePath = "https://www.googleapis.com/pagespeedonline/v2/"
78
79// NewService creates a new Service.
80func 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.
101func 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
110type 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
118func (s *Service) userAgent() string {
119	if s.UserAgent == "" {
120		return googleapi.UserAgent
121	}
122	return googleapi.UserAgent + " " + s.UserAgent
123}
124
125func NewPagespeedapiService(s *Service) *PagespeedapiService {
126	rs := &PagespeedapiService{s: s}
127	return rs
128}
129
130type PagespeedapiService struct {
131	s *Service
132}
133
134type PagespeedApiFormatStringV2 struct {
135	// Args: List of arguments for the format string.
136	Args []*PagespeedApiFormatStringV2Args `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
161func (s *PagespeedApiFormatStringV2) MarshalJSON() ([]byte, error) {
162	type NoMethod PagespeedApiFormatStringV2
163	raw := NoMethod(*s)
164	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
165}
166
167type PagespeedApiFormatStringV2Args 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 []*PagespeedApiFormatStringV2ArgsRects `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 []*PagespeedApiFormatStringV2ArgsSecondaryRects `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
207func (s *PagespeedApiFormatStringV2Args) MarshalJSON() ([]byte, error) {
208	type NoMethod PagespeedApiFormatStringV2Args
209	raw := NoMethod(*s)
210	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
211}
212
213type PagespeedApiFormatStringV2ArgsRects struct {
214	// Height: The height of the rect.
215	Height int64 `json:"height,omitempty"`
216
217	// Left: The left coordinate of the rect, in page coordinates.
218	Left int64 `json:"left,omitempty"`
219
220	// Top: The top coordinate of the rect, in page coordinates.
221	Top int64 `json:"top,omitempty"`
222
223	// Width: The width of the rect.
224	Width int64 `json:"width,omitempty"`
225
226	// ForceSendFields is a list of field names (e.g. "Height") to
227	// unconditionally include in API requests. By default, fields with
228	// empty values are omitted from API requests. However, any non-pointer,
229	// non-interface field appearing in ForceSendFields will be sent to the
230	// server regardless of whether the field is empty or not. This may be
231	// used to include empty fields in Patch requests.
232	ForceSendFields []string `json:"-"`
233
234	// NullFields is a list of field names (e.g. "Height") to include in API
235	// requests with the JSON null value. By default, fields with empty
236	// values are omitted from API requests. However, any field with an
237	// empty value appearing in NullFields will be sent to the server as
238	// null. It is an error if a field in this list has a non-empty value.
239	// This may be used to include null fields in Patch requests.
240	NullFields []string `json:"-"`
241}
242
243func (s *PagespeedApiFormatStringV2ArgsRects) MarshalJSON() ([]byte, error) {
244	type NoMethod PagespeedApiFormatStringV2ArgsRects
245	raw := NoMethod(*s)
246	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
247}
248
249type PagespeedApiFormatStringV2ArgsSecondaryRects struct {
250	// Height: The height of the rect.
251	Height int64 `json:"height,omitempty"`
252
253	// Left: The left coordinate of the rect, in page coordinates.
254	Left int64 `json:"left,omitempty"`
255
256	// Top: The top coordinate of the rect, in page coordinates.
257	Top int64 `json:"top,omitempty"`
258
259	// Width: The width of the rect.
260	Width int64 `json:"width,omitempty"`
261
262	// ForceSendFields is a list of field names (e.g. "Height") to
263	// unconditionally include in API requests. By default, fields with
264	// empty values are omitted from API requests. However, any non-pointer,
265	// non-interface field appearing in ForceSendFields will be sent to the
266	// server regardless of whether the field is empty or not. This may be
267	// used to include empty fields in Patch requests.
268	ForceSendFields []string `json:"-"`
269
270	// NullFields is a list of field names (e.g. "Height") to include in API
271	// requests with the JSON null value. By default, fields with empty
272	// values are omitted from API requests. However, any field with an
273	// empty value appearing in NullFields will be sent to the server as
274	// null. It is an error if a field in this list has a non-empty value.
275	// This may be used to include null fields in Patch requests.
276	NullFields []string `json:"-"`
277}
278
279func (s *PagespeedApiFormatStringV2ArgsSecondaryRects) MarshalJSON() ([]byte, error) {
280	type NoMethod PagespeedApiFormatStringV2ArgsSecondaryRects
281	raw := NoMethod(*s)
282	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
283}
284
285type PagespeedApiImageV2 struct {
286	// Data: Image data base64 encoded.
287	Data string `json:"data,omitempty"`
288
289	// Height: Height of screenshot in pixels.
290	Height int64 `json:"height,omitempty"`
291
292	// Key: Unique string key, if any, identifying this image.
293	Key string `json:"key,omitempty"`
294
295	// MimeType: Mime type of image data (e.g. "image/jpeg").
296	MimeType string `json:"mime_type,omitempty"`
297
298	// PageRect: The region of the page that is captured by this image, with
299	// dimensions measured in CSS pixels.
300	PageRect *PagespeedApiImageV2PageRect `json:"page_rect,omitempty"`
301
302	// Width: Width of screenshot in pixels.
303	Width int64 `json:"width,omitempty"`
304
305	// ForceSendFields is a list of field names (e.g. "Data") 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. "Data") 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
322func (s *PagespeedApiImageV2) MarshalJSON() ([]byte, error) {
323	type NoMethod PagespeedApiImageV2
324	raw := NoMethod(*s)
325	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
326}
327
328// PagespeedApiImageV2PageRect: The region of the page that is captured
329// by this image, with dimensions measured in CSS pixels.
330type PagespeedApiImageV2PageRect struct {
331	// Height: The height of the rect.
332	Height int64 `json:"height,omitempty"`
333
334	// Left: The left coordinate of the rect, in page coordinates.
335	Left int64 `json:"left,omitempty"`
336
337	// Top: The top coordinate of the rect, in page coordinates.
338	Top int64 `json:"top,omitempty"`
339
340	// Width: The width of the rect.
341	Width int64 `json:"width,omitempty"`
342
343	// ForceSendFields is a list of field names (e.g. "Height") to
344	// unconditionally include in API requests. By default, fields with
345	// empty values are omitted from API requests. However, any non-pointer,
346	// non-interface field appearing in ForceSendFields will be sent to the
347	// server regardless of whether the field is empty or not. This may be
348	// used to include empty fields in Patch requests.
349	ForceSendFields []string `json:"-"`
350
351	// NullFields is a list of field names (e.g. "Height") to include in API
352	// requests with the JSON null value. By default, fields with empty
353	// values are omitted from API requests. However, any field with an
354	// empty value appearing in NullFields will be sent to the server as
355	// null. It is an error if a field in this list has a non-empty value.
356	// This may be used to include null fields in Patch requests.
357	NullFields []string `json:"-"`
358}
359
360func (s *PagespeedApiImageV2PageRect) MarshalJSON() ([]byte, error) {
361	type NoMethod PagespeedApiImageV2PageRect
362	raw := NoMethod(*s)
363	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
364}
365
366type Result struct {
367	// CaptchaResult: The captcha verify result
368	CaptchaResult string `json:"captchaResult,omitempty"`
369
370	// FormattedResults: Localized PageSpeed results. Contains a ruleResults
371	// entry for each PageSpeed rule instantiated and run by the server.
372	FormattedResults *ResultFormattedResults `json:"formattedResults,omitempty"`
373
374	// Id: Canonicalized and final URL for the document, after following
375	// page redirects (if any).
376	Id string `json:"id,omitempty"`
377
378	// InvalidRules: List of rules that were specified in the request, but
379	// which the server did not know how to instantiate.
380	InvalidRules []string `json:"invalidRules,omitempty"`
381
382	// Kind: Kind of result.
383	Kind string `json:"kind,omitempty"`
384
385	// PageStats: Summary statistics for the page, such as number of
386	// JavaScript bytes, number of HTML bytes, etc.
387	PageStats *ResultPageStats `json:"pageStats,omitempty"`
388
389	// ResponseCode: Response code for the document. 200 indicates a normal
390	// page load. 4xx/5xx indicates an error.
391	ResponseCode int64 `json:"responseCode,omitempty"`
392
393	// RuleGroups: A map with one entry for each rule group in these
394	// results.
395	RuleGroups map[string]ResultRuleGroups `json:"ruleGroups,omitempty"`
396
397	// Screenshot: Base64-encoded screenshot of the page that was analyzed.
398	Screenshot *PagespeedApiImageV2 `json:"screenshot,omitempty"`
399
400	// Title: Title of the page, as displayed in the browser's title bar.
401	Title string `json:"title,omitempty"`
402
403	// Version: The version of PageSpeed used to generate these results.
404	Version *ResultVersion `json:"version,omitempty"`
405
406	// ServerResponse contains the HTTP response code and headers from the
407	// server.
408	googleapi.ServerResponse `json:"-"`
409
410	// ForceSendFields is a list of field names (e.g. "CaptchaResult") to
411	// unconditionally include in API requests. By default, fields with
412	// empty values are omitted from API requests. However, any non-pointer,
413	// non-interface field appearing in ForceSendFields will be sent to the
414	// server regardless of whether the field is empty or not. This may be
415	// used to include empty fields in Patch requests.
416	ForceSendFields []string `json:"-"`
417
418	// NullFields is a list of field names (e.g. "CaptchaResult") to include
419	// in API requests with the JSON null value. By default, fields with
420	// empty values are omitted from API requests. However, any field with
421	// an empty value appearing in NullFields will be sent to the server as
422	// null. It is an error if a field in this list has a non-empty value.
423	// This may be used to include null fields in Patch requests.
424	NullFields []string `json:"-"`
425}
426
427func (s *Result) MarshalJSON() ([]byte, error) {
428	type NoMethod Result
429	raw := NoMethod(*s)
430	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
431}
432
433// ResultFormattedResults: Localized PageSpeed results. Contains a
434// ruleResults entry for each PageSpeed rule instantiated and run by the
435// server.
436type ResultFormattedResults struct {
437	// Locale: The locale of the formattedResults, e.g. "en_US".
438	Locale string `json:"locale,omitempty"`
439
440	// RuleResults: Dictionary of formatted rule results, with one entry for
441	// each PageSpeed rule instantiated and run by the server.
442	RuleResults map[string]ResultFormattedResultsRuleResults `json:"ruleResults,omitempty"`
443
444	// ForceSendFields is a list of field names (e.g. "Locale") to
445	// unconditionally include in API requests. By default, fields with
446	// empty values are omitted from API requests. However, any non-pointer,
447	// non-interface field appearing in ForceSendFields will be sent to the
448	// server regardless of whether the field is empty or not. This may be
449	// used to include empty fields in Patch requests.
450	ForceSendFields []string `json:"-"`
451
452	// NullFields is a list of field names (e.g. "Locale") to include in API
453	// requests with the JSON null value. By default, fields with empty
454	// values are omitted from API requests. However, any field with an
455	// empty value appearing in NullFields will be sent to the server as
456	// null. It is an error if a field in this list has a non-empty value.
457	// This may be used to include null fields in Patch requests.
458	NullFields []string `json:"-"`
459}
460
461func (s *ResultFormattedResults) MarshalJSON() ([]byte, error) {
462	type NoMethod ResultFormattedResults
463	raw := NoMethod(*s)
464	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
465}
466
467// ResultFormattedResultsRuleResults: The enum-like identifier for this
468// rule. For instance "EnableKeepAlive" or "AvoidCssImport". Not
469// localized.
470type ResultFormattedResultsRuleResults struct {
471	// Groups: List of rule groups that this rule belongs to. Each entry in
472	// the list is one of "SPEED" or "USABILITY".
473	Groups []string `json:"groups,omitempty"`
474
475	// LocalizedRuleName: Localized name of the rule, intended for
476	// presentation to a user.
477	LocalizedRuleName string `json:"localizedRuleName,omitempty"`
478
479	// RuleImpact: The impact (unbounded floating point value) that
480	// implementing the suggestions for this rule would have on making the
481	// page faster. Impact is comparable between rules to determine which
482	// rule's suggestions would have a higher or lower impact on making a
483	// page faster. For instance, if enabling compression would save 1MB,
484	// while optimizing images would save 500kB, the enable compression rule
485	// would have 2x the impact of the image optimization rule, all other
486	// things being equal.
487	RuleImpact float64 `json:"ruleImpact,omitempty"`
488
489	// Summary: A brief summary description for the rule, indicating at a
490	// high level what should be done to follow the rule and what benefit
491	// can be gained by doing so.
492	Summary *PagespeedApiFormatStringV2 `json:"summary,omitempty"`
493
494	// UrlBlocks: List of blocks of URLs. Each block may contain a heading
495	// and a list of URLs. Each URL may optionally include additional
496	// details.
497	UrlBlocks []*ResultFormattedResultsRuleResultsUrlBlocks `json:"urlBlocks,omitempty"`
498
499	// ForceSendFields is a list of field names (e.g. "Groups") to
500	// unconditionally include in API requests. By default, fields with
501	// empty values are omitted from API requests. However, any non-pointer,
502	// non-interface field appearing in ForceSendFields will be sent to the
503	// server regardless of whether the field is empty or not. This may be
504	// used to include empty fields in Patch requests.
505	ForceSendFields []string `json:"-"`
506
507	// NullFields is a list of field names (e.g. "Groups") to include in API
508	// requests with the JSON null value. By default, fields with empty
509	// values are omitted from API requests. However, any field with an
510	// empty value appearing in NullFields will be sent to the server as
511	// null. It is an error if a field in this list has a non-empty value.
512	// This may be used to include null fields in Patch requests.
513	NullFields []string `json:"-"`
514}
515
516func (s *ResultFormattedResultsRuleResults) MarshalJSON() ([]byte, error) {
517	type NoMethod ResultFormattedResultsRuleResults
518	raw := NoMethod(*s)
519	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
520}
521
522func (s *ResultFormattedResultsRuleResults) UnmarshalJSON(data []byte) error {
523	type NoMethod ResultFormattedResultsRuleResults
524	var s1 struct {
525		RuleImpact gensupport.JSONFloat64 `json:"ruleImpact"`
526		*NoMethod
527	}
528	s1.NoMethod = (*NoMethod)(s)
529	if err := json.Unmarshal(data, &s1); err != nil {
530		return err
531	}
532	s.RuleImpact = float64(s1.RuleImpact)
533	return nil
534}
535
536type ResultFormattedResultsRuleResultsUrlBlocks struct {
537	// Header: Heading to be displayed with the list of URLs.
538	Header *PagespeedApiFormatStringV2 `json:"header,omitempty"`
539
540	// Urls: List of entries that provide information about URLs in the url
541	// block. Optional.
542	Urls []*ResultFormattedResultsRuleResultsUrlBlocksUrls `json:"urls,omitempty"`
543
544	// ForceSendFields is a list of field names (e.g. "Header") to
545	// unconditionally include in API requests. By default, fields with
546	// empty values are omitted from API requests. However, any non-pointer,
547	// non-interface field appearing in ForceSendFields will be sent to the
548	// server regardless of whether the field is empty or not. This may be
549	// used to include empty fields in Patch requests.
550	ForceSendFields []string `json:"-"`
551
552	// NullFields is a list of field names (e.g. "Header") to include in API
553	// requests with the JSON null value. By default, fields with empty
554	// values are omitted from API requests. However, any field with an
555	// empty value appearing in NullFields will be sent to the server as
556	// null. It is an error if a field in this list has a non-empty value.
557	// This may be used to include null fields in Patch requests.
558	NullFields []string `json:"-"`
559}
560
561func (s *ResultFormattedResultsRuleResultsUrlBlocks) MarshalJSON() ([]byte, error) {
562	type NoMethod ResultFormattedResultsRuleResultsUrlBlocks
563	raw := NoMethod(*s)
564	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
565}
566
567type ResultFormattedResultsRuleResultsUrlBlocksUrls struct {
568	// Details: List of entries that provide additional details about a
569	// single URL. Optional.
570	Details []*PagespeedApiFormatStringV2 `json:"details,omitempty"`
571
572	// Result: A format string that gives information about the URL, and a
573	// list of arguments for that format string.
574	Result *PagespeedApiFormatStringV2 `json:"result,omitempty"`
575
576	// ForceSendFields is a list of field names (e.g. "Details") to
577	// unconditionally include in API requests. By default, fields with
578	// empty values are omitted from API requests. However, any non-pointer,
579	// non-interface field appearing in ForceSendFields will be sent to the
580	// server regardless of whether the field is empty or not. This may be
581	// used to include empty fields in Patch requests.
582	ForceSendFields []string `json:"-"`
583
584	// NullFields is a list of field names (e.g. "Details") to include in
585	// API requests with the JSON null value. By default, fields with empty
586	// values are omitted from API requests. However, any field with an
587	// empty value appearing in NullFields will be sent to the server as
588	// null. It is an error if a field in this list has a non-empty value.
589	// This may be used to include null fields in Patch requests.
590	NullFields []string `json:"-"`
591}
592
593func (s *ResultFormattedResultsRuleResultsUrlBlocksUrls) MarshalJSON() ([]byte, error) {
594	type NoMethod ResultFormattedResultsRuleResultsUrlBlocksUrls
595	raw := NoMethod(*s)
596	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
597}
598
599// ResultPageStats: Summary statistics for the page, such as number of
600// JavaScript bytes, number of HTML bytes, etc.
601type ResultPageStats struct {
602	// CssResponseBytes: Number of uncompressed response bytes for CSS
603	// resources on the page.
604	CssResponseBytes int64 `json:"cssResponseBytes,omitempty,string"`
605
606	// FlashResponseBytes: Number of response bytes for flash resources on
607	// the page.
608	FlashResponseBytes int64 `json:"flashResponseBytes,omitempty,string"`
609
610	// HtmlResponseBytes: Number of uncompressed response bytes for the main
611	// HTML document and all iframes on the page.
612	HtmlResponseBytes int64 `json:"htmlResponseBytes,omitempty,string"`
613
614	// ImageResponseBytes: Number of response bytes for image resources on
615	// the page.
616	ImageResponseBytes int64 `json:"imageResponseBytes,omitempty,string"`
617
618	// JavascriptResponseBytes: Number of uncompressed response bytes for JS
619	// resources on the page.
620	JavascriptResponseBytes int64 `json:"javascriptResponseBytes,omitempty,string"`
621
622	// NumberCssResources: Number of CSS resources referenced by the page.
623	NumberCssResources int64 `json:"numberCssResources,omitempty"`
624
625	// NumberHosts: Number of unique hosts referenced by the page.
626	NumberHosts int64 `json:"numberHosts,omitempty"`
627
628	// NumberJsResources: Number of JavaScript resources referenced by the
629	// page.
630	NumberJsResources int64 `json:"numberJsResources,omitempty"`
631
632	// NumberResources: Number of HTTP resources loaded by the page.
633	NumberResources int64 `json:"numberResources,omitempty"`
634
635	// NumberStaticResources: Number of static (i.e. cacheable) resources on
636	// the page.
637	NumberStaticResources int64 `json:"numberStaticResources,omitempty"`
638
639	// OtherResponseBytes: Number of response bytes for other resources on
640	// the page.
641	OtherResponseBytes int64 `json:"otherResponseBytes,omitempty,string"`
642
643	// TextResponseBytes: Number of uncompressed response bytes for text
644	// resources not covered by other statistics (i.e non-HTML, non-script,
645	// non-CSS resources) on the page.
646	TextResponseBytes int64 `json:"textResponseBytes,omitempty,string"`
647
648	// TotalRequestBytes: Total size of all request bytes sent by the page.
649	TotalRequestBytes int64 `json:"totalRequestBytes,omitempty,string"`
650
651	// ForceSendFields is a list of field names (e.g. "CssResponseBytes") to
652	// unconditionally include in API requests. By default, fields with
653	// empty values are omitted from API requests. However, any non-pointer,
654	// non-interface field appearing in ForceSendFields will be sent to the
655	// server regardless of whether the field is empty or not. This may be
656	// used to include empty fields in Patch requests.
657	ForceSendFields []string `json:"-"`
658
659	// NullFields is a list of field names (e.g. "CssResponseBytes") to
660	// include in API requests with the JSON null value. By default, fields
661	// with empty values are omitted from API requests. However, any field
662	// with an empty value appearing in NullFields will be sent to the
663	// server as null. It is an error if a field in this list has a
664	// non-empty value. This may be used to include null fields in Patch
665	// requests.
666	NullFields []string `json:"-"`
667}
668
669func (s *ResultPageStats) MarshalJSON() ([]byte, error) {
670	type NoMethod ResultPageStats
671	raw := NoMethod(*s)
672	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
673}
674
675// ResultRuleGroups: The name of this rule group: one of "SPEED" or
676// "USABILITY".
677type ResultRuleGroups struct {
678	// Score: The score (0-100) for this rule group, which indicates how
679	// much better a page could be in that category (e.g. how much faster,
680	// or how much more usable). A high score indicates little room for
681	// improvement, while a lower score indicates more room for improvement.
682	Score int64 `json:"score,omitempty"`
683
684	// ForceSendFields is a list of field names (e.g. "Score") to
685	// unconditionally include in API requests. By default, fields with
686	// empty values are omitted from API requests. However, any non-pointer,
687	// non-interface field appearing in ForceSendFields will be sent to the
688	// server regardless of whether the field is empty or not. This may be
689	// used to include empty fields in Patch requests.
690	ForceSendFields []string `json:"-"`
691
692	// NullFields is a list of field names (e.g. "Score") to include in API
693	// requests with the JSON null value. By default, fields with empty
694	// values are omitted from API requests. However, any field with an
695	// empty value appearing in NullFields will be sent to the server as
696	// null. It is an error if a field in this list has a non-empty value.
697	// This may be used to include null fields in Patch requests.
698	NullFields []string `json:"-"`
699}
700
701func (s *ResultRuleGroups) MarshalJSON() ([]byte, error) {
702	type NoMethod ResultRuleGroups
703	raw := NoMethod(*s)
704	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
705}
706
707// ResultVersion: The version of PageSpeed used to generate these
708// results.
709type ResultVersion struct {
710	// Major: The major version number of PageSpeed used to generate these
711	// results.
712	Major int64 `json:"major,omitempty"`
713
714	// Minor: The minor version number of PageSpeed used to generate these
715	// results.
716	Minor int64 `json:"minor,omitempty"`
717
718	// ForceSendFields is a list of field names (e.g. "Major") to
719	// unconditionally include in API requests. By default, fields with
720	// empty values are omitted from API requests. However, any non-pointer,
721	// non-interface field appearing in ForceSendFields will be sent to the
722	// server regardless of whether the field is empty or not. This may be
723	// used to include empty fields in Patch requests.
724	ForceSendFields []string `json:"-"`
725
726	// NullFields is a list of field names (e.g. "Major") to include in API
727	// requests with the JSON null value. By default, fields with empty
728	// values are omitted from API requests. However, any field with an
729	// empty value appearing in NullFields will be sent to the server as
730	// null. It is an error if a field in this list has a non-empty value.
731	// This may be used to include null fields in Patch requests.
732	NullFields []string `json:"-"`
733}
734
735func (s *ResultVersion) MarshalJSON() ([]byte, error) {
736	type NoMethod ResultVersion
737	raw := NoMethod(*s)
738	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
739}
740
741// method id "pagespeedonline.pagespeedapi.runpagespeed":
742
743type PagespeedapiRunpagespeedCall struct {
744	s            *Service
745	urlParams_   gensupport.URLParams
746	ifNoneMatch_ string
747	ctx_         context.Context
748	header_      http.Header
749}
750
751// Runpagespeed: Runs PageSpeed analysis on the page at the specified
752// URL, and returns PageSpeed scores, a list of suggestions to make that
753// page faster, and other information.
754func (r *PagespeedapiService) Runpagespeed(url string) *PagespeedapiRunpagespeedCall {
755	c := &PagespeedapiRunpagespeedCall{s: r.s, urlParams_: make(gensupport.URLParams)}
756	c.urlParams_.Set("url", url)
757	return c
758}
759
760// FilterThirdPartyResources sets the optional parameter
761// "filter_third_party_resources": Indicates if third party resources
762// should be filtered out before PageSpeed analysis.
763func (c *PagespeedapiRunpagespeedCall) FilterThirdPartyResources(filterThirdPartyResources bool) *PagespeedapiRunpagespeedCall {
764	c.urlParams_.Set("filter_third_party_resources", fmt.Sprint(filterThirdPartyResources))
765	return c
766}
767
768// Locale sets the optional parameter "locale": The locale used to
769// localize formatted results
770func (c *PagespeedapiRunpagespeedCall) Locale(locale string) *PagespeedapiRunpagespeedCall {
771	c.urlParams_.Set("locale", locale)
772	return c
773}
774
775// Rule sets the optional parameter "rule": A PageSpeed rule to run; if
776// none are given, all rules are run
777func (c *PagespeedapiRunpagespeedCall) Rule(rule ...string) *PagespeedapiRunpagespeedCall {
778	c.urlParams_.SetMulti("rule", append([]string{}, rule...))
779	return c
780}
781
782// Screenshot sets the optional parameter "screenshot": Indicates if
783// binary data containing a screenshot should be included
784func (c *PagespeedapiRunpagespeedCall) Screenshot(screenshot bool) *PagespeedapiRunpagespeedCall {
785	c.urlParams_.Set("screenshot", fmt.Sprint(screenshot))
786	return c
787}
788
789// Strategy sets the optional parameter "strategy": The analysis
790// strategy to use
791//
792// Possible values:
793//   "desktop" - Fetch and analyze the URL for desktop browsers
794//   "mobile" - Fetch and analyze the URL for mobile devices
795func (c *PagespeedapiRunpagespeedCall) Strategy(strategy string) *PagespeedapiRunpagespeedCall {
796	c.urlParams_.Set("strategy", strategy)
797	return c
798}
799
800// Fields allows partial responses to be retrieved. See
801// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
802// for more information.
803func (c *PagespeedapiRunpagespeedCall) Fields(s ...googleapi.Field) *PagespeedapiRunpagespeedCall {
804	c.urlParams_.Set("fields", googleapi.CombineFields(s))
805	return c
806}
807
808// IfNoneMatch sets the optional parameter which makes the operation
809// fail if the object's ETag matches the given value. This is useful for
810// getting updates only after the object has changed since the last
811// request. Use googleapi.IsNotModified to check whether the response
812// error from Do is the result of In-None-Match.
813func (c *PagespeedapiRunpagespeedCall) IfNoneMatch(entityTag string) *PagespeedapiRunpagespeedCall {
814	c.ifNoneMatch_ = entityTag
815	return c
816}
817
818// Context sets the context to be used in this call's Do method. Any
819// pending HTTP request will be aborted if the provided context is
820// canceled.
821func (c *PagespeedapiRunpagespeedCall) Context(ctx context.Context) *PagespeedapiRunpagespeedCall {
822	c.ctx_ = ctx
823	return c
824}
825
826// Header returns an http.Header that can be modified by the caller to
827// add HTTP headers to the request.
828func (c *PagespeedapiRunpagespeedCall) Header() http.Header {
829	if c.header_ == nil {
830		c.header_ = make(http.Header)
831	}
832	return c.header_
833}
834
835func (c *PagespeedapiRunpagespeedCall) doRequest(alt string) (*http.Response, error) {
836	reqHeaders := make(http.Header)
837	reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200514")
838	for k, v := range c.header_ {
839		reqHeaders[k] = v
840	}
841	reqHeaders.Set("User-Agent", c.s.userAgent())
842	if c.ifNoneMatch_ != "" {
843		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
844	}
845	var body io.Reader = nil
846	c.urlParams_.Set("alt", alt)
847	c.urlParams_.Set("prettyPrint", "false")
848	urls := googleapi.ResolveRelative(c.s.BasePath, "runPagespeed")
849	urls += "?" + c.urlParams_.Encode()
850	req, err := http.NewRequest("GET", urls, body)
851	if err != nil {
852		return nil, err
853	}
854	req.Header = reqHeaders
855	return gensupport.SendRequest(c.ctx_, c.s.client, req)
856}
857
858// Do executes the "pagespeedonline.pagespeedapi.runpagespeed" call.
859// Exactly one of *Result or error will be non-nil. Any non-2xx status
860// code is an error. Response headers are in either
861// *Result.ServerResponse.Header or (if a response was returned at all)
862// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
863// check whether the returned error was because http.StatusNotModified
864// was returned.
865func (c *PagespeedapiRunpagespeedCall) Do(opts ...googleapi.CallOption) (*Result, error) {
866	gensupport.SetOptions(c.urlParams_, opts...)
867	res, err := c.doRequest("json")
868	if res != nil && res.StatusCode == http.StatusNotModified {
869		if res.Body != nil {
870			res.Body.Close()
871		}
872		return nil, &googleapi.Error{
873			Code:   res.StatusCode,
874			Header: res.Header,
875		}
876	}
877	if err != nil {
878		return nil, err
879	}
880	defer googleapi.CloseBody(res)
881	if err := googleapi.CheckResponse(res); err != nil {
882		return nil, err
883	}
884	ret := &Result{
885		ServerResponse: googleapi.ServerResponse{
886			Header:         res.Header,
887			HTTPStatusCode: res.StatusCode,
888		},
889	}
890	target := &ret
891	if err := gensupport.DecodeResponse(target, res); err != nil {
892		return nil, err
893	}
894	return ret, nil
895	// {
896	//   "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.",
897	//   "httpMethod": "GET",
898	//   "id": "pagespeedonline.pagespeedapi.runpagespeed",
899	//   "parameterOrder": [
900	//     "url"
901	//   ],
902	//   "parameters": {
903	//     "filter_third_party_resources": {
904	//       "default": "false",
905	//       "description": "Indicates if third party resources should be filtered out before PageSpeed analysis.",
906	//       "location": "query",
907	//       "type": "boolean"
908	//     },
909	//     "locale": {
910	//       "description": "The locale used to localize formatted results",
911	//       "location": "query",
912	//       "pattern": "[a-zA-Z]+(_[a-zA-Z]+)?",
913	//       "type": "string"
914	//     },
915	//     "rule": {
916	//       "description": "A PageSpeed rule to run; if none are given, all rules are run",
917	//       "location": "query",
918	//       "pattern": "[a-zA-Z]+",
919	//       "repeated": true,
920	//       "type": "string"
921	//     },
922	//     "screenshot": {
923	//       "default": "false",
924	//       "description": "Indicates if binary data containing a screenshot should be included",
925	//       "location": "query",
926	//       "type": "boolean"
927	//     },
928	//     "strategy": {
929	//       "description": "The analysis strategy to use",
930	//       "enum": [
931	//         "desktop",
932	//         "mobile"
933	//       ],
934	//       "enumDescriptions": [
935	//         "Fetch and analyze the URL for desktop browsers",
936	//         "Fetch and analyze the URL for mobile devices"
937	//       ],
938	//       "location": "query",
939	//       "type": "string"
940	//     },
941	//     "url": {
942	//       "description": "The URL to fetch and analyze",
943	//       "location": "query",
944	//       "pattern": "(?i)http(s)?://.*",
945	//       "required": true,
946	//       "type": "string"
947	//     }
948	//   },
949	//   "path": "runPagespeed",
950	//   "response": {
951	//     "$ref": "Result"
952	//   }
953	// }
954
955}
956