google-apis-pagespeedonline_v5 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ # Copyright 2020 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Apis
17
+ module PagespeedonlineV5
18
+ # Version of the google-apis-pagespeedonline_v5 gem
19
+ GEM_VERSION = "0.1.0"
20
+
21
+ # Version of the code generator used to generate this client
22
+ GENERATOR_VERSION = "0.1.1"
23
+
24
+ # Revision of the discovery document this client was generated from
25
+ REVISION = "20201130"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,361 @@
1
+ # Copyright 2020 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'date'
16
+ require 'google/apis/core/base_service'
17
+ require 'google/apis/core/json_representation'
18
+ require 'google/apis/core/hashable'
19
+ require 'google/apis/errors'
20
+
21
+ module Google
22
+ module Apis
23
+ module PagespeedonlineV5
24
+
25
+ class AuditRefs
26
+ class Representation < Google::Apis::Core::JsonRepresentation; end
27
+
28
+ include Google::Apis::Core::JsonObjectSupport
29
+ end
30
+
31
+ class Bucket
32
+ class Representation < Google::Apis::Core::JsonRepresentation; end
33
+
34
+ include Google::Apis::Core::JsonObjectSupport
35
+ end
36
+
37
+ class Categories
38
+ class Representation < Google::Apis::Core::JsonRepresentation; end
39
+
40
+ include Google::Apis::Core::JsonObjectSupport
41
+ end
42
+
43
+ class CategoryGroupV5
44
+ class Representation < Google::Apis::Core::JsonRepresentation; end
45
+
46
+ include Google::Apis::Core::JsonObjectSupport
47
+ end
48
+
49
+ class ConfigSettings
50
+ class Representation < Google::Apis::Core::JsonRepresentation; end
51
+
52
+ include Google::Apis::Core::JsonObjectSupport
53
+ end
54
+
55
+ class Environment
56
+ class Representation < Google::Apis::Core::JsonRepresentation; end
57
+
58
+ include Google::Apis::Core::JsonObjectSupport
59
+ end
60
+
61
+ class I18n
62
+ class Representation < Google::Apis::Core::JsonRepresentation; end
63
+
64
+ include Google::Apis::Core::JsonObjectSupport
65
+ end
66
+
67
+ class LighthouseAuditResultV5
68
+ class Representation < Google::Apis::Core::JsonRepresentation; end
69
+
70
+ include Google::Apis::Core::JsonObjectSupport
71
+ end
72
+
73
+ class LighthouseCategoryV5
74
+ class Representation < Google::Apis::Core::JsonRepresentation; end
75
+
76
+ include Google::Apis::Core::JsonObjectSupport
77
+ end
78
+
79
+ class LighthouseResultV5
80
+ class Representation < Google::Apis::Core::JsonRepresentation; end
81
+
82
+ include Google::Apis::Core::JsonObjectSupport
83
+ end
84
+
85
+ class PagespeedApiLoadingExperienceV5
86
+ class Representation < Google::Apis::Core::JsonRepresentation; end
87
+
88
+ include Google::Apis::Core::JsonObjectSupport
89
+ end
90
+
91
+ class PagespeedApiPagespeedResponseV5
92
+ class Representation < Google::Apis::Core::JsonRepresentation; end
93
+
94
+ include Google::Apis::Core::JsonObjectSupport
95
+ end
96
+
97
+ class PagespeedVersion
98
+ class Representation < Google::Apis::Core::JsonRepresentation; end
99
+
100
+ include Google::Apis::Core::JsonObjectSupport
101
+ end
102
+
103
+ class RendererFormattedStrings
104
+ class Representation < Google::Apis::Core::JsonRepresentation; end
105
+
106
+ include Google::Apis::Core::JsonObjectSupport
107
+ end
108
+
109
+ class RuntimeError
110
+ class Representation < Google::Apis::Core::JsonRepresentation; end
111
+
112
+ include Google::Apis::Core::JsonObjectSupport
113
+ end
114
+
115
+ class StackPack
116
+ class Representation < Google::Apis::Core::JsonRepresentation; end
117
+
118
+ include Google::Apis::Core::JsonObjectSupport
119
+ end
120
+
121
+ class Timing
122
+ class Representation < Google::Apis::Core::JsonRepresentation; end
123
+
124
+ include Google::Apis::Core::JsonObjectSupport
125
+ end
126
+
127
+ class UserPageLoadMetricV5
128
+ class Representation < Google::Apis::Core::JsonRepresentation; end
129
+
130
+ include Google::Apis::Core::JsonObjectSupport
131
+ end
132
+
133
+ class AuditRefs
134
+ # @private
135
+ class Representation < Google::Apis::Core::JsonRepresentation
136
+ property :group, as: 'group'
137
+ property :id, as: 'id'
138
+ property :weight, as: 'weight'
139
+ end
140
+ end
141
+
142
+ class Bucket
143
+ # @private
144
+ class Representation < Google::Apis::Core::JsonRepresentation
145
+ property :max, as: 'max'
146
+ property :min, as: 'min'
147
+ property :proportion, as: 'proportion'
148
+ end
149
+ end
150
+
151
+ class Categories
152
+ # @private
153
+ class Representation < Google::Apis::Core::JsonRepresentation
154
+ property :accessibility, as: 'accessibility', class: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5, decorator: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5::Representation
155
+
156
+ property :best_practices, as: 'best-practices', class: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5, decorator: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5::Representation
157
+
158
+ property :performance, as: 'performance', class: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5, decorator: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5::Representation
159
+
160
+ property :pwa, as: 'pwa', class: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5, decorator: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5::Representation
161
+
162
+ property :seo, as: 'seo', class: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5, decorator: Google::Apis::PagespeedonlineV5::LighthouseCategoryV5::Representation
163
+
164
+ end
165
+ end
166
+
167
+ class CategoryGroupV5
168
+ # @private
169
+ class Representation < Google::Apis::Core::JsonRepresentation
170
+ property :description, as: 'description'
171
+ property :title, as: 'title'
172
+ end
173
+ end
174
+
175
+ class ConfigSettings
176
+ # @private
177
+ class Representation < Google::Apis::Core::JsonRepresentation
178
+ property :channel, as: 'channel'
179
+ property :emulated_form_factor, as: 'emulatedFormFactor'
180
+ property :locale, as: 'locale'
181
+ property :only_categories, as: 'onlyCategories'
182
+ end
183
+ end
184
+
185
+ class Environment
186
+ # @private
187
+ class Representation < Google::Apis::Core::JsonRepresentation
188
+ property :benchmark_index, as: 'benchmarkIndex'
189
+ property :host_user_agent, as: 'hostUserAgent'
190
+ property :network_user_agent, as: 'networkUserAgent'
191
+ end
192
+ end
193
+
194
+ class I18n
195
+ # @private
196
+ class Representation < Google::Apis::Core::JsonRepresentation
197
+ property :renderer_formatted_strings, as: 'rendererFormattedStrings', class: Google::Apis::PagespeedonlineV5::RendererFormattedStrings, decorator: Google::Apis::PagespeedonlineV5::RendererFormattedStrings::Representation
198
+
199
+ end
200
+ end
201
+
202
+ class LighthouseAuditResultV5
203
+ # @private
204
+ class Representation < Google::Apis::Core::JsonRepresentation
205
+ property :description, as: 'description'
206
+ hash :details, as: 'details'
207
+ property :display_value, as: 'displayValue'
208
+ property :error_message, as: 'errorMessage'
209
+ property :explanation, as: 'explanation'
210
+ property :id, as: 'id'
211
+ property :numeric_value, as: 'numericValue'
212
+ property :score, as: 'score'
213
+ property :score_display_mode, as: 'scoreDisplayMode'
214
+ property :title, as: 'title'
215
+ property :warnings, as: 'warnings'
216
+ end
217
+ end
218
+
219
+ class LighthouseCategoryV5
220
+ # @private
221
+ class Representation < Google::Apis::Core::JsonRepresentation
222
+ collection :audit_refs, as: 'auditRefs', class: Google::Apis::PagespeedonlineV5::AuditRefs, decorator: Google::Apis::PagespeedonlineV5::AuditRefs::Representation
223
+
224
+ property :description, as: 'description'
225
+ property :id, as: 'id'
226
+ property :manual_description, as: 'manualDescription'
227
+ property :score, as: 'score'
228
+ property :title, as: 'title'
229
+ end
230
+ end
231
+
232
+ class LighthouseResultV5
233
+ # @private
234
+ class Representation < Google::Apis::Core::JsonRepresentation
235
+ hash :audits, as: 'audits', class: Google::Apis::PagespeedonlineV5::LighthouseAuditResultV5, decorator: Google::Apis::PagespeedonlineV5::LighthouseAuditResultV5::Representation
236
+
237
+ property :categories, as: 'categories', class: Google::Apis::PagespeedonlineV5::Categories, decorator: Google::Apis::PagespeedonlineV5::Categories::Representation
238
+
239
+ hash :category_groups, as: 'categoryGroups', class: Google::Apis::PagespeedonlineV5::CategoryGroupV5, decorator: Google::Apis::PagespeedonlineV5::CategoryGroupV5::Representation
240
+
241
+ property :config_settings, as: 'configSettings', class: Google::Apis::PagespeedonlineV5::ConfigSettings, decorator: Google::Apis::PagespeedonlineV5::ConfigSettings::Representation
242
+
243
+ property :environment, as: 'environment', class: Google::Apis::PagespeedonlineV5::Environment, decorator: Google::Apis::PagespeedonlineV5::Environment::Representation
244
+
245
+ property :fetch_time, as: 'fetchTime'
246
+ property :final_url, as: 'finalUrl'
247
+ property :i18n, as: 'i18n', class: Google::Apis::PagespeedonlineV5::I18n, decorator: Google::Apis::PagespeedonlineV5::I18n::Representation
248
+
249
+ property :lighthouse_version, as: 'lighthouseVersion'
250
+ property :requested_url, as: 'requestedUrl'
251
+ collection :run_warnings, as: 'runWarnings'
252
+ property :runtime_error, as: 'runtimeError', class: Google::Apis::PagespeedonlineV5::RuntimeError, decorator: Google::Apis::PagespeedonlineV5::RuntimeError::Representation
253
+
254
+ collection :stack_packs, as: 'stackPacks', class: Google::Apis::PagespeedonlineV5::StackPack, decorator: Google::Apis::PagespeedonlineV5::StackPack::Representation
255
+
256
+ property :timing, as: 'timing', class: Google::Apis::PagespeedonlineV5::Timing, decorator: Google::Apis::PagespeedonlineV5::Timing::Representation
257
+
258
+ property :user_agent, as: 'userAgent'
259
+ end
260
+ end
261
+
262
+ class PagespeedApiLoadingExperienceV5
263
+ # @private
264
+ class Representation < Google::Apis::Core::JsonRepresentation
265
+ property :id, as: 'id'
266
+ property :initial_url, as: 'initial_url'
267
+ hash :metrics, as: 'metrics', class: Google::Apis::PagespeedonlineV5::UserPageLoadMetricV5, decorator: Google::Apis::PagespeedonlineV5::UserPageLoadMetricV5::Representation
268
+
269
+ property :origin_fallback, as: 'origin_fallback'
270
+ property :overall_category, as: 'overall_category'
271
+ end
272
+ end
273
+
274
+ class PagespeedApiPagespeedResponseV5
275
+ # @private
276
+ class Representation < Google::Apis::Core::JsonRepresentation
277
+ property :analysis_utc_timestamp, as: 'analysisUTCTimestamp'
278
+ property :captcha_result, as: 'captchaResult'
279
+ property :id, as: 'id'
280
+ property :kind, as: 'kind'
281
+ property :lighthouse_result, as: 'lighthouseResult', class: Google::Apis::PagespeedonlineV5::LighthouseResultV5, decorator: Google::Apis::PagespeedonlineV5::LighthouseResultV5::Representation
282
+
283
+ property :loading_experience, as: 'loadingExperience', class: Google::Apis::PagespeedonlineV5::PagespeedApiLoadingExperienceV5, decorator: Google::Apis::PagespeedonlineV5::PagespeedApiLoadingExperienceV5::Representation
284
+
285
+ property :origin_loading_experience, as: 'originLoadingExperience', class: Google::Apis::PagespeedonlineV5::PagespeedApiLoadingExperienceV5, decorator: Google::Apis::PagespeedonlineV5::PagespeedApiLoadingExperienceV5::Representation
286
+
287
+ property :version, as: 'version', class: Google::Apis::PagespeedonlineV5::PagespeedVersion, decorator: Google::Apis::PagespeedonlineV5::PagespeedVersion::Representation
288
+
289
+ end
290
+ end
291
+
292
+ class PagespeedVersion
293
+ # @private
294
+ class Representation < Google::Apis::Core::JsonRepresentation
295
+ property :major, as: 'major'
296
+ property :minor, as: 'minor'
297
+ end
298
+ end
299
+
300
+ class RendererFormattedStrings
301
+ # @private
302
+ class Representation < Google::Apis::Core::JsonRepresentation
303
+ property :audit_group_expand_tooltip, as: 'auditGroupExpandTooltip'
304
+ property :crc_initial_navigation, as: 'crcInitialNavigation'
305
+ property :crc_longest_duration_label, as: 'crcLongestDurationLabel'
306
+ property :error_label, as: 'errorLabel'
307
+ property :error_missing_audit_info, as: 'errorMissingAuditInfo'
308
+ property :lab_data_title, as: 'labDataTitle'
309
+ property :ls_performance_category_description, as: 'lsPerformanceCategoryDescription'
310
+ property :manual_audits_group_title, as: 'manualAuditsGroupTitle'
311
+ property :not_applicable_audits_group_title, as: 'notApplicableAuditsGroupTitle'
312
+ property :opportunity_resource_column_label, as: 'opportunityResourceColumnLabel'
313
+ property :opportunity_savings_column_label, as: 'opportunitySavingsColumnLabel'
314
+ property :passed_audits_group_title, as: 'passedAuditsGroupTitle'
315
+ property :scorescale_label, as: 'scorescaleLabel'
316
+ property :toplevel_warnings_message, as: 'toplevelWarningsMessage'
317
+ property :variance_disclaimer, as: 'varianceDisclaimer'
318
+ property :warning_header, as: 'warningHeader'
319
+ end
320
+ end
321
+
322
+ class RuntimeError
323
+ # @private
324
+ class Representation < Google::Apis::Core::JsonRepresentation
325
+ property :code, as: 'code'
326
+ property :message, as: 'message'
327
+ end
328
+ end
329
+
330
+ class StackPack
331
+ # @private
332
+ class Representation < Google::Apis::Core::JsonRepresentation
333
+ hash :descriptions, as: 'descriptions'
334
+ property :icon_data_url, as: 'iconDataURL'
335
+ property :id, as: 'id'
336
+ property :title, as: 'title'
337
+ end
338
+ end
339
+
340
+ class Timing
341
+ # @private
342
+ class Representation < Google::Apis::Core::JsonRepresentation
343
+ property :total, as: 'total'
344
+ end
345
+ end
346
+
347
+ class UserPageLoadMetricV5
348
+ # @private
349
+ class Representation < Google::Apis::Core::JsonRepresentation
350
+ property :category, as: 'category'
351
+ collection :distributions, as: 'distributions', class: Google::Apis::PagespeedonlineV5::Bucket, decorator: Google::Apis::PagespeedonlineV5::Bucket::Representation
352
+
353
+ property :form_factor, as: 'formFactor'
354
+ property :median, as: 'median'
355
+ property :metric_id, as: 'metricId'
356
+ property :percentile, as: 'percentile'
357
+ end
358
+ end
359
+ end
360
+ end
361
+ end
@@ -0,0 +1,115 @@
1
+ # Copyright 2020 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'google/apis/core/base_service'
16
+ require 'google/apis/core/json_representation'
17
+ require 'google/apis/core/hashable'
18
+ require 'google/apis/errors'
19
+
20
+ module Google
21
+ module Apis
22
+ module PagespeedonlineV5
23
+ # PageSpeed Insights API
24
+ #
25
+ # The PageSpeed Insights API lets you analyze the performance of your website
26
+ # with a simple API. It offers tailored suggestions for how you can optimize
27
+ # your site, and lets you easily integrate PageSpeed Insights analysis into your
28
+ # development tools and workflow.
29
+ #
30
+ # @example
31
+ # require 'google/apis/pagespeedonline_v5'
32
+ #
33
+ # Pagespeedonline = Google::Apis::PagespeedonlineV5 # Alias the module
34
+ # service = Pagespeedonline::PagespeedInsightsService.new
35
+ #
36
+ # @see https://developers.google.com/speed/docs/insights/v5/about
37
+ class PagespeedInsightsService < Google::Apis::Core::BaseService
38
+ # @return [String]
39
+ # API key. Your API key identifies your project and provides you with API access,
40
+ # quota, and reports. Required unless you provide an OAuth 2.0 token.
41
+ attr_accessor :key
42
+
43
+ # @return [String]
44
+ # Available to use for quota purposes for server-side applications. Can be any
45
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
46
+ attr_accessor :quota_user
47
+
48
+ def initialize
49
+ super('https://pagespeedonline.googleapis.com/', '',
50
+ client_name: 'google-apis-pagespeedonline_v5',
51
+ client_version: Google::Apis::PagespeedonlineV5::GEM_VERSION)
52
+ @batch_path = 'batch'
53
+ end
54
+
55
+ # Runs PageSpeed analysis on the page at the specified URL, and returns
56
+ # PageSpeed scores, a list of suggestions to make that page faster, and other
57
+ # information.
58
+ # @param [String] url
59
+ # Required. The URL to fetch and analyze
60
+ # @param [String] captcha_token
61
+ # The captcha token passed when filling out a captcha.
62
+ # @param [Array<String>, String] category
63
+ # A Lighthouse category to run; if none are given, only Performance category
64
+ # will be run
65
+ # @param [String] locale
66
+ # The locale used to localize formatted results
67
+ # @param [String] strategy
68
+ # The analysis strategy (desktop or mobile) to use, and desktop is the default
69
+ # @param [String] utm_campaign
70
+ # Campaign name for analytics.
71
+ # @param [String] utm_source
72
+ # Campaign source for analytics.
73
+ # @param [String] fields
74
+ # Selector specifying which fields to include in a partial response.
75
+ # @param [String] quota_user
76
+ # Available to use for quota purposes for server-side applications. Can be any
77
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
78
+ # @param [Google::Apis::RequestOptions] options
79
+ # Request-specific options
80
+ #
81
+ # @yield [result, err] Result & error if block supplied
82
+ # @yieldparam result [Google::Apis::PagespeedonlineV5::PagespeedApiPagespeedResponseV5] parsed result object
83
+ # @yieldparam err [StandardError] error object if request failed
84
+ #
85
+ # @return [Google::Apis::PagespeedonlineV5::PagespeedApiPagespeedResponseV5]
86
+ #
87
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
88
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
89
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
90
+ def runpagespeed_pagespeedapi(url, captcha_token: nil, category: nil, locale: nil, strategy: nil, utm_campaign: nil, utm_source: nil, fields: nil, quota_user: nil, options: nil, &block)
91
+ command = make_simple_command(:get, 'pagespeedonline/v5/runPagespeed', options)
92
+ command.response_representation = Google::Apis::PagespeedonlineV5::PagespeedApiPagespeedResponseV5::Representation
93
+ command.response_class = Google::Apis::PagespeedonlineV5::PagespeedApiPagespeedResponseV5
94
+ command.query['captchaToken'] = captcha_token unless captcha_token.nil?
95
+ command.query['category'] = category unless category.nil?
96
+ command.query['locale'] = locale unless locale.nil?
97
+ command.query['strategy'] = strategy unless strategy.nil?
98
+ command.query['url'] = url unless url.nil?
99
+ command.query['utm_campaign'] = utm_campaign unless utm_campaign.nil?
100
+ command.query['utm_source'] = utm_source unless utm_source.nil?
101
+ command.query['fields'] = fields unless fields.nil?
102
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
103
+ execute_or_queue_command(command, &block)
104
+ end
105
+
106
+ protected
107
+
108
+ def apply_command_defaults(command)
109
+ command.query['key'] = key unless key.nil?
110
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end