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.
 
 
 

952 line
37 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/v2/getting-started
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/pagespeedonline/v2"
  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/v2"
  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:v2"
  67. const apiName = "pagespeedonline"
  68. const apiVersion = "v2"
  69. const basePath = "https://www.googleapis.com/pagespeedonline/v2/"
  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 PagespeedApiFormatStringV2 struct {
  118. // Args: List of arguments for the format string.
  119. Args []*PagespeedApiFormatStringV2Args `json:"args,omitempty"`
  120. // Format: A localized format string with {{FOO}} placeholders, where
  121. // 'FOO' is the key of the argument whose value should be substituted.
  122. // For HYPERLINK arguments, the format string will instead contain
  123. // {{BEGIN_FOO}} and {{END_FOO}} for the argument with key 'FOO'.
  124. Format string `json:"format,omitempty"`
  125. // ForceSendFields is a list of field names (e.g. "Args") to
  126. // unconditionally include in API requests. By default, fields with
  127. // empty values are omitted from API requests. However, any non-pointer,
  128. // non-interface field appearing in ForceSendFields will be sent to the
  129. // server regardless of whether the field is empty or not. This may be
  130. // used to include empty fields in Patch requests.
  131. ForceSendFields []string `json:"-"`
  132. // NullFields is a list of field names (e.g. "Args") to include in API
  133. // requests with the JSON null value. By default, fields with empty
  134. // values are omitted from API requests. However, any field with an
  135. // empty value appearing in NullFields will be sent to the server as
  136. // null. It is an error if a field in this list has a non-empty value.
  137. // This may be used to include null fields in Patch requests.
  138. NullFields []string `json:"-"`
  139. }
  140. func (s *PagespeedApiFormatStringV2) MarshalJSON() ([]byte, error) {
  141. type NoMethod PagespeedApiFormatStringV2
  142. raw := NoMethod(*s)
  143. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  144. }
  145. type PagespeedApiFormatStringV2Args struct {
  146. // Key: The placeholder key for this arg, as a string.
  147. Key string `json:"key,omitempty"`
  148. // Rects: The screen rectangles being referred to, with dimensions
  149. // measured in CSS pixels. This is only ever used for SNAPSHOT_RECT
  150. // arguments. If this is absent for a SNAPSHOT_RECT argument, it means
  151. // that that argument refers to the entire snapshot.
  152. Rects []*PagespeedApiFormatStringV2ArgsRects `json:"rects,omitempty"`
  153. // SecondaryRects: Secondary screen rectangles being referred to, with
  154. // dimensions measured in CSS pixels. This is only ever used for
  155. // SNAPSHOT_RECT arguments.
  156. SecondaryRects []*PagespeedApiFormatStringV2ArgsSecondaryRects `json:"secondary_rects,omitempty"`
  157. // Type: Type of argument. One of URL, STRING_LITERAL, INT_LITERAL,
  158. // BYTES, DURATION, VERBATIM_STRING, PERCENTAGE, HYPERLINK, or
  159. // SNAPSHOT_RECT.
  160. Type string `json:"type,omitempty"`
  161. // Value: Argument value, as a localized string.
  162. Value string `json:"value,omitempty"`
  163. // ForceSendFields is a list of field names (e.g. "Key") to
  164. // unconditionally include in API requests. By default, fields with
  165. // empty values are omitted from API requests. However, any non-pointer,
  166. // non-interface field appearing in ForceSendFields will be sent to the
  167. // server regardless of whether the field is empty or not. This may be
  168. // used to include empty fields in Patch requests.
  169. ForceSendFields []string `json:"-"`
  170. // NullFields is a list of field names (e.g. "Key") to include in API
  171. // requests with the JSON null value. By default, fields with empty
  172. // values are omitted from API requests. However, any field with an
  173. // empty value appearing in NullFields will be sent to the server as
  174. // null. It is an error if a field in this list has a non-empty value.
  175. // This may be used to include null fields in Patch requests.
  176. NullFields []string `json:"-"`
  177. }
  178. func (s *PagespeedApiFormatStringV2Args) MarshalJSON() ([]byte, error) {
  179. type NoMethod PagespeedApiFormatStringV2Args
  180. raw := NoMethod(*s)
  181. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  182. }
  183. type PagespeedApiFormatStringV2ArgsRects struct {
  184. // Height: The height of the rect.
  185. Height int64 `json:"height,omitempty"`
  186. // Left: The left coordinate of the rect, in page coordinates.
  187. Left int64 `json:"left,omitempty"`
  188. // Top: The top coordinate of the rect, in page coordinates.
  189. Top int64 `json:"top,omitempty"`
  190. // Width: The width of the rect.
  191. Width int64 `json:"width,omitempty"`
  192. // ForceSendFields is a list of field names (e.g. "Height") to
  193. // unconditionally include in API requests. By default, fields with
  194. // empty values are omitted from API requests. However, any non-pointer,
  195. // non-interface field appearing in ForceSendFields will be sent to the
  196. // server regardless of whether the field is empty or not. This may be
  197. // used to include empty fields in Patch requests.
  198. ForceSendFields []string `json:"-"`
  199. // NullFields is a list of field names (e.g. "Height") to include in API
  200. // requests with the JSON null value. By default, fields with empty
  201. // values are omitted from API requests. However, any field with an
  202. // empty value appearing in NullFields will be sent to the server as
  203. // null. It is an error if a field in this list has a non-empty value.
  204. // This may be used to include null fields in Patch requests.
  205. NullFields []string `json:"-"`
  206. }
  207. func (s *PagespeedApiFormatStringV2ArgsRects) MarshalJSON() ([]byte, error) {
  208. type NoMethod PagespeedApiFormatStringV2ArgsRects
  209. raw := NoMethod(*s)
  210. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  211. }
  212. type PagespeedApiFormatStringV2ArgsSecondaryRects struct {
  213. // Height: The height of the rect.
  214. Height int64 `json:"height,omitempty"`
  215. // Left: The left coordinate of the rect, in page coordinates.
  216. Left int64 `json:"left,omitempty"`
  217. // Top: The top coordinate of the rect, in page coordinates.
  218. Top int64 `json:"top,omitempty"`
  219. // Width: The width of the rect.
  220. Width int64 `json:"width,omitempty"`
  221. // ForceSendFields is a list of field names (e.g. "Height") to
  222. // unconditionally include in API requests. By default, fields with
  223. // empty values are omitted from API requests. However, any non-pointer,
  224. // non-interface field appearing in ForceSendFields will be sent to the
  225. // server regardless of whether the field is empty or not. This may be
  226. // used to include empty fields in Patch requests.
  227. ForceSendFields []string `json:"-"`
  228. // NullFields is a list of field names (e.g. "Height") to include in API
  229. // requests with the JSON null value. By default, fields with empty
  230. // values are omitted from API requests. However, any field with an
  231. // empty value appearing in NullFields will be sent to the server as
  232. // null. It is an error if a field in this list has a non-empty value.
  233. // This may be used to include null fields in Patch requests.
  234. NullFields []string `json:"-"`
  235. }
  236. func (s *PagespeedApiFormatStringV2ArgsSecondaryRects) MarshalJSON() ([]byte, error) {
  237. type NoMethod PagespeedApiFormatStringV2ArgsSecondaryRects
  238. raw := NoMethod(*s)
  239. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  240. }
  241. type PagespeedApiImageV2 struct {
  242. // Data: Image data base64 encoded.
  243. Data string `json:"data,omitempty"`
  244. // Height: Height of screenshot in pixels.
  245. Height int64 `json:"height,omitempty"`
  246. // Key: Unique string key, if any, identifying this image.
  247. Key string `json:"key,omitempty"`
  248. // MimeType: Mime type of image data (e.g. "image/jpeg").
  249. MimeType string `json:"mime_type,omitempty"`
  250. // PageRect: The region of the page that is captured by this image, with
  251. // dimensions measured in CSS pixels.
  252. PageRect *PagespeedApiImageV2PageRect `json:"page_rect,omitempty"`
  253. // Width: Width of screenshot in pixels.
  254. Width int64 `json:"width,omitempty"`
  255. // ForceSendFields is a list of field names (e.g. "Data") to
  256. // unconditionally include in API requests. By default, fields with
  257. // empty values are omitted from API requests. However, any non-pointer,
  258. // non-interface field appearing in ForceSendFields will be sent to the
  259. // server regardless of whether the field is empty or not. This may be
  260. // used to include empty fields in Patch requests.
  261. ForceSendFields []string `json:"-"`
  262. // NullFields is a list of field names (e.g. "Data") to include in API
  263. // requests with the JSON null value. By default, fields with empty
  264. // values are omitted from API requests. However, any field with an
  265. // empty value appearing in NullFields will be sent to the server as
  266. // null. It is an error if a field in this list has a non-empty value.
  267. // This may be used to include null fields in Patch requests.
  268. NullFields []string `json:"-"`
  269. }
  270. func (s *PagespeedApiImageV2) MarshalJSON() ([]byte, error) {
  271. type NoMethod PagespeedApiImageV2
  272. raw := NoMethod(*s)
  273. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  274. }
  275. // PagespeedApiImageV2PageRect: The region of the page that is captured
  276. // by this image, with dimensions measured in CSS pixels.
  277. type PagespeedApiImageV2PageRect struct {
  278. // Height: The height of the rect.
  279. Height int64 `json:"height,omitempty"`
  280. // Left: The left coordinate of the rect, in page coordinates.
  281. Left int64 `json:"left,omitempty"`
  282. // Top: The top coordinate of the rect, in page coordinates.
  283. Top int64 `json:"top,omitempty"`
  284. // Width: The width of the rect.
  285. Width int64 `json:"width,omitempty"`
  286. // ForceSendFields is a list of field names (e.g. "Height") to
  287. // unconditionally include in API requests. By default, fields with
  288. // empty values are omitted from API requests. However, any non-pointer,
  289. // non-interface field appearing in ForceSendFields will be sent to the
  290. // server regardless of whether the field is empty or not. This may be
  291. // used to include empty fields in Patch requests.
  292. ForceSendFields []string `json:"-"`
  293. // NullFields is a list of field names (e.g. "Height") to include in API
  294. // requests with the JSON null value. By default, fields with empty
  295. // values are omitted from API requests. However, any field with an
  296. // empty value appearing in NullFields will be sent to the server as
  297. // null. It is an error if a field in this list has a non-empty value.
  298. // This may be used to include null fields in Patch requests.
  299. NullFields []string `json:"-"`
  300. }
  301. func (s *PagespeedApiImageV2PageRect) MarshalJSON() ([]byte, error) {
  302. type NoMethod PagespeedApiImageV2PageRect
  303. raw := NoMethod(*s)
  304. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  305. }
  306. type Result struct {
  307. // CaptchaResult: The captcha verify result
  308. CaptchaResult string `json:"captchaResult,omitempty"`
  309. // FormattedResults: Localized PageSpeed results. Contains a ruleResults
  310. // entry for each PageSpeed rule instantiated and run by the server.
  311. FormattedResults *ResultFormattedResults `json:"formattedResults,omitempty"`
  312. // Id: Canonicalized and final URL for the document, after following
  313. // page redirects (if any).
  314. Id string `json:"id,omitempty"`
  315. // InvalidRules: List of rules that were specified in the request, but
  316. // which the server did not know how to instantiate.
  317. InvalidRules []string `json:"invalidRules,omitempty"`
  318. // Kind: Kind of result.
  319. Kind string `json:"kind,omitempty"`
  320. // PageStats: Summary statistics for the page, such as number of
  321. // JavaScript bytes, number of HTML bytes, etc.
  322. PageStats *ResultPageStats `json:"pageStats,omitempty"`
  323. // ResponseCode: Response code for the document. 200 indicates a normal
  324. // page load. 4xx/5xx indicates an error.
  325. ResponseCode int64 `json:"responseCode,omitempty"`
  326. // RuleGroups: A map with one entry for each rule group in these
  327. // results.
  328. RuleGroups map[string]ResultRuleGroups `json:"ruleGroups,omitempty"`
  329. // Screenshot: Base64-encoded screenshot of the page that was analyzed.
  330. Screenshot *PagespeedApiImageV2 `json:"screenshot,omitempty"`
  331. // Title: Title of the page, as displayed in the browser's title bar.
  332. Title string `json:"title,omitempty"`
  333. // Version: The version of PageSpeed used to generate these results.
  334. Version *ResultVersion `json:"version,omitempty"`
  335. // ServerResponse contains the HTTP response code and headers from the
  336. // server.
  337. googleapi.ServerResponse `json:"-"`
  338. // ForceSendFields is a list of field names (e.g. "CaptchaResult") to
  339. // unconditionally include in API requests. By default, fields with
  340. // empty values are omitted from API requests. However, any non-pointer,
  341. // non-interface field appearing in ForceSendFields will be sent to the
  342. // server regardless of whether the field is empty or not. This may be
  343. // used to include empty fields in Patch requests.
  344. ForceSendFields []string `json:"-"`
  345. // NullFields is a list of field names (e.g. "CaptchaResult") to include
  346. // in API requests with the JSON null value. By default, fields with
  347. // empty values are omitted from API requests. However, any field with
  348. // an empty value appearing in NullFields will be sent to the server as
  349. // null. It is an error if a field in this list has a non-empty value.
  350. // This may be used to include null fields in Patch requests.
  351. NullFields []string `json:"-"`
  352. }
  353. func (s *Result) MarshalJSON() ([]byte, error) {
  354. type NoMethod Result
  355. raw := NoMethod(*s)
  356. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  357. }
  358. // ResultFormattedResults: Localized PageSpeed results. Contains a
  359. // ruleResults entry for each PageSpeed rule instantiated and run by the
  360. // server.
  361. type ResultFormattedResults struct {
  362. // Locale: The locale of the formattedResults, e.g. "en_US".
  363. Locale string `json:"locale,omitempty"`
  364. // RuleResults: Dictionary of formatted rule results, with one entry for
  365. // each PageSpeed rule instantiated and run by the server.
  366. RuleResults map[string]ResultFormattedResultsRuleResults `json:"ruleResults,omitempty"`
  367. // ForceSendFields is a list of field names (e.g. "Locale") to
  368. // unconditionally include in API requests. By default, fields with
  369. // empty values are omitted from API requests. However, any non-pointer,
  370. // non-interface field appearing in ForceSendFields will be sent to the
  371. // server regardless of whether the field is empty or not. This may be
  372. // used to include empty fields in Patch requests.
  373. ForceSendFields []string `json:"-"`
  374. // NullFields is a list of field names (e.g. "Locale") to include in API
  375. // requests with the JSON null value. By default, fields with empty
  376. // values are omitted from API requests. However, any field with an
  377. // empty value appearing in NullFields will be sent to the server as
  378. // null. It is an error if a field in this list has a non-empty value.
  379. // This may be used to include null fields in Patch requests.
  380. NullFields []string `json:"-"`
  381. }
  382. func (s *ResultFormattedResults) MarshalJSON() ([]byte, error) {
  383. type NoMethod ResultFormattedResults
  384. raw := NoMethod(*s)
  385. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  386. }
  387. // ResultFormattedResultsRuleResults: The enum-like identifier for this
  388. // rule. For instance "EnableKeepAlive" or "AvoidCssImport". Not
  389. // localized.
  390. type ResultFormattedResultsRuleResults struct {
  391. // Groups: List of rule groups that this rule belongs to. Each entry in
  392. // the list is one of "SPEED" or "USABILITY".
  393. Groups []string `json:"groups,omitempty"`
  394. // LocalizedRuleName: Localized name of the rule, intended for
  395. // presentation to a user.
  396. LocalizedRuleName string `json:"localizedRuleName,omitempty"`
  397. // RuleImpact: The impact (unbounded floating point value) that
  398. // implementing the suggestions for this rule would have on making the
  399. // page faster. Impact is comparable between rules to determine which
  400. // rule's suggestions would have a higher or lower impact on making a
  401. // page faster. For instance, if enabling compression would save 1MB,
  402. // while optimizing images would save 500kB, the enable compression rule
  403. // would have 2x the impact of the image optimization rule, all other
  404. // things being equal.
  405. RuleImpact float64 `json:"ruleImpact,omitempty"`
  406. // Summary: A brief summary description for the rule, indicating at a
  407. // high level what should be done to follow the rule and what benefit
  408. // can be gained by doing so.
  409. Summary *PagespeedApiFormatStringV2 `json:"summary,omitempty"`
  410. // UrlBlocks: List of blocks of URLs. Each block may contain a heading
  411. // and a list of URLs. Each URL may optionally include additional
  412. // details.
  413. UrlBlocks []*ResultFormattedResultsRuleResultsUrlBlocks `json:"urlBlocks,omitempty"`
  414. // ForceSendFields is a list of field names (e.g. "Groups") to
  415. // unconditionally include in API requests. By default, fields with
  416. // empty values are omitted from API requests. However, any non-pointer,
  417. // non-interface field appearing in ForceSendFields will be sent to the
  418. // server regardless of whether the field is empty or not. This may be
  419. // used to include empty fields in Patch requests.
  420. ForceSendFields []string `json:"-"`
  421. // NullFields is a list of field names (e.g. "Groups") to include in API
  422. // requests with the JSON null value. By default, fields with empty
  423. // values are omitted from API requests. However, any field with an
  424. // empty value appearing in NullFields will be sent to the server as
  425. // null. It is an error if a field in this list has a non-empty value.
  426. // This may be used to include null fields in Patch requests.
  427. NullFields []string `json:"-"`
  428. }
  429. func (s *ResultFormattedResultsRuleResults) MarshalJSON() ([]byte, error) {
  430. type NoMethod ResultFormattedResultsRuleResults
  431. raw := NoMethod(*s)
  432. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  433. }
  434. func (s *ResultFormattedResultsRuleResults) UnmarshalJSON(data []byte) error {
  435. type NoMethod ResultFormattedResultsRuleResults
  436. var s1 struct {
  437. RuleImpact gensupport.JSONFloat64 `json:"ruleImpact"`
  438. *NoMethod
  439. }
  440. s1.NoMethod = (*NoMethod)(s)
  441. if err := json.Unmarshal(data, &s1); err != nil {
  442. return err
  443. }
  444. s.RuleImpact = float64(s1.RuleImpact)
  445. return nil
  446. }
  447. type ResultFormattedResultsRuleResultsUrlBlocks struct {
  448. // Header: Heading to be displayed with the list of URLs.
  449. Header *PagespeedApiFormatStringV2 `json:"header,omitempty"`
  450. // Urls: List of entries that provide information about URLs in the url
  451. // block. Optional.
  452. Urls []*ResultFormattedResultsRuleResultsUrlBlocksUrls `json:"urls,omitempty"`
  453. // ForceSendFields is a list of field names (e.g. "Header") to
  454. // unconditionally include in API requests. By default, fields with
  455. // empty values are omitted from API requests. However, any non-pointer,
  456. // non-interface field appearing in ForceSendFields will be sent to the
  457. // server regardless of whether the field is empty or not. This may be
  458. // used to include empty fields in Patch requests.
  459. ForceSendFields []string `json:"-"`
  460. // NullFields is a list of field names (e.g. "Header") to include in API
  461. // requests with the JSON null value. By default, fields with empty
  462. // values are omitted from API requests. However, any field with an
  463. // empty value appearing in NullFields will be sent to the server as
  464. // null. It is an error if a field in this list has a non-empty value.
  465. // This may be used to include null fields in Patch requests.
  466. NullFields []string `json:"-"`
  467. }
  468. func (s *ResultFormattedResultsRuleResultsUrlBlocks) MarshalJSON() ([]byte, error) {
  469. type NoMethod ResultFormattedResultsRuleResultsUrlBlocks
  470. raw := NoMethod(*s)
  471. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  472. }
  473. type ResultFormattedResultsRuleResultsUrlBlocksUrls struct {
  474. // Details: List of entries that provide additional details about a
  475. // single URL. Optional.
  476. Details []*PagespeedApiFormatStringV2 `json:"details,omitempty"`
  477. // Result: A format string that gives information about the URL, and a
  478. // list of arguments for that format string.
  479. Result *PagespeedApiFormatStringV2 `json:"result,omitempty"`
  480. // ForceSendFields is a list of field names (e.g. "Details") to
  481. // unconditionally include in API requests. By default, fields with
  482. // empty values are omitted from API requests. However, any non-pointer,
  483. // non-interface field appearing in ForceSendFields will be sent to the
  484. // server regardless of whether the field is empty or not. This may be
  485. // used to include empty fields in Patch requests.
  486. ForceSendFields []string `json:"-"`
  487. // NullFields is a list of field names (e.g. "Details") to include in
  488. // API requests with the JSON null value. By default, fields with empty
  489. // values are omitted from API requests. However, any field with an
  490. // empty value appearing in NullFields will be sent to the server as
  491. // null. It is an error if a field in this list has a non-empty value.
  492. // This may be used to include null fields in Patch requests.
  493. NullFields []string `json:"-"`
  494. }
  495. func (s *ResultFormattedResultsRuleResultsUrlBlocksUrls) MarshalJSON() ([]byte, error) {
  496. type NoMethod ResultFormattedResultsRuleResultsUrlBlocksUrls
  497. raw := NoMethod(*s)
  498. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  499. }
  500. // ResultPageStats: Summary statistics for the page, such as number of
  501. // JavaScript bytes, number of HTML bytes, etc.
  502. type ResultPageStats struct {
  503. // CssResponseBytes: Number of uncompressed response bytes for CSS
  504. // resources on the page.
  505. CssResponseBytes int64 `json:"cssResponseBytes,omitempty,string"`
  506. // FlashResponseBytes: Number of response bytes for flash resources on
  507. // the page.
  508. FlashResponseBytes int64 `json:"flashResponseBytes,omitempty,string"`
  509. // HtmlResponseBytes: Number of uncompressed response bytes for the main
  510. // HTML document and all iframes on the page.
  511. HtmlResponseBytes int64 `json:"htmlResponseBytes,omitempty,string"`
  512. // ImageResponseBytes: Number of response bytes for image resources on
  513. // the page.
  514. ImageResponseBytes int64 `json:"imageResponseBytes,omitempty,string"`
  515. // JavascriptResponseBytes: Number of uncompressed response bytes for JS
  516. // resources on the page.
  517. JavascriptResponseBytes int64 `json:"javascriptResponseBytes,omitempty,string"`
  518. // NumberCssResources: Number of CSS resources referenced by the page.
  519. NumberCssResources int64 `json:"numberCssResources,omitempty"`
  520. // NumberHosts: Number of unique hosts referenced by the page.
  521. NumberHosts int64 `json:"numberHosts,omitempty"`
  522. // NumberJsResources: Number of JavaScript resources referenced by the
  523. // page.
  524. NumberJsResources int64 `json:"numberJsResources,omitempty"`
  525. // NumberResources: Number of HTTP resources loaded by the page.
  526. NumberResources int64 `json:"numberResources,omitempty"`
  527. // NumberStaticResources: Number of static (i.e. cacheable) resources on
  528. // the page.
  529. NumberStaticResources int64 `json:"numberStaticResources,omitempty"`
  530. // OtherResponseBytes: Number of response bytes for other resources on
  531. // the page.
  532. OtherResponseBytes int64 `json:"otherResponseBytes,omitempty,string"`
  533. // TextResponseBytes: Number of uncompressed response bytes for text
  534. // resources not covered by other statistics (i.e non-HTML, non-script,
  535. // non-CSS resources) on the page.
  536. TextResponseBytes int64 `json:"textResponseBytes,omitempty,string"`
  537. // TotalRequestBytes: Total size of all request bytes sent by the page.
  538. TotalRequestBytes int64 `json:"totalRequestBytes,omitempty,string"`
  539. // ForceSendFields is a list of field names (e.g. "CssResponseBytes") to
  540. // unconditionally include in API requests. By default, fields with
  541. // empty values are omitted from API requests. However, any non-pointer,
  542. // non-interface field appearing in ForceSendFields will be sent to the
  543. // server regardless of whether the field is empty or not. This may be
  544. // used to include empty fields in Patch requests.
  545. ForceSendFields []string `json:"-"`
  546. // NullFields is a list of field names (e.g. "CssResponseBytes") to
  547. // include in API requests with the JSON null value. By default, fields
  548. // with empty values are omitted from API requests. However, any field
  549. // with an empty value appearing in NullFields will be sent to the
  550. // server as null. It is an error if a field in this list has a
  551. // non-empty value. This may be used to include null fields in Patch
  552. // requests.
  553. NullFields []string `json:"-"`
  554. }
  555. func (s *ResultPageStats) MarshalJSON() ([]byte, error) {
  556. type NoMethod ResultPageStats
  557. raw := NoMethod(*s)
  558. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  559. }
  560. // ResultRuleGroups: The name of this rule group: one of "SPEED" or
  561. // "USABILITY".
  562. type ResultRuleGroups struct {
  563. // Score: The score (0-100) for this rule group, which indicates how
  564. // much better a page could be in that category (e.g. how much faster,
  565. // or how much more usable). A high score indicates little room for
  566. // improvement, while a lower score indicates more room for improvement.
  567. Score int64 `json:"score,omitempty"`
  568. // ForceSendFields is a list of field names (e.g. "Score") to
  569. // unconditionally include in API requests. By default, fields with
  570. // empty values are omitted from API requests. However, any non-pointer,
  571. // non-interface field appearing in ForceSendFields will be sent to the
  572. // server regardless of whether the field is empty or not. This may be
  573. // used to include empty fields in Patch requests.
  574. ForceSendFields []string `json:"-"`
  575. // NullFields is a list of field names (e.g. "Score") to include in API
  576. // requests with the JSON null value. By default, fields with empty
  577. // values are omitted from API requests. However, any field with an
  578. // empty value appearing in NullFields will be sent to the server as
  579. // null. It is an error if a field in this list has a non-empty value.
  580. // This may be used to include null fields in Patch requests.
  581. NullFields []string `json:"-"`
  582. }
  583. func (s *ResultRuleGroups) MarshalJSON() ([]byte, error) {
  584. type NoMethod ResultRuleGroups
  585. raw := NoMethod(*s)
  586. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  587. }
  588. // ResultVersion: The version of PageSpeed used to generate these
  589. // results.
  590. type ResultVersion struct {
  591. // Major: The major version number of PageSpeed used to generate these
  592. // results.
  593. Major int64 `json:"major,omitempty"`
  594. // Minor: The minor version number of PageSpeed used to generate these
  595. // results.
  596. Minor int64 `json:"minor,omitempty"`
  597. // ForceSendFields is a list of field names (e.g. "Major") to
  598. // unconditionally include in API requests. By default, fields with
  599. // empty values are omitted from API requests. However, any non-pointer,
  600. // non-interface field appearing in ForceSendFields will be sent to the
  601. // server regardless of whether the field is empty or not. This may be
  602. // used to include empty fields in Patch requests.
  603. ForceSendFields []string `json:"-"`
  604. // NullFields is a list of field names (e.g. "Major") to include in API
  605. // requests with the JSON null value. By default, fields with empty
  606. // values are omitted from API requests. However, any field with an
  607. // empty value appearing in NullFields will be sent to the server as
  608. // null. It is an error if a field in this list has a non-empty value.
  609. // This may be used to include null fields in Patch requests.
  610. NullFields []string `json:"-"`
  611. }
  612. func (s *ResultVersion) MarshalJSON() ([]byte, error) {
  613. type NoMethod ResultVersion
  614. raw := NoMethod(*s)
  615. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  616. }
  617. // method id "pagespeedonline.pagespeedapi.runpagespeed":
  618. type PagespeedapiRunpagespeedCall struct {
  619. s *Service
  620. urlParams_ gensupport.URLParams
  621. ifNoneMatch_ string
  622. ctx_ context.Context
  623. header_ http.Header
  624. }
  625. // Runpagespeed: Runs PageSpeed analysis on the page at the specified
  626. // URL, and returns PageSpeed scores, a list of suggestions to make that
  627. // page faster, and other information.
  628. func (r *PagespeedapiService) Runpagespeed(url string) *PagespeedapiRunpagespeedCall {
  629. c := &PagespeedapiRunpagespeedCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  630. c.urlParams_.Set("url", url)
  631. return c
  632. }
  633. // FilterThirdPartyResources sets the optional parameter
  634. // "filter_third_party_resources": Indicates if third party resources
  635. // should be filtered out before PageSpeed analysis.
  636. func (c *PagespeedapiRunpagespeedCall) FilterThirdPartyResources(filterThirdPartyResources bool) *PagespeedapiRunpagespeedCall {
  637. c.urlParams_.Set("filter_third_party_resources", fmt.Sprint(filterThirdPartyResources))
  638. return c
  639. }
  640. // Locale sets the optional parameter "locale": The locale used to
  641. // localize formatted results
  642. func (c *PagespeedapiRunpagespeedCall) Locale(locale string) *PagespeedapiRunpagespeedCall {
  643. c.urlParams_.Set("locale", locale)
  644. return c
  645. }
  646. // Rule sets the optional parameter "rule": A PageSpeed rule to run; if
  647. // none are given, all rules are run
  648. func (c *PagespeedapiRunpagespeedCall) Rule(rule ...string) *PagespeedapiRunpagespeedCall {
  649. c.urlParams_.SetMulti("rule", append([]string{}, rule...))
  650. return c
  651. }
  652. // Screenshot sets the optional parameter "screenshot": Indicates if
  653. // binary data containing a screenshot should be included
  654. func (c *PagespeedapiRunpagespeedCall) Screenshot(screenshot bool) *PagespeedapiRunpagespeedCall {
  655. c.urlParams_.Set("screenshot", fmt.Sprint(screenshot))
  656. return c
  657. }
  658. // Strategy sets the optional parameter "strategy": The analysis
  659. // strategy to use
  660. //
  661. // Possible values:
  662. // "desktop" - Fetch and analyze the URL for desktop browsers
  663. // "mobile" - Fetch and analyze the URL for mobile devices
  664. func (c *PagespeedapiRunpagespeedCall) Strategy(strategy string) *PagespeedapiRunpagespeedCall {
  665. c.urlParams_.Set("strategy", strategy)
  666. return c
  667. }
  668. // Fields allows partial responses to be retrieved. See
  669. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  670. // for more information.
  671. func (c *PagespeedapiRunpagespeedCall) Fields(s ...googleapi.Field) *PagespeedapiRunpagespeedCall {
  672. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  673. return c
  674. }
  675. // IfNoneMatch sets the optional parameter which makes the operation
  676. // fail if the object's ETag matches the given value. This is useful for
  677. // getting updates only after the object has changed since the last
  678. // request. Use googleapi.IsNotModified to check whether the response
  679. // error from Do is the result of In-None-Match.
  680. func (c *PagespeedapiRunpagespeedCall) IfNoneMatch(entityTag string) *PagespeedapiRunpagespeedCall {
  681. c.ifNoneMatch_ = entityTag
  682. return c
  683. }
  684. // Context sets the context to be used in this call's Do method. Any
  685. // pending HTTP request will be aborted if the provided context is
  686. // canceled.
  687. func (c *PagespeedapiRunpagespeedCall) Context(ctx context.Context) *PagespeedapiRunpagespeedCall {
  688. c.ctx_ = ctx
  689. return c
  690. }
  691. // Header returns an http.Header that can be modified by the caller to
  692. // add HTTP headers to the request.
  693. func (c *PagespeedapiRunpagespeedCall) Header() http.Header {
  694. if c.header_ == nil {
  695. c.header_ = make(http.Header)
  696. }
  697. return c.header_
  698. }
  699. func (c *PagespeedapiRunpagespeedCall) doRequest(alt string) (*http.Response, error) {
  700. reqHeaders := make(http.Header)
  701. for k, v := range c.header_ {
  702. reqHeaders[k] = v
  703. }
  704. reqHeaders.Set("User-Agent", c.s.userAgent())
  705. if c.ifNoneMatch_ != "" {
  706. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  707. }
  708. var body io.Reader = nil
  709. c.urlParams_.Set("alt", alt)
  710. c.urlParams_.Set("prettyPrint", "false")
  711. urls := googleapi.ResolveRelative(c.s.BasePath, "runPagespeed")
  712. urls += "?" + c.urlParams_.Encode()
  713. req, err := http.NewRequest("GET", urls, body)
  714. if err != nil {
  715. return nil, err
  716. }
  717. req.Header = reqHeaders
  718. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  719. }
  720. // Do executes the "pagespeedonline.pagespeedapi.runpagespeed" call.
  721. // Exactly one of *Result or error will be non-nil. Any non-2xx status
  722. // code is an error. Response headers are in either
  723. // *Result.ServerResponse.Header or (if a response was returned at all)
  724. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  725. // check whether the returned error was because http.StatusNotModified
  726. // was returned.
  727. func (c *PagespeedapiRunpagespeedCall) Do(opts ...googleapi.CallOption) (*Result, error) {
  728. gensupport.SetOptions(c.urlParams_, opts...)
  729. res, err := c.doRequest("json")
  730. if res != nil && res.StatusCode == http.StatusNotModified {
  731. if res.Body != nil {
  732. res.Body.Close()
  733. }
  734. return nil, &googleapi.Error{
  735. Code: res.StatusCode,
  736. Header: res.Header,
  737. }
  738. }
  739. if err != nil {
  740. return nil, err
  741. }
  742. defer googleapi.CloseBody(res)
  743. if err := googleapi.CheckResponse(res); err != nil {
  744. return nil, err
  745. }
  746. ret := &Result{
  747. ServerResponse: googleapi.ServerResponse{
  748. Header: res.Header,
  749. HTTPStatusCode: res.StatusCode,
  750. },
  751. }
  752. target := &ret
  753. if err := gensupport.DecodeResponse(target, res); err != nil {
  754. return nil, err
  755. }
  756. return ret, nil
  757. // {
  758. // "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.",
  759. // "httpMethod": "GET",
  760. // "id": "pagespeedonline.pagespeedapi.runpagespeed",
  761. // "parameterOrder": [
  762. // "url"
  763. // ],
  764. // "parameters": {
  765. // "filter_third_party_resources": {
  766. // "default": "false",
  767. // "description": "Indicates if third party resources should be filtered out before PageSpeed analysis.",
  768. // "location": "query",
  769. // "type": "boolean"
  770. // },
  771. // "locale": {
  772. // "description": "The locale used to localize formatted results",
  773. // "location": "query",
  774. // "pattern": "[a-zA-Z]+(_[a-zA-Z]+)?",
  775. // "type": "string"
  776. // },
  777. // "rule": {
  778. // "description": "A PageSpeed rule to run; if none are given, all rules are run",
  779. // "location": "query",
  780. // "pattern": "[a-zA-Z]+",
  781. // "repeated": true,
  782. // "type": "string"
  783. // },
  784. // "screenshot": {
  785. // "default": "false",
  786. // "description": "Indicates if binary data containing a screenshot should be included",
  787. // "location": "query",
  788. // "type": "boolean"
  789. // },
  790. // "strategy": {
  791. // "description": "The analysis strategy to use",
  792. // "enum": [
  793. // "desktop",
  794. // "mobile"
  795. // ],
  796. // "enumDescriptions": [
  797. // "Fetch and analyze the URL for desktop browsers",
  798. // "Fetch and analyze the URL for mobile devices"
  799. // ],
  800. // "location": "query",
  801. // "type": "string"
  802. // },
  803. // "url": {
  804. // "description": "The URL to fetch and analyze",
  805. // "location": "query",
  806. // "pattern": "(?i)http(s)?://.*",
  807. // "required": true,
  808. // "type": "string"
  809. // }
  810. // },
  811. // "path": "runPagespeed",
  812. // "response": {
  813. // "$ref": "Result"
  814. // }
  815. // }
  816. }