Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

859 linhas
34 KiB

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