You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1142 lines
43 KiB

  1. // Copyright 2019 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. // Code generated file. DO NOT EDIT.
  5. // Package pagespeedonline provides access to the PageSpeed Insights API.
  6. //
  7. // For product documentation, see: https://developers.google.com/speed/docs/insights/v5/get-started
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/pagespeedonline/v5"
  14. // ...
  15. // ctx := context.Background()
  16. // pagespeedonlineService, err := pagespeedonline.NewService(ctx)
  17. //
  18. // In this example, Google Application Default Credentials are used for authentication.
  19. //
  20. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  21. //
  22. // Other authentication options
  23. //
  24. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  25. //
  26. // pagespeedonlineService, err := pagespeedonline.NewService(ctx, option.WithAPIKey("AIza..."))
  27. //
  28. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  29. //
  30. // config := &oauth2.Config{...}
  31. // // ...
  32. // token, err := config.Exchange(ctx, ...)
  33. // pagespeedonlineService, err := pagespeedonline.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  34. //
  35. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  36. package pagespeedonline // import "google.golang.org/api/pagespeedonline/v5"
  37. import (
  38. "bytes"
  39. "context"
  40. "encoding/json"
  41. "errors"
  42. "fmt"
  43. "io"
  44. "net/http"
  45. "net/url"
  46. "strconv"
  47. "strings"
  48. gensupport "google.golang.org/api/gensupport"
  49. googleapi "google.golang.org/api/googleapi"
  50. option "google.golang.org/api/option"
  51. htransport "google.golang.org/api/transport/http"
  52. )
  53. // Always reference these packages, just in case the auto-generated code
  54. // below doesn't.
  55. var _ = bytes.NewBuffer
  56. var _ = strconv.Itoa
  57. var _ = fmt.Sprintf
  58. var _ = json.NewDecoder
  59. var _ = io.Copy
  60. var _ = url.Parse
  61. var _ = gensupport.MarshalJSON
  62. var _ = googleapi.Version
  63. var _ = errors.New
  64. var _ = strings.Replace
  65. var _ = context.Canceled
  66. const apiId = "pagespeedonline:v5"
  67. const apiName = "pagespeedonline"
  68. const apiVersion = "v5"
  69. const basePath = "https://www.googleapis.com/pagespeedonline/v5/"
  70. // NewService creates a new Service.
  71. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  72. client, endpoint, err := htransport.NewClient(ctx, opts...)
  73. if err != nil {
  74. return nil, err
  75. }
  76. s, err := New(client)
  77. if err != nil {
  78. return nil, err
  79. }
  80. if endpoint != "" {
  81. s.BasePath = endpoint
  82. }
  83. return s, nil
  84. }
  85. // New creates a new Service. It uses the provided http.Client for requests.
  86. //
  87. // Deprecated: please use NewService instead.
  88. // To provide a custom HTTP client, use option.WithHTTPClient.
  89. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  90. func New(client *http.Client) (*Service, error) {
  91. if client == nil {
  92. return nil, errors.New("client is nil")
  93. }
  94. s := &Service{client: client, BasePath: basePath}
  95. s.Pagespeedapi = NewPagespeedapiService(s)
  96. return s, nil
  97. }
  98. type Service struct {
  99. client *http.Client
  100. BasePath string // API endpoint base URL
  101. UserAgent string // optional additional User-Agent fragment
  102. Pagespeedapi *PagespeedapiService
  103. }
  104. func (s *Service) userAgent() string {
  105. if s.UserAgent == "" {
  106. return googleapi.UserAgent
  107. }
  108. return googleapi.UserAgent + " " + s.UserAgent
  109. }
  110. func NewPagespeedapiService(s *Service) *PagespeedapiService {
  111. rs := &PagespeedapiService{s: s}
  112. return rs
  113. }
  114. type PagespeedapiService struct {
  115. s *Service
  116. }
  117. type GoogleprotobufValue interface{}
  118. type LighthouseAuditResultV5 struct {
  119. // Description: The description of the audit.
  120. Description string `json:"description,omitempty"`
  121. // Details: Freeform details section of the audit.
  122. Details googleapi.RawMessage `json:"details,omitempty"`
  123. // DisplayValue: The value that should be displayed on the UI for this
  124. // audit.
  125. DisplayValue string `json:"displayValue,omitempty"`
  126. // ErrorMessage: An error message from a thrown error inside the audit.
  127. ErrorMessage string `json:"errorMessage,omitempty"`
  128. // Explanation: An explanation of the errors in the audit.
  129. Explanation string `json:"explanation,omitempty"`
  130. // Id: The audit's id.
  131. Id string `json:"id,omitempty"`
  132. Score interface{} `json:"score,omitempty"`
  133. // ScoreDisplayMode: The enumerated score display mode.
  134. ScoreDisplayMode string `json:"scoreDisplayMode,omitempty"`
  135. // Title: The human readable title.
  136. Title string `json:"title,omitempty"`
  137. Warnings interface{} `json:"warnings,omitempty"`
  138. // ForceSendFields is a list of field names (e.g. "Description") to
  139. // unconditionally include in API requests. By default, fields with
  140. // empty values are omitted from API requests. However, any non-pointer,
  141. // non-interface field appearing in ForceSendFields will be sent to the
  142. // server regardless of whether the field is empty or not. This may be
  143. // used to include empty fields in Patch requests.
  144. ForceSendFields []string `json:"-"`
  145. // NullFields is a list of field names (e.g. "Description") to include
  146. // in API requests with the JSON null value. By default, fields with
  147. // empty values are omitted from API requests. However, any field with
  148. // an empty value appearing in NullFields will be sent to the server as
  149. // null. It is an error if a field in this list has a non-empty value.
  150. // This may be used to include null fields in Patch requests.
  151. NullFields []string `json:"-"`
  152. }
  153. func (s *LighthouseAuditResultV5) MarshalJSON() ([]byte, error) {
  154. type NoMethod LighthouseAuditResultV5
  155. raw := NoMethod(*s)
  156. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  157. }
  158. type LighthouseCategoryV5 struct {
  159. // AuditRefs: An array of references to all the audit members of this
  160. // category.
  161. AuditRefs []*LighthouseCategoryV5AuditRefs `json:"auditRefs,omitempty"`
  162. // Description: A more detailed description of the category and its
  163. // importance.
  164. Description string `json:"description,omitempty"`
  165. // Id: The string identifier of the category.
  166. Id string `json:"id,omitempty"`
  167. // ManualDescription: A description for the manual audits in the
  168. // category.
  169. ManualDescription string `json:"manualDescription,omitempty"`
  170. Score interface{} `json:"score,omitempty"`
  171. // Title: The human-friendly name of the category.
  172. Title string `json:"title,omitempty"`
  173. // ForceSendFields is a list of field names (e.g. "AuditRefs") to
  174. // unconditionally include in API requests. By default, fields with
  175. // empty values are omitted from API requests. However, any non-pointer,
  176. // non-interface field appearing in ForceSendFields will be sent to the
  177. // server regardless of whether the field is empty or not. This may be
  178. // used to include empty fields in Patch requests.
  179. ForceSendFields []string `json:"-"`
  180. // NullFields is a list of field names (e.g. "AuditRefs") to include in
  181. // API requests with the JSON null value. By default, fields with empty
  182. // values are omitted from API requests. However, any field with an
  183. // empty value appearing in NullFields will be sent to the server as
  184. // null. It is an error if a field in this list has a non-empty value.
  185. // This may be used to include null fields in Patch requests.
  186. NullFields []string `json:"-"`
  187. }
  188. func (s *LighthouseCategoryV5) MarshalJSON() ([]byte, error) {
  189. type NoMethod LighthouseCategoryV5
  190. raw := NoMethod(*s)
  191. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  192. }
  193. type LighthouseCategoryV5AuditRefs struct {
  194. // Group: The category group that the audit belongs to (optional).
  195. Group string `json:"group,omitempty"`
  196. // Id: The audit ref id.
  197. Id string `json:"id,omitempty"`
  198. // Weight: The weight this audit's score has on the overall category
  199. // score.
  200. Weight float64 `json:"weight,omitempty"`
  201. // ForceSendFields is a list of field names (e.g. "Group") to
  202. // unconditionally include in API requests. By default, fields with
  203. // empty values are omitted from API requests. However, any non-pointer,
  204. // non-interface field appearing in ForceSendFields will be sent to the
  205. // server regardless of whether the field is empty or not. This may be
  206. // used to include empty fields in Patch requests.
  207. ForceSendFields []string `json:"-"`
  208. // NullFields is a list of field names (e.g. "Group") to include in API
  209. // requests with the JSON null value. By default, fields with empty
  210. // values are omitted from API requests. However, any field with an
  211. // empty value appearing in NullFields will be sent to the server as
  212. // null. It is an error if a field in this list has a non-empty value.
  213. // This may be used to include null fields in Patch requests.
  214. NullFields []string `json:"-"`
  215. }
  216. func (s *LighthouseCategoryV5AuditRefs) MarshalJSON() ([]byte, error) {
  217. type NoMethod LighthouseCategoryV5AuditRefs
  218. raw := NoMethod(*s)
  219. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  220. }
  221. func (s *LighthouseCategoryV5AuditRefs) UnmarshalJSON(data []byte) error {
  222. type NoMethod LighthouseCategoryV5AuditRefs
  223. var s1 struct {
  224. Weight gensupport.JSONFloat64 `json:"weight"`
  225. *NoMethod
  226. }
  227. s1.NoMethod = (*NoMethod)(s)
  228. if err := json.Unmarshal(data, &s1); err != nil {
  229. return err
  230. }
  231. s.Weight = float64(s1.Weight)
  232. return nil
  233. }
  234. type LighthouseResultV5 struct {
  235. // Audits: Map of audits in the LHR.
  236. Audits map[string]LighthouseAuditResultV5 `json:"audits,omitempty"`
  237. // Categories: Map of categories in the LHR.
  238. Categories *LighthouseResultV5Categories `json:"categories,omitempty"`
  239. // CategoryGroups: Map of category groups in the LHR.
  240. CategoryGroups map[string]LighthouseResultV5CategoryGroups `json:"categoryGroups,omitempty"`
  241. // ConfigSettings: The configuration settings for this LHR.
  242. ConfigSettings *LighthouseResultV5ConfigSettings `json:"configSettings,omitempty"`
  243. // Environment: Environment settings that were used when making this
  244. // LHR.
  245. Environment *LighthouseResultV5Environment `json:"environment,omitempty"`
  246. // FetchTime: The time that this run was fetched.
  247. FetchTime string `json:"fetchTime,omitempty"`
  248. // FinalUrl: The final resolved url that was audited.
  249. FinalUrl string `json:"finalUrl,omitempty"`
  250. // I18n: The internationalization strings that are required to render
  251. // the LHR.
  252. I18n *LighthouseResultV5I18n `json:"i18n,omitempty"`
  253. // LighthouseVersion: The lighthouse version that was used to generate
  254. // this LHR.
  255. LighthouseVersion string `json:"lighthouseVersion,omitempty"`
  256. // RequestedUrl: The original requested url.
  257. RequestedUrl string `json:"requestedUrl,omitempty"`
  258. // RunWarnings: List of all run warnings in the LHR. Will always output
  259. // to at least `[]`.
  260. RunWarnings []interface{} `json:"runWarnings,omitempty"`
  261. // RuntimeError: A top-level error message that, if present, indicates a
  262. // serious enough problem that this Lighthouse result may need to be
  263. // discarded.
  264. RuntimeError *LighthouseResultV5RuntimeError `json:"runtimeError,omitempty"`
  265. // Timing: Timing information for this LHR.
  266. Timing *LighthouseResultV5Timing `json:"timing,omitempty"`
  267. // UserAgent: The user agent that was used to run this LHR.
  268. UserAgent string `json:"userAgent,omitempty"`
  269. // ForceSendFields is a list of field names (e.g. "Audits") to
  270. // unconditionally include in API requests. By default, fields with
  271. // empty values are omitted from API requests. However, any non-pointer,
  272. // non-interface field appearing in ForceSendFields will be sent to the
  273. // server regardless of whether the field is empty or not. This may be
  274. // used to include empty fields in Patch requests.
  275. ForceSendFields []string `json:"-"`
  276. // NullFields is a list of field names (e.g. "Audits") to include in API
  277. // requests with the JSON null value. By default, fields with empty
  278. // values are omitted from API requests. However, any field with an
  279. // empty value appearing in NullFields will be sent to the server as
  280. // null. It is an error if a field in this list has a non-empty value.
  281. // This may be used to include null fields in Patch requests.
  282. NullFields []string `json:"-"`
  283. }
  284. func (s *LighthouseResultV5) MarshalJSON() ([]byte, error) {
  285. type NoMethod LighthouseResultV5
  286. raw := NoMethod(*s)
  287. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  288. }
  289. // LighthouseResultV5Categories: Map of categories in the LHR.
  290. type LighthouseResultV5Categories struct {
  291. // Accessibility: The accessibility category, containing all
  292. // accessibility related audits.
  293. Accessibility *LighthouseCategoryV5 `json:"accessibility,omitempty"`
  294. // BestPractices: The best practices category, containing all web best
  295. // practice related audits.
  296. BestPractices *LighthouseCategoryV5 `json:"best-practices,omitempty"`
  297. // Performance: The performance category, containing all performance
  298. // related audits.
  299. Performance *LighthouseCategoryV5 `json:"performance,omitempty"`
  300. // Pwa: The Progressive-Web-App (PWA) category, containing all pwa
  301. // related audits.
  302. Pwa *LighthouseCategoryV5 `json:"pwa,omitempty"`
  303. // Seo: The Search-Engine-Optimization (SEO) category, containing all
  304. // seo related audits.
  305. Seo *LighthouseCategoryV5 `json:"seo,omitempty"`
  306. // ForceSendFields is a list of field names (e.g. "Accessibility") to
  307. // unconditionally include in API requests. By default, fields with
  308. // empty values are omitted from API requests. However, any non-pointer,
  309. // non-interface field appearing in ForceSendFields will be sent to the
  310. // server regardless of whether the field is empty or not. This may be
  311. // used to include empty fields in Patch requests.
  312. ForceSendFields []string `json:"-"`
  313. // NullFields is a list of field names (e.g. "Accessibility") to include
  314. // in API requests with the JSON null value. By default, fields with
  315. // empty values are omitted from API requests. However, any field with
  316. // an empty value appearing in NullFields will be sent to the server as
  317. // null. It is an error if a field in this list has a non-empty value.
  318. // This may be used to include null fields in Patch requests.
  319. NullFields []string `json:"-"`
  320. }
  321. func (s *LighthouseResultV5Categories) MarshalJSON() ([]byte, error) {
  322. type NoMethod LighthouseResultV5Categories
  323. raw := NoMethod(*s)
  324. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  325. }
  326. // LighthouseResultV5CategoryGroups: A grouping contained in a category
  327. // that groups similar audits together.
  328. type LighthouseResultV5CategoryGroups struct {
  329. // Description: An optional human readable description of the category
  330. // group.
  331. Description string `json:"description,omitempty"`
  332. // Title: The title of the category group.
  333. Title string `json:"title,omitempty"`
  334. // ForceSendFields is a list of field names (e.g. "Description") to
  335. // unconditionally include in API requests. By default, fields with
  336. // empty values are omitted from API requests. However, any non-pointer,
  337. // non-interface field appearing in ForceSendFields will be sent to the
  338. // server regardless of whether the field is empty or not. This may be
  339. // used to include empty fields in Patch requests.
  340. ForceSendFields []string `json:"-"`
  341. // NullFields is a list of field names (e.g. "Description") to include
  342. // in API requests with the JSON null value. By default, fields with
  343. // empty values are omitted from API requests. However, any field with
  344. // an empty value appearing in NullFields will be sent to the server as
  345. // null. It is an error if a field in this list has a non-empty value.
  346. // This may be used to include null fields in Patch requests.
  347. NullFields []string `json:"-"`
  348. }
  349. func (s *LighthouseResultV5CategoryGroups) MarshalJSON() ([]byte, error) {
  350. type NoMethod LighthouseResultV5CategoryGroups
  351. raw := NoMethod(*s)
  352. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  353. }
  354. // LighthouseResultV5ConfigSettings: The configuration settings for this
  355. // LHR.
  356. type LighthouseResultV5ConfigSettings struct {
  357. // EmulatedFormFactor: The form factor the emulation should use.
  358. EmulatedFormFactor string `json:"emulatedFormFactor,omitempty"`
  359. // Locale: The locale setting.
  360. Locale string `json:"locale,omitempty"`
  361. OnlyCategories interface{} `json:"onlyCategories,omitempty"`
  362. // ForceSendFields is a list of field names (e.g. "EmulatedFormFactor")
  363. // to unconditionally include in API requests. By default, fields with
  364. // empty values are omitted from API requests. However, any non-pointer,
  365. // non-interface field appearing in ForceSendFields will be sent to the
  366. // server regardless of whether the field is empty or not. This may be
  367. // used to include empty fields in Patch requests.
  368. ForceSendFields []string `json:"-"`
  369. // NullFields is a list of field names (e.g. "EmulatedFormFactor") to
  370. // include in API requests with the JSON null value. By default, fields
  371. // with empty values are omitted from API requests. However, any field
  372. // with an empty value appearing in NullFields will be sent to the
  373. // server as null. It is an error if a field in this list has a
  374. // non-empty value. This may be used to include null fields in Patch
  375. // requests.
  376. NullFields []string `json:"-"`
  377. }
  378. func (s *LighthouseResultV5ConfigSettings) MarshalJSON() ([]byte, error) {
  379. type NoMethod LighthouseResultV5ConfigSettings
  380. raw := NoMethod(*s)
  381. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  382. }
  383. // LighthouseResultV5Environment: Environment settings that were used
  384. // when making this LHR.
  385. type LighthouseResultV5Environment struct {
  386. // BenchmarkIndex: The benchmark index number that indicates rough
  387. // device class.
  388. BenchmarkIndex float64 `json:"benchmarkIndex,omitempty"`
  389. // HostUserAgent: The user agent string of the version of Chrome used.
  390. HostUserAgent string `json:"hostUserAgent,omitempty"`
  391. // NetworkUserAgent: The user agent string that was sent over the
  392. // network.
  393. NetworkUserAgent string `json:"networkUserAgent,omitempty"`
  394. // ForceSendFields is a list of field names (e.g. "BenchmarkIndex") to
  395. // unconditionally include in API requests. By default, fields with
  396. // empty values are omitted from API requests. However, any non-pointer,
  397. // non-interface field appearing in ForceSendFields will be sent to the
  398. // server regardless of whether the field is empty or not. This may be
  399. // used to include empty fields in Patch requests.
  400. ForceSendFields []string `json:"-"`
  401. // NullFields is a list of field names (e.g. "BenchmarkIndex") to
  402. // include in API requests with the JSON null value. By default, fields
  403. // with empty values are omitted from API requests. However, any field
  404. // with an empty value appearing in NullFields will be sent to the
  405. // server as null. It is an error if a field in this list has a
  406. // non-empty value. This may be used to include null fields in Patch
  407. // requests.
  408. NullFields []string `json:"-"`
  409. }
  410. func (s *LighthouseResultV5Environment) MarshalJSON() ([]byte, error) {
  411. type NoMethod LighthouseResultV5Environment
  412. raw := NoMethod(*s)
  413. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  414. }
  415. func (s *LighthouseResultV5Environment) UnmarshalJSON(data []byte) error {
  416. type NoMethod LighthouseResultV5Environment
  417. var s1 struct {
  418. BenchmarkIndex gensupport.JSONFloat64 `json:"benchmarkIndex"`
  419. *NoMethod
  420. }
  421. s1.NoMethod = (*NoMethod)(s)
  422. if err := json.Unmarshal(data, &s1); err != nil {
  423. return err
  424. }
  425. s.BenchmarkIndex = float64(s1.BenchmarkIndex)
  426. return nil
  427. }
  428. // LighthouseResultV5I18n: The internationalization strings that are
  429. // required to render the LHR.
  430. type LighthouseResultV5I18n struct {
  431. // RendererFormattedStrings: Internationalized strings that are
  432. // formatted to the locale in configSettings.
  433. RendererFormattedStrings *LighthouseResultV5I18nRendererFormattedStrings `json:"rendererFormattedStrings,omitempty"`
  434. // ForceSendFields is a list of field names (e.g.
  435. // "RendererFormattedStrings") to unconditionally include in API
  436. // requests. By default, fields with empty values are omitted from API
  437. // requests. However, any non-pointer, non-interface field appearing in
  438. // ForceSendFields will be sent to the server regardless of whether the
  439. // field is empty or not. This may be used to include empty fields in
  440. // Patch requests.
  441. ForceSendFields []string `json:"-"`
  442. // NullFields is a list of field names (e.g. "RendererFormattedStrings")
  443. // to include in API requests with the JSON null value. By default,
  444. // fields with empty values are omitted from API requests. However, any
  445. // field with an empty value appearing in NullFields will be sent to the
  446. // server as null. It is an error if a field in this list has a
  447. // non-empty value. This may be used to include null fields in Patch
  448. // requests.
  449. NullFields []string `json:"-"`
  450. }
  451. func (s *LighthouseResultV5I18n) MarshalJSON() ([]byte, error) {
  452. type NoMethod LighthouseResultV5I18n
  453. raw := NoMethod(*s)
  454. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  455. }
  456. // LighthouseResultV5I18nRendererFormattedStrings: Internationalized
  457. // strings that are formatted to the locale in configSettings.
  458. type LighthouseResultV5I18nRendererFormattedStrings struct {
  459. // AuditGroupExpandTooltip: The tooltip text on an expandable chevron
  460. // icon.
  461. AuditGroupExpandTooltip string `json:"auditGroupExpandTooltip,omitempty"`
  462. // CrcInitialNavigation: The label for the initial request in a critical
  463. // request chain.
  464. CrcInitialNavigation string `json:"crcInitialNavigation,omitempty"`
  465. // CrcLongestDurationLabel: The label for values shown in the summary of
  466. // critical request chains.
  467. CrcLongestDurationLabel string `json:"crcLongestDurationLabel,omitempty"`
  468. // ErrorLabel: The label shown next to an audit or metric that has had
  469. // an error.
  470. ErrorLabel string `json:"errorLabel,omitempty"`
  471. // ErrorMissingAuditInfo: The error string shown next to an erroring
  472. // audit.
  473. ErrorMissingAuditInfo string `json:"errorMissingAuditInfo,omitempty"`
  474. // LabDataTitle: The title of the lab data performance category.
  475. LabDataTitle string `json:"labDataTitle,omitempty"`
  476. // LsPerformanceCategoryDescription: The disclaimer shown under
  477. // performance explaning that the network can vary.
  478. LsPerformanceCategoryDescription string `json:"lsPerformanceCategoryDescription,omitempty"`
  479. // ManualAuditsGroupTitle: The heading shown above a list of audits that
  480. // were not computerd in the run.
  481. ManualAuditsGroupTitle string `json:"manualAuditsGroupTitle,omitempty"`
  482. // NotApplicableAuditsGroupTitle: The heading shown above a list of
  483. // audits that do not apply to a page.
  484. NotApplicableAuditsGroupTitle string `json:"notApplicableAuditsGroupTitle,omitempty"`
  485. // OpportunityResourceColumnLabel: The heading for the estimated page
  486. // load savings opportunity of an audit.
  487. OpportunityResourceColumnLabel string `json:"opportunityResourceColumnLabel,omitempty"`
  488. // OpportunitySavingsColumnLabel: The heading for the estimated page
  489. // load savings of opportunity audits.
  490. OpportunitySavingsColumnLabel string `json:"opportunitySavingsColumnLabel,omitempty"`
  491. // PassedAuditsGroupTitle: The heading that is shown above a list of
  492. // audits that are passing.
  493. PassedAuditsGroupTitle string `json:"passedAuditsGroupTitle,omitempty"`
  494. // ScorescaleLabel: The label that explains the score gauges scale
  495. // (0-49, 50-89, 90-100).
  496. ScorescaleLabel string `json:"scorescaleLabel,omitempty"`
  497. // ToplevelWarningsMessage: The label shown preceding important warnings
  498. // that may have invalidated an entire report.
  499. ToplevelWarningsMessage string `json:"toplevelWarningsMessage,omitempty"`
  500. // VarianceDisclaimer: The disclaimer shown below a performance metric
  501. // value.
  502. VarianceDisclaimer string `json:"varianceDisclaimer,omitempty"`
  503. // WarningHeader: The label shown above a bulleted list of warnings.
  504. WarningHeader string `json:"warningHeader,omitempty"`
  505. // ForceSendFields is a list of field names (e.g.
  506. // "AuditGroupExpandTooltip") to unconditionally include in API
  507. // requests. By default, fields with empty values are omitted from API
  508. // requests. However, any non-pointer, non-interface field appearing in
  509. // ForceSendFields will be sent to the server regardless of whether the
  510. // field is empty or not. This may be used to include empty fields in
  511. // Patch requests.
  512. ForceSendFields []string `json:"-"`
  513. // NullFields is a list of field names (e.g. "AuditGroupExpandTooltip")
  514. // to include in API requests with the JSON null value. By default,
  515. // fields with empty values are omitted from API requests. However, any
  516. // field with an empty value appearing in NullFields will be sent to the
  517. // server as null. It is an error if a field in this list has a
  518. // non-empty value. This may be used to include null fields in Patch
  519. // requests.
  520. NullFields []string `json:"-"`
  521. }
  522. func (s *LighthouseResultV5I18nRendererFormattedStrings) MarshalJSON() ([]byte, error) {
  523. type NoMethod LighthouseResultV5I18nRendererFormattedStrings
  524. raw := NoMethod(*s)
  525. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  526. }
  527. // LighthouseResultV5RuntimeError: A top-level error message that, if
  528. // present, indicates a serious enough problem that this Lighthouse
  529. // result may need to be discarded.
  530. type LighthouseResultV5RuntimeError struct {
  531. // Code: The enumerated Lighthouse Error code.
  532. Code string `json:"code,omitempty"`
  533. // Message: A human readable message explaining the error code.
  534. Message string `json:"message,omitempty"`
  535. // ForceSendFields is a list of field names (e.g. "Code") to
  536. // unconditionally include in API requests. By default, fields with
  537. // empty values are omitted from API requests. However, any non-pointer,
  538. // non-interface field appearing in ForceSendFields will be sent to the
  539. // server regardless of whether the field is empty or not. This may be
  540. // used to include empty fields in Patch requests.
  541. ForceSendFields []string `json:"-"`
  542. // NullFields is a list of field names (e.g. "Code") to include in API
  543. // requests with the JSON null value. By default, fields with empty
  544. // values are omitted from API requests. However, any field with an
  545. // empty value appearing in NullFields will be sent to the server as
  546. // null. It is an error if a field in this list has a non-empty value.
  547. // This may be used to include null fields in Patch requests.
  548. NullFields []string `json:"-"`
  549. }
  550. func (s *LighthouseResultV5RuntimeError) MarshalJSON() ([]byte, error) {
  551. type NoMethod LighthouseResultV5RuntimeError
  552. raw := NoMethod(*s)
  553. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  554. }
  555. // LighthouseResultV5Timing: Timing information for this LHR.
  556. type LighthouseResultV5Timing struct {
  557. // Total: The total duration of Lighthouse's run.
  558. Total float64 `json:"total,omitempty"`
  559. // ForceSendFields is a list of field names (e.g. "Total") to
  560. // unconditionally include in API requests. By default, fields with
  561. // empty values are omitted from API requests. However, any non-pointer,
  562. // non-interface field appearing in ForceSendFields will be sent to the
  563. // server regardless of whether the field is empty or not. This may be
  564. // used to include empty fields in Patch requests.
  565. ForceSendFields []string `json:"-"`
  566. // NullFields is a list of field names (e.g. "Total") to include in API
  567. // requests with the JSON null value. By default, fields with empty
  568. // values are omitted from API requests. However, any field with an
  569. // empty value appearing in NullFields will be sent to the server as
  570. // null. It is an error if a field in this list has a non-empty value.
  571. // This may be used to include null fields in Patch requests.
  572. NullFields []string `json:"-"`
  573. }
  574. func (s *LighthouseResultV5Timing) MarshalJSON() ([]byte, error) {
  575. type NoMethod LighthouseResultV5Timing
  576. raw := NoMethod(*s)
  577. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  578. }
  579. func (s *LighthouseResultV5Timing) UnmarshalJSON(data []byte) error {
  580. type NoMethod LighthouseResultV5Timing
  581. var s1 struct {
  582. Total gensupport.JSONFloat64 `json:"total"`
  583. *NoMethod
  584. }
  585. s1.NoMethod = (*NoMethod)(s)
  586. if err := json.Unmarshal(data, &s1); err != nil {
  587. return err
  588. }
  589. s.Total = float64(s1.Total)
  590. return nil
  591. }
  592. type PagespeedApiLoadingExperienceV5 struct {
  593. // Id: The url, pattern or origin which the metrics are on.
  594. Id string `json:"id,omitempty"`
  595. InitialUrl string `json:"initial_url,omitempty"`
  596. Metrics map[string]PagespeedApiLoadingExperienceV5Metrics `json:"metrics,omitempty"`
  597. OverallCategory string `json:"overall_category,omitempty"`
  598. // ForceSendFields is a list of field names (e.g. "Id") to
  599. // unconditionally include in API requests. By default, fields with
  600. // empty values are omitted from API requests. However, any non-pointer,
  601. // non-interface field appearing in ForceSendFields will be sent to the
  602. // server regardless of whether the field is empty or not. This may be
  603. // used to include empty fields in Patch requests.
  604. ForceSendFields []string `json:"-"`
  605. // NullFields is a list of field names (e.g. "Id") to include in API
  606. // requests with the JSON null value. By default, fields with empty
  607. // values are omitted from API requests. However, any field with an
  608. // empty value appearing in NullFields will be sent to the server as
  609. // null. It is an error if a field in this list has a non-empty value.
  610. // This may be used to include null fields in Patch requests.
  611. NullFields []string `json:"-"`
  612. }
  613. func (s *PagespeedApiLoadingExperienceV5) MarshalJSON() ([]byte, error) {
  614. type NoMethod PagespeedApiLoadingExperienceV5
  615. raw := NoMethod(*s)
  616. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  617. }
  618. // PagespeedApiLoadingExperienceV5Metrics: The type of the metric.
  619. type PagespeedApiLoadingExperienceV5Metrics struct {
  620. Category string `json:"category,omitempty"`
  621. Distributions []*PagespeedApiLoadingExperienceV5MetricsDistributions `json:"distributions,omitempty"`
  622. Percentile int64 `json:"percentile,omitempty"`
  623. // ForceSendFields is a list of field names (e.g. "Category") to
  624. // unconditionally include in API requests. By default, fields with
  625. // empty values are omitted from API requests. However, any non-pointer,
  626. // non-interface field appearing in ForceSendFields will be sent to the
  627. // server regardless of whether the field is empty or not. This may be
  628. // used to include empty fields in Patch requests.
  629. ForceSendFields []string `json:"-"`
  630. // NullFields is a list of field names (e.g. "Category") to include in
  631. // API requests with the JSON null value. By default, fields with empty
  632. // values are omitted from API requests. However, any field with an
  633. // empty value appearing in NullFields will be sent to the server as
  634. // null. It is an error if a field in this list has a non-empty value.
  635. // This may be used to include null fields in Patch requests.
  636. NullFields []string `json:"-"`
  637. }
  638. func (s *PagespeedApiLoadingExperienceV5Metrics) MarshalJSON() ([]byte, error) {
  639. type NoMethod PagespeedApiLoadingExperienceV5Metrics
  640. raw := NoMethod(*s)
  641. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  642. }
  643. type PagespeedApiLoadingExperienceV5MetricsDistributions struct {
  644. Max int64 `json:"max,omitempty"`
  645. Min int64 `json:"min,omitempty"`
  646. Proportion float64 `json:"proportion,omitempty"`
  647. // ForceSendFields is a list of field names (e.g. "Max") to
  648. // unconditionally include in API requests. By default, fields with
  649. // empty values are omitted from API requests. However, any non-pointer,
  650. // non-interface field appearing in ForceSendFields will be sent to the
  651. // server regardless of whether the field is empty or not. This may be
  652. // used to include empty fields in Patch requests.
  653. ForceSendFields []string `json:"-"`
  654. // NullFields is a list of field names (e.g. "Max") to include in API
  655. // requests with the JSON null value. By default, fields with empty
  656. // values are omitted from API requests. However, any field with an
  657. // empty value appearing in NullFields will be sent to the server as
  658. // null. It is an error if a field in this list has a non-empty value.
  659. // This may be used to include null fields in Patch requests.
  660. NullFields []string `json:"-"`
  661. }
  662. func (s *PagespeedApiLoadingExperienceV5MetricsDistributions) MarshalJSON() ([]byte, error) {
  663. type NoMethod PagespeedApiLoadingExperienceV5MetricsDistributions
  664. raw := NoMethod(*s)
  665. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  666. }
  667. func (s *PagespeedApiLoadingExperienceV5MetricsDistributions) UnmarshalJSON(data []byte) error {
  668. type NoMethod PagespeedApiLoadingExperienceV5MetricsDistributions
  669. var s1 struct {
  670. Proportion gensupport.JSONFloat64 `json:"proportion"`
  671. *NoMethod
  672. }
  673. s1.NoMethod = (*NoMethod)(s)
  674. if err := json.Unmarshal(data, &s1); err != nil {
  675. return err
  676. }
  677. s.Proportion = float64(s1.Proportion)
  678. return nil
  679. }
  680. type PagespeedApiPagespeedResponseV5 struct {
  681. // AnalysisUTCTimestamp: The UTC timestamp of this analysis.
  682. AnalysisUTCTimestamp string `json:"analysisUTCTimestamp,omitempty"`
  683. // CaptchaResult: The captcha verify result
  684. CaptchaResult string `json:"captchaResult,omitempty"`
  685. // Id: Canonicalized and final URL for the document, after following
  686. // page redirects (if any).
  687. Id string `json:"id,omitempty"`
  688. // Kind: Kind of result.
  689. Kind string `json:"kind,omitempty"`
  690. // LighthouseResult: Lighthouse response for the audit url as an object.
  691. LighthouseResult *LighthouseResultV5 `json:"lighthouseResult,omitempty"`
  692. // LoadingExperience: Metrics of end users' page loading experience.
  693. LoadingExperience *PagespeedApiLoadingExperienceV5 `json:"loadingExperience,omitempty"`
  694. // OriginLoadingExperience: Metrics of the aggregated page loading
  695. // experience of the origin
  696. OriginLoadingExperience *PagespeedApiLoadingExperienceV5 `json:"originLoadingExperience,omitempty"`
  697. // Version: The version of PageSpeed used to generate these results.
  698. Version *PagespeedApiPagespeedResponseV5Version `json:"version,omitempty"`
  699. // ServerResponse contains the HTTP response code and headers from the
  700. // server.
  701. googleapi.ServerResponse `json:"-"`
  702. // ForceSendFields is a list of field names (e.g.
  703. // "AnalysisUTCTimestamp") to unconditionally include in API requests.
  704. // By default, fields with empty values are omitted from API requests.
  705. // However, any non-pointer, non-interface field appearing in
  706. // ForceSendFields will be sent to the server regardless of whether the
  707. // field is empty or not. This may be used to include empty fields in
  708. // Patch requests.
  709. ForceSendFields []string `json:"-"`
  710. // NullFields is a list of field names (e.g. "AnalysisUTCTimestamp") to
  711. // include in API requests with the JSON null value. By default, fields
  712. // with empty values are omitted from API requests. However, any field
  713. // with an empty value appearing in NullFields will be sent to the
  714. // server as null. It is an error if a field in this list has a
  715. // non-empty value. This may be used to include null fields in Patch
  716. // requests.
  717. NullFields []string `json:"-"`
  718. }
  719. func (s *PagespeedApiPagespeedResponseV5) MarshalJSON() ([]byte, error) {
  720. type NoMethod PagespeedApiPagespeedResponseV5
  721. raw := NoMethod(*s)
  722. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  723. }
  724. // PagespeedApiPagespeedResponseV5Version: The version of PageSpeed used
  725. // to generate these results.
  726. type PagespeedApiPagespeedResponseV5Version struct {
  727. // Major: The major version number of PageSpeed used to generate these
  728. // results.
  729. Major int64 `json:"major,omitempty"`
  730. // Minor: The minor version number of PageSpeed used to generate these
  731. // results.
  732. Minor int64 `json:"minor,omitempty"`
  733. // ForceSendFields is a list of field names (e.g. "Major") to
  734. // unconditionally include in API requests. By default, fields with
  735. // empty values are omitted from API requests. However, any non-pointer,
  736. // non-interface field appearing in ForceSendFields will be sent to the
  737. // server regardless of whether the field is empty or not. This may be
  738. // used to include empty fields in Patch requests.
  739. ForceSendFields []string `json:"-"`
  740. // NullFields is a list of field names (e.g. "Major") to include in API
  741. // requests with the JSON null value. By default, fields with empty
  742. // values are omitted from API requests. However, any field with an
  743. // empty value appearing in NullFields will be sent to the server as
  744. // null. It is an error if a field in this list has a non-empty value.
  745. // This may be used to include null fields in Patch requests.
  746. NullFields []string `json:"-"`
  747. }
  748. func (s *PagespeedApiPagespeedResponseV5Version) MarshalJSON() ([]byte, error) {
  749. type NoMethod PagespeedApiPagespeedResponseV5Version
  750. raw := NoMethod(*s)
  751. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  752. }
  753. // method id "pagespeedonline.pagespeedapi.runpagespeed":
  754. type PagespeedapiRunpagespeedCall struct {
  755. s *Service
  756. urlParams_ gensupport.URLParams
  757. ifNoneMatch_ string
  758. ctx_ context.Context
  759. header_ http.Header
  760. }
  761. // Runpagespeed: Runs PageSpeed analysis on the page at the specified
  762. // URL, and returns PageSpeed scores, a list of suggestions to make that
  763. // page faster, and other information.
  764. func (r *PagespeedapiService) Runpagespeed(url string) *PagespeedapiRunpagespeedCall {
  765. c := &PagespeedapiRunpagespeedCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  766. c.urlParams_.Set("url", url)
  767. return c
  768. }
  769. // Category sets the optional parameter "category": A Lighthouse
  770. // category to run; if none are given, only Performance category will be
  771. // run
  772. //
  773. // Possible values:
  774. // "accessibility"
  775. // "best-practices"
  776. // "performance"
  777. // "pwa"
  778. // "seo"
  779. func (c *PagespeedapiRunpagespeedCall) Category(category ...string) *PagespeedapiRunpagespeedCall {
  780. c.urlParams_.SetMulti("category", append([]string{}, category...))
  781. return c
  782. }
  783. // Locale sets the optional parameter "locale": The locale used to
  784. // localize formatted results
  785. func (c *PagespeedapiRunpagespeedCall) Locale(locale string) *PagespeedapiRunpagespeedCall {
  786. c.urlParams_.Set("locale", locale)
  787. return c
  788. }
  789. // Strategy sets the optional parameter "strategy": The analysis
  790. // strategy (desktop or mobile) to use, and desktop is the default
  791. //
  792. // Possible values:
  793. // "desktop" - Fetch and analyze the URL for desktop browsers
  794. // "mobile" - Fetch and analyze the URL for mobile devices
  795. func (c *PagespeedapiRunpagespeedCall) Strategy(strategy string) *PagespeedapiRunpagespeedCall {
  796. c.urlParams_.Set("strategy", strategy)
  797. return c
  798. }
  799. // UtmCampaign sets the optional parameter "utm_campaign": Campaign name
  800. // for analytics.
  801. func (c *PagespeedapiRunpagespeedCall) UtmCampaign(utmCampaign string) *PagespeedapiRunpagespeedCall {
  802. c.urlParams_.Set("utm_campaign", utmCampaign)
  803. return c
  804. }
  805. // UtmSource sets the optional parameter "utm_source": Campaign source
  806. // for analytics.
  807. func (c *PagespeedapiRunpagespeedCall) UtmSource(utmSource string) *PagespeedapiRunpagespeedCall {
  808. c.urlParams_.Set("utm_source", utmSource)
  809. return c
  810. }
  811. // Fields allows partial responses to be retrieved. See
  812. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  813. // for more information.
  814. func (c *PagespeedapiRunpagespeedCall) Fields(s ...googleapi.Field) *PagespeedapiRunpagespeedCall {
  815. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  816. return c
  817. }
  818. // IfNoneMatch sets the optional parameter which makes the operation
  819. // fail if the object's ETag matches the given value. This is useful for
  820. // getting updates only after the object has changed since the last
  821. // request. Use googleapi.IsNotModified to check whether the response
  822. // error from Do is the result of In-None-Match.
  823. func (c *PagespeedapiRunpagespeedCall) IfNoneMatch(entityTag string) *PagespeedapiRunpagespeedCall {
  824. c.ifNoneMatch_ = entityTag
  825. return c
  826. }
  827. // Context sets the context to be used in this call's Do method. Any
  828. // pending HTTP request will be aborted if the provided context is
  829. // canceled.
  830. func (c *PagespeedapiRunpagespeedCall) Context(ctx context.Context) *PagespeedapiRunpagespeedCall {
  831. c.ctx_ = ctx
  832. return c
  833. }
  834. // Header returns an http.Header that can be modified by the caller to
  835. // add HTTP headers to the request.
  836. func (c *PagespeedapiRunpagespeedCall) Header() http.Header {
  837. if c.header_ == nil {
  838. c.header_ = make(http.Header)
  839. }
  840. return c.header_
  841. }
  842. func (c *PagespeedapiRunpagespeedCall) doRequest(alt string) (*http.Response, error) {
  843. reqHeaders := make(http.Header)
  844. for k, v := range c.header_ {
  845. reqHeaders[k] = v
  846. }
  847. reqHeaders.Set("User-Agent", c.s.userAgent())
  848. if c.ifNoneMatch_ != "" {
  849. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  850. }
  851. var body io.Reader = nil
  852. c.urlParams_.Set("alt", alt)
  853. c.urlParams_.Set("prettyPrint", "false")
  854. urls := googleapi.ResolveRelative(c.s.BasePath, "runPagespeed")
  855. urls += "?" + c.urlParams_.Encode()
  856. req, err := http.NewRequest("GET", urls, body)
  857. if err != nil {
  858. return nil, err
  859. }
  860. req.Header = reqHeaders
  861. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  862. }
  863. // Do executes the "pagespeedonline.pagespeedapi.runpagespeed" call.
  864. // Exactly one of *PagespeedApiPagespeedResponseV5 or error will be
  865. // non-nil. Any non-2xx status code is an error. Response headers are in
  866. // either *PagespeedApiPagespeedResponseV5.ServerResponse.Header or (if
  867. // a response was returned at all) in error.(*googleapi.Error).Header.
  868. // Use googleapi.IsNotModified to check whether the returned error was
  869. // because http.StatusNotModified was returned.
  870. func (c *PagespeedapiRunpagespeedCall) Do(opts ...googleapi.CallOption) (*PagespeedApiPagespeedResponseV5, error) {
  871. gensupport.SetOptions(c.urlParams_, opts...)
  872. res, err := c.doRequest("json")
  873. if res != nil && res.StatusCode == http.StatusNotModified {
  874. if res.Body != nil {
  875. res.Body.Close()
  876. }
  877. return nil, &googleapi.Error{
  878. Code: res.StatusCode,
  879. Header: res.Header,
  880. }
  881. }
  882. if err != nil {
  883. return nil, err
  884. }
  885. defer googleapi.CloseBody(res)
  886. if err := googleapi.CheckResponse(res); err != nil {
  887. return nil, err
  888. }
  889. ret := &PagespeedApiPagespeedResponseV5{
  890. ServerResponse: googleapi.ServerResponse{
  891. Header: res.Header,
  892. HTTPStatusCode: res.StatusCode,
  893. },
  894. }
  895. target := &ret
  896. if err := gensupport.DecodeResponse(target, res); err != nil {
  897. return nil, err
  898. }
  899. return ret, nil
  900. // {
  901. // "description": "Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information.",
  902. // "httpMethod": "GET",
  903. // "id": "pagespeedonline.pagespeedapi.runpagespeed",
  904. // "parameterOrder": [
  905. // "url"
  906. // ],
  907. // "parameters": {
  908. // "category": {
  909. // "description": "A Lighthouse category to run; if none are given, only Performance category will be run",
  910. // "enum": [
  911. // "accessibility",
  912. // "best-practices",
  913. // "performance",
  914. // "pwa",
  915. // "seo"
  916. // ],
  917. // "enumDescriptions": [
  918. // "",
  919. // "",
  920. // "",
  921. // "",
  922. // ""
  923. // ],
  924. // "location": "query",
  925. // "repeated": true,
  926. // "type": "string"
  927. // },
  928. // "locale": {
  929. // "description": "The locale used to localize formatted results",
  930. // "location": "query",
  931. // "pattern": "[a-zA-Z]+((_|-)[a-zA-Z]+)?",
  932. // "type": "string"
  933. // },
  934. // "strategy": {
  935. // "description": "The analysis strategy (desktop or mobile) to use, and desktop is the default",
  936. // "enum": [
  937. // "desktop",
  938. // "mobile"
  939. // ],
  940. // "enumDescriptions": [
  941. // "Fetch and analyze the URL for desktop browsers",
  942. // "Fetch and analyze the URL for mobile devices"
  943. // ],
  944. // "location": "query",
  945. // "type": "string"
  946. // },
  947. // "url": {
  948. // "description": "The URL to fetch and analyze",
  949. // "location": "query",
  950. // "pattern": "(?i)http(s)?://.*",
  951. // "required": true,
  952. // "type": "string"
  953. // },
  954. // "utm_campaign": {
  955. // "description": "Campaign name for analytics.",
  956. // "location": "query",
  957. // "type": "string"
  958. // },
  959. // "utm_source": {
  960. // "description": "Campaign source for analytics.",
  961. // "location": "query",
  962. // "type": "string"
  963. // }
  964. // },
  965. // "path": "runPagespeed",
  966. // "response": {
  967. // "$ref": "PagespeedApiPagespeedResponseV5"
  968. // }
  969. // }
  970. }