~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/google.golang.org/api/pagespeedonline/v1/pagespeedonline-gen.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
11
 
 
12
import (
 
13
        "bytes"
 
14
        "encoding/json"
 
15
        "errors"
 
16
        "fmt"
 
17
        "google.golang.org/api/googleapi"
 
18
        "io"
 
19
        "net/http"
 
20
        "net/url"
 
21
        "strconv"
 
22
        "strings"
 
23
)
 
24
 
 
25
// Always reference these packages, just in case the auto-generated code
 
26
// below doesn't.
 
27
var _ = bytes.NewBuffer
 
28
var _ = strconv.Itoa
 
29
var _ = fmt.Sprintf
 
30
var _ = json.NewDecoder
 
31
var _ = io.Copy
 
32
var _ = url.Parse
 
33
var _ = googleapi.Version
 
34
var _ = errors.New
 
35
var _ = strings.Replace
 
36
 
 
37
const apiId = "pagespeedonline:v1"
 
38
const apiName = "pagespeedonline"
 
39
const apiVersion = "v1"
 
40
const basePath = "https://www.googleapis.com/pagespeedonline/v1/"
 
41
 
 
42
func New(client *http.Client) (*Service, error) {
 
43
        if client == nil {
 
44
                return nil, errors.New("client is nil")
 
45
        }
 
46
        s := &Service{client: client, BasePath: basePath}
 
47
        s.Pagespeedapi = NewPagespeedapiService(s)
 
48
        return s, nil
 
49
}
 
50
 
 
51
type Service struct {
 
52
        client   *http.Client
 
53
        BasePath string // API endpoint base URL
 
54
 
 
55
        Pagespeedapi *PagespeedapiService
 
56
}
 
57
 
 
58
func NewPagespeedapiService(s *Service) *PagespeedapiService {
 
59
        rs := &PagespeedapiService{s: s}
 
60
        return rs
 
61
}
 
62
 
 
63
type PagespeedapiService struct {
 
64
        s *Service
 
65
}
 
66
 
 
67
type Result struct {
 
68
        // FormattedResults: Localized Page Speed results. Contains a
 
69
        // ruleResults entry for each Page Speed rule instantiated and run by
 
70
        // the server.
 
71
        FormattedResults *ResultFormattedResults `json:"formattedResults,omitempty"`
 
72
 
 
73
        // Id: Canonicalized and final URL for the document, after following
 
74
        // page redirects (if any).
 
75
        Id string `json:"id,omitempty"`
 
76
 
 
77
        // InvalidRules: List of rules that were specified in the request, but
 
78
        // which the server did not know how to instantiate.
 
79
        InvalidRules []string `json:"invalidRules,omitempty"`
 
80
 
 
81
        // Kind: Kind of result.
 
82
        Kind string `json:"kind,omitempty"`
 
83
 
 
84
        // PageStats: Summary statistics for the page, such as number of
 
85
        // JavaScript bytes, number of HTML bytes, etc.
 
86
        PageStats *ResultPageStats `json:"pageStats,omitempty"`
 
87
 
 
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
 
 
92
        // Score: The Page Speed Score (0-100), which indicates how much faster
 
93
        // a page could be. A high score indicates little room for improvement,
 
94
        // while a lower score indicates more room for improvement.
 
95
        Score int64 `json:"score,omitempty"`
 
96
 
 
97
        // Screenshot: Base64 encoded screenshot of the page that was analyzed.
 
98
        Screenshot *ResultScreenshot `json:"screenshot,omitempty"`
 
99
 
 
100
        // Title: Title of the page, as displayed in the browser's title bar.
 
101
        Title string `json:"title,omitempty"`
 
102
 
 
103
        // Version: The version of the Page Speed SDK used to generate these
 
104
        // results.
 
105
        Version *ResultVersion `json:"version,omitempty"`
 
106
}
 
