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.
 
 
 

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