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.
 
 
 

1070 lines
43 KiB

  1. // Package pagespeedonline provides access to the PageSpeed Insights API.
  2. //
  3. // See https://developers.google.com/speed/docs/insights/v4/getting-started
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/pagespeedonline/v4"
  8. // ...
  9. // pagespeedonlineService, err := pagespeedonline.New(oauthHttpClient)
  10. package pagespeedonline // import "google.golang.org/api/pagespeedonline/v4"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "pagespeedonline:v4"
  41. const apiName = "pagespeedonline"
  42. const apiVersion = "v4"
  43. const basePath = "https://www.googleapis.com/pagespeedonline/v4/"
  44. func New(client *http.Client) (*Service, error) {
  45. if client == nil {
  46. return nil, errors.New("client is nil")
  47. }
  48. s := &Service{client: client, BasePath: basePath}
  49. s.Pagespeedapi = NewPagespeedapiService(s)
  50. return s, nil
  51. }
  52. type Service struct {
  53. client *http.Client
  54. BasePath string // API endpoint base URL
  55. UserAgent string // optional additional User-Agent fragment
  56. Pagespeedapi *PagespeedapiService
  57. }
  58. func (s *Service) userAgent() string {
  59. if s.UserAgent == "" {
  60. return googleapi.UserAgent
  61. }
  62. return googleapi.UserAgent + " " + s.UserAgent
  63. }
  64. func NewPagespeedapiService(s *Service) *PagespeedapiService {
  65. rs := &PagespeedapiService{s: s}
  66. return rs
  67. }
  68. type PagespeedapiService struct {
  69. s *Service
  70. }
  71. type PagespeedApiFormatStringV4 struct {
  72. // Args: List of arguments for the format string.
  73. Args []*PagespeedApiFormatStringV4Args `json:"args,omitempty"`
  74. // Format: A localized format string with {{FOO}} placeholders, where
  75. // 'FOO' is the key of the argument whose value should be substituted.
  76. // For HYPERLINK arguments, the format string will instead contain
  77. // {{BEGIN_FOO}} and {{END_FOO}} for the argument with key 'FOO'.
  78. Format string `json:"format,omitempty"`
  79. // ForceSendFields is a list of field names (e.g. "Args") to
  80. // unconditionally include in API requests. By default, fields with
  81. // empty values are omitted from API requests. However, any non-pointer,
  82. // non-interface field appearing in ForceSendFields will be sent to the
  83. // server regardless of whether the field is empty or not. This may be
  84. // used to include empty fields in Patch requests.
  85. ForceSendFields []string `json:"-"`
  86. // NullFields is a list of field names (e.g. "Args") to include in API
  87. // requests with the JSON null value. By default, fields with empty
  88. // values are omitted from API requests. However, any field with an
  89. // empty value appearing in NullFields will be sent to the server as
  90. // null. It is an error if a field in this list has a non-empty value.
  91. // This may be used to include null fields in Patch requests.
  92. NullFields []string `json:"-"`
  93. }
  94. func (s *PagespeedApiFormatStringV4) MarshalJSON() ([]byte, error) {
  95. type NoMethod PagespeedApiFormatStringV4
  96. raw := NoMethod(*s)
  97. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  98. }
  99. type PagespeedApiFormatStringV4Args struct {
  100. // Key: The placeholder key for this arg, as a string.
  101. Key string `json:"key,omitempty"`
  102. // Rects: The screen rectangles being referred to, with dimensions
  103. // measured in CSS pixels. This is only ever used for SNAPSHOT_RECT
  104. // arguments. If this is absent for a SNAPSHOT_RECT argument, it means
  105. // that that argument refers to the entire snapshot.
  106. Rects []*PagespeedApiFormatStringV4ArgsRects `json:"rects,omitempty"`
  107. // SecondaryRects: Secondary screen rectangles being referred to, with
  108. // dimensions measured in CSS pixels. This is only ever used for
  109. // SNAPSHOT_RECT arguments.
  110. SecondaryRects []*PagespeedApiFormatStringV4ArgsSecondaryRects `json:"secondary_rects,omitempty"`
  111. // Type: Type of argument. One of URL, STRING_LITERAL, INT_LITERAL,
  112. // BYTES, DURATION, VERBATIM_STRING, PERCENTAGE, HYPERLINK, or
  113. // SNAPSHOT_RECT.
  114. Type string `json:"type,omitempty"`
  115. // Value: Argument value, as a localized string.
  116. Value string `json:"value,omitempty"`
  117. // ForceSendFields is a list of field names (e.g. "Key") to
  118. // unconditionally include in API requests. By default, fields with
  119. // empty values are omitted from API requests. However, any non-pointer,
  120. // non-interface field appearing in ForceSendFields will be sent to the
  121. // server regardless of whether the field is empty or not. This may be
  122. // used to include empty fields in Patch requests.
  123. ForceSendFields []string `json:"-"`
  124. // NullFields is a list of field names (e.g. "Key") to include in API
  125. // requests with the JSON null value. By default, fields with empty
  126. // values are omitted from API requests. However, any field with an
  127. // empty value appearing in NullFields will be sent to the server as
  128. // null. It is an error if a field in this list has a non-empty value.
  129. // This may be used to include null fields in Patch requests.
  130. NullFields []string `json:"-"`
  131. }
  132. func (s *PagespeedApiFormatStringV4Args) MarshalJSON() ([]byte, error) {
  133. type NoMethod PagespeedApiFormatStringV4Args
  134. raw := NoMethod(*s)
  135. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  136. }
  137. type PagespeedApiFormatStringV4ArgsRects struct {
  138. Height int64 `json:"height,omitempty"`
  139. Left int64 `json:"left,omitempty"`
  140. Top int64 `json:"top,omitempty"`
  141. Width int64 `json:"width,omitempty"`
  142. // ForceSendFields is a list of field names (e.g. "Height") to
  143. // unconditionally include in API requests. By default, fields with
  144. // empty values are omitted from API requests. However, any non-pointer,
  145. // non-interface field appearing in ForceSendFields will be sent to the
  146. // server regardless of whether the field is empty or not. This may be
  147. // used to include empty fields in Patch requests.
  148. ForceSendFields []string `json:"-"`
  149. // NullFields is a list of field names (e.g. "Height") to include in API
  150. // requests with the JSON null value. By default, fields with empty
  151. // values are omitted from API requests. However, any field with an
  152. // empty value appearing in NullFields will be sent to the server as
  153. // null. It is an error if a field in this list has a non-empty value.
  154. // This may be used to include null fields in Patch requests.
  155. NullFields []string `json:"-"`
  156. }
  157. func (s *PagespeedApiFormatStringV4ArgsRects) MarshalJSON() ([]byte, error) {
  158. type NoMethod PagespeedApiFormatStringV4ArgsRects
  159. raw := NoMethod(*s)
  160. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  161. }
  162. type PagespeedApiFormatStringV4ArgsSecondaryRects struct {
  163. Height int64 `json:"height,omitempty"`
  164. Left int64 `json:"left,omitempty"`
  165. Top int64 `json:"top,omitempty"`
  166. Width int64 `json:"width,omitempty"`
  167. // ForceSendFields is a list of field names (e.g. "Height") to
  168. // unconditionally include in API requests. By default, fields with
  169. // empty values are omitted from API requests. However, any non-pointer,
  170. // non-interface field appearing in ForceSendFields will be sent to the
  171. // server regardless of whether the field is empty or not. This may be
  172. // used to include empty fields in Patch requests.
  173. ForceSendFields []string `json:"-"`
  174. // NullFields is a list of field names (e.g. "Height") to include in API
  175. // requests with the JSON null value. By default, fields with empty
  176. // values are omitted from API requests. However, any field with an
  177. // empty value appearing in NullFields will be sent to the server as
  178. // null. It is an error if a field in this list has a non-empty value.
  179. // This may be used to include null fields in Patch requests.
  180. NullFields []string `json:"-"`
  181. }
  182. func (s *PagespeedApiFormatStringV4ArgsSecondaryRects) MarshalJSON() ([]byte, error) {
  183. type NoMethod PagespeedApiFormatStringV4ArgsSecondaryRects
  184. raw := NoMethod(*s)
  185. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  186. }
  187. type PagespeedApiImageV4 struct {
  188. // Data: Image data base64 encoded.
  189. Data string `json:"data,omitempty"`
  190. // Height: Height of screenshot in pixels.
  191. Height int64 `json:"height,omitempty"`
  192. // Key: Unique string key, if any, identifying this image.
  193. Key string `json:"key,omitempty"`
  194. // MimeType: Mime type of image data (e.g. "image/jpeg").
  195. MimeType string `json:"mime_type,omitempty"`
  196. PageRect *PagespeedApiImageV4PageRect `json:"page_rect,omitempty"`
  197. // Width: Width of screenshot in pixels.
  198. Width int64 `json:"width,omitempty"`
  199. // ForceSendFields is a list of field names (e.g. "Data") to
  200. // unconditionally include in API requests. By default, fields with
  201. // empty values are omitted from API requests. However, any non-pointer,
  202. // non-interface field appearing in ForceSendFields will be sent to the
  203. // server regardless of whether the field is empty or not. This may be
  204. // used to include empty fields in Patch requests.
  205. ForceSendFields []string `json:"-"`
  206. // NullFields is a list of field names (e.g. "Data") to include in API
  207. // requests with the JSON null value. By default, fields with empty
  208. // values are omitted from API requests. However, any field with an
  209. // empty value appearing in NullFields will be sent to the server as
  210. // null. It is an error if a field in this list has a non-empty value.
  211. // This may be used to include null fields in Patch requests.
  212. NullFields []string `json:"-"`
  213. }
  214. func (s *PagespeedApiImageV4) MarshalJSON() ([]byte, error) {
  215. type NoMethod PagespeedApiImageV4
  216. raw := NoMethod(*s)
  217. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  218. }
  219. type PagespeedApiImageV4PageRect struct {
  220. Height int64 `json:"height,omitempty"`
  221. Left int64 `json:"left,omitempty"`
  222. Top int64 `json:"top,omitempty"`
  223. Width int64 `json:"width,omitempty"`
  224. // ForceSendFields is a list of field names (e.g. "Height") to
  225. // unconditionally include in API requests. By default, fields with
  226. // empty values are omitted from API requests. However, any non-pointer,
  227. // non-interface field appearing in ForceSendFields will be sent to the
  228. // server regardless of whether the field is empty or not. This may be
  229. // used to include empty fields in Patch requests.
  230. ForceSendFields []string `json:"-"`
  231. // NullFields is a list of field names (e.g. "Height") to include in API
  232. // requests with the JSON null value. By default, fields with empty
  233. // values are omitted from API requests. However, any field with an
  234. // empty value appearing in NullFields will be sent to the server as
  235. // null. It is an error if a field in this list has a non-empty value.
  236. // This may be used to include null fields in Patch requests.
  237. NullFields []string `json:"-"`
  238. }
  239. func (s *PagespeedApiImageV4PageRect) MarshalJSON() ([]byte, error) {
  240. type NoMethod PagespeedApiImageV4PageRect
  241. raw := NoMethod(*s)
  242. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  243. }
  244. type PagespeedApiPagespeedResponseV4 struct {
  245. // CaptchaResult: The captcha verify result
  246. CaptchaResult string `json:"captchaResult,omitempty"`
  247. // FormattedResults: Localized PageSpeed results. Contains a ruleResults
  248. // entry for each PageSpeed rule instantiated and run by the server.
  249. FormattedResults *PagespeedApiPagespeedResponseV4FormattedResults `json:"formattedResults,omitempty"`
  250. // Id: Canonicalized and final URL for the document, after following
  251. // page redirects (if any).
  252. Id string `json:"id,omitempty"`
  253. // InvalidRules: List of rules that were specified in the request, but
  254. // which the server did not know how to instantiate.
  255. InvalidRules []string `json:"invalidRules,omitempty"`
  256. // Kind: Kind of result.
  257. Kind string `json:"kind,omitempty"`
  258. // LoadingExperience: Metrics of end users' page loading experience.
  259. LoadingExperience *PagespeedApiPagespeedResponseV4LoadingExperience `json:"loadingExperience,omitempty"`
  260. // PageStats: Summary statistics for the page, such as number of
  261. // JavaScript bytes, number of HTML bytes, etc.
  262. PageStats *PagespeedApiPagespeedResponseV4PageStats `json:"pageStats,omitempty"`
  263. // ResponseCode: Response code for the document. 200 indicates a normal
  264. // page load. 4xx/5xx indicates an error.
  265. ResponseCode int64 `json:"responseCode,omitempty"`
  266. // RuleGroups: A map with one entry for each rule group in these
  267. // results.
  268. RuleGroups map[string]PagespeedApiPagespeedResponseV4RuleGroups `json:"ruleGroups,omitempty"`
  269. // Screenshot: Base64-encoded screenshot of the page that was analyzed.
  270. Screenshot *PagespeedApiImageV4 `json:"screenshot,omitempty"`
  271. // Snapshots: Additional base64-encoded screenshots of the page, in
  272. // various partial render states.
  273. Snapshots []*PagespeedApiImageV4 `json:"snapshots,omitempty"`
  274. // Title: Title of the page, as displayed in the browser's title bar.
  275. Title string `json:"title,omitempty"`
  276. // Version: The version of PageSpeed used to generate these results.
  277. Version *PagespeedApiPagespeedResponseV4Version `json:"version,omitempty"`
  278. // ServerResponse contains the HTTP response code and headers from the
  279. // server.
  280. googleapi.ServerResponse `json:"-"`
  281. // ForceSendFields is a list of field names (e.g. "CaptchaResult") to
  282. // unconditionally include in API requests. By default, fields with
  283. // empty values are omitted from API requests. However, any non-pointer,
  284. // non-interface field appearing in ForceSendFields will be sent to the
  285. // server regardless of whether the field is empty or not. This may be
  286. // used to include empty fields in Patch requests.
  287. ForceSendFields []string `json:"-"`
  288. // NullFields is a list of field names (e.g. "CaptchaResult") to include
  289. // in API requests with the JSON null value. By default, fields with
  290. // empty values are omitted from API requests. However, any field with
  291. // an empty value appearing in NullFields will be sent to the server as
  292. // null. It is an error if a field in this list has a non-empty value.
  293. // This may be used to include null fields in Patch requests.
  294. NullFields []string `json:"-"`
  295. }
  296. func (s *PagespeedApiPagespeedResponseV4) MarshalJSON() ([]byte, error) {
  297. type NoMethod PagespeedApiPagespeedResponseV4
  298. raw := NoMethod(*s)
  299. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  300. }
  301. // PagespeedApiPagespeedResponseV4FormattedResults: Localized PageSpeed
  302. // results. Contains a ruleResults entry for each PageSpeed rule
  303. // instantiated and run by the server.
  304. type PagespeedApiPagespeedResponseV4FormattedResults struct {
  305. // Locale: The locale of the formattedResults, e.g. "en_US".
  306. Locale string `json:"locale,omitempty"`
  307. // RuleResults: Dictionary of formatted rule results, with one entry for
  308. // each PageSpeed rule instantiated and run by the server.
  309. RuleResults map[string]PagespeedApiPagespeedResponseV4FormattedResultsRuleResults `json:"ruleResults,omitempty"`
  310. // ForceSendFields is a list of field names (e.g. "Locale") to
  311. // unconditionally include in API requests. By default, fields with
  312. // empty values are omitted from API requests. However, any non-pointer,
  313. // non-interface field appearing in ForceSendFields will be sent to the
  314. // server regardless of whether the field is empty or not. This may be
  315. // used to include empty fields in Patch requests.
  316. ForceSendFields []string `json:"-"`
  317. // NullFields is a list of field names (e.g. "Locale") to include in API
  318. // requests with the JSON null value. By default, fields with empty
  319. // values are omitted from API requests. However, any field with an
  320. // empty value appearing in NullFields will be sent to the server as
  321. // null. It is an error if a field in this list has a non-empty value.
  322. // This may be used to include null fields in Patch requests.
  323. NullFields []string `json:"-"`
  324. }
  325. func (s *PagespeedApiPagespeedResponseV4FormattedResults) MarshalJSON() ([]byte, error) {
  326. type NoMethod PagespeedApiPagespeedResponseV4FormattedResults
  327. raw := NoMethod(*s)
  328. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  329. }
  330. // PagespeedApiPagespeedResponseV4FormattedResultsRuleResults: The
  331. // enum-like identifier for this rule. For instance "EnableKeepAlive" or
  332. // "AvoidCssImport". Not localized.
  333. type PagespeedApiPagespeedResponseV4FormattedResultsRuleResults struct {
  334. // Beta: Whether this rule is in 'beta'. Rules in beta are new rules
  335. // that are being tested, which do not impact the overall score.
  336. Beta bool `json:"beta,omitempty"`
  337. // Groups: List of rule groups that this rule belongs to. Each entry in
  338. // the list is one of "SPEED", "USABILITY", or "SECURITY".
  339. Groups []string `json:"groups,omitempty"`
  340. // LocalizedRuleName: Localized name of the rule, intended for
  341. // presentation to a user.
  342. LocalizedRuleName string `json:"localizedRuleName,omitempty"`
  343. // RuleImpact: The impact (unbounded floating point value) that
  344. // implementing the suggestions for this rule would have on making the
  345. // page faster. Impact is comparable between rules to determine which
  346. // rule's suggestions would have a higher or lower impact on making a
  347. // page faster. For instance, if enabling compression would save 1MB,
  348. // while optimizing images would save 500kB, the enable compression rule
  349. // would have 2x the impact of the image optimization rule, all other
  350. // things being equal.
  351. RuleImpact float64 `json:"ruleImpact,omitempty"`
  352. // Summary: A brief summary description for the rule, indicating at a
  353. // high level what should be done to follow the rule and what benefit
  354. // can be gained by doing so.
  355. Summary *PagespeedApiFormatStringV4 `json:"summary,omitempty"`
  356. // UrlBlocks: List of blocks of URLs. Each block may contain a heading
  357. // and a list of URLs. Each URL may optionally include additional
  358. // details.
  359. UrlBlocks []*PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocks `json:"urlBlocks,omitempty"`
  360. // ForceSendFields is a list of field names (e.g. "Beta") to
  361. // unconditionally include in API requests. By default, fields with
  362. // empty values are omitted from API requests. However, any non-pointer,
  363. // non-interface field appearing in ForceSendFields will be sent to the
  364. // server regardless of whether the field is empty or not. This may be
  365. // used to include empty fields in Patch requests.
  366. ForceSendFields []string `json:"-"`
  367. // NullFields is a list of field names (e.g. "Beta") to include in API
  368. // requests with the JSON null value. By default, fields with empty
  369. // values are omitted from API requests. However, any field with an
  370. // empty value appearing in NullFields will be sent to the server as
  371. // null. It is an error if a field in this list has a non-empty value.
  372. // This may be used to include null fields in Patch requests.
  373. NullFields []string `json:"-"`
  374. }
  375. func (s *PagespeedApiPagespeedResponseV4FormattedResultsRuleResults) MarshalJSON() ([]byte, error) {
  376. type NoMethod PagespeedApiPagespeedResponseV4FormattedResultsRuleResults
  377. raw := NoMethod(*s)
  378. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  379. }
  380. func (s *PagespeedApiPagespeedResponseV4FormattedResultsRuleResults) UnmarshalJSON(data []byte) error {
  381. type NoMethod PagespeedApiPagespeedResponseV4FormattedResultsRuleResults
  382. var s1 struct {
  383. RuleImpact gensupport.JSONFloat64 `json:"ruleImpact"`
  384. *NoMethod
  385. }
  386. s1.NoMethod = (*NoMethod)(s)
  387. if err := json.Unmarshal(data, &s1); err != nil {
  388. return err
  389. }
  390. s.RuleImpact = float64(s1.RuleImpact)
  391. return nil
  392. }
  393. type PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocks struct {
  394. // Header: Heading to be displayed with the list of URLs.
  395. Header *PagespeedApiFormatStringV4 `json:"header,omitempty"`
  396. // Urls: List of entries that provide information about URLs in the url
  397. // block. Optional.
  398. Urls []*PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocksUrls `json:"urls,omitempty"`
  399. // ForceSendFields is a list of field names (e.g. "Header") to
  400. // unconditionally include in API requests. By default, fields with
  401. // empty values are omitted from API requests. However, any non-pointer,
  402. // non-interface field appearing in ForceSendFields will be sent to the
  403. // server regardless of whether the field is empty or not. This may be
  404. // used to include empty fields in Patch requests.
  405. ForceSendFields []string `json:"-"`
  406. // NullFields is a list of field names (e.g. "Header") to include in API
  407. // requests with the JSON null value. By default, fields with empty
  408. // values are omitted from API requests. However, any field with an
  409. // empty value appearing in NullFields will be sent to the server as
  410. // null. It is an error if a field in this list has a non-empty value.
  411. // This may be used to include null fields in Patch requests.
  412. NullFields []string `json:"-"`
  413. }
  414. func (s *PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocks) MarshalJSON() ([]byte, error) {
  415. type NoMethod PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocks
  416. raw := NoMethod(*s)
  417. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  418. }
  419. type PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocksUrls struct {
  420. // Details: List of entries that provide additional details about a
  421. // single URL. Optional.
  422. Details []*PagespeedApiFormatStringV4 `json:"details,omitempty"`
  423. // Result: A format string that gives information about the URL, and a
  424. // list of arguments for that format string.
  425. Result *PagespeedApiFormatStringV4 `json:"result,omitempty"`
  426. // ForceSendFields is a list of field names (e.g. "Details") to
  427. // unconditionally include in API requests. By default, fields with
  428. // empty values are omitted from API requests. However, any non-pointer,
  429. // non-interface field appearing in ForceSendFields will be sent to the
  430. // server regardless of whether the field is empty or not. This may be
  431. // used to include empty fields in Patch requests.
  432. ForceSendFields []string `json:"-"`
  433. // NullFields is a list of field names (e.g. "Details") to include in
  434. // API requests with the JSON null value. By default, fields with empty
  435. // values are omitted from API requests. However, any field with an
  436. // empty value appearing in NullFields will be sent to the server as
  437. // null. It is an error if a field in this list has a non-empty value.
  438. // This may be used to include null fields in Patch requests.
  439. NullFields []string `json:"-"`
  440. }
  441. func (s *PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocksUrls) MarshalJSON() ([]byte, error) {
  442. type NoMethod PagespeedApiPagespeedResponseV4FormattedResultsRuleResultsUrlBlocksUrls
  443. raw := NoMethod(*s)
  444. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  445. }
  446. // PagespeedApiPagespeedResponseV4LoadingExperience: Metrics of end
  447. // users' page loading experience.
  448. type PagespeedApiPagespeedResponseV4LoadingExperience struct {
  449. // Id: The url, pattern or origin which the metrics are on.
  450. Id string `json:"id,omitempty"`
  451. InitialUrl string `json:"initial_url,omitempty"`
  452. Metrics map[string]PagespeedApiPagespeedResponseV4LoadingExperienceMetrics `json:"metrics,omitempty"`
  453. OverallCategory string `json:"overall_category,omitempty"`
  454. // ForceSendFields is a list of field names (e.g. "Id") to
  455. // unconditionally include in API requests. By default, fields with
  456. // empty values are omitted from API requests. However, any non-pointer,
  457. // non-interface field appearing in ForceSendFields will be sent to the
  458. // server regardless of whether the field is empty or not. This may be
  459. // used to include empty fields in Patch requests.
  460. ForceSendFields []string `json:"-"`
  461. // NullFields is a list of field names (e.g. "Id") to include in API
  462. // requests with the JSON null value. By default, fields with empty
  463. // values are omitted from API requests. However, any field with an
  464. // empty value appearing in NullFields will be sent to the server as
  465. // null. It is an error if a field in this list has a non-empty value.
  466. // This may be used to include null fields in Patch requests.
  467. NullFields []string `json:"-"`
  468. }
  469. func (s *PagespeedApiPagespeedResponseV4LoadingExperience) MarshalJSON() ([]byte, error) {
  470. type NoMethod PagespeedApiPagespeedResponseV4LoadingExperience
  471. raw := NoMethod(*s)
  472. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  473. }
  474. // PagespeedApiPagespeedResponseV4LoadingExperienceMetrics: The type of
  475. // the metric.
  476. type PagespeedApiPagespeedResponseV4LoadingExperienceMetrics struct {
  477. Category string `json:"category,omitempty"`
  478. Distributions []*PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions `json:"distributions,omitempty"`
  479. Median int64 `json:"median,omitempty"`
  480. // ForceSendFields is a list of field names (e.g. "Category") 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. "Category") 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 *PagespeedApiPagespeedResponseV4LoadingExperienceMetrics) MarshalJSON() ([]byte, error) {
  496. type NoMethod PagespeedApiPagespeedResponseV4LoadingExperienceMetrics
  497. raw := NoMethod(*s)
  498. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  499. }
  500. type PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions struct {
  501. Max int64 `json:"max,omitempty"`
  502. Min int64 `json:"min,omitempty"`
  503. Proportion float64 `json:"proportion,omitempty"`
  504. // ForceSendFields is a list of field names (e.g. "Max") to
  505. // unconditionally include in API requests. By default, fields with
  506. // empty values are omitted from API requests. However, any non-pointer,
  507. // non-interface field appearing in ForceSendFields will be sent to the
  508. // server regardless of whether the field is empty or not. This may be
  509. // used to include empty fields in Patch requests.
  510. ForceSendFields []string `json:"-"`
  511. // NullFields is a list of field names (e.g. "Max") to include in API
  512. // requests with the JSON null value. By default, fields with empty
  513. // values are omitted from API requests. However, any field with an
  514. // empty value appearing in NullFields will be sent to the server as
  515. // null. It is an error if a field in this list has a non-empty value.
  516. // This may be used to include null fields in Patch requests.
  517. NullFields []string `json:"-"`
  518. }
  519. func (s *PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions) MarshalJSON() ([]byte, error) {
  520. type NoMethod PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions
  521. raw := NoMethod(*s)
  522. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  523. }
  524. func (s *PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions) UnmarshalJSON(data []byte) error {
  525. type NoMethod PagespeedApiPagespeedResponseV4LoadingExperienceMetricsDistributions
  526. var s1 struct {
  527. Proportion gensupport.JSONFloat64 `json:"proportion"`
  528. *NoMethod
  529. }
  530. s1.NoMethod = (*NoMethod)(s)
  531. if err := json.Unmarshal(data, &s1); err != nil {
  532. return err
  533. }
  534. s.Proportion = float64(s1.Proportion)
  535. return nil
  536. }
  537. // PagespeedApiPagespeedResponseV4PageStats: Summary statistics for the
  538. // page, such as number of JavaScript bytes, number of HTML bytes, etc.
  539. type PagespeedApiPagespeedResponseV4PageStats struct {
  540. // Cms: Content management system (CMS) used for the page.
  541. Cms string `json:"cms,omitempty"`
  542. // CssResponseBytes: Number of uncompressed response bytes for CSS
  543. // resources on the page.
  544. CssResponseBytes int64 `json:"cssResponseBytes,omitempty,string"`
  545. // FlashResponseBytes: Number of response bytes for flash resources on
  546. // the page.
  547. FlashResponseBytes int64 `json:"flashResponseBytes,omitempty,string"`
  548. // HtmlResponseBytes: Number of uncompressed response bytes for the main
  549. // HTML document and all iframes on the page.
  550. HtmlResponseBytes int64 `json:"htmlResponseBytes,omitempty,string"`
  551. // ImageResponseBytes: Number of response bytes for image resources on
  552. // the page.
  553. ImageResponseBytes int64 `json:"imageResponseBytes,omitempty,string"`
  554. // JavascriptResponseBytes: Number of uncompressed response bytes for JS
  555. // resources on the page.
  556. JavascriptResponseBytes int64 `json:"javascriptResponseBytes,omitempty,string"`
  557. // NumRenderBlockingRoundTrips: The needed round trips to load render
  558. // blocking resources
  559. NumRenderBlockingRoundTrips int64 `json:"numRenderBlockingRoundTrips,omitempty"`
  560. // NumTotalRoundTrips: The needed round trips to load the full page
  561. NumTotalRoundTrips int64 `json:"numTotalRoundTrips,omitempty"`
  562. // NumberCssResources: Number of CSS resources referenced by the page.
  563. NumberCssResources int64 `json:"numberCssResources,omitempty"`
  564. // NumberHosts: Number of unique hosts referenced by the page.
  565. NumberHosts int64 `json:"numberHosts,omitempty"`
  566. // NumberJsResources: Number of JavaScript resources referenced by the
  567. // page.
  568. NumberJsResources int64 `json:"numberJsResources,omitempty"`
  569. // NumberResources: Number of HTTP resources loaded by the page.
  570. NumberResources int64 `json:"numberResources,omitempty"`
  571. // NumberRobotedResources: Number of roboted resources.
  572. NumberRobotedResources int64 `json:"numberRobotedResources,omitempty"`
  573. // NumberStaticResources: Number of static (i.e. cacheable) resources on
  574. // the page.
  575. NumberStaticResources int64 `json:"numberStaticResources,omitempty"`
  576. // NumberTransientFetchFailureResources: Number of transient-failed
  577. // resources.
  578. NumberTransientFetchFailureResources int64 `json:"numberTransientFetchFailureResources,omitempty"`
  579. // OtherResponseBytes: Number of response bytes for other resources on
  580. // the page.
  581. OtherResponseBytes int64 `json:"otherResponseBytes,omitempty,string"`
  582. // OverTheWireResponseBytes: Number of over-the-wire bytes, uses the
  583. // default gzip compression strategy as an estimation.
  584. OverTheWireResponseBytes int64 `json:"overTheWireResponseBytes,omitempty,string"`
  585. // RobotedUrls: List of roboted urls.
  586. RobotedUrls []string `json:"robotedUrls,omitempty"`
  587. // TextResponseBytes: Number of uncompressed response bytes for text
  588. // resources not covered by other statistics (i.e non-HTML, non-script,
  589. // non-CSS resources) on the page.
  590. TextResponseBytes int64 `json:"textResponseBytes,omitempty,string"`
  591. // TotalRequestBytes: Total size of all request bytes sent by the page.
  592. TotalRequestBytes int64 `json:"totalRequestBytes,omitempty,string"`
  593. // TransientFetchFailureUrls: List of transient fetch failure urls.
  594. TransientFetchFailureUrls []string `json:"transientFetchFailureUrls,omitempty"`
  595. // ForceSendFields is a list of field names (e.g. "Cms") to
  596. // unconditionally include in API requests. By default, fields with
  597. // empty values are omitted from API requests. However, any non-pointer,
  598. // non-interface field appearing in ForceSendFields will be sent to the
  599. // server regardless of whether the field is empty or not. This may be
  600. // used to include empty fields in Patch requests.
  601. ForceSendFields []string `json:"-"`
  602. // NullFields is a list of field names (e.g. "Cms") to include in API
  603. // requests with the JSON null value. By default, fields with empty
  604. // values are omitted from API requests. However, any field with an
  605. // empty value appearing in NullFields will be sent to the server as
  606. // null. It is an error if a field in this list has a non-empty value.
  607. // This may be used to include null fields in Patch requests.
  608. NullFields []string `json:"-"`
  609. }
  610. func (s *PagespeedApiPagespeedResponseV4PageStats) MarshalJSON() ([]byte, error) {
  611. type NoMethod PagespeedApiPagespeedResponseV4PageStats
  612. raw := NoMethod(*s)
  613. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  614. }
  615. // PagespeedApiPagespeedResponseV4RuleGroups: The name of this rule
  616. // group: one of "SPEED", "USABILITY", or "SECURITY".
  617. type PagespeedApiPagespeedResponseV4RuleGroups struct {
  618. Pass bool `json:"pass,omitempty"`
  619. // Score: The score (0-100) for this rule group, which indicates how
  620. // much better a page could be in that category (e.g. how much faster,
  621. // or how much more usable, or how much more secure). A high score
  622. // indicates little room for improvement, while a lower score indicates
  623. // more room for improvement.
  624. Score int64 `json:"score,omitempty"`
  625. // ForceSendFields is a list of field names (e.g. "Pass") to
  626. // unconditionally include in API requests. By default, fields with
  627. // empty values are omitted from API requests. However, any non-pointer,
  628. // non-interface field appearing in ForceSendFields will be sent to the
  629. // server regardless of whether the field is empty or not. This may be
  630. // used to include empty fields in Patch requests.
  631. ForceSendFields []string `json:"-"`
  632. // NullFields is a list of field names (e.g. "Pass") to include in API
  633. // requests with the JSON null value. By default, fields with empty
  634. // values are omitted from API requests. However, any field with an
  635. // empty value appearing in NullFields will be sent to the server as
  636. // null. It is an error if a field in this list has a non-empty value.
  637. // This may be used to include null fields in Patch requests.
  638. NullFields []string `json:"-"`
  639. }
  640. func (s *PagespeedApiPagespeedResponseV4RuleGroups) MarshalJSON() ([]byte, error) {
  641. type NoMethod PagespeedApiPagespeedResponseV4RuleGroups
  642. raw := NoMethod(*s)
  643. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  644. }
  645. // PagespeedApiPagespeedResponseV4Version: The version of PageSpeed used
  646. // to generate these results.
  647. type PagespeedApiPagespeedResponseV4Version struct {
  648. // Major: The major version number of PageSpeed used to generate these
  649. // results.
  650. Major int64 `json:"major,omitempty"`
  651. // Minor: The minor version number of PageSpeed used to generate these
  652. // results.
  653. Minor int64 `json:"minor,omitempty"`
  654. // ForceSendFields is a list of field names (e.g. "Major") to
  655. // unconditionally include in API requests. By default, fields with
  656. // empty values are omitted from API requests. However, any non-pointer,
  657. // non-interface field appearing in ForceSendFields will be sent to the
  658. // server regardless of whether the field is empty or not. This may be
  659. // used to include empty fields in Patch requests.
  660. ForceSendFields []string `json:"-"`
  661. // NullFields is a list of field names (e.g. "Major") to include in API
  662. // requests with the JSON null value. By default, fields with empty
  663. // values are omitted from API requests. However, any field with an
  664. // empty value appearing in NullFields will be sent to the server as
  665. // null. It is an error if a field in this list has a non-empty value.
  666. // This may be used to include null fields in Patch requests.
  667. NullFields []string `json:"-"`
  668. }
  669. func (s *PagespeedApiPagespeedResponseV4Version) MarshalJSON() ([]byte, error) {
  670. type NoMethod PagespeedApiPagespeedResponseV4Version
  671. raw := NoMethod(*s)
  672. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  673. }
  674. // method id "pagespeedonline.pagespeedapi.runpagespeed":
  675. type PagespeedapiRunpagespeedCall struct {
  676. s *Service
  677. urlParams_ gensupport.URLParams
  678. ifNoneMatch_ string
  679. ctx_ context.Context
  680. header_ http.Header
  681. }
  682. // Runpagespeed: Runs PageSpeed analysis on the page at the specified
  683. // URL, and returns PageSpeed scores, a list of suggestions to make that
  684. // page faster, and other information.
  685. func (r *PagespeedapiService) Runpagespeed(url string) *PagespeedapiRunpagespeedCall {
  686. c := &PagespeedapiRunpagespeedCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  687. c.urlParams_.Set("url", url)
  688. return c
  689. }
  690. // FilterThirdPartyResources sets the optional parameter
  691. // "filter_third_party_resources": Indicates if third party resources
  692. // should be filtered out before PageSpeed analysis.
  693. func (c *PagespeedapiRunpagespeedCall) FilterThirdPartyResources(filterThirdPartyResources bool) *PagespeedapiRunpagespeedCall {
  694. c.urlParams_.Set("filter_third_party_resources", fmt.Sprint(filterThirdPartyResources))
  695. return c
  696. }
  697. // Locale sets the optional parameter "locale": The locale used to
  698. // localize formatted results
  699. func (c *PagespeedapiRunpagespeedCall) Locale(locale string) *PagespeedapiRunpagespeedCall {
  700. c.urlParams_.Set("locale", locale)
  701. return c
  702. }
  703. // Rule sets the optional parameter "rule": A PageSpeed rule to run; if
  704. // none are given, all rules are run
  705. func (c *PagespeedapiRunpagespeedCall) Rule(rule ...string) *PagespeedapiRunpagespeedCall {
  706. c.urlParams_.SetMulti("rule", append([]string{}, rule...))
  707. return c
  708. }
  709. // Screenshot sets the optional parameter "screenshot": Indicates if
  710. // binary data containing a screenshot should be included
  711. func (c *PagespeedapiRunpagespeedCall) Screenshot(screenshot bool) *PagespeedapiRunpagespeedCall {
  712. c.urlParams_.Set("screenshot", fmt.Sprint(screenshot))
  713. return c
  714. }
  715. // Snapshots sets the optional parameter "snapshots": Indicates if
  716. // binary data containing snapshot images should be included
  717. func (c *PagespeedapiRunpagespeedCall) Snapshots(snapshots bool) *PagespeedapiRunpagespeedCall {
  718. c.urlParams_.Set("snapshots", fmt.Sprint(snapshots))
  719. return c
  720. }
  721. // Strategy sets the optional parameter "strategy": The analysis
  722. // strategy (desktop or mobile) to use, and desktop is the default
  723. //
  724. // Possible values:
  725. // "desktop" - Fetch and analyze the URL for desktop browsers
  726. // "mobile" - Fetch and analyze the URL for mobile devices
  727. func (c *PagespeedapiRunpagespeedCall) Strategy(strategy string) *PagespeedapiRunpagespeedCall {
  728. c.urlParams_.Set("strategy", strategy)
  729. return c
  730. }
  731. // UtmCampaign sets the optional parameter "utm_campaign": Campaign name
  732. // for analytics.
  733. func (c *PagespeedapiRunpagespeedCall) UtmCampaign(utmCampaign string) *PagespeedapiRunpagespeedCall {
  734. c.urlParams_.Set("utm_campaign", utmCampaign)
  735. return c
  736. }
  737. // UtmSource sets the optional parameter "utm_source": Campaign source
  738. // for analytics.
  739. func (c *PagespeedapiRunpagespeedCall) UtmSource(utmSource string) *PagespeedapiRunpagespeedCall {
  740. c.urlParams_.Set("utm_source", utmSource)
  741. return c
  742. }
  743. // Fields allows partial responses to be retrieved. See
  744. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  745. // for more information.
  746. func (c *PagespeedapiRunpagespeedCall) Fields(s ...googleapi.Field) *PagespeedapiRunpagespeedCall {
  747. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  748. return c
  749. }
  750. // IfNoneMatch sets the optional parameter which makes the operation
  751. // fail if the object's ETag matches the given value. This is useful for
  752. // getting updates only after the object has changed since the last
  753. // request. Use googleapi.IsNotModified to check whether the response
  754. // error from Do is the result of In-None-Match.
  755. func (c *PagespeedapiRunpagespeedCall) IfNoneMatch(entityTag string) *PagespeedapiRunpagespeedCall {
  756. c.ifNoneMatch_ = entityTag
  757. return c
  758. }
  759. // Context sets the context to be used in this call's Do method. Any
  760. // pending HTTP request will be aborted if the provided context is
  761. // canceled.
  762. func (c *PagespeedapiRunpagespeedCall) Context(ctx context.Context) *PagespeedapiRunpagespeedCall {
  763. c.ctx_ = ctx
  764. return c
  765. }
  766. // Header returns an http.Header that can be modified by the caller to
  767. // add HTTP headers to the request.
  768. func (c *PagespeedapiRunpagespeedCall) Header() http.Header {
  769. if c.header_ == nil {
  770. c.header_ = make(http.Header)
  771. }
  772. return c.header_
  773. }
  774. func (c *PagespeedapiRunpagespeedCall) doRequest(alt string) (*http.Response, error) {
  775. reqHeaders := make(http.Header)
  776. for k, v := range c.header_ {
  777. reqHeaders[k] = v
  778. }
  779. reqHeaders.Set("User-Agent", c.s.userAgent())
  780. if c.ifNoneMatch_ != "" {
  781. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  782. }
  783. var body io.Reader = nil
  784. c.urlParams_.Set("alt", alt)
  785. urls := googleapi.ResolveRelative(c.s.BasePath, "runPagespeed")
  786. urls += "?" + c.urlParams_.Encode()
  787. req, _ := http.NewRequest("GET", urls, body)
  788. req.Header = reqHeaders
  789. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  790. }
  791. // Do executes the "pagespeedonline.pagespeedapi.runpagespeed" call.
  792. // Exactly one of *PagespeedApiPagespeedResponseV4 or error will be
  793. // non-nil. Any non-2xx status code is an error. Response headers are in
  794. // either *PagespeedApiPagespeedResponseV4.ServerResponse.Header or (if
  795. // a response was returned at all) in error.(*googleapi.Error).Header.
  796. // Use googleapi.IsNotModified to check whether the returned error was
  797. // because http.StatusNotModified was returned.
  798. func (c *PagespeedapiRunpagespeedCall) Do(opts ...googleapi.CallOption) (*PagespeedApiPagespeedResponseV4, error) {
  799. gensupport.SetOptions(c.urlParams_, opts...)
  800. res, err := c.doRequest("json")
  801. if res != nil && res.StatusCode == http.StatusNotModified {
  802. if res.Body != nil {
  803. res.Body.Close()
  804. }
  805. return nil, &googleapi.Error{
  806. Code: res.StatusCode,
  807. Header: res.Header,
  808. }
  809. }
  810. if err != nil {
  811. return nil, err
  812. }
  813. defer googleapi.CloseBody(res)
  814. if err := googleapi.CheckResponse(res); err != nil {
  815. return nil, err
  816. }
  817. ret := &PagespeedApiPagespeedResponseV4{
  818. ServerResponse: googleapi.ServerResponse{
  819. Header: res.Header,
  820. HTTPStatusCode: res.StatusCode,
  821. },
  822. }
  823. target := &ret
  824. if err := gensupport.DecodeResponse(target, res); err != nil {
  825. return nil, err
  826. }
  827. return ret, nil
  828. // {
  829. // "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.",
  830. // "httpMethod": "GET",
  831. // "id": "pagespeedonline.pagespeedapi.runpagespeed",
  832. // "parameterOrder": [
  833. // "url"
  834. // ],
  835. // "parameters": {
  836. // "filter_third_party_resources": {
  837. // "default": "false",
  838. // "description": "Indicates if third party resources should be filtered out before PageSpeed analysis.",
  839. // "location": "query",
  840. // "type": "boolean"
  841. // },
  842. // "locale": {
  843. // "description": "The locale used to localize formatted results",
  844. // "location": "query",
  845. // "pattern": "[a-zA-Z]+(_[a-zA-Z]+)?",
  846. // "type": "string"
  847. // },
  848. // "rule": {
  849. // "description": "A PageSpeed rule to run; if none are given, all rules are run",
  850. // "location": "query",
  851. // "pattern": "[a-zA-Z]+",
  852. // "repeated": true,
  853. // "type": "string"
  854. // },
  855. // "screenshot": {
  856. // "default": "false",
  857. // "description": "Indicates if binary data containing a screenshot should be included",
  858. // "location": "query",
  859. // "type": "boolean"
  860. // },
  861. // "snapshots": {
  862. // "default": "false",
  863. // "description": "Indicates if binary data containing snapshot images should be included",
  864. // "location": "query",
  865. // "type": "boolean"
  866. // },
  867. // "strategy": {
  868. // "description": "The analysis strategy (desktop or mobile) to use, and desktop is the default",
  869. // "enum": [
  870. // "desktop",
  871. // "mobile"
  872. // ],
  873. // "enumDescriptions": [
  874. // "Fetch and analyze the URL for desktop browsers",
  875. // "Fetch and analyze the URL for mobile devices"
  876. // ],
  877. // "location": "query",
  878. // "type": "string"
  879. // },
  880. // "url": {
  881. // "description": "The URL to fetch and analyze",
  882. // "location": "query",
  883. // "pattern": "(?i)(site:|origin:)?http(s)?://.*",
  884. // "required": true,
  885. // "type": "string"
  886. // },
  887. // "utm_campaign": {
  888. // "description": "Campaign name for analytics.",
  889. // "location": "query",
  890. // "type": "string"
  891. // },
  892. // "utm_source": {
  893. // "description": "Campaign source for analytics.",
  894. // "location": "query",
  895. // "type": "string"
  896. // }
  897. // },
  898. // "path": "runPagespeed",
  899. // "response": {
  900. // "$ref": "PagespeedApiPagespeedResponseV4"
  901. // }
  902. // }
  903. }