107
 
 
108
type ResultFormattedResults struct {
 
109
        // Locale: The locale of the formattedResults, e.g. "en_US".
 
110
        Locale string `json:"locale,omitempty"`
 
111
 
 
112
        // RuleResults: Dictionary of formatted rule results, with one entry for
 
113
        // each Page Speed rule instantiated and run by the server.
 
114
        RuleResults *ResultFormattedResultsRuleResults `json:"ruleResults,omitempty"`
 
115
}
 
116
 
 
117
type ResultFormattedResultsRuleResults struct {
 
118
}
 
119
 
 
120
type ResultPageStats struct {
 
121
        // CssResponseBytes: Number of uncompressed response bytes for CSS
 
122
        // resources on the page.
 
123
        CssResponseBytes int64 `json:"cssResponseBytes,omitempty,string"`
 
124
 
 
125
        // FlashResponseBytes: Number of response bytes for flash resources on
 
126
        // the page.
 
127
        FlashResponseBytes int64 `json:"flashResponseBytes,omitempty,string"`
 
128
 
 
129
        // HtmlResponseBytes: Number of uncompressed response bytes for the main
 
130
        // HTML document and all iframes on the page.
 
131
        HtmlResponseBytes int64 `json:"htmlResponseBytes,omitempty,string"`
 
132
 
 
133
        // ImageResponseBytes: Number of response bytes for image resources on
 
134
        // the page.
 
135
        ImageResponseBytes int64 `json:"imageResponseBytes,omitempty,string"`
 
136
 
 
137
        // JavascriptResponseBytes: Number of uncompressed response bytes for JS
 
138
        // resources on the page.
 
139
        JavascriptResponseBytes int64 `json:"javascriptResponseBytes,omitempty,string"`
 
140
 
 
141
        // NumberCssResources: Number of CSS resources referenced by the page.
 
142
        NumberCssResources int64 `json:"numberCssResources,omitempty"`
 
143
 
 
144
        // NumberHosts: Number of unique hosts referenced by the page.
 
145
        NumberHosts int64 `json:"numberHosts,omitempty"`
 
146
 
 
147
        // NumberJsResources: Number of JavaScript resources referenced by the
 
148
        // page.
 
149
        NumberJsResources int64 `json:"numberJsResources,omitempty"`
 
150
 
 
151
        // NumberResources: Number of HTTP resources loaded by the page.
 
152
        NumberResources int64 `json:"numberResources,omitempty"`
 
153
 
 
154
        // NumberStaticResources: Number of static (i.e. cacheable) resources on
 
155
        // the page.
 
156
        NumberStaticResources int64 `json:"numberStaticResources,omitempty"`
 
157
 
 
158
        // OtherResponseBytes: Number of response bytes for other resources on
 
159
        // the page.
 
160
        OtherResponseBytes int64 `json:"otherResponseBytes,omitempty,string"`
 
161
 
 
162
        // TextResponseBytes: Number of uncompressed response bytes for text
 
163
        // resources not covered by other statistics (i.e non-HTML, non-script,
 
164
        // non-CSS resources) on the page.
 
165
        TextResponseBytes int64 `json:"textResponseBytes,omitempty,string"`
 
166
 
 
167
        // TotalRequestBytes: Total size of all request bytes sent by the page.
 
168
        TotalRequestBytes int64 `json:"totalRequestBytes,omitempty,string"`
 
169
}
 
170
 
 
171
type ResultScreenshot struct {
 
172
        // Data: Image data base64 encoded.
 
173
        Data string `json:"data,omitempty"`
 
174
 
 
175
        // Height: Height of screenshot in pixels.
 
176
        Height int64 `json:"height,omitempty"`
 
177
 
 
178
        // Mime_type: Mime type of image data. E.g. "image/jpeg".
 
179
        Mime_type string `json:"mime_type,omitempty"`
 
180
 
 
181
        // Width: Width of screenshot in pixels.
 
182
        Width int64 `json:"width,omitempty"`
 
183
}
 
