google_pagespeedonline5/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// Associate you with your personal info on Google
17    Openid,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::Openid => "openid",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::Openid
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all PagespeedInsights related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_pagespeedonline5 as pagespeedonline5;
49/// use pagespeedonline5::{Result, Error};
50/// # async fn dox() {
51/// use pagespeedonline5::{PagespeedInsights, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace  `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
62///     .with_native_roots()
63///     .unwrap()
64///     .https_only()
65///     .enable_http2()
66///     .build();
67///
68/// let executor = hyper_util::rt::TokioExecutor::new();
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
70///     secret,
71///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72///     yup_oauth2::client::CustomHyperClientBuilder::from(
73///         hyper_util::client::legacy::Client::builder(executor).build(connector),
74///     ),
75/// ).build().await.unwrap();
76///
77/// let client = hyper_util::client::legacy::Client::builder(
78///     hyper_util::rt::TokioExecutor::new()
79/// )
80/// .build(
81///     hyper_rustls::HttpsConnectorBuilder::new()
82///         .with_native_roots()
83///         .unwrap()
84///         .https_or_http()
85///         .enable_http2()
86///         .build()
87/// );
88/// let mut hub = PagespeedInsights::new(client, auth);
89/// // You can configure optional parameters by calling the respective setters at will, and
90/// // execute the final call using `doit()`.
91/// // Values shown here are possibly random and not representative !
92/// let result = hub.pagespeedapi().runpagespeed("url")
93///              .utm_source("gubergren")
94///              .utm_campaign("eos")
95///              .strategy("dolor")
96///              .locale("ea")
97///              .add_category("ipsum")
98///              .captcha_token("invidunt")
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct PagespeedInsights<C> {
122    pub client: common::Client<C>,
123    pub auth: Box<dyn common::GetToken>,
124    _user_agent: String,
125    _base_url: String,
126    _root_url: String,
127}
128
129impl<C> common::Hub for PagespeedInsights<C> {}
130
131impl<'a, C> PagespeedInsights<C> {
132    pub fn new<A: 'static + common::GetToken>(
133        client: common::Client<C>,
134        auth: A,
135    ) -> PagespeedInsights<C> {
136        PagespeedInsights {
137            client,
138            auth: Box::new(auth),
139            _user_agent: "google-api-rust-client/7.0.0".to_string(),
140            _base_url: "https://pagespeedonline.googleapis.com/".to_string(),
141            _root_url: "https://pagespeedonline.googleapis.com/".to_string(),
142        }
143    }
144
145    pub fn pagespeedapi(&'a self) -> PagespeedapiMethods<'a, C> {
146        PagespeedapiMethods { hub: self }
147    }
148
149    /// Set the user-agent header field to use in all requests to the server.
150    /// It defaults to `google-api-rust-client/7.0.0`.
151    ///
152    /// Returns the previously set user-agent.
153    pub fn user_agent(&mut self, agent_name: String) -> String {
154        std::mem::replace(&mut self._user_agent, agent_name)
155    }
156
157    /// Set the base url to use in all requests to the server.
158    /// It defaults to `https://pagespeedonline.googleapis.com/`.
159    ///
160    /// Returns the previously set base url.
161    pub fn base_url(&mut self, new_base_url: String) -> String {
162        std::mem::replace(&mut self._base_url, new_base_url)
163    }
164
165    /// Set the root url to use in all requests to the server.
166    /// It defaults to `https://pagespeedonline.googleapis.com/`.
167    ///
168    /// Returns the previously set root url.
169    pub fn root_url(&mut self, new_root_url: String) -> String {
170        std::mem::replace(&mut self._root_url, new_root_url)
171    }
172}
173
174// ############
175// SCHEMAS ###
176// ##########
177/// A light reference to an audit by id, used to group and weight audits in a given category.
178///
179/// This type is not used in any activity, and only used as *part* of another schema.
180///
181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
182#[serde_with::serde_as]
183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
184pub struct AuditRefs {
185    /// The conventional acronym for the audit/metric.
186    pub acronym: Option<String>,
187    /// The category group that the audit belongs to (optional).
188    pub group: Option<String>,
189    /// The audit ref id.
190    pub id: Option<String>,
191    /// Any audit IDs closely relevant to this one.
192    #[serde(rename = "relevantAudits")]
193    pub relevant_audits: Option<Vec<String>>,
194    /// The weight this audit's score has on the overall category score.
195    pub weight: Option<f64>,
196}
197
198impl common::Part for AuditRefs {}
199
200/// A proportion of data in the total distribution, bucketed by a min/max percentage. Each bucket's range is bounded by min <= x < max, In millisecond.
201///
202/// This type is not used in any activity, and only used as *part* of another schema.
203///
204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
205#[serde_with::serde_as]
206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
207pub struct Bucket {
208    /// Upper bound for a bucket's range.
209    pub max: Option<i32>,
210    /// Lower bound for a bucket's range.
211    pub min: Option<i32>,
212    /// The proportion of data in this bucket.
213    pub proportion: Option<f64>,
214}
215
216impl common::Part for Bucket {}
217
218/// The categories in a Lighthouse run.
219///
220/// This type is not used in any activity, and only used as *part* of another schema.
221///
222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
223#[serde_with::serde_as]
224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
225pub struct Categories {
226    /// The accessibility category, containing all accessibility related audits.
227    pub accessibility: Option<LighthouseCategoryV5>,
228    /// The best practices category, containing all best practices related audits.
229    #[serde(rename = "best-practices")]
230    pub best_practices: Option<LighthouseCategoryV5>,
231    /// The performance category, containing all performance related audits.
232    pub performance: Option<LighthouseCategoryV5>,
233    /// The Progressive-Web-App (PWA) category, containing all pwa related audits. This is deprecated in Lighthouse's 12.0 release.
234    pub pwa: Option<LighthouseCategoryV5>,
235    /// The Search-Engine-Optimization (SEO) category, containing all seo related audits.
236    pub seo: Option<LighthouseCategoryV5>,
237}
238
239impl common::Part for Categories {}
240
241/// Message containing a category
242///
243/// This type is not used in any activity, and only used as *part* of another schema.
244///
245#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
246#[serde_with::serde_as]
247#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
248pub struct CategoryGroupV5 {
249    /// The description of what the category is grouping
250    pub description: Option<String>,
251    /// The human readable title of the group
252    pub title: Option<String>,
253}
254
255impl common::Part for CategoryGroupV5 {}
256
257/// Message containing the configuration settings for the Lighthouse run.
258///
259/// This type is not used in any activity, and only used as *part* of another schema.
260///
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct ConfigSettings {
265    /// How Lighthouse was run, e.g. from the Chrome extension or from the npm module.
266    pub channel: Option<String>,
267    /// The form factor the emulation should use. This field is deprecated, form_factor should be used instead.
268    #[serde(rename = "emulatedFormFactor")]
269    pub emulated_form_factor: Option<String>,
270    /// How Lighthouse should interpret this run in regards to scoring performance metrics and skipping mobile-only tests in desktop.
271    #[serde(rename = "formFactor")]
272    pub form_factor: Option<String>,
273    /// The locale setting.
274    pub locale: Option<String>,
275    /// List of categories of audits the run should conduct.
276    #[serde(rename = "onlyCategories")]
277    pub only_categories: Option<serde_json::Value>,
278}
279
280impl common::Part for ConfigSettings {}
281
282/// Message containing environment configuration for a Lighthouse run.
283///
284/// This type is not used in any activity, and only used as *part* of another schema.
285///
286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
287#[serde_with::serde_as]
288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
289pub struct Environment {
290    /// The benchmark index number that indicates rough device class.
291    #[serde(rename = "benchmarkIndex")]
292    pub benchmark_index: Option<f64>,
293    /// The version of libraries with which these results were generated. Ex: axe-core.
294    pub credits: Option<HashMap<String, String>>,
295    /// The user agent string of the version of Chrome used.
296    #[serde(rename = "hostUserAgent")]
297    pub host_user_agent: Option<String>,
298    /// The user agent string that was sent over the network.
299    #[serde(rename = "networkUserAgent")]
300    pub network_user_agent: Option<String>,
301}
302
303impl common::Part for Environment {}
304
305/// Message containing the i18n data for the LHR - Version 1.
306///
307/// This type is not used in any activity, and only used as *part* of another schema.
308///
309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
310#[serde_with::serde_as]
311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
312pub struct I18n {
313    /// Internationalized strings that are formatted to the locale in configSettings.
314    #[serde(rename = "rendererFormattedStrings")]
315    pub renderer_formatted_strings: Option<RendererFormattedStrings>,
316}
317
318impl common::Part for I18n {}
319
320/// Message containing an Entity.
321///
322/// This type is not used in any activity, and only used as *part* of another schema.
323///
324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
325#[serde_with::serde_as]
326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
327pub struct LhrEntity {
328    /// Optional. An optional category name for the entity.
329    pub category: Option<String>,
330    /// Optional. An optional homepage URL of the entity.
331    pub homepage: Option<String>,
332    /// Optional. An optional flag indicating if the entity is the first party.
333    #[serde(rename = "isFirstParty")]
334    pub is_first_party: Option<bool>,
335    /// Optional. An optional flag indicating if the entity is not recognized.
336    #[serde(rename = "isUnrecognized")]
337    pub is_unrecognized: Option<bool>,
338    /// Required. Name of the entity.
339    pub name: Option<String>,
340    /// Required. A list of URL origin strings that belong to this entity.
341    pub origins: Option<Vec<String>>,
342}
343
344impl common::Part for LhrEntity {}
345
346/// An audit's result object in a Lighthouse result.
347///
348/// This type is not used in any activity, and only used as *part* of another schema.
349///
350#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
351#[serde_with::serde_as]
352#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
353pub struct LighthouseAuditResultV5 {
354    /// The description of the audit.
355    pub description: Option<String>,
356    /// Freeform details section of the audit.
357    pub details: Option<HashMap<String, serde_json::Value>>,
358    /// The value that should be displayed on the UI for this audit.
359    #[serde(rename = "displayValue")]
360    pub display_value: Option<String>,
361    /// An error message from a thrown error inside the audit.
362    #[serde(rename = "errorMessage")]
363    pub error_message: Option<String>,
364    /// An explanation of the errors in the audit.
365    pub explanation: Option<String>,
366    /// The audit's id.
367    pub id: Option<String>,
368    /// The metric savings of the audit.
369    #[serde(rename = "metricSavings")]
370    pub metric_savings: Option<MetricSavings>,
371    /// The unit of the numeric_value field. Used to format the numeric value for display.
372    #[serde(rename = "numericUnit")]
373    pub numeric_unit: Option<String>,
374    /// A numeric value that has a meaning specific to the audit, e.g. the number of nodes in the DOM or the timestamp of a specific load event. More information can be found in the audit details, if present.
375    #[serde(rename = "numericValue")]
376    pub numeric_value: Option<f64>,
377    /// The score of the audit, can be null.
378    pub score: Option<serde_json::Value>,
379    /// The enumerated score display mode.
380    #[serde(rename = "scoreDisplayMode")]
381    pub score_display_mode: Option<String>,
382    /// The human readable title.
383    pub title: Option<String>,
384    /// Possible warnings that occurred in the audit, can be null.
385    pub warnings: Option<serde_json::Value>,
386}
387
388impl common::Part for LighthouseAuditResultV5 {}
389
390/// A Lighthouse category.
391///
392/// This type is not used in any activity, and only used as *part* of another schema.
393///
394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
395#[serde_with::serde_as]
396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
397pub struct LighthouseCategoryV5 {
398    /// An array of references to all the audit members of this category.
399    #[serde(rename = "auditRefs")]
400    pub audit_refs: Option<Vec<AuditRefs>>,
401    /// A more detailed description of the category and its importance.
402    pub description: Option<String>,
403    /// The string identifier of the category.
404    pub id: Option<String>,
405    /// A description for the manual audits in the category.
406    #[serde(rename = "manualDescription")]
407    pub manual_description: Option<String>,
408    /// The overall score of the category, the weighted average of all its audits. (The category's score, can be null.)
409    pub score: Option<serde_json::Value>,
410    /// The human-friendly name of the category.
411    pub title: Option<String>,
412}
413
414impl common::Part for LighthouseCategoryV5 {}
415
416/// The Lighthouse result object.
417///
418/// This type is not used in any activity, and only used as *part* of another schema.
419///
420#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
421#[serde_with::serde_as]
422#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
423pub struct LighthouseResultV5 {
424    /// Map of audits in the LHR.
425    pub audits: Option<HashMap<String, LighthouseAuditResultV5>>,
426    /// Map of categories in the LHR.
427    pub categories: Option<Categories>,
428    /// Map of category groups in the LHR.
429    #[serde(rename = "categoryGroups")]
430    pub category_groups: Option<HashMap<String, CategoryGroupV5>>,
431    /// The configuration settings for this LHR.
432    #[serde(rename = "configSettings")]
433    pub config_settings: Option<ConfigSettings>,
434    /// Entity classification data.
435    pub entities: Option<Vec<LhrEntity>>,
436    /// Environment settings that were used when making this LHR.
437    pub environment: Option<Environment>,
438    /// The time that this run was fetched.
439    #[serde(rename = "fetchTime")]
440    pub fetch_time: Option<String>,
441    /// URL displayed on the page after Lighthouse finishes.
442    #[serde(rename = "finalDisplayedUrl")]
443    pub final_displayed_url: Option<String>,
444    /// The final resolved url that was audited.
445    #[serde(rename = "finalUrl")]
446    pub final_url: Option<String>,
447    /// Screenshot data of the full page, along with node rects relevant to the audit results.
448    #[serde(rename = "fullPageScreenshot")]
449    pub full_page_screenshot: Option<serde_json::Value>,
450    /// The internationalization strings that are required to render the LHR.
451    pub i18n: Option<I18n>,
452    /// The lighthouse version that was used to generate this LHR.
453    #[serde(rename = "lighthouseVersion")]
454    pub lighthouse_version: Option<String>,
455    /// URL of the main document request of the final navigation.
456    #[serde(rename = "mainDocumentUrl")]
457    pub main_document_url: Option<String>,
458    /// The original requested url.
459    #[serde(rename = "requestedUrl")]
460    pub requested_url: Option<String>,
461    /// List of all run warnings in the LHR. Will always output to at least `[]`.
462    #[serde(rename = "runWarnings")]
463    pub run_warnings: Option<Vec<serde_json::Value>>,
464    /// A top-level error message that, if present, indicates a serious enough problem that this Lighthouse result may need to be discarded.
465    #[serde(rename = "runtimeError")]
466    pub runtime_error: Option<RuntimeError>,
467    /// The Stack Pack advice strings.
468    #[serde(rename = "stackPacks")]
469    pub stack_packs: Option<Vec<StackPack>>,
470    /// Timing information for this LHR.
471    pub timing: Option<Timing>,
472    /// The user agent that was used to run this LHR.
473    #[serde(rename = "userAgent")]
474    pub user_agent: Option<String>,
475}
476
477impl common::Part for LighthouseResultV5 {}
478
479/// The metric savings of the audit.
480///
481/// This type is not used in any activity, and only used as *part* of another schema.
482///
483#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
484#[serde_with::serde_as]
485#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
486pub struct MetricSavings {
487    /// Optional. Optional numeric value representing the audit's savings for the CLS metric.
488    #[serde(rename = "CLS")]
489    pub cls: Option<f64>,
490    /// Optional. Optional numeric value representing the audit's savings for the FCP metric.
491    #[serde(rename = "FCP")]
492    pub fcp: Option<f64>,
493    /// Optional. Optional numeric value representing the audit's savings for the INP metric.
494    #[serde(rename = "INP")]
495    pub inp: Option<f64>,
496    /// Optional. Optional numeric value representing the audit's savings for the LCP metric.
497    #[serde(rename = "LCP")]
498    pub lcp: Option<f64>,
499    /// Optional. Optional numeric value representing the audit's savings for the TBT metric.
500    #[serde(rename = "TBT")]
501    pub tbt: Option<f64>,
502}
503
504impl common::Part for MetricSavings {}
505
506/// The CrUX loading experience object that contains CrUX data breakdowns.
507///
508/// This type is not used in any activity, and only used as *part* of another schema.
509///
510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
511#[serde_with::serde_as]
512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
513pub struct PagespeedApiLoadingExperienceV5 {
514    /// The url, pattern or origin which the metrics are on.
515    pub id: Option<String>,
516    /// The requested URL, which may differ from the resolved "id".
517    pub initial_url: Option<String>,
518    /// The map of .
519    pub metrics: Option<HashMap<String, UserPageLoadMetricV5>>,
520    /// True if the result is an origin fallback from a page, false otherwise.
521    pub origin_fallback: Option<bool>,
522    /// The human readable speed "category" of the id.
523    pub overall_category: Option<String>,
524}
525
526impl common::Part for PagespeedApiLoadingExperienceV5 {}
527
528/// The Pagespeed API response object.
529///
530/// # Activities
531///
532/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
533/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
534///
535/// * [runpagespeed pagespeedapi](PagespeedapiRunpagespeedCall) (response)
536#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
537#[serde_with::serde_as]
538#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
539pub struct PagespeedApiPagespeedResponseV5 {
540    /// The UTC timestamp of this analysis.
541    #[serde(rename = "analysisUTCTimestamp")]
542    pub analysis_utc_timestamp: Option<String>,
543    /// The captcha verify result
544    #[serde(rename = "captchaResult")]
545    pub captcha_result: Option<String>,
546    /// Canonicalized and final URL for the document, after following page redirects (if any).
547    pub id: Option<String>,
548    /// Kind of result.
549    pub kind: Option<String>,
550    /// Lighthouse response for the audit url as an object.
551    #[serde(rename = "lighthouseResult")]
552    pub lighthouse_result: Option<LighthouseResultV5>,
553    /// Metrics of end users' page loading experience.
554    #[serde(rename = "loadingExperience")]
555    pub loading_experience: Option<PagespeedApiLoadingExperienceV5>,
556    /// Metrics of the aggregated page loading experience of the origin
557    #[serde(rename = "originLoadingExperience")]
558    pub origin_loading_experience: Option<PagespeedApiLoadingExperienceV5>,
559    /// The version of PageSpeed used to generate these results.
560    pub version: Option<PagespeedVersion>,
561}
562
563impl common::ResponseResult for PagespeedApiPagespeedResponseV5 {}
564
565/// The Pagespeed Version object.
566///
567/// This type is not used in any activity, and only used as *part* of another schema.
568///
569#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
570#[serde_with::serde_as]
571#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
572pub struct PagespeedVersion {
573    /// The major version number of PageSpeed used to generate these results.
574    pub major: Option<String>,
575    /// The minor version number of PageSpeed used to generate these results.
576    pub minor: Option<String>,
577}
578
579impl common::Part for PagespeedVersion {}
580
581/// Message holding the formatted strings used in the renderer.
582///
583/// This type is not used in any activity, and only used as *part* of another schema.
584///
585#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
586#[serde_with::serde_as]
587#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
588pub struct RendererFormattedStrings {
589    /// The tooltip text on an expandable chevron icon.
590    #[serde(rename = "auditGroupExpandTooltip")]
591    pub audit_group_expand_tooltip: Option<String>,
592    /// Text link pointing to the Lighthouse scoring calculator. This link immediately follows a sentence stating the performance score is calculated from the perf metrics.
593    #[serde(rename = "calculatorLink")]
594    pub calculator_link: Option<String>,
595    /// The label for the initial request in a critical request chain.
596    #[serde(rename = "crcInitialNavigation")]
597    pub crc_initial_navigation: Option<String>,
598    /// The label for values shown in the summary of critical request chains.
599    #[serde(rename = "crcLongestDurationLabel")]
600    pub crc_longest_duration_label: Option<String>,
601    /// Option in a dropdown menu that copies the Lighthouse JSON object to the system clipboard.
602    #[serde(rename = "dropdownCopyJSON")]
603    pub dropdown_copy_json: Option<String>,
604    /// Option in a dropdown menu that toggles the themeing of the report between Light(default) and Dark themes.
605    #[serde(rename = "dropdownDarkTheme")]
606    pub dropdown_dark_theme: Option<String>,
607    /// Option in a dropdown menu that opens a full Lighthouse report in a print dialog.
608    #[serde(rename = "dropdownPrintExpanded")]
609    pub dropdown_print_expanded: Option<String>,
610    /// Option in a dropdown menu that opens a small, summary report in a print dialog.
611    #[serde(rename = "dropdownPrintSummary")]
612    pub dropdown_print_summary: Option<String>,
613    /// Option in a dropdown menu that saves the current report as a new GitHub Gist.
614    #[serde(rename = "dropdownSaveGist")]
615    pub dropdown_save_gist: Option<String>,
616    /// Option in a dropdown menu that saves the Lighthouse report HTML locally to the system as a '.html' file.
617    #[serde(rename = "dropdownSaveHTML")]
618    pub dropdown_save_html: Option<String>,
619    /// Option in a dropdown menu that saves the Lighthouse JSON object to the local system as a '.json' file.
620    #[serde(rename = "dropdownSaveJSON")]
621    pub dropdown_save_json: Option<String>,
622    /// Option in a dropdown menu that opens the current report in the Lighthouse Viewer Application.
623    #[serde(rename = "dropdownViewer")]
624    pub dropdown_viewer: Option<String>,
625    /// The label shown next to an audit or metric that has had an error.
626    #[serde(rename = "errorLabel")]
627    pub error_label: Option<String>,
628    /// The error string shown next to an erroring audit.
629    #[serde(rename = "errorMissingAuditInfo")]
630    pub error_missing_audit_info: Option<String>,
631    /// Label for button to create an issue against the Lighthouse GitHub project.
632    #[serde(rename = "footerIssue")]
633    pub footer_issue: Option<String>,
634    /// The title of the lab data performance category.
635    #[serde(rename = "labDataTitle")]
636    pub lab_data_title: Option<String>,
637    /// The disclaimer shown under performance explaining that the network can vary.
638    #[serde(rename = "lsPerformanceCategoryDescription")]
639    pub ls_performance_category_description: Option<String>,
640    /// The heading shown above a list of audits that were not computerd in the run.
641    #[serde(rename = "manualAuditsGroupTitle")]
642    pub manual_audits_group_title: Option<String>,
643    /// The heading shown above a list of audits that do not apply to a page.
644    #[serde(rename = "notApplicableAuditsGroupTitle")]
645    pub not_applicable_audits_group_title: Option<String>,
646    /// The heading for the estimated page load savings opportunity of an audit.
647    #[serde(rename = "opportunityResourceColumnLabel")]
648    pub opportunity_resource_column_label: Option<String>,
649    /// The heading for the estimated page load savings of opportunity audits.
650    #[serde(rename = "opportunitySavingsColumnLabel")]
651    pub opportunity_savings_column_label: Option<String>,
652    /// The heading that is shown above a list of audits that are passing.
653    #[serde(rename = "passedAuditsGroupTitle")]
654    pub passed_audits_group_title: Option<String>,
655    /// Descriptive explanation for emulation setting when emulating a generic desktop form factor, as opposed to a mobile-device like form factor.
656    #[serde(rename = "runtimeDesktopEmulation")]
657    pub runtime_desktop_emulation: Option<String>,
658    /// Descriptive explanation for emulation setting when emulating a Nexus 5X mobile device.
659    #[serde(rename = "runtimeMobileEmulation")]
660    pub runtime_mobile_emulation: Option<String>,
661    /// Descriptive explanation for emulation setting when no device emulation is set.
662    #[serde(rename = "runtimeNoEmulation")]
663    pub runtime_no_emulation: Option<String>,
664    /// Label for a row in a table that shows the version of the Axe library used
665    #[serde(rename = "runtimeSettingsAxeVersion")]
666    pub runtime_settings_axe_version: Option<String>,
667    /// Label for a row in a table that shows the estimated CPU power of the machine running Lighthouse. Example row values: 532, 1492, 783.
668    #[serde(rename = "runtimeSettingsBenchmark")]
669    pub runtime_settings_benchmark: Option<String>,
670    /// Label for a row in a table that describes the CPU throttling conditions that were used during a Lighthouse run, if any.
671    #[serde(rename = "runtimeSettingsCPUThrottling")]
672    pub runtime_settings_cpu_throttling: Option<String>,
673    /// Label for a row in a table that shows in what tool Lighthouse is being run (e.g. The lighthouse CLI, Chrome DevTools, Lightrider, WebPageTest, etc).
674    #[serde(rename = "runtimeSettingsChannel")]
675    pub runtime_settings_channel: Option<String>,
676    /// Label for a row in a table that describes the kind of device that was emulated for the Lighthouse run. Example values for row elements: 'No Emulation', 'Emulated Desktop', etc.
677    #[serde(rename = "runtimeSettingsDevice")]
678    pub runtime_settings_device: Option<String>,
679    /// Label for a row in a table that shows the time at which a Lighthouse run was conducted; formatted as a timestamp, e.g. Jan 1, 1970 12:00 AM UTC.
680    #[serde(rename = "runtimeSettingsFetchTime")]
681    pub runtime_settings_fetch_time: Option<String>,
682    /// Label for a row in a table that describes the network throttling conditions that were used during a Lighthouse run, if any.
683    #[serde(rename = "runtimeSettingsNetworkThrottling")]
684    pub runtime_settings_network_throttling: Option<String>,
685    /// Title of the Runtime settings table in a Lighthouse report. Runtime settings are the environment configurations that a specific report used at auditing time.
686    #[serde(rename = "runtimeSettingsTitle")]
687    pub runtime_settings_title: Option<String>,
688    /// Label for a row in a table that shows the User Agent that was detected on the Host machine that ran Lighthouse.
689    #[serde(rename = "runtimeSettingsUA")]
690    pub runtime_settings_ua: Option<String>,
691    /// Label for a row in a table that shows the User Agent that was used to send out all network requests during the Lighthouse run.
692    #[serde(rename = "runtimeSettingsUANetwork")]
693    pub runtime_settings_ua_network: Option<String>,
694    /// Label for a row in a table that shows the URL that was audited during a Lighthouse run.
695    #[serde(rename = "runtimeSettingsUrl")]
696    pub runtime_settings_url: Option<String>,
697    /// Descriptive explanation for a runtime setting that is set to an unknown value.
698    #[serde(rename = "runtimeUnknown")]
699    pub runtime_unknown: Option<String>,
700    /// The label that explains the score gauges scale (0-49, 50-89, 90-100).
701    #[serde(rename = "scorescaleLabel")]
702    pub scorescale_label: Option<String>,
703    /// Label preceding a radio control for filtering the list of audits. The radio choices are various performance metrics (FCP, LCP, TBT), and if chosen, the audits in the report are hidden if they are not relevant to the selected metric.
704    #[serde(rename = "showRelevantAudits")]
705    pub show_relevant_audits: Option<String>,
706    /// The label for the button to show only a few lines of a snippet
707    #[serde(rename = "snippetCollapseButtonLabel")]
708    pub snippet_collapse_button_label: Option<String>,
709    /// The label for the button to show all lines of a snippet
710    #[serde(rename = "snippetExpandButtonLabel")]
711    pub snippet_expand_button_label: Option<String>,
712    /// This label is for a filter checkbox above a table of items
713    #[serde(rename = "thirdPartyResourcesLabel")]
714    pub third_party_resources_label: Option<String>,
715    /// Descriptive explanation for environment throttling that was provided by the runtime environment instead of provided by Lighthouse throttling.
716    #[serde(rename = "throttlingProvided")]
717    pub throttling_provided: Option<String>,
718    /// The label shown preceding important warnings that may have invalidated an entire report.
719    #[serde(rename = "toplevelWarningsMessage")]
720    pub toplevel_warnings_message: Option<String>,
721    /// The disclaimer shown below a performance metric value.
722    #[serde(rename = "varianceDisclaimer")]
723    pub variance_disclaimer: Option<String>,
724    /// Label for a button that opens the Treemap App
725    #[serde(rename = "viewTreemapLabel")]
726    pub view_treemap_label: Option<String>,
727    /// The heading that is shown above a list of audits that have warnings
728    #[serde(rename = "warningAuditsGroupTitle")]
729    pub warning_audits_group_title: Option<String>,
730    /// The label shown above a bulleted list of warnings.
731    #[serde(rename = "warningHeader")]
732    pub warning_header: Option<String>,
733}
734
735impl common::Part for RendererFormattedStrings {}
736
737/// Message containing a runtime error config.
738///
739/// This type is not used in any activity, and only used as *part* of another schema.
740///
741#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
742#[serde_with::serde_as]
743#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
744pub struct RuntimeError {
745    /// The enumerated Lighthouse Error code.
746    pub code: Option<String>,
747    /// A human readable message explaining the error code.
748    pub message: Option<String>,
749}
750
751impl common::Part for RuntimeError {}
752
753/// Message containing Stack Pack information.
754///
755/// This type is not used in any activity, and only used as *part* of another schema.
756///
757#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
758#[serde_with::serde_as]
759#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
760pub struct StackPack {
761    /// The stack pack advice strings.
762    pub descriptions: Option<HashMap<String, String>>,
763    /// The stack pack icon data uri.
764    #[serde(rename = "iconDataURL")]
765    pub icon_data_url: Option<String>,
766    /// The stack pack id.
767    pub id: Option<String>,
768    /// The stack pack title.
769    pub title: Option<String>,
770}
771
772impl common::Part for StackPack {}
773
774/// Message containing the performance timing data for the Lighthouse run.
775///
776/// This type is not used in any activity, and only used as *part* of another schema.
777///
778#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
779#[serde_with::serde_as]
780#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
781pub struct Timing {
782    /// The total duration of Lighthouse's run.
783    pub total: Option<f64>,
784}
785
786impl common::Part for Timing {}
787
788/// A CrUX metric object for a single metric and form factor.
789///
790/// This type is not used in any activity, and only used as *part* of another schema.
791///
792#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
793#[serde_with::serde_as]
794#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
795pub struct UserPageLoadMetricV5 {
796    /// The category of the specific time metric.
797    pub category: Option<String>,
798    /// Metric distributions. Proportions should sum up to 1.
799    pub distributions: Option<Vec<Bucket>>,
800    /// Identifies the form factor of the metric being collected.
801    #[serde(rename = "formFactor")]
802    pub form_factor: Option<String>,
803    /// The median number of the metric, in millisecond.
804    pub median: Option<i32>,
805    /// Identifies the type of the metric.
806    #[serde(rename = "metricId")]
807    pub metric_id: Option<String>,
808    /// We use this field to store certain percentile value for this metric. For v4, this field contains pc50. For v5, this field contains pc90.
809    pub percentile: Option<i32>,
810}
811
812impl common::Part for UserPageLoadMetricV5 {}
813
814// ###################
815// MethodBuilders ###
816// #################
817
818/// A builder providing access to all methods supported on *pagespeedapi* resources.
819/// It is not used directly, but through the [`PagespeedInsights`] hub.
820///
821/// # Example
822///
823/// Instantiate a resource builder
824///
825/// ```test_harness,no_run
826/// extern crate hyper;
827/// extern crate hyper_rustls;
828/// extern crate google_pagespeedonline5 as pagespeedonline5;
829///
830/// # async fn dox() {
831/// use pagespeedonline5::{PagespeedInsights, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
832///
833/// let secret: yup_oauth2::ApplicationSecret = Default::default();
834/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
835///     .with_native_roots()
836///     .unwrap()
837///     .https_only()
838///     .enable_http2()
839///     .build();
840///
841/// let executor = hyper_util::rt::TokioExecutor::new();
842/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
843///     secret,
844///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
845///     yup_oauth2::client::CustomHyperClientBuilder::from(
846///         hyper_util::client::legacy::Client::builder(executor).build(connector),
847///     ),
848/// ).build().await.unwrap();
849///
850/// let client = hyper_util::client::legacy::Client::builder(
851///     hyper_util::rt::TokioExecutor::new()
852/// )
853/// .build(
854///     hyper_rustls::HttpsConnectorBuilder::new()
855///         .with_native_roots()
856///         .unwrap()
857///         .https_or_http()
858///         .enable_http2()
859///         .build()
860/// );
861/// let mut hub = PagespeedInsights::new(client, auth);
862/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
863/// // like `runpagespeed(...)`
864/// // to build up your call.
865/// let rb = hub.pagespeedapi();
866/// # }
867/// ```
868pub struct PagespeedapiMethods<'a, C>
869where
870    C: 'a,
871{
872    hub: &'a PagespeedInsights<C>,
873}
874
875impl<'a, C> common::MethodsBuilder for PagespeedapiMethods<'a, C> {}
876
877impl<'a, C> PagespeedapiMethods<'a, C> {
878    /// Create a builder to help you perform the following task:
879    ///
880    /// Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information.
881    ///
882    /// # Arguments
883    ///
884    /// * `url` - Required. The URL to fetch and analyze
885    pub fn runpagespeed(&self, url: &str) -> PagespeedapiRunpagespeedCall<'a, C> {
886        PagespeedapiRunpagespeedCall {
887            hub: self.hub,
888            _url: url.to_string(),
889            _utm_source: Default::default(),
890            _utm_campaign: Default::default(),
891            _strategy: Default::default(),
892            _locale: Default::default(),
893            _category: Default::default(),
894            _captcha_token: Default::default(),
895            _delegate: Default::default(),
896            _additional_params: Default::default(),
897            _scopes: Default::default(),
898        }
899    }
900}
901
902// ###################
903// CallBuilders   ###
904// #################
905
906/// Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information.
907///
908/// A builder for the *runpagespeed* method supported by a *pagespeedapi* resource.
909/// It is not used directly, but through a [`PagespeedapiMethods`] instance.
910///
911/// # Example
912///
913/// Instantiate a resource method builder
914///
915/// ```test_harness,no_run
916/// # extern crate hyper;
917/// # extern crate hyper_rustls;
918/// # extern crate google_pagespeedonline5 as pagespeedonline5;
919/// # async fn dox() {
920/// # use pagespeedonline5::{PagespeedInsights, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
921///
922/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
923/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
924/// #     .with_native_roots()
925/// #     .unwrap()
926/// #     .https_only()
927/// #     .enable_http2()
928/// #     .build();
929///
930/// # let executor = hyper_util::rt::TokioExecutor::new();
931/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
932/// #     secret,
933/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
934/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
935/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
936/// #     ),
937/// # ).build().await.unwrap();
938///
939/// # let client = hyper_util::client::legacy::Client::builder(
940/// #     hyper_util::rt::TokioExecutor::new()
941/// # )
942/// # .build(
943/// #     hyper_rustls::HttpsConnectorBuilder::new()
944/// #         .with_native_roots()
945/// #         .unwrap()
946/// #         .https_or_http()
947/// #         .enable_http2()
948/// #         .build()
949/// # );
950/// # let mut hub = PagespeedInsights::new(client, auth);
951/// // You can configure optional parameters by calling the respective setters at will, and
952/// // execute the final call using `doit()`.
953/// // Values shown here are possibly random and not representative !
954/// let result = hub.pagespeedapi().runpagespeed("url")
955///              .utm_source("duo")
956///              .utm_campaign("ipsum")
957///              .strategy("sed")
958///              .locale("ut")
959///              .add_category("gubergren")
960///              .captcha_token("rebum.")
961///              .doit().await;
962/// # }
963/// ```
964pub struct PagespeedapiRunpagespeedCall<'a, C>
965where
966    C: 'a,
967{
968    hub: &'a PagespeedInsights<C>,
969    _url: String,
970    _utm_source: Option<String>,
971    _utm_campaign: Option<String>,
972    _strategy: Option<String>,
973    _locale: Option<String>,
974    _category: Vec<String>,
975    _captcha_token: Option<String>,
976    _delegate: Option<&'a mut dyn common::Delegate>,
977    _additional_params: HashMap<String, String>,
978    _scopes: BTreeSet<String>,
979}
980
981impl<'a, C> common::CallBuilder for PagespeedapiRunpagespeedCall<'a, C> {}
982
983impl<'a, C> PagespeedapiRunpagespeedCall<'a, C>
984where
985    C: common::Connector,
986{
987    /// Perform the operation you have build so far.
988    pub async fn doit(
989        mut self,
990    ) -> common::Result<(common::Response, PagespeedApiPagespeedResponseV5)> {
991        use std::borrow::Cow;
992        use std::io::{Read, Seek};
993
994        use common::{url::Params, ToParts};
995        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
996
997        let mut dd = common::DefaultDelegate;
998        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
999        dlg.begin(common::MethodInfo {
1000            id: "pagespeedonline.pagespeedapi.runpagespeed",
1001            http_method: hyper::Method::GET,
1002        });
1003
1004        for &field in [
1005            "alt",
1006            "url",
1007            "utm_source",
1008            "utm_campaign",
1009            "strategy",
1010            "locale",
1011            "category",
1012            "captchaToken",
1013        ]
1014        .iter()
1015        {
1016            if self._additional_params.contains_key(field) {
1017                dlg.finished(false);
1018                return Err(common::Error::FieldClash(field));
1019            }
1020        }
1021
1022        let mut params = Params::with_capacity(9 + self._additional_params.len());
1023        params.push("url", self._url);
1024        if let Some(value) = self._utm_source.as_ref() {
1025            params.push("utm_source", value);
1026        }
1027        if let Some(value) = self._utm_campaign.as_ref() {
1028            params.push("utm_campaign", value);
1029        }
1030        if let Some(value) = self._strategy.as_ref() {
1031            params.push("strategy", value);
1032        }
1033        if let Some(value) = self._locale.as_ref() {
1034            params.push("locale", value);
1035        }
1036        if !self._category.is_empty() {
1037            for f in self._category.iter() {
1038                params.push("category", f);
1039            }
1040        }
1041        if let Some(value) = self._captcha_token.as_ref() {
1042            params.push("captchaToken", value);
1043        }
1044
1045        params.extend(self._additional_params.iter());
1046
1047        params.push("alt", "json");
1048        let mut url = self.hub._base_url.clone() + "pagespeedonline/v5/runPagespeed";
1049        if self._scopes.is_empty() {
1050            self._scopes.insert(Scope::Openid.as_ref().to_string());
1051        }
1052
1053        let url = params.parse_with_url(&url);
1054
1055        loop {
1056            let token = match self
1057                .hub
1058                .auth
1059                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1060                .await
1061            {
1062                Ok(token) => token,
1063                Err(e) => match dlg.token(e) {
1064                    Ok(token) => token,
1065                    Err(e) => {
1066                        dlg.finished(false);
1067                        return Err(common::Error::MissingToken(e));
1068                    }
1069                },
1070            };
1071            let mut req_result = {
1072                let client = &self.hub.client;
1073                dlg.pre_request();
1074                let mut req_builder = hyper::Request::builder()
1075                    .method(hyper::Method::GET)
1076                    .uri(url.as_str())
1077                    .header(USER_AGENT, self.hub._user_agent.clone());
1078
1079                if let Some(token) = token.as_ref() {
1080                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1081                }
1082
1083                let request = req_builder
1084                    .header(CONTENT_LENGTH, 0_u64)
1085                    .body(common::to_body::<String>(None));
1086
1087                client.request(request.unwrap()).await
1088            };
1089
1090            match req_result {
1091                Err(err) => {
1092                    if let common::Retry::After(d) = dlg.http_error(&err) {
1093                        sleep(d).await;
1094                        continue;
1095                    }
1096                    dlg.finished(false);
1097                    return Err(common::Error::HttpError(err));
1098                }
1099                Ok(res) => {
1100                    let (mut parts, body) = res.into_parts();
1101                    let mut body = common::Body::new(body);
1102                    if !parts.status.is_success() {
1103                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1104                        let error = serde_json::from_str(&common::to_string(&bytes));
1105                        let response = common::to_response(parts, bytes.into());
1106
1107                        if let common::Retry::After(d) =
1108                            dlg.http_failure(&response, error.as_ref().ok())
1109                        {
1110                            sleep(d).await;
1111                            continue;
1112                        }
1113
1114                        dlg.finished(false);
1115
1116                        return Err(match error {
1117                            Ok(value) => common::Error::BadRequest(value),
1118                            _ => common::Error::Failure(response),
1119                        });
1120                    }
1121                    let response = {
1122                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1123                        let encoded = common::to_string(&bytes);
1124                        match serde_json::from_str(&encoded) {
1125                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1126                            Err(error) => {
1127                                dlg.response_json_decode_error(&encoded, &error);
1128                                return Err(common::Error::JsonDecodeError(
1129                                    encoded.to_string(),
1130                                    error,
1131                                ));
1132                            }
1133                        }
1134                    };
1135
1136                    dlg.finished(true);
1137                    return Ok(response);
1138                }
1139            }
1140        }
1141    }
1142
1143    /// Required. The URL to fetch and analyze
1144    ///
1145    /// Sets the *url* query property to the given value.
1146    ///
1147    /// Even though the property as already been set when instantiating this call,
1148    /// we provide this method for API completeness.
1149    pub fn url(mut self, new_value: &str) -> PagespeedapiRunpagespeedCall<'a, C> {
1150        self._url = new_value.to_string();
1151        self
1152    }
1153    /// Campaign source for analytics.
1154    ///
1155    /// Sets the *utm_source* query property to the given value.
1156    pub fn utm_source(mut self, new_value: &str) -> PagespeedapiRunpagespeedCall<'a, C> {
1157        self._utm_source = Some(new_value.to_string());
1158        self
1159    }
1160    /// Campaign name for analytics.
1161    ///
1162    /// Sets the *utm_campaign* query property to the given value.
1163    pub fn utm_campaign(mut self, new_value: &str) -> PagespeedapiRunpagespeedCall<'a, C> {
1164        self._utm_campaign = Some(new_value.to_string());
1165        self
1166    }
1167    /// The analysis strategy (desktop or mobile) to use, and desktop is the default
1168    ///
1169    /// Sets the *strategy* query property to the given value.
1170    pub fn strategy(mut self, new_value: &str) -> PagespeedapiRunpagespeedCall<'a, C> {
1171        self._strategy = Some(new_value.to_string());
1172        self
1173    }
1174    /// The locale used to localize formatted results
1175    ///
1176    /// Sets the *locale* query property to the given value.
1177    pub fn locale(mut self, new_value: &str) -> PagespeedapiRunpagespeedCall<'a, C> {
1178        self._locale = Some(new_value.to_string());
1179        self
1180    }
1181    /// A Lighthouse category to run; if none are given, only Performance category will be run
1182    ///
1183    /// Append the given value to the *category* query property.
1184    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
1185    pub fn add_category(mut self, new_value: &str) -> PagespeedapiRunpagespeedCall<'a, C> {
1186        self._category.push(new_value.to_string());
1187        self
1188    }
1189    /// The captcha token passed when filling out a captcha.
1190    ///
1191    /// Sets the *captcha token* query property to the given value.
1192    pub fn captcha_token(mut self, new_value: &str) -> PagespeedapiRunpagespeedCall<'a, C> {
1193        self._captcha_token = Some(new_value.to_string());
1194        self
1195    }
1196    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1197    /// while executing the actual API request.
1198    ///
1199    /// ````text
1200    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1201    /// ````
1202    ///
1203    /// Sets the *delegate* property to the given value.
1204    pub fn delegate(
1205        mut self,
1206        new_value: &'a mut dyn common::Delegate,
1207    ) -> PagespeedapiRunpagespeedCall<'a, C> {
1208        self._delegate = Some(new_value);
1209        self
1210    }
1211
1212    /// Set any additional parameter of the query string used in the request.
1213    /// It should be used to set parameters which are not yet available through their own
1214    /// setters.
1215    ///
1216    /// Please note that this method must not be used to set any of the known parameters
1217    /// which have their own setter method. If done anyway, the request will fail.
1218    ///
1219    /// # Additional Parameters
1220    ///
1221    /// * *$.xgafv* (query-string) - V1 error format.
1222    /// * *access_token* (query-string) - OAuth access token.
1223    /// * *alt* (query-string) - Data format for response.
1224    /// * *callback* (query-string) - JSONP
1225    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1226    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1227    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1228    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1229    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1230    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1231    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1232    pub fn param<T>(mut self, name: T, value: T) -> PagespeedapiRunpagespeedCall<'a, C>
1233    where
1234        T: AsRef<str>,
1235    {
1236        self._additional_params
1237            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1238        self
1239    }
1240
1241    /// Identifies the authorization scope for the method you are building.
1242    ///
1243    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1244    /// [`Scope::Openid`].
1245    ///
1246    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1247    /// tokens for more than one scope.
1248    ///
1249    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1250    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1251    /// sufficient, a read-write scope will do as well.
1252    pub fn add_scope<St>(mut self, scope: St) -> PagespeedapiRunpagespeedCall<'a, C>
1253    where
1254        St: AsRef<str>,
1255    {
1256        self._scopes.insert(String::from(scope.as_ref()));
1257        self
1258    }
1259    /// Identifies the authorization scope(s) for the method you are building.
1260    ///
1261    /// See [`Self::add_scope()`] for details.
1262    pub fn add_scopes<I, St>(mut self, scopes: I) -> PagespeedapiRunpagespeedCall<'a, C>
1263    where
1264        I: IntoIterator<Item = St>,
1265        St: AsRef<str>,
1266    {
1267        self._scopes
1268            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1269        self
1270    }
1271
1272    /// Removes all scopes, and no default scope will be used either.
1273    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1274    /// for details).
1275    pub fn clear_scopes(mut self) -> PagespeedapiRunpagespeedCall<'a, C> {
1276        self._scopes.clear();
1277        self
1278    }
1279}