Debian Codegraph @

pagespeedonline/v5/pagespeedonline-gen.go

raw symbols SCIP
1 // Copyright 2026 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/v5/about
10 //
11 // # Library status
12 //
13 // These client libraries are officially supported by Google. However, this
14 // library is considered complete and is in maintenance mode. This means
15 // that we will address critical bugs and security issues but will not add
16 // any new features.
17 //
18 // When possible, we recommend using our newer
19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
20 // that are still actively being worked and iterated on.
21 //
22 // # Creating a client
23 //
24 // Usage example:
25 //
26 // import "google.golang.org/api/pagespeedonline/v5"
27 // ...
28 // ctx := context.Background()
29 // pagespeedonlineService, err := pagespeedonline.NewService(ctx)
30 //
31 // In this example, Google Application Default Credentials are used for
32 // authentication. For information on how to create and obtain Application
33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
34 //
35 // # Other authentication options
36 //
37 // To use an API key for authentication (note: some APIs do not support API
38 // keys), use [google.golang.org/api/option.WithAPIKey]:
39 //
40 // pagespeedonlineService, err := pagespeedonline.NewService(ctx, option.WithAPIKey("AIza..."))
41 //
42 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
43 // flow, use [google.golang.org/api/option.WithTokenSource]:
44 //
45 // config := &oauth2.Config{...}
46 // // ...
47 // token, err := config.Exchange(ctx, ...)
48 // pagespeedonlineService, err := pagespeedonline.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
49 //
50 // See [google.golang.org/api/option.ClientOption] for details on options.
51 package pagespeedonline // import "google.golang.org/api/pagespeedonline/v5"
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "log/slog"
61 "net/http"
62 "net/url"
63 "strconv"
64 "strings"
65
66 "github.com/googleapis/gax-go/v2/internallog"
67 googleapi "google.golang.org/api/googleapi"
68 internal "google.golang.org/api/internal"
69 gensupport "google.golang.org/api/internal/gensupport"
70 option "google.golang.org/api/option"
71 internaloption "google.golang.org/api/option/internaloption"
72 htransport "google.golang.org/api/transport/http"
73 )
74
75 // Always reference these packages, just in case the auto-generated code
76 // below doesn't.
77 var _ = bytes.NewBuffer
78 var _ = strconv.Itoa
79 var _ = fmt.Sprintf
80 var _ = json.NewDecoder
81 var _ = io.Copy
82 var _ = url.Parse
83 var _ = gensupport.MarshalJSON
84 var _ = googleapi.Version
85 var _ = errors.New
86 var _ = strings.Replace
87 var _ = context.Canceled
88 var _ = internaloption.WithDefaultEndpoint
89 var _ = internal.Version
90 var _ = internallog.New
91
92 const apiId = "pagespeedonline:v5"
93 const apiName = "pagespeedonline"
94 const apiVersion = "v5"
95 const basePath = "https://pagespeedonline.googleapis.com/"
96 const basePathTemplate = "https://pagespeedonline.UNIVERSE_DOMAIN/"
97 const mtlsBasePath = "https://pagespeedonline.mtls.googleapis.com/"
98
99 // OAuth2 scopes used by this API.
100 const (
101 // Associate you with your personal info on Google
102 OpenIDScope = "openid"
103 )
104
105 // NewService creates a new Service.
106 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
107 scopesOption := internaloption.WithDefaultScopes(
108 "openid",
109 )
110 // NOTE: prepend, so we don't override user-specified scopes.
111 opts = append([]option.ClientOption{scopesOption}, opts...)
112 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
113 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
114 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
115 opts = append(opts, internaloption.EnableNewAuthLibrary())
116 client, endpoint, err := htransport.NewClient(ctx, opts...)
117 if err != nil {
118 return nil, err
119 }
120 s := &Service{client: client, BasePath: basePath, logger: internaloption.GetLogger(opts)}
121 s.Pagespeedapi = NewPagespeedapiService(s)
122 if endpoint != "" {
123 s.BasePath = endpoint
124 }
125 return s, nil
126 }
127
128 // New creates a new Service. It uses the provided http.Client for requests.
129 //
130 // Deprecated: please use NewService instead.
131 // To provide a custom HTTP client, use option.WithHTTPClient.
132 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
133 func New(client *http.Client) (*Service, error) {
134 if client == nil {
135 return nil, errors.New("client is nil")
136 }
137 return NewService(context.TODO(), option.WithHTTPClient(client))
138 }
139
140 type Service struct {
141 client *http.Client
142 logger *slog.Logger
143 BasePath string // API endpoint base URL
144 UserAgent string // optional additional User-Agent fragment
145
146 Pagespeedapi *PagespeedapiService
147 }
148
149 func (s *Service) userAgent() string {
150 if s.UserAgent == "" {
151 return googleapi.UserAgent
152 }
153 return googleapi.UserAgent + " " + s.UserAgent
154 }
155
156 func NewPagespeedapiService(s *Service) *PagespeedapiService {
157 rs := &PagespeedapiService{s: s}
158 return rs
159 }
160
161 type PagespeedapiService struct {
162 s *Service
163 }
164
165 // AuditRefs: A light reference to an audit by id, used to group and weight
166 // audits in a given category.
167 type AuditRefs struct {
168 // Acronym: The conventional acronym for the audit/metric.
169 Acronym string `json:"acronym,omitempty"`
170 // Group: The category group that the audit belongs to (optional).
171 Group string `json:"group,omitempty"`
172 // Id: The audit ref id.
173 Id string `json:"id,omitempty"`
174 // RelevantAudits: Any audit IDs closely relevant to this one.
175 RelevantAudits []string `json:"relevantAudits,omitempty"`
176 // Weight: The weight this audit's score has on the overall category score.
177 Weight float64 `json:"weight,omitempty"`
178 // ForceSendFields is a list of field names (e.g. "Acronym") to unconditionally
179 // include in API requests. By default, fields with empty or default values are
180 // omitted from API requests. See
181 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
182 // details.
183 ForceSendFields []string `json:"-"`
184 // NullFields is a list of field names (e.g. "Acronym") to include in API
185 // requests with the JSON null value. By default, fields with empty values are
186 // omitted from API requests. See
187 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
188 NullFields []string `json:"-"`
189 }
190
191 func (s AuditRefs) MarshalJSON() ([]byte, error) {
192 type NoMethod AuditRefs
193 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
194 }
195
196 func (s *AuditRefs) UnmarshalJSON(data []byte) error {
197 type NoMethod AuditRefs
198 var s1 struct {
199 Weight gensupport.JSONFloat64 `json:"weight"`
200 *NoMethod
201 }
202 s1.NoMethod = (*NoMethod)(s)
203 if err := json.Unmarshal(data, &s1); err != nil {
204 return err
205 }
206 s.Weight = float64(s1.Weight)
207 return nil
208 }
209
210 // Bucket: A proportion of data in the total distribution, bucketed by a
211 // min/max percentage. Each bucket's range is bounded by min <= x < max, In
212 // millisecond.
213 type Bucket struct {
214 // Max: Upper bound for a bucket's range.
215 Max int64 `json:"max,omitempty"`
216 // Min: Lower bound for a bucket's range.
217 Min int64 `json:"min,omitempty"`
218 // Proportion: The proportion of data in this bucket.
219 Proportion float64 `json:"proportion,omitempty"`
220 // ForceSendFields is a list of field names (e.g. "Max") to unconditionally
221 // include in API requests. By default, fields with empty or default values are
222 // omitted from API requests. See
223 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
224 // details.
225 ForceSendFields []string `json:"-"`
226 // NullFields is a list of field names (e.g. "Max") to include in API requests
227 // with the JSON null value. By default, fields with empty values are omitted
228 // from API requests. See
229 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
230 NullFields []string `json:"-"`
231 }
232
233 func (s Bucket) MarshalJSON() ([]byte, error) {
234 type NoMethod Bucket
235 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
236 }
237
238 func (s *Bucket) UnmarshalJSON(data []byte) error {
239 type NoMethod Bucket
240 var s1 struct {
241 Proportion gensupport.JSONFloat64 `json:"proportion"`
242 *NoMethod
243 }
244 s1.NoMethod = (*NoMethod)(s)
245 if err := json.Unmarshal(data, &s1); err != nil {
246 return err
247 }
248 s.Proportion = float64(s1.Proportion)
249 return nil
250 }
251
252 // Categories: The categories in a Lighthouse run.
253 type Categories struct {
254 // Accessibility: The accessibility category, containing all accessibility
255 // related audits.
256 Accessibility *LighthouseCategoryV5 `json:"accessibility,omitempty"`
257 // BestPractices: The best practices category, containing all best practices
258 // related audits.
259 BestPractices *LighthouseCategoryV5 `json:"best-practices,omitempty"`
260 // Performance: The performance category, containing all performance related
261 // audits.
262 Performance *LighthouseCategoryV5 `json:"performance,omitempty"`
263 // Pwa: The Progressive-Web-App (PWA) category, containing all pwa related
264 // audits. This is deprecated in Lighthouse's 12.0 release.
265 Pwa *LighthouseCategoryV5 `json:"pwa,omitempty"`
266 // Seo: The Search-Engine-Optimization (SEO) category, containing all seo
267 // related audits.
268 Seo *LighthouseCategoryV5 `json:"seo,omitempty"`
269 // ForceSendFields is a list of field names (e.g. "Accessibility") to
270 // unconditionally include in API requests. By default, fields with empty or
271 // default values are omitted from API requests. See
272 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
273 // details.
274 ForceSendFields []string `json:"-"`
275 // NullFields is a list of field names (e.g. "Accessibility") to include in API
276 // requests with the JSON null value. By default, fields with empty values are
277 // omitted from API requests. See
278 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
279 NullFields []string `json:"-"`
280 }
281
282 func (s Categories) MarshalJSON() ([]byte, error) {
283 type NoMethod Categories
284 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
285 }
286
287 // CategoryGroupV5: Message containing a category
288 type CategoryGroupV5 struct {
289 // Description: The description of what the category is grouping
290 Description string `json:"description,omitempty"`
291 // Title: The human readable title of the group
292 Title string `json:"title,omitempty"`
293 // ForceSendFields is a list of field names (e.g. "Description") to
294 // unconditionally include in API requests. By default, fields with empty or
295 // default values are omitted from API requests. See
296 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
297 // details.
298 ForceSendFields []string `json:"-"`
299 // NullFields is a list of field names (e.g. "Description") to include in API
300 // requests with the JSON null value. By default, fields with empty values are
301 // omitted from API requests. See
302 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
303 NullFields []string `json:"-"`
304 }
305
306 func (s CategoryGroupV5) MarshalJSON() ([]byte, error) {
307 type NoMethod CategoryGroupV5
308 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
309 }
310
311 // ConfigSettings: Message containing the configuration settings for the
312 // Lighthouse run.
313 type ConfigSettings struct {
314 // Channel: How Lighthouse was run, e.g. from the Chrome extension or from the
315 // npm module.
316 Channel string `json:"channel,omitempty"`
317 // EmulatedFormFactor: The form factor the emulation should use. This field is
318 // deprecated, form_factor should be used instead.
319 EmulatedFormFactor string `json:"emulatedFormFactor,omitempty"`
320 // FormFactor: How Lighthouse should interpret this run in regards to scoring
321 // performance metrics and skipping mobile-only tests in desktop.
322 FormFactor string `json:"formFactor,omitempty"`
323 // Locale: The locale setting.
324 Locale string `json:"locale,omitempty"`
325 // OnlyCategories: List of categories of audits the run should conduct.
326 OnlyCategories interface{} `json:"onlyCategories,omitempty"`
327 // ForceSendFields is a list of field names (e.g. "Channel") to unconditionally
328 // include in API requests. By default, fields with empty or default values are
329 // omitted from API requests. See
330 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
331 // details.
332 ForceSendFields []string `json:"-"`
333 // NullFields is a list of field names (e.g. "Channel") to include in API
334 // requests with the JSON null value. By default, fields with empty values are
335 // omitted from API requests. See
336 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
337 NullFields []string `json:"-"`
338 }
339
340 func (s ConfigSettings) MarshalJSON() ([]byte, error) {
341 type NoMethod ConfigSettings
342 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
343 }
344
345 // Environment: Message containing environment configuration for a Lighthouse
346 // run.
347 type Environment struct {
348 // BenchmarkIndex: The benchmark index number that indicates rough device
349 // class.
350 BenchmarkIndex float64 `json:"benchmarkIndex,omitempty"`
351 // Credits: The version of libraries with which these results were generated.
352 // Ex: axe-core.
353 Credits map[string]string `json:"credits,omitempty"`
354 // HostUserAgent: The user agent string of the version of Chrome used.
355 HostUserAgent string `json:"hostUserAgent,omitempty"`
356 // NetworkUserAgent: The user agent string that was sent over the network.
357 NetworkUserAgent string `json:"networkUserAgent,omitempty"`
358 // ForceSendFields is a list of field names (e.g. "BenchmarkIndex") to
359 // unconditionally include in API requests. By default, fields with empty or
360 // default values are omitted from API requests. See
361 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
362 // details.
363 ForceSendFields []string `json:"-"`
364 // NullFields is a list of field names (e.g. "BenchmarkIndex") to include in
365 // API requests with the JSON null value. By default, fields with empty values
366 // are omitted from API requests. See
367 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
368 NullFields []string `json:"-"`
369 }
370
371 func (s Environment) MarshalJSON() ([]byte, error) {
372 type NoMethod Environment
373 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
374 }
375
376 func (s *Environment) UnmarshalJSON(data []byte) error {
377 type NoMethod Environment
378 var s1 struct {
379 BenchmarkIndex gensupport.JSONFloat64 `json:"benchmarkIndex"`
380 *NoMethod
381 }
382 s1.NoMethod = (*NoMethod)(s)
383 if err := json.Unmarshal(data, &s1); err != nil {
384 return err
385 }
386 s.BenchmarkIndex = float64(s1.BenchmarkIndex)
387 return nil
388 }
389
390 // I18n: Message containing the i18n data for the LHR - Version 1.
391 type I18n struct {
392 // RendererFormattedStrings: Internationalized strings that are formatted to
393 // the locale in configSettings.
394 RendererFormattedStrings *RendererFormattedStrings `json:"rendererFormattedStrings,omitempty"`
395 // ForceSendFields is a list of field names (e.g. "RendererFormattedStrings")
396 // to unconditionally include in API requests. By default, fields with empty or
397 // default values are omitted from API requests. See
398 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
399 // details.
400 ForceSendFields []string `json:"-"`
401 // NullFields is a list of field names (e.g. "RendererFormattedStrings") to
402 // include in API requests with the JSON null value. By default, fields with
403 // empty values are omitted from API requests. See
404 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
405 NullFields []string `json:"-"`
406 }
407
408 func (s I18n) MarshalJSON() ([]byte, error) {
409 type NoMethod I18n
410 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
411 }
412
413 // LhrEntity: Message containing an Entity.
414 type LhrEntity struct {
415 // Category: Optional. An optional category name for the entity.
416 Category string `json:"category,omitempty"`
417 // Homepage: Optional. An optional homepage URL of the entity.
418 Homepage string `json:"homepage,omitempty"`
419 // IsFirstParty: Optional. An optional flag indicating if the entity is the
420 // first party.
421 IsFirstParty bool `json:"isFirstParty,omitempty"`
422 // IsUnrecognized: Optional. An optional flag indicating if the entity is not
423 // recognized.
424 IsUnrecognized bool `json:"isUnrecognized,omitempty"`
425 // Name: Required. Name of the entity.
426 Name string `json:"name,omitempty"`
427 // Origins: Required. A list of URL origin strings that belong to this entity.
428 Origins []string `json:"origins,omitempty"`
429 // ForceSendFields is a list of field names (e.g. "Category") to
430 // unconditionally include in API requests. By default, fields with empty or
431 // default values are omitted from API requests. See
432 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
433 // details.
434 ForceSendFields []string `json:"-"`
435 // NullFields is a list of field names (e.g. "Category") to include in API
436 // requests with the JSON null value. By default, fields with empty values are
437 // omitted from API requests. See
438 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
439 NullFields []string `json:"-"`
440 }
441
442 func (s LhrEntity) MarshalJSON() ([]byte, error) {
443 type NoMethod LhrEntity
444 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
445 }
446
447 // LighthouseAuditResultV5: An audit's result object in a Lighthouse result.
448 type LighthouseAuditResultV5 struct {
449 // Description: The description of the audit.
450 Description string `json:"description,omitempty"`
451 // Details: Freeform details section of the audit.
452 Details googleapi.RawMessage `json:"details,omitempty"`
453 // DisplayValue: The value that should be displayed on the UI for this audit.
454 DisplayValue string `json:"displayValue,omitempty"`
455 // ErrorMessage: An error message from a thrown error inside the audit.
456 ErrorMessage string `json:"errorMessage,omitempty"`
457 // Explanation: An explanation of the errors in the audit.
458 Explanation string `json:"explanation,omitempty"`
459 // Id: The audit's id.
460 Id string `json:"id,omitempty"`
461 // MetricSavings: The metric savings of the audit.
462 MetricSavings *MetricSavings `json:"metricSavings,omitempty"`
463 // NumericUnit: The unit of the numeric_value field. Used to format the numeric
464 // value for display.
465 NumericUnit string `json:"numericUnit,omitempty"`
466 // NumericValue: A numeric value that has a meaning specific to the audit, e.g.
467 // the number of nodes in the DOM or the timestamp of a specific load event.
468 // More information can be found in the audit details, if present.
469 NumericValue float64 `json:"numericValue,omitempty"`
470 // Score: The score of the audit, can be null.
471 Score interface{} `json:"score,omitempty"`
472 // ScoreDisplayMode: The enumerated score display mode.
473 ScoreDisplayMode string `json:"scoreDisplayMode,omitempty"`
474 // Title: The human readable title.
475 Title string `json:"title,omitempty"`
476 // Warnings: Possible warnings that occurred in the audit, can be null.
477 Warnings interface{} `json:"warnings,omitempty"`
478 // ForceSendFields is a list of field names (e.g. "Description") to
479 // unconditionally include in API requests. By default, fields with empty or
480 // default values are omitted from API requests. See
481 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
482 // details.
483 ForceSendFields []string `json:"-"`
484 // NullFields is a list of field names (e.g. "Description") to include in API
485 // requests with the JSON null value. By default, fields with empty values are
486 // omitted from API requests. See
487 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
488 NullFields []string `json:"-"`
489 }
490
491 func (s LighthouseAuditResultV5) MarshalJSON() ([]byte, error) {
492 type NoMethod LighthouseAuditResultV5
493 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
494 }
495
496 func (s *LighthouseAuditResultV5) UnmarshalJSON(data []byte) error {
497 type NoMethod LighthouseAuditResultV5
498 var s1 struct {
499 NumericValue gensupport.JSONFloat64 `json:"numericValue"`
500 *NoMethod
501 }
502 s1.NoMethod = (*NoMethod)(s)
503 if err := json.Unmarshal(data, &s1); err != nil {
504 return err
505 }
506 s.NumericValue = float64(s1.NumericValue)
507 return nil
508 }
509
510 // LighthouseCategoryV5: A Lighthouse category.
511 type LighthouseCategoryV5 struct {
512 // AuditRefs: An array of references to all the audit members of this category.
513 AuditRefs []*AuditRefs `json:"auditRefs,omitempty"`
514 // Description: A more detailed description of the category and its importance.
515 Description string `json:"description,omitempty"`
516 // Id: The string identifier of the category.
517 Id string `json:"id,omitempty"`
518 // ManualDescription: A description for the manual audits in the category.
519 ManualDescription string `json:"manualDescription,omitempty"`
520 // Score: The overall score of the category, the weighted average of all its
521 // audits. (The category's score, can be null.)
522 Score interface{} `json:"score,omitempty"`
523 // Title: The human-friendly name of the category.
524 Title string `json:"title,omitempty"`
525 // ForceSendFields is a list of field names (e.g. "AuditRefs") to
526 // unconditionally include in API requests. By default, fields with empty or
527 // default values are omitted from API requests. See
528 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
529 // details.
530 ForceSendFields []string `json:"-"`
531 // NullFields is a list of field names (e.g. "AuditRefs") to include in API
532 // requests with the JSON null value. By default, fields with empty values are
533 // omitted from API requests. See
534 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
535 NullFields []string `json:"-"`
536 }
537
538 func (s LighthouseCategoryV5) MarshalJSON() ([]byte, error) {
539 type NoMethod LighthouseCategoryV5
540 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
541 }
542
543 // LighthouseResultV5: The Lighthouse result object.
544 type LighthouseResultV5 struct {
545 // Audits: Map of audits in the LHR.
546 Audits map[string]LighthouseAuditResultV5 `json:"audits,omitempty"`
547 // Categories: Map of categories in the LHR.
548 Categories *Categories `json:"categories,omitempty"`
549 // CategoryGroups: Map of category groups in the LHR.
550 CategoryGroups map[string]CategoryGroupV5 `json:"categoryGroups,omitempty"`
551 // ConfigSettings: The configuration settings for this LHR.
552 ConfigSettings *ConfigSettings `json:"configSettings,omitempty"`
553 // Entities: Entity classification data.
554 Entities []*LhrEntity `json:"entities,omitempty"`
555 // Environment: Environment settings that were used when making this LHR.
556 Environment *Environment `json:"environment,omitempty"`
557 // FetchTime: The time that this run was fetched.
558 FetchTime string `json:"fetchTime,omitempty"`
559 // FinalDisplayedUrl: URL displayed on the page after Lighthouse finishes.
560 FinalDisplayedUrl string `json:"finalDisplayedUrl,omitempty"`
561 // FinalUrl: The final resolved url that was audited.
562 FinalUrl string `json:"finalUrl,omitempty"`
563 // FullPageScreenshot: Screenshot data of the full page, along with node rects
564 // relevant to the audit results.
565 FullPageScreenshot interface{} `json:"fullPageScreenshot,omitempty"`
566 // I18n: The internationalization strings that are required to render the LHR.
567 I18n *I18n `json:"i18n,omitempty"`
568 // LighthouseVersion: The lighthouse version that was used to generate this
569 // LHR.
570 LighthouseVersion string `json:"lighthouseVersion,omitempty"`
571 // MainDocumentUrl: URL of the main document request of the final navigation.
572 MainDocumentUrl string `json:"mainDocumentUrl,omitempty"`
573 // RequestedUrl: The original requested url.
574 RequestedUrl string `json:"requestedUrl,omitempty"`
575 // RunWarnings: List of all run warnings in the LHR. Will always output to at
576 // least `[]`.
577 RunWarnings []interface{} `json:"runWarnings,omitempty"`
578 // RuntimeError: A top-level error message that, if present, indicates a
579 // serious enough problem that this Lighthouse result may need to be discarded.
580 RuntimeError *RuntimeError `json:"runtimeError,omitempty"`
581 // StackPacks: The Stack Pack advice strings.
582 StackPacks []*StackPack `json:"stackPacks,omitempty"`
583 // Timing: Timing information for this LHR.
584 Timing *Timing `json:"timing,omitempty"`
585 // UserAgent: The user agent that was used to run this LHR.
586 UserAgent string `json:"userAgent,omitempty"`
587 // ForceSendFields is a list of field names (e.g. "Audits") to unconditionally
588 // include in API requests. By default, fields with empty or default values are
589 // omitted from API requests. See
590 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
591 // details.
592 ForceSendFields []string `json:"-"`
593 // NullFields is a list of field names (e.g. "Audits") to include in API
594 // requests with the JSON null value. By default, fields with empty values are
595 // omitted from API requests. See
596 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
597 NullFields []string `json:"-"`
598 }
599
600 func (s LighthouseResultV5) MarshalJSON() ([]byte, error) {
601 type NoMethod LighthouseResultV5
602 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
603 }
604
605 // MetricSavings: The metric savings of the audit.
606 type MetricSavings struct {
607 // CLS: Optional. Optional numeric value representing the audit's savings for
608 // the CLS metric.
609 CLS float64 `json:"CLS,omitempty"`
610 // FCP: Optional. Optional numeric value representing the audit's savings for
611 // the FCP metric.
612 FCP float64 `json:"FCP,omitempty"`
613 // INP: Optional. Optional numeric value representing the audit's savings for
614 // the INP metric.
615 INP float64 `json:"INP,omitempty"`
616 // LCP: Optional. Optional numeric value representing the audit's savings for
617 // the LCP metric.
618 LCP float64 `json:"LCP,omitempty"`
619 // TBT: Optional. Optional numeric value representing the audit's savings for
620 // the TBT metric.
621 TBT float64 `json:"TBT,omitempty"`
622 // ForceSendFields is a list of field names (e.g. "CLS") to unconditionally
623 // include in API requests. By default, fields with empty or default values are
624 // omitted from API requests. See
625 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
626 // details.
627 ForceSendFields []string `json:"-"`
628 // NullFields is a list of field names (e.g. "CLS") to include in API requests
629 // with the JSON null value. By default, fields with empty values are omitted
630 // from API requests. See
631 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
632 NullFields []string `json:"-"`
633 }
634
635 func (s MetricSavings) MarshalJSON() ([]byte, error) {
636 type NoMethod MetricSavings
637 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
638 }
639
640 func (s *MetricSavings) UnmarshalJSON(data []byte) error {
641 type NoMethod MetricSavings
642 var s1 struct {
643 CLS gensupport.JSONFloat64 `json:"CLS"`
644 FCP gensupport.JSONFloat64 `json:"FCP"`
645 INP gensupport.JSONFloat64 `json:"INP"`
646 LCP gensupport.JSONFloat64 `json:"LCP"`
647 TBT gensupport.JSONFloat64 `json:"TBT"`
648 *NoMethod
649 }
650 s1.NoMethod = (*NoMethod)(s)
651 if err := json.Unmarshal(data, &s1); err != nil {
652 return err
653 }
654 s.CLS = float64(s1.CLS)
655 s.FCP = float64(s1.FCP)
656 s.INP = float64(s1.INP)
657 s.LCP = float64(s1.LCP)
658 s.TBT = float64(s1.TBT)
659 return nil
660 }
661
662 // PagespeedApiLoadingExperienceV5: The CrUX loading experience object that
663 // contains CrUX data breakdowns.
664 type PagespeedApiLoadingExperienceV5 struct {
665 // Id: The url, pattern or origin which the metrics are on.
666 Id string `json:"id,omitempty"`
667 // InitialUrl: The requested URL, which may differ from the resolved "id".
668 InitialUrl string `json:"initial_url,omitempty"`
669 // Metrics: The map of .
670 Metrics map[string]UserPageLoadMetricV5 `json:"metrics,omitempty"`
671 // OriginFallback: True if the result is an origin fallback from a page, false
672 // otherwise.
673 OriginFallback bool `json:"origin_fallback,omitempty"`
674 // OverallCategory: The human readable speed "category" of the id.
675 OverallCategory string `json:"overall_category,omitempty"`
676 // ForceSendFields is a list of field names (e.g. "Id") to unconditionally
677 // include in API requests. By default, fields with empty or default values are
678 // omitted from API requests. See
679 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
680 // details.
681 ForceSendFields []string `json:"-"`
682 // NullFields is a list of field names (e.g. "Id") to include in API requests
683 // with the JSON null value. By default, fields with empty values are omitted
684 // from API requests. See
685 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
686 NullFields []string `json:"-"`
687 }
688
689 func (s PagespeedApiLoadingExperienceV5) MarshalJSON() ([]byte, error) {
690 type NoMethod PagespeedApiLoadingExperienceV5
691 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
692 }
693
694 // PagespeedApiPagespeedResponseV5: The Pagespeed API response object.
695 type PagespeedApiPagespeedResponseV5 struct {
696 // AnalysisUTCTimestamp: The UTC timestamp of this analysis.
697 AnalysisUTCTimestamp string `json:"analysisUTCTimestamp,omitempty"`
698 // CaptchaResult: The captcha verify result
699 CaptchaResult string `json:"captchaResult,omitempty"`
700 // Id: Canonicalized and final URL for the document, after following page
701 // redirects (if any).
702 Id string `json:"id,omitempty"`
703 // Kind: Kind of result.
704 Kind string `json:"kind,omitempty"`
705 // LighthouseResult: Lighthouse response for the audit url as an object.
706 LighthouseResult *LighthouseResultV5 `json:"lighthouseResult,omitempty"`
707 // LoadingExperience: Metrics of end users' page loading experience.
708 LoadingExperience *PagespeedApiLoadingExperienceV5 `json:"loadingExperience,omitempty"`
709 // OriginLoadingExperience: Metrics of the aggregated page loading experience
710 // of the origin
711 OriginLoadingExperience *PagespeedApiLoadingExperienceV5 `json:"originLoadingExperience,omitempty"`
712 // Version: The version of PageSpeed used to generate these results.
713 Version *PagespeedVersion `json:"version,omitempty"`
714
715 // ServerResponse contains the HTTP response code and headers from the server.
716 googleapi.ServerResponse `json:"-"`
717 // ForceSendFields is a list of field names (e.g. "AnalysisUTCTimestamp") to
718 // unconditionally include in API requests. By default, fields with empty or
719 // default values are omitted from API requests. See
720 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
721 // details.
722 ForceSendFields []string `json:"-"`
723 // NullFields is a list of field names (e.g. "AnalysisUTCTimestamp") to include
724 // in API requests with the JSON null value. By default, fields with empty
725 // values are omitted from API requests. See
726 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
727 NullFields []string `json:"-"`
728 }
729
730 func (s PagespeedApiPagespeedResponseV5) MarshalJSON() ([]byte, error) {
731 type NoMethod PagespeedApiPagespeedResponseV5
732 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
733 }
734
735 // PagespeedVersion: The Pagespeed Version object.
736 type PagespeedVersion struct {
737 // Major: The major version number of PageSpeed used to generate these results.
738 Major string `json:"major,omitempty"`
739 // Minor: The minor version number of PageSpeed used to generate these results.
740 Minor string `json:"minor,omitempty"`
741 // ForceSendFields is a list of field names (e.g. "Major") to unconditionally
742 // include in API requests. By default, fields with empty or default values are
743 // omitted from API requests. See
744 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
745 // details.
746 ForceSendFields []string `json:"-"`
747 // NullFields is a list of field names (e.g. "Major") to include in API
748 // requests with the JSON null value. By default, fields with empty values are
749 // omitted from API requests. See
750 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
751 NullFields []string `json:"-"`
752 }
753
754 func (s PagespeedVersion) MarshalJSON() ([]byte, error) {
755 type NoMethod PagespeedVersion
756 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
757 }
758
759 // RendererFormattedStrings: Message holding the formatted strings used in the
760 // renderer.
761 type RendererFormattedStrings struct {
762 // AuditGroupExpandTooltip: The tooltip text on an expandable chevron icon.
763 AuditGroupExpandTooltip string `json:"auditGroupExpandTooltip,omitempty"`
764 // CalculatorLink: Text link pointing to the Lighthouse scoring calculator.
765 // This link immediately follows a sentence stating the performance score is
766 // calculated from the perf metrics.
767 CalculatorLink string `json:"calculatorLink,omitempty"`
768 // CrcInitialNavigation: The label for the initial request in a critical
769 // request chain.
770 CrcInitialNavigation string `json:"crcInitialNavigation,omitempty"`
771 // CrcLongestDurationLabel: The label for values shown in the summary of
772 // critical request chains.
773 CrcLongestDurationLabel string `json:"crcLongestDurationLabel,omitempty"`
774 // DropdownCopyJSON: Option in a dropdown menu that copies the Lighthouse JSON
775 // object to the system clipboard.
776 DropdownCopyJSON string `json:"dropdownCopyJSON,omitempty"`
777 // DropdownDarkTheme: Option in a dropdown menu that toggles the themeing of
778 // the report between Light(default) and Dark themes.
779 DropdownDarkTheme string `json:"dropdownDarkTheme,omitempty"`
780 // DropdownPrintExpanded: Option in a dropdown menu that opens a full
781 // Lighthouse report in a print dialog.
782 DropdownPrintExpanded string `json:"dropdownPrintExpanded,omitempty"`
783 // DropdownPrintSummary: Option in a dropdown menu that opens a small, summary
784 // report in a print dialog.
785 DropdownPrintSummary string `json:"dropdownPrintSummary,omitempty"`
786 // DropdownSaveGist: Option in a dropdown menu that saves the current report as
787 // a new GitHub Gist.
788 DropdownSaveGist string `json:"dropdownSaveGist,omitempty"`
789 // DropdownSaveHTML: Option in a dropdown menu that saves the Lighthouse report
790 // HTML locally to the system as a '.html' file.
791 DropdownSaveHTML string `json:"dropdownSaveHTML,omitempty"`
792 // DropdownSaveJSON: Option in a dropdown menu that saves the Lighthouse JSON
793 // object to the local system as a '.json' file.
794 DropdownSaveJSON string `json:"dropdownSaveJSON,omitempty"`
795 // DropdownViewer: Option in a dropdown menu that opens the current report in
796 // the Lighthouse Viewer Application.
797 DropdownViewer string `json:"dropdownViewer,omitempty"`
798 // ErrorLabel: The label shown next to an audit or metric that has had an
799 // error.
800 ErrorLabel string `json:"errorLabel,omitempty"`
801 // ErrorMissingAuditInfo: The error string shown next to an erroring audit.
802 ErrorMissingAuditInfo string `json:"errorMissingAuditInfo,omitempty"`
803 // FooterIssue: Label for button to create an issue against the Lighthouse
804 // GitHub project.
805 FooterIssue string `json:"footerIssue,omitempty"`
806 // LabDataTitle: The title of the lab data performance category.
807 LabDataTitle string `json:"labDataTitle,omitempty"`
808 // LsPerformanceCategoryDescription: The disclaimer shown under performance
809 // explaining that the network can vary.
810 LsPerformanceCategoryDescription string `json:"lsPerformanceCategoryDescription,omitempty"`
811 // ManualAuditsGroupTitle: The heading shown above a list of audits that were
812 // not computerd in the run.
813 ManualAuditsGroupTitle string `json:"manualAuditsGroupTitle,omitempty"`
814 // NotApplicableAuditsGroupTitle: The heading shown above a list of audits that
815 // do not apply to a page.
816 NotApplicableAuditsGroupTitle string `json:"notApplicableAuditsGroupTitle,omitempty"`
817 // OpportunityResourceColumnLabel: The heading for the estimated page load
818 // savings opportunity of an audit.
819 OpportunityResourceColumnLabel string `json:"opportunityResourceColumnLabel,omitempty"`
820 // OpportunitySavingsColumnLabel: The heading for the estimated page load
821 // savings of opportunity audits.
822 OpportunitySavingsColumnLabel string `json:"opportunitySavingsColumnLabel,omitempty"`
823 // PassedAuditsGroupTitle: The heading that is shown above a list of audits
824 // that are passing.
825 PassedAuditsGroupTitle string `json:"passedAuditsGroupTitle,omitempty"`
826 // RuntimeDesktopEmulation: Descriptive explanation for emulation setting when
827 // emulating a generic desktop form factor, as opposed to a mobile-device like
828 // form factor.
829 RuntimeDesktopEmulation string `json:"runtimeDesktopEmulation,omitempty"`
830 // RuntimeMobileEmulation: Descriptive explanation for emulation setting when
831 // emulating a Nexus 5X mobile device.
832 RuntimeMobileEmulation string `json:"runtimeMobileEmulation,omitempty"`
833 // RuntimeNoEmulation: Descriptive explanation for emulation setting when no
834 // device emulation is set.
835 RuntimeNoEmulation string `json:"runtimeNoEmulation,omitempty"`
836 // RuntimeSettingsAxeVersion: Label for a row in a table that shows the version
837 // of the Axe library used
838 RuntimeSettingsAxeVersion string `json:"runtimeSettingsAxeVersion,omitempty"`
839 // RuntimeSettingsBenchmark: Label for a row in a table that shows the
840 // estimated CPU power of the machine running Lighthouse. Example row values:
841 // 532, 1492, 783.
842 RuntimeSettingsBenchmark string `json:"runtimeSettingsBenchmark,omitempty"`
843 // RuntimeSettingsCPUThrottling: Label for a row in a table that describes the
844 // CPU throttling conditions that were used during a Lighthouse run, if any.
845 RuntimeSettingsCPUThrottling string `json:"runtimeSettingsCPUThrottling,omitempty"`
846 // RuntimeSettingsChannel: Label for a row in a table that shows in what tool
847 // Lighthouse is being run (e.g. The lighthouse CLI, Chrome DevTools,
848 // Lightrider, WebPageTest, etc).
849 RuntimeSettingsChannel string `json:"runtimeSettingsChannel,omitempty"`
850 // RuntimeSettingsDevice: Label for a row in a table that describes the kind of
851 // device that was emulated for the Lighthouse run. Example values for row
852 // elements: 'No Emulation', 'Emulated Desktop', etc.
853 RuntimeSettingsDevice string `json:"runtimeSettingsDevice,omitempty"`
854 // RuntimeSettingsFetchTime: Label for a row in a table that shows the time at
855 // which a Lighthouse run was conducted; formatted as a timestamp, e.g. Jan 1,
856 // 1970 12:00 AM UTC.
857 RuntimeSettingsFetchTime string `json:"runtimeSettingsFetchTime,omitempty"`
858 // RuntimeSettingsNetworkThrottling: Label for a row in a table that describes
859 // the network throttling conditions that were used during a Lighthouse run, if
860 // any.
861 RuntimeSettingsNetworkThrottling string `json:"runtimeSettingsNetworkThrottling,omitempty"`
862 // RuntimeSettingsTitle: Title of the Runtime settings table in a Lighthouse
863 // report. Runtime settings are the environment configurations that a specific
864 // report used at auditing time.
865 RuntimeSettingsTitle string `json:"runtimeSettingsTitle,omitempty"`
866 // RuntimeSettingsUA: Label for a row in a table that shows the User Agent that
867 // was detected on the Host machine that ran Lighthouse.
868 RuntimeSettingsUA string `json:"runtimeSettingsUA,omitempty"`
869 // RuntimeSettingsUANetwork: Label for a row in a table that shows the User
870 // Agent that was used to send out all network requests during the Lighthouse
871 // run.
872 RuntimeSettingsUANetwork string `json:"runtimeSettingsUANetwork,omitempty"`
873 // RuntimeSettingsUrl: Label for a row in a table that shows the URL that was
874 // audited during a Lighthouse run.
875 RuntimeSettingsUrl string `json:"runtimeSettingsUrl,omitempty"`
876 // RuntimeUnknown: Descriptive explanation for a runtime setting that is set to
877 // an unknown value.
878 RuntimeUnknown string `json:"runtimeUnknown,omitempty"`
879 // ScorescaleLabel: The label that explains the score gauges scale (0-49,
880 // 50-89, 90-100).
881 ScorescaleLabel string `json:"scorescaleLabel,omitempty"`
882 // ShowRelevantAudits: Label preceding a radio control for filtering the list
883 // of audits. The radio choices are various performance metrics (FCP, LCP,
884 // TBT), and if chosen, the audits in the report are hidden if they are not
885 // relevant to the selected metric.
886 ShowRelevantAudits string `json:"showRelevantAudits,omitempty"`
887 // SnippetCollapseButtonLabel: The label for the button to show only a few
888 // lines of a snippet
889 SnippetCollapseButtonLabel string `json:"snippetCollapseButtonLabel,omitempty"`
890 // SnippetExpandButtonLabel: The label for the button to show all lines of a
891 // snippet
892 SnippetExpandButtonLabel string `json:"snippetExpandButtonLabel,omitempty"`
893 // ThirdPartyResourcesLabel: This label is for a filter checkbox above a table
894 // of items
895 ThirdPartyResourcesLabel string `json:"thirdPartyResourcesLabel,omitempty"`
896 // ThrottlingProvided: Descriptive explanation for environment throttling that
897 // was provided by the runtime environment instead of provided by Lighthouse
898 // throttling.
899 ThrottlingProvided string `json:"throttlingProvided,omitempty"`
900 // ToplevelWarningsMessage: The label shown preceding important warnings that
901 // may have invalidated an entire report.
902 ToplevelWarningsMessage string `json:"toplevelWarningsMessage,omitempty"`
903 // VarianceDisclaimer: The disclaimer shown below a performance metric value.
904 VarianceDisclaimer string `json:"varianceDisclaimer,omitempty"`
905 // ViewTreemapLabel: Label for a button that opens the Treemap App
906 ViewTreemapLabel string `json:"viewTreemapLabel,omitempty"`
907 // WarningAuditsGroupTitle: The heading that is shown above a list of audits
908 // that have warnings
909 WarningAuditsGroupTitle string `json:"warningAuditsGroupTitle,omitempty"`
910 // WarningHeader: The label shown above a bulleted list of warnings.
911 WarningHeader string `json:"warningHeader,omitempty"`
912 // ForceSendFields is a list of field names (e.g. "AuditGroupExpandTooltip") to
913 // unconditionally include in API requests. By default, fields with empty or
914 // default values are omitted from API requests. See
915 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
916 // details.
917 ForceSendFields []string `json:"-"`
918 // NullFields is a list of field names (e.g. "AuditGroupExpandTooltip") to
919 // include in API requests with the JSON null value. By default, fields with
920 // empty values are omitted from API requests. See
921 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
922 NullFields []string `json:"-"`
923 }
924
925 func (s RendererFormattedStrings) MarshalJSON() ([]byte, error) {
926 type NoMethod RendererFormattedStrings
927 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
928 }
929
930 // RuntimeError: Message containing a runtime error config.
931 type RuntimeError struct {
932 // Code: The enumerated Lighthouse Error code.
933 Code string `json:"code,omitempty"`
934 // Message: A human readable message explaining the error code.
935 Message string `json:"message,omitempty"`
936 // ForceSendFields is a list of field names (e.g. "Code") to unconditionally
937 // include in API requests. By default, fields with empty or default values are
938 // omitted from API requests. See
939 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
940 // details.
941 ForceSendFields []string `json:"-"`
942 // NullFields is a list of field names (e.g. "Code") to include in API requests
943 // with the JSON null value. By default, fields with empty values are omitted
944 // from API requests. See
945 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
946 NullFields []string `json:"-"`
947 }
948
949 func (s RuntimeError) MarshalJSON() ([]byte, error) {
950 type NoMethod RuntimeError
951 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
952 }
953
954 // StackPack: Message containing Stack Pack information.
955 type StackPack struct {
956 // Descriptions: The stack pack advice strings.
957 Descriptions map[string]string `json:"descriptions,omitempty"`
958 // IconDataURL: The stack pack icon data uri.
959 IconDataURL string `json:"iconDataURL,omitempty"`
960 // Id: The stack pack id.
961 Id string `json:"id,omitempty"`
962 // Title: The stack pack title.
963 Title string `json:"title,omitempty"`
964 // ForceSendFields is a list of field names (e.g. "Descriptions") to
965 // unconditionally include in API requests. By default, fields with empty or
966 // default values are omitted from API requests. See
967 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
968 // details.
969 ForceSendFields []string `json:"-"`
970 // NullFields is a list of field names (e.g. "Descriptions") to include in API
971 // requests with the JSON null value. By default, fields with empty values are
972 // omitted from API requests. See
973 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
974 NullFields []string `json:"-"`
975 }
976
977 func (s StackPack) MarshalJSON() ([]byte, error) {
978 type NoMethod StackPack
979 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
980 }
981
982 // Timing: Message containing the performance timing data for the Lighthouse
983 // run.
984 type Timing struct {
985 // Total: The total duration of Lighthouse's run.
986 Total float64 `json:"total,omitempty"`
987 // ForceSendFields is a list of field names (e.g. "Total") to unconditionally
988 // include in API requests. By default, fields with empty or default values are
989 // omitted from API requests. See
990 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
991 // details.
992 ForceSendFields []string `json:"-"`
993 // NullFields is a list of field names (e.g. "Total") to include in API
994 // requests with the JSON null value. By default, fields with empty values are
995 // omitted from API requests. See
996 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
997 NullFields []string `json:"-"`
998 }
999
1000 func (s Timing) MarshalJSON() ([]byte, error) {
1001 type NoMethod Timing
1002 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
1003 }
1004
1005 func (s *Timing) UnmarshalJSON(data []byte) error {
1006 type NoMethod Timing
1007 var s1 struct {
1008 Total gensupport.JSONFloat64 `json:"total"`
1009 *NoMethod
1010 }
1011 s1.NoMethod = (*NoMethod)(s)
1012 if err := json.Unmarshal(data, &s1); err != nil {
1013 return err
1014 }
1015 s.Total = float64(s1.Total)
1016 return nil
1017 }
1018
1019 // UserPageLoadMetricV5: A CrUX metric object for a single metric and form
1020 // factor.
1021 type UserPageLoadMetricV5 struct {
1022 // Category: The category of the specific time metric.
1023 Category string `json:"category,omitempty"`
1024 // Distributions: Metric distributions. Proportions should sum up to 1.
1025 Distributions []*Bucket `json:"distributions,omitempty"`
1026 // FormFactor: Identifies the form factor of the metric being collected.
1027 FormFactor string `json:"formFactor,omitempty"`
1028 // Median: The median number of the metric, in millisecond.
1029 Median int64 `json:"median,omitempty"`
1030 // MetricId: Identifies the type of the metric.
1031 MetricId string `json:"metricId,omitempty"`
1032 // Percentile: We use this field to store certain percentile value for this
1033 // metric. For v4, this field contains pc50. For v5, this field contains pc90.
1034 Percentile int64 `json:"percentile,omitempty"`
1035 // ForceSendFields is a list of field names (e.g. "Category") to
1036 // unconditionally include in API requests. By default, fields with empty or
1037 // default values are omitted from API requests. See
1038 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
1039 // details.
1040 ForceSendFields []string `json:"-"`
1041 // NullFields is a list of field names (e.g. "Category") to include in API
1042 // requests with the JSON null value. By default, fields with empty values are
1043 // omitted from API requests. See
1044 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
1045 NullFields []string `json:"-"`
1046 }
1047
1048 func (s UserPageLoadMetricV5) MarshalJSON() ([]byte, error) {
1049 type NoMethod UserPageLoadMetricV5
1050 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
1051 }
1052
1053 type PagespeedapiRunpagespeedCall struct {
1054 s *Service
1055 urlParams_ gensupport.URLParams
1056 ifNoneMatch_ string
1057 ctx_ context.Context
1058 header_ http.Header
1059 }
1060
1061 // Runpagespeed: Runs PageSpeed analysis on the page at the specified URL, and
1062 // returns PageSpeed scores, a list of suggestions to make that page faster,
1063 // and other information.
1064 //
1065 // - url: The URL to fetch and analyze.
1066 func (r *PagespeedapiService) Runpagespeed(url string) *PagespeedapiRunpagespeedCall {
1067 c := &PagespeedapiRunpagespeedCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1068 c.urlParams_.Set("url", url)
1069 return c
1070 }
1071
1072 // CaptchaToken sets the optional parameter "captchaToken": The captcha token
1073 // passed when filling out a captcha.
1074 func (c *PagespeedapiRunpagespeedCall) CaptchaToken(captchaToken string) *PagespeedapiRunpagespeedCall {
1075 c.urlParams_.Set("captchaToken", captchaToken)
1076 return c
1077 }
1078
1079 // Category sets the optional parameter "category": A Lighthouse category to
1080 // run; if none are given, only Performance category will be run
1081 //
1082 // Possible values:
1083 //
1084 // "CATEGORY_UNSPECIFIED" - Default UNDEFINED category.
1085 // "ACCESSIBILITY" - Accessibility (a11y), category pertaining to a website's
1086 //
1087 // capacity to be accessible to all users.
1088 //
1089 // "BEST_PRACTICES" - Best Practices, category pertaining to a website's
1090 //
1091 // conformance to web best practice.
1092 //
1093 // "PERFORMANCE" - Performance, category pertaining to a website's
1094 //
1095 // performance.
1096 //
1097 // "PWA" - Progressive Web App (PWA), category pertaining to a website's
1098 //
1099 // ability to be run as a PWA. This is deprecated in Lighthouse's 12.0 release.
1100 //
1101 // "SEO" - Search Engine Optimization (SEO), category pertaining to a
1102 //
1103 // website's ability to be indexed by search engines.
1104 func (c *PagespeedapiRunpagespeedCall) Category(category ...string) *PagespeedapiRunpagespeedCall {
1105 c.urlParams_.SetMulti("category", append([]string{}, category...))
1106 return c
1107 }
1108
1109 // Locale sets the optional parameter "locale": The locale used to localize
1110 // formatted results
1111 func (c *PagespeedapiRunpagespeedCall) Locale(locale string) *PagespeedapiRunpagespeedCall {
1112 c.urlParams_.Set("locale", locale)
1113 return c
1114 }
1115
1116 // Strategy sets the optional parameter "strategy": The analysis strategy
1117 // (desktop or mobile) to use, and desktop is the default
1118 //
1119 // Possible values:
1120 //
1121 // "STRATEGY_UNSPECIFIED" - UNDEFINED.
1122 // "DESKTOP" - Fetch and analyze the URL for desktop browsers.
1123 // "MOBILE" - Fetch and analyze the URL for mobile devices.
1124 func (c *PagespeedapiRunpagespeedCall) Strategy(strategy string) *PagespeedapiRunpagespeedCall {
1125 c.urlParams_.Set("strategy", strategy)
1126 return c
1127 }
1128
1129 // UtmCampaign sets the optional parameter "utm_campaign": Campaign name for
1130 // analytics.
1131 func (c *PagespeedapiRunpagespeedCall) UtmCampaign(utmCampaign string) *PagespeedapiRunpagespeedCall {
1132 c.urlParams_.Set("utm_campaign", utmCampaign)
1133 return c
1134 }
1135
1136 // UtmSource sets the optional parameter "utm_source": Campaign source for
1137 // analytics.
1138 func (c *PagespeedapiRunpagespeedCall) UtmSource(utmSource string) *PagespeedapiRunpagespeedCall {
1139 c.urlParams_.Set("utm_source", utmSource)
1140 return c
1141 }
1142
1143 // Fields allows partial responses to be retrieved. See
1144 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
1145 // details.
1146 func (c *PagespeedapiRunpagespeedCall) Fields(s ...googleapi.Field) *PagespeedapiRunpagespeedCall {
1147 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1148 return c
1149 }
1150
1151 // IfNoneMatch sets an optional parameter which makes the operation fail if the
1152 // object's ETag matches the given value. This is useful for getting updates
1153 // only after the object has changed since the last request.
1154 func (c *PagespeedapiRunpagespeedCall) IfNoneMatch(entityTag string) *PagespeedapiRunpagespeedCall {
1155 c.ifNoneMatch_ = entityTag
1156 return c
1157 }
1158
1159 // Context sets the context to be used in this call's Do method.
1160 func (c *PagespeedapiRunpagespeedCall) Context(ctx context.Context) *PagespeedapiRunpagespeedCall {
1161 c.ctx_ = ctx
1162 return c
1163 }
1164
1165 // Header returns a http.Header that can be modified by the caller to add
1166 // headers to the request.
1167 func (c *PagespeedapiRunpagespeedCall) Header() http.Header {
1168 if c.header_ == nil {
1169 c.header_ = make(http.Header)
1170 }
1171 return c.header_
1172 }
1173
1174 func (c *PagespeedapiRunpagespeedCall) doRequest(alt string) (*http.Response, error) {
1175 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1176 if c.ifNoneMatch_ != "" {
1177 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1178 }
1179 c.urlParams_.Set("alt", alt)
1180 c.urlParams_.Set("prettyPrint", "false")
1181 urls := googleapi.ResolveRelative(c.s.BasePath, "pagespeedonline/v5/runPagespeed")
1182 urls += "?" + c.urlParams_.Encode()
1183 req, err := http.NewRequest("GET", urls, nil)
1184 if err != nil {
1185 return nil, err
1186 }
1187 req.Header = reqHeaders
1188 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "pagespeedonline.pagespeedapi.runpagespeed", "request", internallog.HTTPRequest(req, nil))
1189 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1190 }
1191
1192 // Do executes the "pagespeedonline.pagespeedapi.runpagespeed" call.
1193 // Any non-2xx status code is an error. Response headers are in either
1194 // *PagespeedApiPagespeedResponseV5.ServerResponse.Header or (if a response was
1195 // returned at all) in error.(*googleapi.Error).Header. Use
1196 // googleapi.IsNotModified to check whether the returned error was because
1197 // http.StatusNotModified was returned.
1198 func (c *PagespeedapiRunpagespeedCall) Do(opts ...googleapi.CallOption) (*PagespeedApiPagespeedResponseV5, error) {
1199 gensupport.SetOptions(c.urlParams_, opts...)
1200 res, err := c.doRequest("json")
1201 if res != nil && res.StatusCode == http.StatusNotModified {
1202 if res.Body != nil {
1203 res.Body.Close()
1204 }
1205 return nil, gensupport.WrapError(&googleapi.Error{
1206 Code: res.StatusCode,
1207 Header: res.Header,
1208 })
1209 }
1210 if err != nil {
1211 return nil, err
1212 }
1213 defer googleapi.CloseBody(res)
1214 if err := googleapi.CheckResponse(res); err != nil {
1215 return nil, gensupport.WrapError(err)
1216 }
1217 ret := &PagespeedApiPagespeedResponseV5{
1218 ServerResponse: googleapi.ServerResponse{
1219 Header: res.Header,
1220 HTTPStatusCode: res.StatusCode,
1221 },
1222 }
1223 target := &ret
1224 b, err := gensupport.DecodeResponseBytes(target, res)
1225 if err != nil {
1226 return nil, err
1227 }
1228 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "pagespeedonline.pagespeedapi.runpagespeed", "response", internallog.HTTPResponse(res, b))
1229 return ret, nil
1230 }