184
 
 
185
type ResultVersion struct {
 
186
        // Major: The major version number of the Page Speed SDK used to
 
187
        // generate these results.
 
188
        Major int64 `json:"major,omitempty"`
 
189
 
 
190
        // Minor: The minor version number of the Page Speed SDK used to
 
191
        // generate these results.
 
192
        Minor int64 `json:"minor,omitempty"`
 
193
}
 
194
 
 
195
// method id "pagespeedonline.pagespeedapi.runpagespeed":
 
196
 
 
197
type PagespeedapiRunpagespeedCall struct {
 
198
        s    *Service
 
199
        url  string
 
200
        opt_ map[string]interface{}
 
201
}
 
202
 
 
203
// Runpagespeed: Runs Page Speed analysis on the page at the specified
 
204
// URL, and returns a Page Speed score, a list of suggestions to make
 
205
// that page faster, and other information.
 
206
func (r *PagespeedapiService) Runpagespeed(url string) *PagespeedapiRunpagespeedCall {
 
207
        c := &PagespeedapiRunpagespeedCall{s: r.s, opt_: make(map[string]interface{})}
 
208
        c.url = url
 
209
        return c
 
210
}
 
211
 
 
212
// Filter_third_party_resources sets the optional parameter
 
213
// "filter_third_party_resources": Indicates if third party resources
 
214
// should be filtered out before PageSpeed analysis.
 
215
func (c *PagespeedapiRunpagespeedCall) Filter_third_party_resources(filter_third_party_resources bool) *PagespeedapiRunpagespeedCall {
 
216
        c.opt_["filter_third_party_resources"] = filter_third_party_resources
 
217
        return c
 
218
}
 
219
 
 
220
// Locale sets the optional parameter "locale": The locale used to
 
221
// localize formatted results
 
222
func (c *PagespeedapiRunpagespeedCall) Locale(locale string) *PagespeedapiRunpagespeedCall {
 
223
        c.opt_["locale"] = locale
 
224
        return c
 
225
}
 
226
 
 
227
// Rule sets the optional parameter "rule": A Page Speed rule to run; if
 
228
// none are given, all rules are run
 
229
func (c *PagespeedapiRunpagespeedCall) Rule(rule string) *PagespeedapiRunpagespeedCall {
 
230
        c.opt_["rule"] = rule
 
231
        return c
 
232
}
 
233
 
 
234
// Screenshot sets the optional parameter "screenshot": Indicates if
 
235
// binary data containing a screenshot should be included
 
236
func (c *PagespeedapiRunpagespeedCall) Screenshot(screenshot bool) *PagespeedapiRunpagespeedCall {
 
237
        c.opt_["screenshot"] = screenshot
 
238
        return c
 
239
}
 
240
 
 
241
// Strategy sets the optional parameter "strategy": The analysis
 
242
// strategy to use
 
243
func (c *PagespeedapiRunpagespeedCall) Strategy(strategy string) *PagespeedapiRunpagespeedCall {
 
244
        c.opt_["strategy"] = strategy
 
245
        return c
 
246
}
 
247
 
 
248
// Fields allows partial responses to be retrieved.
 
249
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
 
250
// for more information.
 
251
func (c *PagespeedapiRunpagespeedCall) Fields(s ...googleapi.Field) *PagespeedapiRunpagespeedCall {
 
252
        c.opt_["fields"] = googleapi.CombineFields(s)
 
253
        return c
 
254
}
 
