1 // Copyright 2024 Google LLC. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated file. DO NOT EDIT. 6 7 // Package 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 "net/http" 61 "net/url" 62 "strconv" 63 "strings" 64 65 googleapi "google.golang.org/api/googleapi" 66 internal "google.golang.org/api/internal" 67 gensupport "google.golang.org/api/internal/gensupport" 68 option "google.golang.org/api/option" 69 internaloption "google.golang.org/api/option/internaloption" 70 htransport "google.golang.org/api/transport/http" 71 ) 72 73 // Always reference these packages, just in case the auto-generated code 74 // below doesn't. 75 var _ = bytes.NewBuffer 76 var _ = strconv.Itoa 77 var _ = fmt.Sprintf 78 var _ = json.NewDecoder 79 var _ = io.Copy 80 var _ = url.Parse 81 var _ = gensupport.MarshalJSON 82 var _ = googleapi.Version 83 var _ = errors.New 84 var _ = strings.Replace 85 var _ = context.Canceled 86 var _ = internaloption.WithDefaultEndpoint 87 var _ = internal.Version 88 89 const apiId = "pagespeedonline:v5" 90 const apiName = "pagespeedonline" 91 const apiVersion = "v5" 92 const basePath = "https://pagespeedonline.googleapis.com/" 93 const basePathTemplate = "https://pagespeedonline.UNIVERSE_DOMAIN/" 94 const mtlsBasePath = "https://pagespeedonline.mtls.googleapis.com/" 95 96 // OAuth2 scopes used by this API. 97 const ( 98 // Associate you with your personal info on Google 99 OpenIDScope = "openid" 100 ) 101 102 // NewService creates a new Service. 103 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 104 scopesOption := internaloption.WithDefaultScopes( 105 "openid", 106 ) 107 // NOTE: prepend, so we don't override user-specified scopes. 108 opts = append([]option.ClientOption{scopesOption}, opts...) 109 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 110 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) 111 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 112 opts = append(opts, internaloption.EnableNewAuthLibrary()) 113 client, endpoint, err := htransport.NewClient(ctx, opts...) 114 if err != nil { 115 return nil, err 116 } 117 s, err := New(client) 118 if err != nil { 119 return nil, err 120 } 121 if endpoint != "" { 122 s.BasePath = endpoint 123 } 124 return s, nil 125 } 126 127 // New creates a new Service. It uses the provided http.Client for requests. 128 // 129 // Deprecated: please use NewService instead. 130 // To provide a custom HTTP client, use option.WithHTTPClient. 131 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 132 func New(client *http.Client) (*Service, error) { 133 if client == nil { 134 return nil, errors.New("client is nil") 135 } 136 s := &Service{client: client, BasePath: basePath} 137 s.Pagespeedapi = NewPagespeedapiService(s) 138 return s, nil 139 } 140 141 type Service struct { 142 client *http.Client 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 // NumericUnit: The unit of the numeric_value field. Used to format the numeric 462 // value for display. 463 NumericUnit string `json:"numericUnit,omitempty"` 464 // NumericValue: A numeric value that has a meaning specific to the audit, e.g. 465 // the number of nodes in the DOM or the timestamp of a specific load event. 466 // More information can be found in the audit details, if present. 467 NumericValue float64 `json:"numericValue,omitempty"` 468 // Score: The score of the audit, can be null. 469 Score interface{} `json:"score,omitempty"` 470 // ScoreDisplayMode: The enumerated score display mode. 471 ScoreDisplayMode string `json:"scoreDisplayMode,omitempty"` 472 // Title: The human readable title. 473 Title string `json:"title,omitempty"` 474 // Warnings: Possible warnings that occurred in the audit, can be null. 475 Warnings interface{} `json:"warnings,omitempty"` 476 // ForceSendFields is a list of field names (e.g. "Description") to 477 // unconditionally include in API requests. By default, fields with empty or 478 // default values are omitted from API requests. See 479 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 480 // details. 481 ForceSendFields []string `json:"-"` 482 // NullFields is a list of field names (e.g. "Description") to include in API 483 // requests with the JSON null value. By default, fields with empty values are 484 // omitted from API requests. See 485 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 486 NullFields []string `json:"-"` 487 } 488 489 func (s *LighthouseAuditResultV5) MarshalJSON() ([]byte, error) { 490 type NoMethod LighthouseAuditResultV5 491 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 492 } 493 494 func (s *LighthouseAuditResultV5) UnmarshalJSON(data []byte) error { 495 type NoMethod LighthouseAuditResultV5 496 var s1 struct { 497 NumericValue gensupport.JSONFloat64 `json:"numericValue"` 498 *NoMethod 499 } 500 s1.NoMethod = (*NoMethod)(s) 501 if err := json.Unmarshal(data, &s1); err != nil { 502 return err 503 } 504 s.NumericValue = float64(s1.NumericValue) 505 return nil 506 } 507 508 // LighthouseCategoryV5: A Lighthouse category. 509 type LighthouseCategoryV5 struct { 510 // AuditRefs: An array of references to all the audit members of this category. 511 AuditRefs []*AuditRefs `json:"auditRefs,omitempty"` 512 // Description: A more detailed description of the category and its importance. 513 Description string `json:"description,omitempty"` 514 // Id: The string identifier of the category. 515 Id string `json:"id,omitempty"` 516 // ManualDescription: A description for the manual audits in the category. 517 ManualDescription string `json:"manualDescription,omitempty"` 518 // Score: The overall score of the category, the weighted average of all its 519 // audits. (The category's score, can be null.) 520 Score interface{} `json:"score,omitempty"` 521 // Title: The human-friendly name of the category. 522 Title string `json:"title,omitempty"` 523 // ForceSendFields is a list of field names (e.g. "AuditRefs") to 524 // unconditionally include in API requests. By default, fields with empty or 525 // default values are omitted from API requests. See 526 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 527 // details. 528 ForceSendFields []string `json:"-"` 529 // NullFields is a list of field names (e.g. "AuditRefs") to include in API 530 // requests with the JSON null value. By default, fields with empty values are 531 // omitted from API requests. See 532 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 533 NullFields []string `json:"-"` 534 } 535 536 func (s *LighthouseCategoryV5) MarshalJSON() ([]byte, error) { 537 type NoMethod LighthouseCategoryV5 538 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 539 } 540 541 // LighthouseResultV5: The Lighthouse result object. 542 type LighthouseResultV5 struct { 543 // Audits: Map of audits in the LHR. 544 Audits map[string]LighthouseAuditResultV5 `json:"audits,omitempty"` 545 // Categories: Map of categories in the LHR. 546 Categories *Categories `json:"categories,omitempty"` 547 // CategoryGroups: Map of category groups in the LHR. 548 CategoryGroups map[string]CategoryGroupV5 `json:"categoryGroups,omitempty"` 549 // ConfigSettings: The configuration settings for this LHR. 550 ConfigSettings *ConfigSettings `json:"configSettings,omitempty"` 551 // Entities: Entity classification data. 552 Entities []*LhrEntity `json:"entities,omitempty"` 553 // Environment: Environment settings that were used when making this LHR. 554 Environment *Environment `json:"environment,omitempty"` 555 // FetchTime: The time that this run was fetched. 556 FetchTime string `json:"fetchTime,omitempty"` 557 // FinalDisplayedUrl: URL displayed on the page after Lighthouse finishes. 558 FinalDisplayedUrl string `json:"finalDisplayedUrl,omitempty"` 559 // FinalUrl: The final resolved url that was audited. 560 FinalUrl string `json:"finalUrl,omitempty"` 561 // FullPageScreenshot: Screenshot data of the full page, along with node rects 562 // relevant to the audit results. 563 FullPageScreenshot interface{} `json:"fullPageScreenshot,omitempty"` 564 // I18n: The internationalization strings that are required to render the LHR. 565 I18n *I18n `json:"i18n,omitempty"` 566 // LighthouseVersion: The lighthouse version that was used to generate this 567 // LHR. 568 LighthouseVersion string `json:"lighthouseVersion,omitempty"` 569 // MainDocumentUrl: URL of the main document request of the final navigation. 570 MainDocumentUrl string `json:"mainDocumentUrl,omitempty"` 571 // RequestedUrl: The original requested url. 572 RequestedUrl string `json:"requestedUrl,omitempty"` 573 // RunWarnings: List of all run warnings in the LHR. Will always output to at 574 // least `[]`. 575 RunWarnings []interface{} `json:"runWarnings,omitempty"` 576 // RuntimeError: A top-level error message that, if present, indicates a 577 // serious enough problem that this Lighthouse result may need to be discarded. 578 RuntimeError *RuntimeError `json:"runtimeError,omitempty"` 579 // StackPacks: The Stack Pack advice strings. 580 StackPacks []*StackPack `json:"stackPacks,omitempty"` 581 // Timing: Timing information for this LHR. 582 Timing *Timing `json:"timing,omitempty"` 583 // UserAgent: The user agent that was used to run this LHR. 584 UserAgent string `json:"userAgent,omitempty"` 585 // ForceSendFields is a list of field names (e.g. "Audits") to unconditionally 586 // include in API requests. By default, fields with empty or default values are 587 // omitted from API requests. See 588 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 589 // details. 590 ForceSendFields []string `json:"-"` 591 // NullFields is a list of field names (e.g. "Audits") to include in API 592 // requests with the JSON null value. By default, fields with empty values are 593 // omitted from API requests. See 594 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 595 NullFields []string `json:"-"` 596 } 597 598 func (s *LighthouseResultV5) MarshalJSON() ([]byte, error) { 599 type NoMethod LighthouseResultV5 600 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 601 } 602 603 // PagespeedApiLoadingExperienceV5: The CrUX loading experience object that 604 // contains CrUX data breakdowns. 605 type PagespeedApiLoadingExperienceV5 struct { 606 // Id: The url, pattern or origin which the metrics are on. 607 Id string `json:"id,omitempty"` 608 // InitialUrl: The requested URL, which may differ from the resolved "id". 609 InitialUrl string `json:"initial_url,omitempty"` 610 // Metrics: The map of . 611 Metrics map[string]UserPageLoadMetricV5 `json:"metrics,omitempty"` 612 // OriginFallback: True if the result is an origin fallback from a page, false 613 // otherwise. 614 OriginFallback bool `json:"origin_fallback,omitempty"` 615 // OverallCategory: The human readable speed "category" of the id. 616 OverallCategory string `json:"overall_category,omitempty"` 617 // ForceSendFields is a list of field names (e.g. "Id") to unconditionally 618 // include in API requests. By default, fields with empty or default values are 619 // omitted from API requests. See 620 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 621 // details. 622 ForceSendFields []string `json:"-"` 623 // NullFields is a list of field names (e.g. "Id") to include in API requests 624 // with the JSON null value. By default, fields with empty values are omitted 625 // from API requests. See 626 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 627 NullFields []string `json:"-"` 628 } 629 630 func (s *PagespeedApiLoadingExperienceV5) MarshalJSON() ([]byte, error) { 631 type NoMethod PagespeedApiLoadingExperienceV5 632 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 633 } 634 635 // PagespeedApiPagespeedResponseV5: The Pagespeed API response object. 636 type PagespeedApiPagespeedResponseV5 struct { 637 // AnalysisUTCTimestamp: The UTC timestamp of this analysis. 638 AnalysisUTCTimestamp string `json:"analysisUTCTimestamp,omitempty"` 639 // CaptchaResult: The captcha verify result 640 CaptchaResult string `json:"captchaResult,omitempty"` 641 // Id: Canonicalized and final URL for the document, after following page 642 // redirects (if any). 643 Id string `json:"id,omitempty"` 644 // Kind: Kind of result. 645 Kind string `json:"kind,omitempty"` 646 // LighthouseResult: Lighthouse response for the audit url as an object. 647 LighthouseResult *LighthouseResultV5 `json:"lighthouseResult,omitempty"` 648 // LoadingExperience: Metrics of end users' page loading experience. 649 LoadingExperience *PagespeedApiLoadingExperienceV5 `json:"loadingExperience,omitempty"` 650 // OriginLoadingExperience: Metrics of the aggregated page loading experience 651 // of the origin 652 OriginLoadingExperience *PagespeedApiLoadingExperienceV5 `json:"originLoadingExperience,omitempty"` 653 // Version: The version of PageSpeed used to generate these results. 654 Version *PagespeedVersion `json:"version,omitempty"` 655 656 // ServerResponse contains the HTTP response code and headers from the server. 657 googleapi.ServerResponse `json:"-"` 658 // ForceSendFields is a list of field names (e.g. "AnalysisUTCTimestamp") to 659 // unconditionally include in API requests. By default, fields with empty or 660 // default values are omitted from API requests. See 661 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 662 // details. 663 ForceSendFields []string `json:"-"` 664 // NullFields is a list of field names (e.g. "AnalysisUTCTimestamp") to include 665 // in API requests with the JSON null value. By default, fields with empty 666 // values are omitted from API requests. See 667 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 668 NullFields []string `json:"-"` 669 } 670 671 func (s *PagespeedApiPagespeedResponseV5) MarshalJSON() ([]byte, error) { 672 type NoMethod PagespeedApiPagespeedResponseV5 673 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 674 } 675 676 // PagespeedVersion: The Pagespeed Version object. 677 type PagespeedVersion struct { 678 // Major: The major version number of PageSpeed used to generate these results. 679 Major string `json:"major,omitempty"` 680 // Minor: The minor version number of PageSpeed used to generate these results. 681 Minor string `json:"minor,omitempty"` 682 // ForceSendFields is a list of field names (e.g. "Major") to unconditionally 683 // include in API requests. By default, fields with empty or default values are 684 // omitted from API requests. See 685 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 686 // details. 687 ForceSendFields []string `json:"-"` 688 // NullFields is a list of field names (e.g. "Major") to include in API 689 // requests with the JSON null value. By default, fields with empty values are 690 // omitted from API requests. See 691 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 692 NullFields []string `json:"-"` 693 } 694 695 func (s *PagespeedVersion) MarshalJSON() ([]byte, error) { 696 type NoMethod PagespeedVersion 697 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 698 } 699 700 // RendererFormattedStrings: Message holding the formatted strings used in the 701 // renderer. 702 type RendererFormattedStrings struct { 703 // AuditGroupExpandTooltip: The tooltip text on an expandable chevron icon. 704 AuditGroupExpandTooltip string `json:"auditGroupExpandTooltip,omitempty"` 705 // CalculatorLink: Text link pointing to the Lighthouse scoring calculator. 706 // This link immediately follows a sentence stating the performance score is 707 // calculated from the perf metrics. 708 CalculatorLink string `json:"calculatorLink,omitempty"` 709 // CrcInitialNavigation: The label for the initial request in a critical 710 // request chain. 711 CrcInitialNavigation string `json:"crcInitialNavigation,omitempty"` 712 // CrcLongestDurationLabel: The label for values shown in the summary of 713 // critical request chains. 714 CrcLongestDurationLabel string `json:"crcLongestDurationLabel,omitempty"` 715 // DropdownCopyJSON: Option in a dropdown menu that copies the Lighthouse JSON 716 // object to the system clipboard. 717 DropdownCopyJSON string `json:"dropdownCopyJSON,omitempty"` 718 // DropdownDarkTheme: Option in a dropdown menu that toggles the themeing of 719 // the report between Light(default) and Dark themes. 720 DropdownDarkTheme string `json:"dropdownDarkTheme,omitempty"` 721 // DropdownPrintExpanded: Option in a dropdown menu that opens a full 722 // Lighthouse report in a print dialog. 723 DropdownPrintExpanded string `json:"dropdownPrintExpanded,omitempty"` 724 // DropdownPrintSummary: Option in a dropdown menu that opens a small, summary 725 // report in a print dialog. 726 DropdownPrintSummary string `json:"dropdownPrintSummary,omitempty"` 727 // DropdownSaveGist: Option in a dropdown menu that saves the current report as 728 // a new GitHub Gist. 729 DropdownSaveGist string `json:"dropdownSaveGist,omitempty"` 730 // DropdownSaveHTML: Option in a dropdown menu that saves the Lighthouse report 731 // HTML locally to the system as a '.html' file. 732 DropdownSaveHTML string `json:"dropdownSaveHTML,omitempty"` 733 // DropdownSaveJSON: Option in a dropdown menu that saves the Lighthouse JSON 734 // object to the local system as a '.json' file. 735 DropdownSaveJSON string `json:"dropdownSaveJSON,omitempty"` 736 // DropdownViewer: Option in a dropdown menu that opens the current report in 737 // the Lighthouse Viewer Application. 738 DropdownViewer string `json:"dropdownViewer,omitempty"` 739 // ErrorLabel: The label shown next to an audit or metric that has had an 740 // error. 741 ErrorLabel string `json:"errorLabel,omitempty"` 742 // ErrorMissingAuditInfo: The error string shown next to an erroring audit. 743 ErrorMissingAuditInfo string `json:"errorMissingAuditInfo,omitempty"` 744 // FooterIssue: Label for button to create an issue against the Lighthouse 745 // GitHub project. 746 FooterIssue string `json:"footerIssue,omitempty"` 747 // LabDataTitle: The title of the lab data performance category. 748 LabDataTitle string `json:"labDataTitle,omitempty"` 749 // LsPerformanceCategoryDescription: The disclaimer shown under performance 750 // explaining that the network can vary. 751 LsPerformanceCategoryDescription string `json:"lsPerformanceCategoryDescription,omitempty"` 752 // ManualAuditsGroupTitle: The heading shown above a list of audits that were 753 // not computerd in the run. 754 ManualAuditsGroupTitle string `json:"manualAuditsGroupTitle,omitempty"` 755 // NotApplicableAuditsGroupTitle: The heading shown above a list of audits that 756 // do not apply to a page. 757 NotApplicableAuditsGroupTitle string `json:"notApplicableAuditsGroupTitle,omitempty"` 758 // OpportunityResourceColumnLabel: The heading for the estimated page load 759 // savings opportunity of an audit. 760 OpportunityResourceColumnLabel string `json:"opportunityResourceColumnLabel,omitempty"` 761 // OpportunitySavingsColumnLabel: The heading for the estimated page load 762 // savings of opportunity audits. 763 OpportunitySavingsColumnLabel string `json:"opportunitySavingsColumnLabel,omitempty"` 764 // PassedAuditsGroupTitle: The heading that is shown above a list of audits 765 // that are passing. 766 PassedAuditsGroupTitle string `json:"passedAuditsGroupTitle,omitempty"` 767 // RuntimeDesktopEmulation: Descriptive explanation for emulation setting when 768 // emulating a generic desktop form factor, as opposed to a mobile-device like 769 // form factor. 770 RuntimeDesktopEmulation string `json:"runtimeDesktopEmulation,omitempty"` 771 // RuntimeMobileEmulation: Descriptive explanation for emulation setting when 772 // emulating a Nexus 5X mobile device. 773 RuntimeMobileEmulation string `json:"runtimeMobileEmulation,omitempty"` 774 // RuntimeNoEmulation: Descriptive explanation for emulation setting when no 775 // device emulation is set. 776 RuntimeNoEmulation string `json:"runtimeNoEmulation,omitempty"` 777 // RuntimeSettingsAxeVersion: Label for a row in a table that shows the version 778 // of the Axe library used 779 RuntimeSettingsAxeVersion string `json:"runtimeSettingsAxeVersion,omitempty"` 780 // RuntimeSettingsBenchmark: Label for a row in a table that shows the 781 // estimated CPU power of the machine running Lighthouse. Example row values: 782 // 532, 1492, 783. 783 RuntimeSettingsBenchmark string `json:"runtimeSettingsBenchmark,omitempty"` 784 // RuntimeSettingsCPUThrottling: Label for a row in a table that describes the 785 // CPU throttling conditions that were used during a Lighthouse run, if any. 786 RuntimeSettingsCPUThrottling string `json:"runtimeSettingsCPUThrottling,omitempty"` 787 // RuntimeSettingsChannel: Label for a row in a table that shows in what tool 788 // Lighthouse is being run (e.g. The lighthouse CLI, Chrome DevTools, 789 // Lightrider, WebPageTest, etc). 790 RuntimeSettingsChannel string `json:"runtimeSettingsChannel,omitempty"` 791 // RuntimeSettingsDevice: Label for a row in a table that describes the kind of 792 // device that was emulated for the Lighthouse run. Example values for row 793 // elements: 'No Emulation', 'Emulated Desktop', etc. 794 RuntimeSettingsDevice string `json:"runtimeSettingsDevice,omitempty"` 795 // RuntimeSettingsFetchTime: Label for a row in a table that shows the time at 796 // which a Lighthouse run was conducted; formatted as a timestamp, e.g. Jan 1, 797 // 1970 12:00 AM UTC. 798 RuntimeSettingsFetchTime string `json:"runtimeSettingsFetchTime,omitempty"` 799 // RuntimeSettingsNetworkThrottling: Label for a row in a table that describes 800 // the network throttling conditions that were used during a Lighthouse run, if 801 // any. 802 RuntimeSettingsNetworkThrottling string `json:"runtimeSettingsNetworkThrottling,omitempty"` 803 // RuntimeSettingsTitle: Title of the Runtime settings table in a Lighthouse 804 // report. Runtime settings are the environment configurations that a specific 805 // report used at auditing time. 806 RuntimeSettingsTitle string `json:"runtimeSettingsTitle,omitempty"` 807 // RuntimeSettingsUA: Label for a row in a table that shows the User Agent that 808 // was detected on the Host machine that ran Lighthouse. 809 RuntimeSettingsUA string `json:"runtimeSettingsUA,omitempty"` 810 // RuntimeSettingsUANetwork: Label for a row in a table that shows the User 811 // Agent that was used to send out all network requests during the Lighthouse 812 // run. 813 RuntimeSettingsUANetwork string `json:"runtimeSettingsUANetwork,omitempty"` 814 // RuntimeSettingsUrl: Label for a row in a table that shows the URL that was 815 // audited during a Lighthouse run. 816 RuntimeSettingsUrl string `json:"runtimeSettingsUrl,omitempty"` 817 // RuntimeUnknown: Descriptive explanation for a runtime setting that is set to 818 // an unknown value. 819 RuntimeUnknown string `json:"runtimeUnknown,omitempty"` 820 // ScorescaleLabel: The label that explains the score gauges scale (0-49, 821 // 50-89, 90-100). 822 ScorescaleLabel string `json:"scorescaleLabel,omitempty"` 823 // ShowRelevantAudits: Label preceding a radio control for filtering the list 824 // of audits. The radio choices are various performance metrics (FCP, LCP, 825 // TBT), and if chosen, the audits in the report are hidden if they are not 826 // relevant to the selected metric. 827 ShowRelevantAudits string `json:"showRelevantAudits,omitempty"` 828 // SnippetCollapseButtonLabel: The label for the button to show only a few 829 // lines of a snippet 830 SnippetCollapseButtonLabel string `json:"snippetCollapseButtonLabel,omitempty"` 831 // SnippetExpandButtonLabel: The label for the button to show all lines of a 832 // snippet 833 SnippetExpandButtonLabel string `json:"snippetExpandButtonLabel,omitempty"` 834 // ThirdPartyResourcesLabel: This label is for a filter checkbox above a table 835 // of items 836 ThirdPartyResourcesLabel string `json:"thirdPartyResourcesLabel,omitempty"` 837 // ThrottlingProvided: Descriptive explanation for environment throttling that 838 // was provided by the runtime environment instead of provided by Lighthouse 839 // throttling. 840 ThrottlingProvided string `json:"throttlingProvided,omitempty"` 841 // ToplevelWarningsMessage: The label shown preceding important warnings that 842 // may have invalidated an entire report. 843 ToplevelWarningsMessage string `json:"toplevelWarningsMessage,omitempty"` 844 // VarianceDisclaimer: The disclaimer shown below a performance metric value. 845 VarianceDisclaimer string `json:"varianceDisclaimer,omitempty"` 846 // ViewTreemapLabel: Label for a button that opens the Treemap App 847 ViewTreemapLabel string `json:"viewTreemapLabel,omitempty"` 848 // WarningAuditsGroupTitle: The heading that is shown above a list of audits 849 // that have warnings 850 WarningAuditsGroupTitle string `json:"warningAuditsGroupTitle,omitempty"` 851 // WarningHeader: The label shown above a bulleted list of warnings. 852 WarningHeader string `json:"warningHeader,omitempty"` 853 // ForceSendFields is a list of field names (e.g. "AuditGroupExpandTooltip") to 854 // unconditionally include in API requests. By default, fields with empty or 855 // default values are omitted from API requests. See 856 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 857 // details. 858 ForceSendFields []string `json:"-"` 859 // NullFields is a list of field names (e.g. "AuditGroupExpandTooltip") to 860 // include in API requests with the JSON null value. By default, fields with 861 // empty values are omitted from API requests. See 862 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 863 NullFields []string `json:"-"` 864 } 865 866 func (s *RendererFormattedStrings) MarshalJSON() ([]byte, error) { 867 type NoMethod RendererFormattedStrings 868 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 869 } 870 871 // RuntimeError: Message containing a runtime error config. 872 type RuntimeError struct { 873 // Code: The enumerated Lighthouse Error code. 874 Code string `json:"code,omitempty"` 875 // Message: A human readable message explaining the error code. 876 Message string `json:"message,omitempty"` 877 // ForceSendFields is a list of field names (e.g. "Code") to unconditionally 878 // include in API requests. By default, fields with empty or default values are 879 // omitted from API requests. See 880 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 881 // details. 882 ForceSendFields []string `json:"-"` 883 // NullFields is a list of field names (e.g. "Code") to include in API requests 884 // with the JSON null value. By default, fields with empty values are omitted 885 // from API requests. See 886 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 887 NullFields []string `json:"-"` 888 } 889 890 func (s *RuntimeError) MarshalJSON() ([]byte, error) { 891 type NoMethod RuntimeError 892 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 893 } 894 895 // StackPack: Message containing Stack Pack information. 896 type StackPack struct { 897 // Descriptions: The stack pack advice strings. 898 Descriptions map[string]string `json:"descriptions,omitempty"` 899 // IconDataURL: The stack pack icon data uri. 900 IconDataURL string `json:"iconDataURL,omitempty"` 901 // Id: The stack pack id. 902 Id string `json:"id,omitempty"` 903 // Title: The stack pack title. 904 Title string `json:"title,omitempty"` 905 // ForceSendFields is a list of field names (e.g. "Descriptions") to 906 // unconditionally include in API requests. By default, fields with empty or 907 // default values are omitted from API requests. See 908 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 909 // details. 910 ForceSendFields []string `json:"-"` 911 // NullFields is a list of field names (e.g. "Descriptions") to include in API 912 // requests with the JSON null value. By default, fields with empty values are 913 // omitted from API requests. See 914 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 915 NullFields []string `json:"-"` 916 } 917 918 func (s *StackPack) MarshalJSON() ([]byte, error) { 919 type NoMethod StackPack 920 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 921 } 922 923 // Timing: Message containing the performance timing data for the Lighthouse 924 // run. 925 type Timing struct { 926 // Total: The total duration of Lighthouse's run. 927 Total float64 `json:"total,omitempty"` 928 // ForceSendFields is a list of field names (e.g. "Total") to unconditionally 929 // include in API requests. By default, fields with empty or default values are 930 // omitted from API requests. See 931 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 932 // details. 933 ForceSendFields []string `json:"-"` 934 // NullFields is a list of field names (e.g. "Total") to include in API 935 // requests with the JSON null value. By default, fields with empty values are 936 // omitted from API requests. See 937 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 938 NullFields []string `json:"-"` 939 } 940 941 func (s *Timing) MarshalJSON() ([]byte, error) { 942 type NoMethod Timing 943 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 944 } 945 946 func (s *Timing) UnmarshalJSON(data []byte) error { 947 type NoMethod Timing 948 var s1 struct { 949 Total gensupport.JSONFloat64 `json:"total"` 950 *NoMethod 951 } 952 s1.NoMethod = (*NoMethod)(s) 953 if err := json.Unmarshal(data, &s1); err != nil { 954 return err 955 } 956 s.Total = float64(s1.Total) 957 return nil 958 } 959 960 // UserPageLoadMetricV5: A CrUX metric object for a single metric and form 961 // factor. 962 type UserPageLoadMetricV5 struct { 963 // Category: The category of the specific time metric. 964 Category string `json:"category,omitempty"` 965 // Distributions: Metric distributions. Proportions should sum up to 1. 966 Distributions []*Bucket `json:"distributions,omitempty"` 967 // FormFactor: Identifies the form factor of the metric being collected. 968 FormFactor string `json:"formFactor,omitempty"` 969 // Median: The median number of the metric, in millisecond. 970 Median int64 `json:"median,omitempty"` 971 // MetricId: Identifies the type of the metric. 972 MetricId string `json:"metricId,omitempty"` 973 // Percentile: We use this field to store certain percentile value for this 974 // metric. For v4, this field contains pc50. For v5, this field contains pc90. 975 Percentile int64 `json:"percentile,omitempty"` 976 // ForceSendFields is a list of field names (e.g. "Category") to 977 // unconditionally include in API requests. By default, fields with empty or 978 // default values are omitted from API requests. See 979 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 980 // details. 981 ForceSendFields []string `json:"-"` 982 // NullFields is a list of field names (e.g. "Category") to include in API 983 // requests with the JSON null value. By default, fields with empty values are 984 // omitted from API requests. See 985 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 986 NullFields []string `json:"-"` 987 } 988 989 func (s *UserPageLoadMetricV5) MarshalJSON() ([]byte, error) { 990 type NoMethod UserPageLoadMetricV5 991 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 992 } 993 994 type PagespeedapiRunpagespeedCall struct { 995 s *Service 996 urlParams_ gensupport.URLParams 997 ifNoneMatch_ string 998 ctx_ context.Context 999 header_ http.Header 1000 } 1001 1002 // Runpagespeed: Runs PageSpeed analysis on the page at the specified URL, and 1003 // returns PageSpeed scores, a list of suggestions to make that page faster, 1004 // and other information. 1005 // 1006 // - url: The URL to fetch and analyze. 1007 func (r *PagespeedapiService) Runpagespeed(url string) *PagespeedapiRunpagespeedCall { 1008 c := &PagespeedapiRunpagespeedCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1009 c.urlParams_.Set("url", url) 1010 return c 1011 } 1012 1013 // CaptchaToken sets the optional parameter "captchaToken": The captcha token 1014 // passed when filling out a captcha. 1015 func (c *PagespeedapiRunpagespeedCall) CaptchaToken(captchaToken string) *PagespeedapiRunpagespeedCall { 1016 c.urlParams_.Set("captchaToken", captchaToken) 1017 return c 1018 } 1019 1020 // Category sets the optional parameter "category": A Lighthouse category to 1021 // run; if none are given, only Performance category will be run 1022 // 1023 // Possible values: 1024 // 1025 // "CATEGORY_UNSPECIFIED" - Default UNDEFINED category. 1026 // "ACCESSIBILITY" - Accessibility (a11y), category pertaining to a website's 1027 // 1028 // capacity to be accessible to all users. 1029 // 1030 // "BEST_PRACTICES" - Best Practices, category pertaining to a website's 1031 // 1032 // conformance to web best practice. 1033 // 1034 // "PERFORMANCE" - Performance, category pertaining to a website's 1035 // 1036 // performance. 1037 // 1038 // "PWA" - Progressive Web App (PWA), category pertaining to a website's 1039 // 1040 // ability to be run as a PWA. This is deprecated in Lighthouse's 12.0 release. 1041 // 1042 // "SEO" - Search Engine Optimization (SEO), category pertaining to a 1043 // 1044 // website's ability to be indexed by search engines. 1045 func (c *PagespeedapiRunpagespeedCall) Category(category ...string) *PagespeedapiRunpagespeedCall { 1046 c.urlParams_.SetMulti("category", append([]string{}, category...)) 1047 return c 1048 } 1049 1050 // Locale sets the optional parameter "locale": The locale used to localize 1051 // formatted results 1052 func (c *PagespeedapiRunpagespeedCall) Locale(locale string) *PagespeedapiRunpagespeedCall { 1053 c.urlParams_.Set("locale", locale) 1054 return c 1055 } 1056 1057 // Strategy sets the optional parameter "strategy": The analysis strategy 1058 // (desktop or mobile) to use, and desktop is the default 1059 // 1060 // Possible values: 1061 // 1062 // "STRATEGY_UNSPECIFIED" - UNDEFINED. 1063 // "DESKTOP" - Fetch and analyze the URL for desktop browsers. 1064 // "MOBILE" - Fetch and analyze the URL for mobile devices. 1065 func (c *PagespeedapiRunpagespeedCall) Strategy(strategy string) *PagespeedapiRunpagespeedCall { 1066 c.urlParams_.Set("strategy", strategy) 1067 return c 1068 } 1069 1070 // UtmCampaign sets the optional parameter "utm_campaign": Campaign name for 1071 // analytics. 1072 func (c *PagespeedapiRunpagespeedCall) UtmCampaign(utmCampaign string) *PagespeedapiRunpagespeedCall { 1073 c.urlParams_.Set("utm_campaign", utmCampaign) 1074 return c 1075 } 1076 1077 // UtmSource sets the optional parameter "utm_source": Campaign source for 1078 // analytics. 1079 func (c *PagespeedapiRunpagespeedCall) UtmSource(utmSource string) *PagespeedapiRunpagespeedCall { 1080 c.urlParams_.Set("utm_source", utmSource) 1081 return c 1082 } 1083 1084 // Fields allows partial responses to be retrieved. See 1085 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1086 // details. 1087 func (c *PagespeedapiRunpagespeedCall) Fields(s ...googleapi.Field) *PagespeedapiRunpagespeedCall { 1088 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1089 return c 1090 } 1091 1092 // IfNoneMatch sets an optional parameter which makes the operation fail if the 1093 // object's ETag matches the given value. This is useful for getting updates 1094 // only after the object has changed since the last request. 1095 func (c *PagespeedapiRunpagespeedCall) IfNoneMatch(entityTag string) *PagespeedapiRunpagespeedCall { 1096 c.ifNoneMatch_ = entityTag 1097 return c 1098 } 1099 1100 // Context sets the context to be used in this call's Do method. 1101 func (c *PagespeedapiRunpagespeedCall) Context(ctx context.Context) *PagespeedapiRunpagespeedCall { 1102 c.ctx_ = ctx 1103 return c 1104 } 1105 1106 // Header returns a http.Header that can be modified by the caller to add 1107 // headers to the request. 1108 func (c *PagespeedapiRunpagespeedCall) Header() http.Header { 1109 if c.header_ == nil { 1110 c.header_ = make(http.Header) 1111 } 1112 return c.header_ 1113 } 1114 1115 func (c *PagespeedapiRunpagespeedCall) doRequest(alt string) (*http.Response, error) { 1116 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 1117 if c.ifNoneMatch_ != "" { 1118 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1119 } 1120 var body io.Reader = nil 1121 c.urlParams_.Set("alt", alt) 1122 c.urlParams_.Set("prettyPrint", "false") 1123 urls := googleapi.ResolveRelative(c.s.BasePath, "pagespeedonline/v5/runPagespeed") 1124 urls += "?" + c.urlParams_.Encode() 1125 req, err := http.NewRequest("GET", urls, body) 1126 if err != nil { 1127 return nil, err 1128 } 1129 req.Header = reqHeaders 1130 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1131 } 1132 1133 // Do executes the "pagespeedonline.pagespeedapi.runpagespeed" call. 1134 // Any non-2xx status code is an error. Response headers are in either 1135 // *PagespeedApiPagespeedResponseV5.ServerResponse.Header or (if a response was 1136 // returned at all) in error.(*googleapi.Error).Header. Use 1137 // googleapi.IsNotModified to check whether the returned error was because 1138 // http.StatusNotModified was returned. 1139 func (c *PagespeedapiRunpagespeedCall) Do(opts ...googleapi.CallOption) (*PagespeedApiPagespeedResponseV5, error) { 1140 gensupport.SetOptions(c.urlParams_, opts...) 1141 res, err := c.doRequest("json") 1142 if res != nil && res.StatusCode == http.StatusNotModified { 1143 if res.Body != nil { 1144 res.Body.Close() 1145 } 1146 return nil, gensupport.WrapError(&googleapi.Error{ 1147 Code: res.StatusCode, 1148 Header: res.Header, 1149 }) 1150 } 1151 if err != nil { 1152 return nil, err 1153 } 1154 defer googleapi.CloseBody(res) 1155 if err := googleapi.CheckResponse(res); err != nil { 1156 return nil, gensupport.WrapError(err) 1157 } 1158 ret := &PagespeedApiPagespeedResponseV5{ 1159 ServerResponse: googleapi.ServerResponse{ 1160 Header: res.Header, 1161 HTTPStatusCode: res.StatusCode, 1162 }, 1163 } 1164 target := &ret 1165 if err := gensupport.DecodeResponse(target, res); err != nil { 1166 return nil, err 1167 } 1168 return ret, nil 1169 } 1170