255
 
 
256
func (c *PagespeedapiRunpagespeedCall) Do() (*Result, error) {
 
257
        var body io.Reader = nil
 
258
        params := make(url.Values)
 
259
        params.Set("alt", "json")
 
260
        params.Set("url", fmt.Sprintf("%v", c.url))
 
261
        if v, ok := c.opt_["filter_third_party_resources"]; ok {
 
262
                params.Set("filter_third_party_resources", fmt.Sprintf("%v", v))
 
263
        }
 
264
        if v, ok := c.opt_["locale"]; ok {
 
265
                params.Set("locale", fmt.Sprintf("%v", v))
 
266
        }
 
267
        if v, ok := c.opt_["rule"]; ok {
 
268
                params.Set("rule", fmt.Sprintf("%v", v))
 
269
        }
 
270
        if v, ok := c.opt_["screenshot"]; ok {
 
271
                params.Set("screenshot", fmt.Sprintf("%v", v))
 
272
        }
 
273
        if v, ok := c.opt_["strategy"]; ok {
 
274
                params.Set("strategy", fmt.Sprintf("%v", v))
 
275
        }
 
276
        if v, ok := c.opt_["fields"]; ok {
 
277
                params.Set("fields", fmt.Sprintf("%v", v))
 
278
        }
 
279
        urls := googleapi.ResolveRelative(c.s.BasePath, "runPagespeed")
 
280
        urls += "?" + params.Encode()
 
281
        req, _ := http.NewRequest("GET", urls, body)
 
282
        googleapi.SetOpaque(req.URL)
 
283
        req.Header.Set("User-Agent", "google-api-go-client/0.5")
 
284
        res, err := c.s.client.Do(req)
 
285
        if err != nil {
 
286
                return nil, err
 
287
        }
 
288
        defer googleapi.CloseBody(res)
 
289
        if err := googleapi.CheckResponse(res); err != nil {
 
290
                return nil, err
 
291
        }
 
292
        var ret *Result
 
293
        if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
 
294
                return nil, err
 
295
        }
 
296
        return ret, nil
 
297
        // {
 
298
        //   "description": "Runs Page Speed analysis on the page at the specified URL, and returns a Page Speed score, a list of suggestions to make that page faster, and other information.",
 
299
        //   "httpMethod": "GET",
 
300
        //   "id": "pagespeedonline.pagespeedapi.runpagespeed",
 
301
        //   "parameterOrder": [
 
302
        //     "url"
 
303
        //   ],
 
304
        //   "parameters": {
 
305
        //     "filter_third_party_resources": {
 
306
        //       "default": "false",
 
307
        //       "description": "Indicates if third party resources should be filtered out before PageSpeed analysis.",
 
308
        //       "location": "query",
 
309
        //       "type": "boolean"
 
310
        //     },
 
311
        //     "locale": {
 
312
        //       "description": "The locale used to localize formatted results",
 
313
        //       "location": "query",
 
314
        //       "pattern": "[a-zA-Z]+(_[a-zA-Z]+)?",
 
315
        //       "type": "string"
 
316
        //     },
 
317
        //     "rule": {
 
318
        //       "description": "A Page Speed rule to run; if none are given, all rules are run",
 
319
        //       "location": "query",
 
320
        //       "pattern": "[a-zA-Z]+",
 
321
        //       "repeated": true,
 
322
        //       "type": "string"
 
323
        //     },
 
324
        //     "screenshot": {
 
325
        //       "default": "false",
 
326
        //       "description": "Indicates if binary data containing a screenshot should be included",
 
327
        //       "location": "query",
 
328
        //       "type": "boolean"
 
329
        //     },
 
330
        //     "strategy": {
 
331
        //       "description": "The analysis strategy to use",
 
332
        //       "enum": [
 
333
        //         "desktop",
 
334
        //         "mobile"
 
335
        //       ],
 
336
        //       "enumDescriptions": [
 
337
        //         "Fetch and analyze the URL for desktop browsers",
 
338
        //         "Fetch and analyze the URL for mobile devices"
 
339
        //       ],
 
340
        //       "location": "query",
 
341
        //       "type": "string"
 
342
        //     },
 
343
        //     "url": {
 
344
        //       "description": "The URL to fetch and analyze",
 
345
        //       "location": "query",
 
346
        //       "pattern": "http(s)?://.*",
 
347
        //       "required": true,
 
348
        //       "type": "string"
 
349
        //     }
 
350
        //   },
 
351
        //   "path": "runPagespeed",
 
352
        //   "response": {
 
353
        //     "$ref": "Result"
 
354
        //   }
 
355
        // }
 
356
 
 
357
}