google_customsearch1/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// ########
12// HUB ###
13// ######
14
15/// Central instance to access all CustomSearchAPI related resource activities
16///
17/// # Examples
18///
19/// Instantiate a new hub
20///
21/// ```test_harness,no_run
22/// extern crate hyper;
23/// extern crate hyper_rustls;
24/// extern crate google_customsearch1 as customsearch1;
25/// use customsearch1::{Result, Error};
26/// # async fn dox() {
27/// use customsearch1::{CustomSearchAPI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28///
29/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
30/// // `client_secret`, among other things.
31/// let secret: yup_oauth2::ApplicationSecret = Default::default();
32/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
33/// // unless you replace `None` with the desired Flow.
34/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
35/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
36/// // retrieve them from storage.
37/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
38/// .with_native_roots()
39/// .unwrap()
40/// .https_only()
41/// .enable_http2()
42/// .build();
43///
44/// let executor = hyper_util::rt::TokioExecutor::new();
45/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
46/// secret,
47/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
48/// yup_oauth2::client::CustomHyperClientBuilder::from(
49/// hyper_util::client::legacy::Client::builder(executor).build(connector),
50/// ),
51/// ).build().await.unwrap();
52///
53/// let client = hyper_util::client::legacy::Client::builder(
54/// hyper_util::rt::TokioExecutor::new()
55/// )
56/// .build(
57/// hyper_rustls::HttpsConnectorBuilder::new()
58/// .with_native_roots()
59/// .unwrap()
60/// .https_or_http()
61/// .enable_http2()
62/// .build()
63/// );
64/// let mut hub = CustomSearchAPI::new(client, auth);
65/// // You can configure optional parameters by calling the respective setters at will, and
66/// // execute the final call using `doit()`.
67/// // Values shown here are possibly random and not representative !
68/// let result = hub.cse().siterestrict_list()
69/// .start(25)
70/// .sort("invidunt")
71/// .snippet_length(-65)
72/// .site_search_filter("vero")
73/// .site_search("elitr")
74/// .search_type("Lorem")
75/// .safe("diam")
76/// .rights("no")
77/// .related_site("ipsum")
78/// .q("accusam")
79/// .or_terms("takimata")
80/// .num(-46)
81/// .lr("voluptua.")
82/// .low_range("et")
83/// .link_site("erat")
84/// .img_type("consetetur")
85/// .img_size("amet.")
86/// .img_dominant_color("sed")
87/// .img_color_type("takimata")
88/// .hq("dolores")
89/// .hl("gubergren")
90/// .high_range("et")
91/// .googlehost("accusam")
92/// .gl("voluptua.")
93/// .filter("dolore")
94/// .file_type("dolore")
95/// .exclude_terms("dolore")
96/// .exact_terms("voluptua.")
97/// .enable_alternate_search_handler(false)
98/// .date_restrict("Lorem")
99/// .cx("invidunt")
100/// .cr("no")
101/// .c2coff("est")
102/// .doit().await;
103///
104/// match result {
105/// Err(e) => match e {
106/// // The Error enum provides details about what exactly happened.
107/// // You can also just use its `Debug`, `Display` or `Error` traits
108/// Error::HttpError(_)
109/// |Error::Io(_)
110/// |Error::MissingAPIKey
111/// |Error::MissingToken(_)
112/// |Error::Cancelled
113/// |Error::UploadSizeLimitExceeded(_, _)
114/// |Error::Failure(_)
115/// |Error::BadRequest(_)
116/// |Error::FieldClash(_)
117/// |Error::JsonDecodeError(_, _) => println!("{}", e),
118/// },
119/// Ok(res) => println!("Success: {:?}", res),
120/// }
121/// # }
122/// ```
123#[derive(Clone)]
124pub struct CustomSearchAPI<C> {
125 pub client: common::Client<C>,
126 pub auth: Box<dyn common::GetToken>,
127 _user_agent: String,
128 _base_url: String,
129 _root_url: String,
130}
131
132impl<C> common::Hub for CustomSearchAPI<C> {}
133
134impl<'a, C> CustomSearchAPI<C> {
135 pub fn new<A: 'static + common::GetToken>(
136 client: common::Client<C>,
137 auth: A,
138 ) -> CustomSearchAPI<C> {
139 CustomSearchAPI {
140 client,
141 auth: Box::new(auth),
142 _user_agent: "google-api-rust-client/7.0.0".to_string(),
143 _base_url: "https://customsearch.googleapis.com/".to_string(),
144 _root_url: "https://customsearch.googleapis.com/".to_string(),
145 }
146 }
147
148 pub fn cse(&'a self) -> CseMethods<'a, C> {
149 CseMethods { hub: self }
150 }
151
152 /// Set the user-agent header field to use in all requests to the server.
153 /// It defaults to `google-api-rust-client/7.0.0`.
154 ///
155 /// Returns the previously set user-agent.
156 pub fn user_agent(&mut self, agent_name: String) -> String {
157 std::mem::replace(&mut self._user_agent, agent_name)
158 }
159
160 /// Set the base url to use in all requests to the server.
161 /// It defaults to `https://customsearch.googleapis.com/`.
162 ///
163 /// Returns the previously set base url.
164 pub fn base_url(&mut self, new_base_url: String) -> String {
165 std::mem::replace(&mut self._base_url, new_base_url)
166 }
167
168 /// Set the root url to use in all requests to the server.
169 /// It defaults to `https://customsearch.googleapis.com/`.
170 ///
171 /// Returns the previously set root url.
172 pub fn root_url(&mut self, new_root_url: String) -> String {
173 std::mem::replace(&mut self._root_url, new_root_url)
174 }
175}
176
177// ############
178// SCHEMAS ###
179// ##########
180/// Promotion result.
181///
182/// This type is not used in any activity, and only used as *part* of another schema.
183///
184#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
185#[serde_with::serde_as]
186#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
187pub struct Promotion {
188 /// An array of block objects for this promotion.
189 #[serde(rename = "bodyLines")]
190 pub body_lines: Option<Vec<PromotionBodyLines>>,
191 /// An abridged version of this search's result URL, e.g. www.example.com.
192 #[serde(rename = "displayLink")]
193 pub display_link: Option<String>,
194 /// The title of the promotion, in HTML.
195 #[serde(rename = "htmlTitle")]
196 pub html_title: Option<String>,
197 /// Image belonging to a promotion.
198 pub image: Option<PromotionImage>,
199 /// The URL of the promotion.
200 pub link: Option<String>,
201 /// The title of the promotion.
202 pub title: Option<String>,
203}
204
205impl common::Part for Promotion {}
206
207/// A custom search result.
208///
209/// This type is not used in any activity, and only used as *part* of another schema.
210///
211#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
212#[serde_with::serde_as]
213#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
214pub struct Result {
215 /// Indicates the ID of Google's cached version of the search result.
216 #[serde(rename = "cacheId")]
217 pub cache_id: Option<String>,
218 /// An abridged version of this search result’s URL, e.g. www.example.com.
219 #[serde(rename = "displayLink")]
220 pub display_link: Option<String>,
221 /// The file format of the search result.
222 #[serde(rename = "fileFormat")]
223 pub file_format: Option<String>,
224 /// The URL displayed after the snippet for each search result.
225 #[serde(rename = "formattedUrl")]
226 pub formatted_url: Option<String>,
227 /// The HTML-formatted URL displayed after the snippet for each search result.
228 #[serde(rename = "htmlFormattedUrl")]
229 pub html_formatted_url: Option<String>,
230 /// The snippet of the search result, in HTML.
231 #[serde(rename = "htmlSnippet")]
232 pub html_snippet: Option<String>,
233 /// The title of the search result, in HTML.
234 #[serde(rename = "htmlTitle")]
235 pub html_title: Option<String>,
236 /// Image belonging to a custom search result.
237 pub image: Option<ResultImage>,
238 /// A unique identifier for the type of current object. For this API, it is `customsearch#result.`
239 pub kind: Option<String>,
240 /// Encapsulates all information about refinement labels.
241 pub labels: Option<Vec<ResultLabels>>,
242 /// The full URL to which the search result is pointing, e.g. http://www.example.com/foo/bar.
243 pub link: Option<String>,
244 /// The MIME type of the search result.
245 pub mime: Option<String>,
246 /// Contains [PageMap](https://developers.google.com/custom-search/docs/structured_data#pagemaps) information for this search result.
247 pub pagemap: Option<HashMap<String, serde_json::Value>>,
248 /// The snippet of the search result, in plain text.
249 pub snippet: Option<String>,
250 /// The title of the search result, in plain text.
251 pub title: Option<String>,
252}
253
254impl common::Part for Result {}
255
256/// Response to a custom search request.
257///
258/// # Activities
259///
260/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
261/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
262///
263/// * [siterestrict list cse](CseSiterestrictListCall) (response)
264/// * [list cse](CseListCall) (response)
265#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
266#[serde_with::serde_as]
267#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
268pub struct Search {
269 /// Metadata and refinements associated with the given search engine, including: * The name of the search engine that was used for the query. * A set of [facet objects](https://developers.google.com/custom-search/docs/refinements#create) (refinements) you can use for refining a search.
270 pub context: Option<HashMap<String, serde_json::Value>>,
271 /// The current set of custom search results.
272 pub items: Option<Vec<Result>>,
273 /// Unique identifier for the type of current object. For this API, it is customsearch#search.
274 pub kind: Option<String>,
275 /// The set of [promotions](https://developers.google.com/custom-search/docs/promotions). Present only if the custom search engine's configuration files define any promotions for the given query.
276 pub promotions: Option<Vec<Promotion>>,
277 /// Query metadata for the previous, current, and next pages of results.
278 pub queries: Option<SearchQueries>,
279 /// Metadata about a search operation.
280 #[serde(rename = "searchInformation")]
281 pub search_information: Option<SearchSearchInformation>,
282 /// Spell correction information for a query.
283 pub spelling: Option<SearchSpelling>,
284 /// OpenSearch template and URL.
285 pub url: Option<SearchUrl>,
286}
287
288impl common::ResponseResult for Search {}
289
290/// Block object belonging to a promotion.
291///
292/// This type is not used in any activity, and only used as *part* of another schema.
293///
294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
295#[serde_with::serde_as]
296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
297pub struct PromotionBodyLines {
298 /// The block object's text in HTML, if it has text.
299 #[serde(rename = "htmlTitle")]
300 pub html_title: Option<String>,
301 /// The anchor text of the block object's link, if it has a link.
302 pub link: Option<String>,
303 /// The block object's text, if it has text.
304 pub title: Option<String>,
305 /// The URL of the block object's link, if it has one.
306 pub url: Option<String>,
307}
308
309impl common::NestedType for PromotionBodyLines {}
310impl common::Part for PromotionBodyLines {}
311
312/// Image belonging to a promotion.
313///
314/// This type is not used in any activity, and only used as *part* of another schema.
315///
316#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
317#[serde_with::serde_as]
318#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
319pub struct PromotionImage {
320 /// Image height in pixels.
321 pub height: Option<i32>,
322 /// URL of the image for this promotion link.
323 pub source: Option<String>,
324 /// Image width in pixels.
325 pub width: Option<i32>,
326}
327
328impl common::NestedType for PromotionImage {}
329impl common::Part for PromotionImage {}
330
331/// Image belonging to a custom search result.
332///
333/// This type is not used in any activity, and only used as *part* of another schema.
334///
335#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
336#[serde_with::serde_as]
337#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
338pub struct ResultImage {
339 /// The size of the image, in bytes.
340 #[serde(rename = "byteSize")]
341 pub byte_size: Option<i32>,
342 /// A URL pointing to the webpage hosting the image.
343 #[serde(rename = "contextLink")]
344 pub context_link: Option<String>,
345 /// The height of the image, in pixels.
346 pub height: Option<i32>,
347 /// The height of the thumbnail image, in pixels.
348 #[serde(rename = "thumbnailHeight")]
349 pub thumbnail_height: Option<i32>,
350 /// A URL to the thumbnail image.
351 #[serde(rename = "thumbnailLink")]
352 pub thumbnail_link: Option<String>,
353 /// The width of the thumbnail image, in pixels.
354 #[serde(rename = "thumbnailWidth")]
355 pub thumbnail_width: Option<i32>,
356 /// The width of the image, in pixels.
357 pub width: Option<i32>,
358}
359
360impl common::NestedType for ResultImage {}
361impl common::Part for ResultImage {}
362
363/// Refinement label associated with a custom search result.
364///
365/// This type is not used in any activity, and only used as *part* of another schema.
366///
367#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
368#[serde_with::serde_as]
369#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
370pub struct ResultLabels {
371 /// The display name of a refinement label. This is the name you should display in your user interface.
372 #[serde(rename = "displayName")]
373 pub display_name: Option<String>,
374 /// Refinement label and the associated refinement operation.
375 pub label_with_op: Option<String>,
376 /// The name of a refinement label, which you can use to refine searches. Don't display this in your user interface; instead, use displayName.
377 pub name: Option<String>,
378}
379
380impl common::NestedType for ResultLabels {}
381impl common::Part for ResultLabels {}
382
383/// Query metadata for the previous, current, and next pages of results.
384///
385/// This type is not used in any activity, and only used as *part* of another schema.
386///
387#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
388#[serde_with::serde_as]
389#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
390pub struct SearchQueries {
391 /// Metadata representing the next page of results, if applicable.
392 #[serde(rename = "nextPage")]
393 pub next_page: Option<Vec<SearchQueriesNextPage>>,
394 /// Metadata representing the previous page of results, if applicable.
395 #[serde(rename = "previousPage")]
396 pub previous_page: Option<Vec<SearchQueriesPreviousPage>>,
397 /// Metadata representing the current request.
398 pub request: Option<Vec<SearchQueriesRequest>>,
399}
400
401impl common::NestedType for SearchQueries {}
402impl common::Part for SearchQueries {}
403
404/// Custom search request metadata.
405///
406/// This type is not used in any activity, and only used as *part* of another schema.
407///
408#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
409#[serde_with::serde_as]
410#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
411pub struct SearchQueriesNextPage {
412 /// Number of search results returned in this set.
413 pub count: Option<i32>,
414 /// Restricts search results to documents originating in a particular country. You may use [Boolean operators](https://developers.google.com/custom-search/docs/json_api_reference#BooleanOrSearch) in the `cr` parameter's value. Google WebSearch determines the country of a document by analyzing the following: * The top-level domain (TLD) of the document's URL. * The geographic location of the web server's IP address. See [Country (cr) Parameter Values](https://developers.google.com/custom-search/docs/json_api_reference#countryCollections) for a list of valid values for this parameter.
415 pub cr: Option<String>,
416 /// The identifier of an engine created using the Programmable Search Engine [Control Panel](https://programmablesearchengine.google.com/). This is a custom property not defined in the OpenSearch spec. This parameter is **required**.
417 pub cx: Option<String>,
418 /// Restricts results to URLs based on date. Supported values include: * `d[number]`: requests results from the specified number of past days. * `w[number]`: requests results from the specified number of past weeks. * `m[number]`: requests results from the specified number of past months. * `y[number]`: requests results from the specified number of past years.
419 #[serde(rename = "dateRestrict")]
420 pub date_restrict: Option<String>,
421 /// Enables or disables the [Simplified and Traditional Chinese Search](https://developers.google.com/custom-search/docs/json_api_reference#chineseSearch) feature. Supported values are: * `0`: enabled (default) * `1`: disabled
422 #[serde(rename = "disableCnTwTranslation")]
423 pub disable_cn_tw_translation: Option<String>,
424 /// Identifies a phrase that all documents in the search results must contain.
425 #[serde(rename = "exactTerms")]
426 pub exact_terms: Option<String>,
427 /// Identifies a word or phrase that should not appear in any documents in the search results.
428 #[serde(rename = "excludeTerms")]
429 pub exclude_terms: Option<String>,
430 /// Restricts results to files of a specified extension. Filetypes supported by Google include: * Adobe Portable Document Format (`pdf`) * Adobe PostScript (`ps`) * Lotus 1-2-3 (`wk1`, `wk2`, `wk3`, `wk4`, `wk5`, `wki`, `wks`, `wku`) * Lotus WordPro (`lwp`) * Macwrite (`mw`) * Microsoft Excel (`xls`) * Microsoft PowerPoint (`ppt`) * Microsoft Word (`doc`) * Microsoft Works (`wks`, `wps`, `wdb`) * Microsoft Write (`wri`) * Rich Text Format (`rtf`) * Shockwave Flash (`swf`) * Text (`ans`, `txt`). Additional filetypes may be added in the future. An up-to-date list can always be found in Google's [file type FAQ](https://support.google.com/webmasters/answer/35287).
431 #[serde(rename = "fileType")]
432 pub file_type: Option<String>,
433 /// Activates or deactivates the automatic filtering of Google search results. See [Automatic Filtering](https://developers.google.com/custom-search/docs/json_api_reference#automaticFiltering) for more information about Google's search results filters. Valid values for this parameter are: * `0`: Disabled * `1`: Enabled (default) **Note**: By default, Google applies filtering to all search results to improve the quality of those results.
434 pub filter: Option<String>,
435 /// Boosts search results whose country of origin matches the parameter value. See [Country Codes](https://developers.google.com/custom-search/docs/json_api_reference#countryCodes) for a list of valid values. Specifying a `gl` parameter value in WebSearch requests should improve the relevance of results. This is particularly true for international customers and, even more specifically, for customers in English-speaking countries other than the United States.
436 pub gl: Option<String>,
437 /// Specifies the Google domain (for example, google.com, google.de, or google.fr) to which the search should be limited.
438 #[serde(rename = "googleHost")]
439 pub google_host: Option<String>,
440 /// Specifies the ending value for a search range. Use `cse:lowRange` and `cse:highrange` to append an inclusive search range of `lowRange...highRange` to the query.
441 #[serde(rename = "highRange")]
442 pub high_range: Option<String>,
443 /// Specifies the interface language (host language) of your user interface. Explicitly setting this parameter improves the performance and the quality of your search results. See the [Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#wsInterfaceLanguages) section of [Internationalizing Queries and Results Presentation](https://developers.google.com/custom-search/docs/json_api_reference#wsInternationalizing) for more information, and [Supported Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#interfaceLanguages) for a list of supported languages.
444 pub hl: Option<String>,
445 /// Appends the specified query terms to the query, as if they were combined with a logical `AND` operator.
446 pub hq: Option<String>,
447 /// Restricts results to images of a specified color type. Supported values are: * `mono` (black and white) * `gray` (grayscale) * `color` (color)
448 #[serde(rename = "imgColorType")]
449 pub img_color_type: Option<String>,
450 /// Restricts results to images with a specific dominant color. Supported values are: * `red` * `orange` * `yellow` * `green` * `teal` * `blue` * `purple` * `pink` * `white` * `gray` * `black` * `brown`
451 #[serde(rename = "imgDominantColor")]
452 pub img_dominant_color: Option<String>,
453 /// Restricts results to images of a specified size. Supported values are: * `icon` (small) * `small | medium | large | xlarge` (medium) * `xxlarge` (large) * `huge` (extra-large)
454 #[serde(rename = "imgSize")]
455 pub img_size: Option<String>,
456 /// Restricts results to images of a specified type. Supported values are: * `clipart` (Clip art) * `face` (Face) * `lineart` (Line drawing) * `photo` (Photo) * `animated` (Animated) * `stock` (Stock)
457 #[serde(rename = "imgType")]
458 pub img_type: Option<String>,
459 /// The character encoding supported for search requests.
460 #[serde(rename = "inputEncoding")]
461 pub input_encoding: Option<String>,
462 /// The language of the search results.
463 pub language: Option<String>,
464 /// Specifies that all results should contain a link to a specific URL.
465 #[serde(rename = "linkSite")]
466 pub link_site: Option<String>,
467 /// Specifies the starting value for a search range. Use `cse:lowRange` and `cse:highrange` to append an inclusive search range of `lowRange...highRange` to the query.
468 #[serde(rename = "lowRange")]
469 pub low_range: Option<String>,
470 /// Provides additional search terms to check for in a document, where each document in the search results must contain at least one of the additional search terms. You can also use the [Boolean OR](https://developers.google.com/custom-search/docs/json_api_reference#BooleanOrSearch) query term for this type of query.
471 #[serde(rename = "orTerms")]
472 pub or_terms: Option<String>,
473 /// The character encoding supported for search results.
474 #[serde(rename = "outputEncoding")]
475 pub output_encoding: Option<String>,
476 /// Specifies that all search results should be pages that are related to the specified URL. The parameter value should be a URL.
477 #[serde(rename = "relatedSite")]
478 pub related_site: Option<String>,
479 /// Filters based on licensing. Supported values include: * `cc_publicdomain` * `cc_attribute` * `cc_sharealike` * `cc_noncommercial` * `cc_nonderived`
480 pub rights: Option<String>,
481 /// Specifies the [SafeSearch level](https://developers.google.com/custom-search/docs/json_api_reference#safeSearchLevels) used for filtering out adult results. This is a custom property not defined in the OpenSearch spec. Valid parameter values are: * `"off"`: Disable SafeSearch * `"active"`: Enable SafeSearch
482 pub safe: Option<String>,
483 /// The search terms entered by the user.
484 #[serde(rename = "searchTerms")]
485 pub search_terms: Option<String>,
486 /// Allowed values are `web` or `image`. If unspecified, results are limited to webpages.
487 #[serde(rename = "searchType")]
488 pub search_type: Option<String>,
489 /// Restricts results to URLs from a specified site.
490 #[serde(rename = "siteSearch")]
491 pub site_search: Option<String>,
492 /// Specifies whether to include or exclude results from the site named in the `sitesearch` parameter. Supported values are: * `i`: include content from site * `e`: exclude content from site
493 #[serde(rename = "siteSearchFilter")]
494 pub site_search_filter: Option<String>,
495 /// Specifies that results should be sorted according to the specified expression. For example, sort by date.
496 pub sort: Option<String>,
497 /// The index of the current set of search results into the total set of results, where the index of the first result is 1.
498 #[serde(rename = "startIndex")]
499 pub start_index: Option<i32>,
500 /// The page number of this set of results, where the page length is set by the `count` property.
501 #[serde(rename = "startPage")]
502 pub start_page: Option<i32>,
503 /// A description of the query.
504 pub title: Option<String>,
505 /// Estimated number of total search results. May not be accurate.
506 #[serde(rename = "totalResults")]
507 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
508 pub total_results: Option<i64>,
509}
510
511impl common::NestedType for SearchQueriesNextPage {}
512impl common::Part for SearchQueriesNextPage {}
513
514/// Custom search request metadata.
515///
516/// This type is not used in any activity, and only used as *part* of another schema.
517///
518#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
519#[serde_with::serde_as]
520#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
521pub struct SearchQueriesPreviousPage {
522 /// Number of search results returned in this set.
523 pub count: Option<i32>,
524 /// Restricts search results to documents originating in a particular country. You may use [Boolean operators](https://developers.google.com/custom-search/docs/json_api_reference#BooleanOrSearch) in the `cr` parameter's value. Google WebSearch determines the country of a document by analyzing the following: * The top-level domain (TLD) of the document's URL. * The geographic location of the web server's IP address. See [Country (cr) Parameter Values](https://developers.google.com/custom-search/docs/json_api_reference#countryCollections) for a list of valid values for this parameter.
525 pub cr: Option<String>,
526 /// The identifier of an engine created using the Programmable Search Engine [Control Panel](https://programmablesearchengine.google.com/). This is a custom property not defined in the OpenSearch spec. This parameter is **required**.
527 pub cx: Option<String>,
528 /// Restricts results to URLs based on date. Supported values include: * `d[number]`: requests results from the specified number of past days. * `w[number]`: requests results from the specified number of past weeks. * `m[number]`: requests results from the specified number of past months. * `y[number]`: requests results from the specified number of past years.
529 #[serde(rename = "dateRestrict")]
530 pub date_restrict: Option<String>,
531 /// Enables or disables the [Simplified and Traditional Chinese Search](https://developers.google.com/custom-search/docs/json_api_reference#chineseSearch) feature. Supported values are: * `0`: enabled (default) * `1`: disabled
532 #[serde(rename = "disableCnTwTranslation")]
533 pub disable_cn_tw_translation: Option<String>,
534 /// Identifies a phrase that all documents in the search results must contain.
535 #[serde(rename = "exactTerms")]
536 pub exact_terms: Option<String>,
537 /// Identifies a word or phrase that should not appear in any documents in the search results.
538 #[serde(rename = "excludeTerms")]
539 pub exclude_terms: Option<String>,
540 /// Restricts results to files of a specified extension. Filetypes supported by Google include: * Adobe Portable Document Format (`pdf`) * Adobe PostScript (`ps`) * Lotus 1-2-3 (`wk1`, `wk2`, `wk3`, `wk4`, `wk5`, `wki`, `wks`, `wku`) * Lotus WordPro (`lwp`) * Macwrite (`mw`) * Microsoft Excel (`xls`) * Microsoft PowerPoint (`ppt`) * Microsoft Word (`doc`) * Microsoft Works (`wks`, `wps`, `wdb`) * Microsoft Write (`wri`) * Rich Text Format (`rtf`) * Shockwave Flash (`swf`) * Text (`ans`, `txt`). Additional filetypes may be added in the future. An up-to-date list can always be found in Google's [file type FAQ](https://support.google.com/webmasters/answer/35287).
541 #[serde(rename = "fileType")]
542 pub file_type: Option<String>,
543 /// Activates or deactivates the automatic filtering of Google search results. See [Automatic Filtering](https://developers.google.com/custom-search/docs/json_api_reference#automaticFiltering) for more information about Google's search results filters. Valid values for this parameter are: * `0`: Disabled * `1`: Enabled (default) **Note**: By default, Google applies filtering to all search results to improve the quality of those results.
544 pub filter: Option<String>,
545 /// Boosts search results whose country of origin matches the parameter value. See [Country Codes](https://developers.google.com/custom-search/docs/json_api_reference#countryCodes) for a list of valid values. Specifying a `gl` parameter value in WebSearch requests should improve the relevance of results. This is particularly true for international customers and, even more specifically, for customers in English-speaking countries other than the United States.
546 pub gl: Option<String>,
547 /// Specifies the Google domain (for example, google.com, google.de, or google.fr) to which the search should be limited.
548 #[serde(rename = "googleHost")]
549 pub google_host: Option<String>,
550 /// Specifies the ending value for a search range. Use `cse:lowRange` and `cse:highrange` to append an inclusive search range of `lowRange...highRange` to the query.
551 #[serde(rename = "highRange")]
552 pub high_range: Option<String>,
553 /// Specifies the interface language (host language) of your user interface. Explicitly setting this parameter improves the performance and the quality of your search results. See the [Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#wsInterfaceLanguages) section of [Internationalizing Queries and Results Presentation](https://developers.google.com/custom-search/docs/json_api_reference#wsInternationalizing) for more information, and [Supported Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#interfaceLanguages) for a list of supported languages.
554 pub hl: Option<String>,
555 /// Appends the specified query terms to the query, as if they were combined with a logical `AND` operator.
556 pub hq: Option<String>,
557 /// Restricts results to images of a specified color type. Supported values are: * `mono` (black and white) * `gray` (grayscale) * `color` (color)
558 #[serde(rename = "imgColorType")]
559 pub img_color_type: Option<String>,
560 /// Restricts results to images with a specific dominant color. Supported values are: * `red` * `orange` * `yellow` * `green` * `teal` * `blue` * `purple` * `pink` * `white` * `gray` * `black` * `brown`
561 #[serde(rename = "imgDominantColor")]
562 pub img_dominant_color: Option<String>,
563 /// Restricts results to images of a specified size. Supported values are: * `icon` (small) * `small | medium | large | xlarge` (medium) * `xxlarge` (large) * `huge` (extra-large)
564 #[serde(rename = "imgSize")]
565 pub img_size: Option<String>,
566 /// Restricts results to images of a specified type. Supported values are: * `clipart` (Clip art) * `face` (Face) * `lineart` (Line drawing) * `photo` (Photo) * `animated` (Animated) * `stock` (Stock)
567 #[serde(rename = "imgType")]
568 pub img_type: Option<String>,
569 /// The character encoding supported for search requests.
570 #[serde(rename = "inputEncoding")]
571 pub input_encoding: Option<String>,
572 /// The language of the search results.
573 pub language: Option<String>,
574 /// Specifies that all results should contain a link to a specific URL.
575 #[serde(rename = "linkSite")]
576 pub link_site: Option<String>,
577 /// Specifies the starting value for a search range. Use `cse:lowRange` and `cse:highrange` to append an inclusive search range of `lowRange...highRange` to the query.
578 #[serde(rename = "lowRange")]
579 pub low_range: Option<String>,
580 /// Provides additional search terms to check for in a document, where each document in the search results must contain at least one of the additional search terms. You can also use the [Boolean OR](https://developers.google.com/custom-search/docs/json_api_reference#BooleanOrSearch) query term for this type of query.
581 #[serde(rename = "orTerms")]
582 pub or_terms: Option<String>,
583 /// The character encoding supported for search results.
584 #[serde(rename = "outputEncoding")]
585 pub output_encoding: Option<String>,
586 /// Specifies that all search results should be pages that are related to the specified URL. The parameter value should be a URL.
587 #[serde(rename = "relatedSite")]
588 pub related_site: Option<String>,
589 /// Filters based on licensing. Supported values include: * `cc_publicdomain` * `cc_attribute` * `cc_sharealike` * `cc_noncommercial` * `cc_nonderived`
590 pub rights: Option<String>,
591 /// Specifies the [SafeSearch level](https://developers.google.com/custom-search/docs/json_api_reference#safeSearchLevels) used for filtering out adult results. This is a custom property not defined in the OpenSearch spec. Valid parameter values are: * `"off"`: Disable SafeSearch * `"active"`: Enable SafeSearch
592 pub safe: Option<String>,
593 /// The search terms entered by the user.
594 #[serde(rename = "searchTerms")]
595 pub search_terms: Option<String>,
596 /// Allowed values are `web` or `image`. If unspecified, results are limited to webpages.
597 #[serde(rename = "searchType")]
598 pub search_type: Option<String>,
599 /// Restricts results to URLs from a specified site.
600 #[serde(rename = "siteSearch")]
601 pub site_search: Option<String>,
602 /// Specifies whether to include or exclude results from the site named in the `sitesearch` parameter. Supported values are: * `i`: include content from site * `e`: exclude content from site
603 #[serde(rename = "siteSearchFilter")]
604 pub site_search_filter: Option<String>,
605 /// Specifies that results should be sorted according to the specified expression. For example, sort by date.
606 pub sort: Option<String>,
607 /// The index of the current set of search results into the total set of results, where the index of the first result is 1.
608 #[serde(rename = "startIndex")]
609 pub start_index: Option<i32>,
610 /// The page number of this set of results, where the page length is set by the `count` property.
611 #[serde(rename = "startPage")]
612 pub start_page: Option<i32>,
613 /// A description of the query.
614 pub title: Option<String>,
615 /// Estimated number of total search results. May not be accurate.
616 #[serde(rename = "totalResults")]
617 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
618 pub total_results: Option<i64>,
619}
620
621impl common::NestedType for SearchQueriesPreviousPage {}
622impl common::Part for SearchQueriesPreviousPage {}
623
624/// Custom search request metadata.
625///
626/// This type is not used in any activity, and only used as *part* of another schema.
627///
628#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
629#[serde_with::serde_as]
630#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
631pub struct SearchQueriesRequest {
632 /// Number of search results returned in this set.
633 pub count: Option<i32>,
634 /// Restricts search results to documents originating in a particular country. You may use [Boolean operators](https://developers.google.com/custom-search/docs/json_api_reference#BooleanOrSearch) in the `cr` parameter's value. Google WebSearch determines the country of a document by analyzing the following: * The top-level domain (TLD) of the document's URL. * The geographic location of the web server's IP address. See [Country (cr) Parameter Values](https://developers.google.com/custom-search/docs/json_api_reference#countryCollections) for a list of valid values for this parameter.
635 pub cr: Option<String>,
636 /// The identifier of an engine created using the Programmable Search Engine [Control Panel](https://programmablesearchengine.google.com/). This is a custom property not defined in the OpenSearch spec. This parameter is **required**.
637 pub cx: Option<String>,
638 /// Restricts results to URLs based on date. Supported values include: * `d[number]`: requests results from the specified number of past days. * `w[number]`: requests results from the specified number of past weeks. * `m[number]`: requests results from the specified number of past months. * `y[number]`: requests results from the specified number of past years.
639 #[serde(rename = "dateRestrict")]
640 pub date_restrict: Option<String>,
641 /// Enables or disables the [Simplified and Traditional Chinese Search](https://developers.google.com/custom-search/docs/json_api_reference#chineseSearch) feature. Supported values are: * `0`: enabled (default) * `1`: disabled
642 #[serde(rename = "disableCnTwTranslation")]
643 pub disable_cn_tw_translation: Option<String>,
644 /// Identifies a phrase that all documents in the search results must contain.
645 #[serde(rename = "exactTerms")]
646 pub exact_terms: Option<String>,
647 /// Identifies a word or phrase that should not appear in any documents in the search results.
648 #[serde(rename = "excludeTerms")]
649 pub exclude_terms: Option<String>,
650 /// Restricts results to files of a specified extension. Filetypes supported by Google include: * Adobe Portable Document Format (`pdf`) * Adobe PostScript (`ps`) * Lotus 1-2-3 (`wk1`, `wk2`, `wk3`, `wk4`, `wk5`, `wki`, `wks`, `wku`) * Lotus WordPro (`lwp`) * Macwrite (`mw`) * Microsoft Excel (`xls`) * Microsoft PowerPoint (`ppt`) * Microsoft Word (`doc`) * Microsoft Works (`wks`, `wps`, `wdb`) * Microsoft Write (`wri`) * Rich Text Format (`rtf`) * Shockwave Flash (`swf`) * Text (`ans`, `txt`). Additional filetypes may be added in the future. An up-to-date list can always be found in Google's [file type FAQ](https://support.google.com/webmasters/answer/35287).
651 #[serde(rename = "fileType")]
652 pub file_type: Option<String>,
653 /// Activates or deactivates the automatic filtering of Google search results. See [Automatic Filtering](https://developers.google.com/custom-search/docs/json_api_reference#automaticFiltering) for more information about Google's search results filters. Valid values for this parameter are: * `0`: Disabled * `1`: Enabled (default) **Note**: By default, Google applies filtering to all search results to improve the quality of those results.
654 pub filter: Option<String>,
655 /// Boosts search results whose country of origin matches the parameter value. See [Country Codes](https://developers.google.com/custom-search/docs/json_api_reference#countryCodes) for a list of valid values. Specifying a `gl` parameter value in WebSearch requests should improve the relevance of results. This is particularly true for international customers and, even more specifically, for customers in English-speaking countries other than the United States.
656 pub gl: Option<String>,
657 /// Specifies the Google domain (for example, google.com, google.de, or google.fr) to which the search should be limited.
658 #[serde(rename = "googleHost")]
659 pub google_host: Option<String>,
660 /// Specifies the ending value for a search range. Use `cse:lowRange` and `cse:highrange` to append an inclusive search range of `lowRange...highRange` to the query.
661 #[serde(rename = "highRange")]
662 pub high_range: Option<String>,
663 /// Specifies the interface language (host language) of your user interface. Explicitly setting this parameter improves the performance and the quality of your search results. See the [Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#wsInterfaceLanguages) section of [Internationalizing Queries and Results Presentation](https://developers.google.com/custom-search/docs/json_api_reference#wsInternationalizing) for more information, and [Supported Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#interfaceLanguages) for a list of supported languages.
664 pub hl: Option<String>,
665 /// Appends the specified query terms to the query, as if they were combined with a logical `AND` operator.
666 pub hq: Option<String>,
667 /// Restricts results to images of a specified color type. Supported values are: * `mono` (black and white) * `gray` (grayscale) * `color` (color)
668 #[serde(rename = "imgColorType")]
669 pub img_color_type: Option<String>,
670 /// Restricts results to images with a specific dominant color. Supported values are: * `red` * `orange` * `yellow` * `green` * `teal` * `blue` * `purple` * `pink` * `white` * `gray` * `black` * `brown`
671 #[serde(rename = "imgDominantColor")]
672 pub img_dominant_color: Option<String>,
673 /// Restricts results to images of a specified size. Supported values are: * `icon` (small) * `small | medium | large | xlarge` (medium) * `xxlarge` (large) * `huge` (extra-large)
674 #[serde(rename = "imgSize")]
675 pub img_size: Option<String>,
676 /// Restricts results to images of a specified type. Supported values are: * `clipart` (Clip art) * `face` (Face) * `lineart` (Line drawing) * `photo` (Photo) * `animated` (Animated) * `stock` (Stock)
677 #[serde(rename = "imgType")]
678 pub img_type: Option<String>,
679 /// The character encoding supported for search requests.
680 #[serde(rename = "inputEncoding")]
681 pub input_encoding: Option<String>,
682 /// The language of the search results.
683 pub language: Option<String>,
684 /// Specifies that all results should contain a link to a specific URL.
685 #[serde(rename = "linkSite")]
686 pub link_site: Option<String>,
687 /// Specifies the starting value for a search range. Use `cse:lowRange` and `cse:highrange` to append an inclusive search range of `lowRange...highRange` to the query.
688 #[serde(rename = "lowRange")]
689 pub low_range: Option<String>,
690 /// Provides additional search terms to check for in a document, where each document in the search results must contain at least one of the additional search terms. You can also use the [Boolean OR](https://developers.google.com/custom-search/docs/json_api_reference#BooleanOrSearch) query term for this type of query.
691 #[serde(rename = "orTerms")]
692 pub or_terms: Option<String>,
693 /// The character encoding supported for search results.
694 #[serde(rename = "outputEncoding")]
695 pub output_encoding: Option<String>,
696 /// Specifies that all search results should be pages that are related to the specified URL. The parameter value should be a URL.
697 #[serde(rename = "relatedSite")]
698 pub related_site: Option<String>,
699 /// Filters based on licensing. Supported values include: * `cc_publicdomain` * `cc_attribute` * `cc_sharealike` * `cc_noncommercial` * `cc_nonderived`
700 pub rights: Option<String>,
701 /// Specifies the [SafeSearch level](https://developers.google.com/custom-search/docs/json_api_reference#safeSearchLevels) used for filtering out adult results. This is a custom property not defined in the OpenSearch spec. Valid parameter values are: * `"off"`: Disable SafeSearch * `"active"`: Enable SafeSearch
702 pub safe: Option<String>,
703 /// The search terms entered by the user.
704 #[serde(rename = "searchTerms")]
705 pub search_terms: Option<String>,
706 /// Allowed values are `web` or `image`. If unspecified, results are limited to webpages.
707 #[serde(rename = "searchType")]
708 pub search_type: Option<String>,
709 /// Restricts results to URLs from a specified site.
710 #[serde(rename = "siteSearch")]
711 pub site_search: Option<String>,
712 /// Specifies whether to include or exclude results from the site named in the `sitesearch` parameter. Supported values are: * `i`: include content from site * `e`: exclude content from site
713 #[serde(rename = "siteSearchFilter")]
714 pub site_search_filter: Option<String>,
715 /// Specifies that results should be sorted according to the specified expression. For example, sort by date.
716 pub sort: Option<String>,
717 /// The index of the current set of search results into the total set of results, where the index of the first result is 1.
718 #[serde(rename = "startIndex")]
719 pub start_index: Option<i32>,
720 /// The page number of this set of results, where the page length is set by the `count` property.
721 #[serde(rename = "startPage")]
722 pub start_page: Option<i32>,
723 /// A description of the query.
724 pub title: Option<String>,
725 /// Estimated number of total search results. May not be accurate.
726 #[serde(rename = "totalResults")]
727 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
728 pub total_results: Option<i64>,
729}
730
731impl common::NestedType for SearchQueriesRequest {}
732impl common::Part for SearchQueriesRequest {}
733
734/// Metadata about a search operation.
735///
736/// This type is not used in any activity, and only used as *part* of another schema.
737///
738#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
739#[serde_with::serde_as]
740#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
741pub struct SearchSearchInformation {
742 /// The time taken for the server to return search results, formatted according to locale style.
743 #[serde(rename = "formattedSearchTime")]
744 pub formatted_search_time: Option<String>,
745 /// The total number of search results, formatted according to locale style.
746 #[serde(rename = "formattedTotalResults")]
747 pub formatted_total_results: Option<String>,
748 /// The time taken for the server to return search results.
749 #[serde(rename = "searchTime")]
750 pub search_time: Option<f64>,
751 /// The total number of search results returned by the query.
752 #[serde(rename = "totalResults")]
753 pub total_results: Option<String>,
754}
755
756impl common::NestedType for SearchSearchInformation {}
757impl common::Part for SearchSearchInformation {}
758
759/// Spell correction information for a query.
760///
761/// This type is not used in any activity, and only used as *part* of another schema.
762///
763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
764#[serde_with::serde_as]
765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
766pub struct SearchSpelling {
767 /// The corrected query.
768 #[serde(rename = "correctedQuery")]
769 pub corrected_query: Option<String>,
770 /// The corrected query, formatted in HTML.
771 #[serde(rename = "htmlCorrectedQuery")]
772 pub html_corrected_query: Option<String>,
773}
774
775impl common::NestedType for SearchSpelling {}
776impl common::Part for SearchSpelling {}
777
778/// OpenSearch template and URL.
779///
780/// This type is not used in any activity, and only used as *part* of another schema.
781///
782#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
783#[serde_with::serde_as]
784#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
785pub struct SearchUrl {
786 /// The actual [OpenSearch template](http://www.opensearch.org/specifications/opensearch/1.1#opensearch_url_template_syntax) for this API.
787 pub template: Option<String>,
788 /// The MIME type of the OpenSearch URL template for the Custom Search JSON API.
789 #[serde(rename = "type")]
790 pub type_: Option<String>,
791}
792
793impl common::NestedType for SearchUrl {}
794impl common::Part for SearchUrl {}
795
796// ###################
797// MethodBuilders ###
798// #################
799
800/// A builder providing access to all methods supported on *cse* resources.
801/// It is not used directly, but through the [`CustomSearchAPI`] hub.
802///
803/// # Example
804///
805/// Instantiate a resource builder
806///
807/// ```test_harness,no_run
808/// extern crate hyper;
809/// extern crate hyper_rustls;
810/// extern crate google_customsearch1 as customsearch1;
811///
812/// # async fn dox() {
813/// use customsearch1::{CustomSearchAPI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
814///
815/// let secret: yup_oauth2::ApplicationSecret = Default::default();
816/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
817/// .with_native_roots()
818/// .unwrap()
819/// .https_only()
820/// .enable_http2()
821/// .build();
822///
823/// let executor = hyper_util::rt::TokioExecutor::new();
824/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
825/// secret,
826/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
827/// yup_oauth2::client::CustomHyperClientBuilder::from(
828/// hyper_util::client::legacy::Client::builder(executor).build(connector),
829/// ),
830/// ).build().await.unwrap();
831///
832/// let client = hyper_util::client::legacy::Client::builder(
833/// hyper_util::rt::TokioExecutor::new()
834/// )
835/// .build(
836/// hyper_rustls::HttpsConnectorBuilder::new()
837/// .with_native_roots()
838/// .unwrap()
839/// .https_or_http()
840/// .enable_http2()
841/// .build()
842/// );
843/// let mut hub = CustomSearchAPI::new(client, auth);
844/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
845/// // like `list(...)` and `siterestrict_list(...)`
846/// // to build up your call.
847/// let rb = hub.cse();
848/// # }
849/// ```
850pub struct CseMethods<'a, C>
851where
852 C: 'a,
853{
854 hub: &'a CustomSearchAPI<C>,
855}
856
857impl<'a, C> common::MethodsBuilder for CseMethods<'a, C> {}
858
859impl<'a, C> CseMethods<'a, C> {
860 /// Create a builder to help you perform the following task:
861 ///
862 /// Returns metadata about the search performed, metadata about the engine used for the search, and the search results. Uses a small set of url patterns.
863 pub fn siterestrict_list(&self) -> CseSiterestrictListCall<'a, C> {
864 CseSiterestrictListCall {
865 hub: self.hub,
866 _start: Default::default(),
867 _sort: Default::default(),
868 _snippet_length: Default::default(),
869 _site_search_filter: Default::default(),
870 _site_search: Default::default(),
871 _search_type: Default::default(),
872 _safe: Default::default(),
873 _rights: Default::default(),
874 _related_site: Default::default(),
875 _q: Default::default(),
876 _or_terms: Default::default(),
877 _num: Default::default(),
878 _lr: Default::default(),
879 _low_range: Default::default(),
880 _link_site: Default::default(),
881 _img_type: Default::default(),
882 _img_size: Default::default(),
883 _img_dominant_color: Default::default(),
884 _img_color_type: Default::default(),
885 _hq: Default::default(),
886 _hl: Default::default(),
887 _high_range: Default::default(),
888 _googlehost: Default::default(),
889 _gl: Default::default(),
890 _filter: Default::default(),
891 _file_type: Default::default(),
892 _exclude_terms: Default::default(),
893 _exact_terms: Default::default(),
894 _enable_alternate_search_handler: Default::default(),
895 _date_restrict: Default::default(),
896 _cx: Default::default(),
897 _cr: Default::default(),
898 _c2coff: Default::default(),
899 _delegate: Default::default(),
900 _additional_params: Default::default(),
901 }
902 }
903
904 /// Create a builder to help you perform the following task:
905 ///
906 /// Returns metadata about the search performed, metadata about the engine used for the search, and the search results.
907 pub fn list(&self) -> CseListCall<'a, C> {
908 CseListCall {
909 hub: self.hub,
910 _start: Default::default(),
911 _sort: Default::default(),
912 _snippet_length: Default::default(),
913 _site_search_filter: Default::default(),
914 _site_search: Default::default(),
915 _search_type: Default::default(),
916 _safe: Default::default(),
917 _rights: Default::default(),
918 _related_site: Default::default(),
919 _q: Default::default(),
920 _or_terms: Default::default(),
921 _num: Default::default(),
922 _lr: Default::default(),
923 _low_range: Default::default(),
924 _link_site: Default::default(),
925 _img_type: Default::default(),
926 _img_size: Default::default(),
927 _img_dominant_color: Default::default(),
928 _img_color_type: Default::default(),
929 _hq: Default::default(),
930 _hl: Default::default(),
931 _high_range: Default::default(),
932 _googlehost: Default::default(),
933 _gl: Default::default(),
934 _filter: Default::default(),
935 _file_type: Default::default(),
936 _exclude_terms: Default::default(),
937 _exact_terms: Default::default(),
938 _enable_alternate_search_handler: Default::default(),
939 _date_restrict: Default::default(),
940 _cx: Default::default(),
941 _cr: Default::default(),
942 _c2coff: Default::default(),
943 _delegate: Default::default(),
944 _additional_params: Default::default(),
945 }
946 }
947}
948
949// ###################
950// CallBuilders ###
951// #################
952
953/// Returns metadata about the search performed, metadata about the engine used for the search, and the search results. Uses a small set of url patterns.
954///
955/// A builder for the *siterestrict.list* method supported by a *cse* resource.
956/// It is not used directly, but through a [`CseMethods`] instance.
957///
958/// # Example
959///
960/// Instantiate a resource method builder
961///
962/// ```test_harness,no_run
963/// # extern crate hyper;
964/// # extern crate hyper_rustls;
965/// # extern crate google_customsearch1 as customsearch1;
966/// # async fn dox() {
967/// # use customsearch1::{CustomSearchAPI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
968///
969/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
970/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
971/// # .with_native_roots()
972/// # .unwrap()
973/// # .https_only()
974/// # .enable_http2()
975/// # .build();
976///
977/// # let executor = hyper_util::rt::TokioExecutor::new();
978/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
979/// # secret,
980/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
981/// # yup_oauth2::client::CustomHyperClientBuilder::from(
982/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
983/// # ),
984/// # ).build().await.unwrap();
985///
986/// # let client = hyper_util::client::legacy::Client::builder(
987/// # hyper_util::rt::TokioExecutor::new()
988/// # )
989/// # .build(
990/// # hyper_rustls::HttpsConnectorBuilder::new()
991/// # .with_native_roots()
992/// # .unwrap()
993/// # .https_or_http()
994/// # .enable_http2()
995/// # .build()
996/// # );
997/// # let mut hub = CustomSearchAPI::new(client, auth);
998/// // You can configure optional parameters by calling the respective setters at will, and
999/// // execute the final call using `doit()`.
1000/// // Values shown here are possibly random and not representative !
1001/// let result = hub.cse().siterestrict_list()
1002/// .start(74)
1003/// .sort("sed")
1004/// .snippet_length(-98)
1005/// .site_search_filter("et")
1006/// .site_search("tempor")
1007/// .search_type("aliquyam")
1008/// .safe("ipsum")
1009/// .rights("et")
1010/// .related_site("sanctus")
1011/// .q("Lorem")
1012/// .or_terms("est")
1013/// .num(-30)
1014/// .lr("diam")
1015/// .low_range("dolores")
1016/// .link_site("dolores")
1017/// .img_type("et")
1018/// .img_size("sed")
1019/// .img_dominant_color("no")
1020/// .img_color_type("et")
1021/// .hq("elitr")
1022/// .hl("sed")
1023/// .high_range("no")
1024/// .googlehost("nonumy")
1025/// .gl("At")
1026/// .filter("sadipscing")
1027/// .file_type("aliquyam")
1028/// .exclude_terms("dolores")
1029/// .exact_terms("sadipscing")
1030/// .enable_alternate_search_handler(false)
1031/// .date_restrict("amet")
1032/// .cx("est")
1033/// .cr("et")
1034/// .c2coff("sea")
1035/// .doit().await;
1036/// # }
1037/// ```
1038pub struct CseSiterestrictListCall<'a, C>
1039where
1040 C: 'a,
1041{
1042 hub: &'a CustomSearchAPI<C>,
1043 _start: Option<u32>,
1044 _sort: Option<String>,
1045 _snippet_length: Option<i32>,
1046 _site_search_filter: Option<String>,
1047 _site_search: Option<String>,
1048 _search_type: Option<String>,
1049 _safe: Option<String>,
1050 _rights: Option<String>,
1051 _related_site: Option<String>,
1052 _q: Option<String>,
1053 _or_terms: Option<String>,
1054 _num: Option<i32>,
1055 _lr: Option<String>,
1056 _low_range: Option<String>,
1057 _link_site: Option<String>,
1058 _img_type: Option<String>,
1059 _img_size: Option<String>,
1060 _img_dominant_color: Option<String>,
1061 _img_color_type: Option<String>,
1062 _hq: Option<String>,
1063 _hl: Option<String>,
1064 _high_range: Option<String>,
1065 _googlehost: Option<String>,
1066 _gl: Option<String>,
1067 _filter: Option<String>,
1068 _file_type: Option<String>,
1069 _exclude_terms: Option<String>,
1070 _exact_terms: Option<String>,
1071 _enable_alternate_search_handler: Option<bool>,
1072 _date_restrict: Option<String>,
1073 _cx: Option<String>,
1074 _cr: Option<String>,
1075 _c2coff: Option<String>,
1076 _delegate: Option<&'a mut dyn common::Delegate>,
1077 _additional_params: HashMap<String, String>,
1078}
1079
1080impl<'a, C> common::CallBuilder for CseSiterestrictListCall<'a, C> {}
1081
1082impl<'a, C> CseSiterestrictListCall<'a, C>
1083where
1084 C: common::Connector,
1085{
1086 /// Perform the operation you have build so far.
1087 pub async fn doit(mut self) -> common::Result<(common::Response, Search)> {
1088 use std::borrow::Cow;
1089 use std::io::{Read, Seek};
1090
1091 use common::{url::Params, ToParts};
1092 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1093
1094 let mut dd = common::DefaultDelegate;
1095 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1096 dlg.begin(common::MethodInfo {
1097 id: "search.cse.siterestrict.list",
1098 http_method: hyper::Method::GET,
1099 });
1100
1101 for &field in [
1102 "alt",
1103 "start",
1104 "sort",
1105 "snippetLength",
1106 "siteSearchFilter",
1107 "siteSearch",
1108 "searchType",
1109 "safe",
1110 "rights",
1111 "relatedSite",
1112 "q",
1113 "orTerms",
1114 "num",
1115 "lr",
1116 "lowRange",
1117 "linkSite",
1118 "imgType",
1119 "imgSize",
1120 "imgDominantColor",
1121 "imgColorType",
1122 "hq",
1123 "hl",
1124 "highRange",
1125 "googlehost",
1126 "gl",
1127 "filter",
1128 "fileType",
1129 "excludeTerms",
1130 "exactTerms",
1131 "enableAlternateSearchHandler",
1132 "dateRestrict",
1133 "cx",
1134 "cr",
1135 "c2coff",
1136 ]
1137 .iter()
1138 {
1139 if self._additional_params.contains_key(field) {
1140 dlg.finished(false);
1141 return Err(common::Error::FieldClash(field));
1142 }
1143 }
1144
1145 let mut params = Params::with_capacity(35 + self._additional_params.len());
1146 if let Some(value) = self._start.as_ref() {
1147 params.push("start", value.to_string());
1148 }
1149 if let Some(value) = self._sort.as_ref() {
1150 params.push("sort", value);
1151 }
1152 if let Some(value) = self._snippet_length.as_ref() {
1153 params.push("snippetLength", value.to_string());
1154 }
1155 if let Some(value) = self._site_search_filter.as_ref() {
1156 params.push("siteSearchFilter", value);
1157 }
1158 if let Some(value) = self._site_search.as_ref() {
1159 params.push("siteSearch", value);
1160 }
1161 if let Some(value) = self._search_type.as_ref() {
1162 params.push("searchType", value);
1163 }
1164 if let Some(value) = self._safe.as_ref() {
1165 params.push("safe", value);
1166 }
1167 if let Some(value) = self._rights.as_ref() {
1168 params.push("rights", value);
1169 }
1170 if let Some(value) = self._related_site.as_ref() {
1171 params.push("relatedSite", value);
1172 }
1173 if let Some(value) = self._q.as_ref() {
1174 params.push("q", value);
1175 }
1176 if let Some(value) = self._or_terms.as_ref() {
1177 params.push("orTerms", value);
1178 }
1179 if let Some(value) = self._num.as_ref() {
1180 params.push("num", value.to_string());
1181 }
1182 if let Some(value) = self._lr.as_ref() {
1183 params.push("lr", value);
1184 }
1185 if let Some(value) = self._low_range.as_ref() {
1186 params.push("lowRange", value);
1187 }
1188 if let Some(value) = self._link_site.as_ref() {
1189 params.push("linkSite", value);
1190 }
1191 if let Some(value) = self._img_type.as_ref() {
1192 params.push("imgType", value);
1193 }
1194 if let Some(value) = self._img_size.as_ref() {
1195 params.push("imgSize", value);
1196 }
1197 if let Some(value) = self._img_dominant_color.as_ref() {
1198 params.push("imgDominantColor", value);
1199 }
1200 if let Some(value) = self._img_color_type.as_ref() {
1201 params.push("imgColorType", value);
1202 }
1203 if let Some(value) = self._hq.as_ref() {
1204 params.push("hq", value);
1205 }
1206 if let Some(value) = self._hl.as_ref() {
1207 params.push("hl", value);
1208 }
1209 if let Some(value) = self._high_range.as_ref() {
1210 params.push("highRange", value);
1211 }
1212 if let Some(value) = self._googlehost.as_ref() {
1213 params.push("googlehost", value);
1214 }
1215 if let Some(value) = self._gl.as_ref() {
1216 params.push("gl", value);
1217 }
1218 if let Some(value) = self._filter.as_ref() {
1219 params.push("filter", value);
1220 }
1221 if let Some(value) = self._file_type.as_ref() {
1222 params.push("fileType", value);
1223 }
1224 if let Some(value) = self._exclude_terms.as_ref() {
1225 params.push("excludeTerms", value);
1226 }
1227 if let Some(value) = self._exact_terms.as_ref() {
1228 params.push("exactTerms", value);
1229 }
1230 if let Some(value) = self._enable_alternate_search_handler.as_ref() {
1231 params.push("enableAlternateSearchHandler", value.to_string());
1232 }
1233 if let Some(value) = self._date_restrict.as_ref() {
1234 params.push("dateRestrict", value);
1235 }
1236 if let Some(value) = self._cx.as_ref() {
1237 params.push("cx", value);
1238 }
1239 if let Some(value) = self._cr.as_ref() {
1240 params.push("cr", value);
1241 }
1242 if let Some(value) = self._c2coff.as_ref() {
1243 params.push("c2coff", value);
1244 }
1245
1246 params.extend(self._additional_params.iter());
1247
1248 params.push("alt", "json");
1249 let mut url = self.hub._base_url.clone() + "customsearch/v1/siterestrict";
1250
1251 match dlg.api_key() {
1252 Some(value) => params.push("key", value),
1253 None => {
1254 dlg.finished(false);
1255 return Err(common::Error::MissingAPIKey);
1256 }
1257 }
1258
1259 let url = params.parse_with_url(&url);
1260
1261 loop {
1262 let mut req_result = {
1263 let client = &self.hub.client;
1264 dlg.pre_request();
1265 let mut req_builder = hyper::Request::builder()
1266 .method(hyper::Method::GET)
1267 .uri(url.as_str())
1268 .header(USER_AGENT, self.hub._user_agent.clone());
1269
1270 let request = req_builder
1271 .header(CONTENT_LENGTH, 0_u64)
1272 .body(common::to_body::<String>(None));
1273
1274 client.request(request.unwrap()).await
1275 };
1276
1277 match req_result {
1278 Err(err) => {
1279 if let common::Retry::After(d) = dlg.http_error(&err) {
1280 sleep(d).await;
1281 continue;
1282 }
1283 dlg.finished(false);
1284 return Err(common::Error::HttpError(err));
1285 }
1286 Ok(res) => {
1287 let (mut parts, body) = res.into_parts();
1288 let mut body = common::Body::new(body);
1289 if !parts.status.is_success() {
1290 let bytes = common::to_bytes(body).await.unwrap_or_default();
1291 let error = serde_json::from_str(&common::to_string(&bytes));
1292 let response = common::to_response(parts, bytes.into());
1293
1294 if let common::Retry::After(d) =
1295 dlg.http_failure(&response, error.as_ref().ok())
1296 {
1297 sleep(d).await;
1298 continue;
1299 }
1300
1301 dlg.finished(false);
1302
1303 return Err(match error {
1304 Ok(value) => common::Error::BadRequest(value),
1305 _ => common::Error::Failure(response),
1306 });
1307 }
1308 let response = {
1309 let bytes = common::to_bytes(body).await.unwrap_or_default();
1310 let encoded = common::to_string(&bytes);
1311 match serde_json::from_str(&encoded) {
1312 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1313 Err(error) => {
1314 dlg.response_json_decode_error(&encoded, &error);
1315 return Err(common::Error::JsonDecodeError(
1316 encoded.to_string(),
1317 error,
1318 ));
1319 }
1320 }
1321 };
1322
1323 dlg.finished(true);
1324 return Ok(response);
1325 }
1326 }
1327 }
1328 }
1329
1330 /// The index of the first result to return. The default number of results per page is 10, so `&start=11` would start at the top of the second page of results. **Note**: The JSON API will never return more than 100 results, even if more than 100 documents match the query, so setting the sum of `start + num` to a number greater than 100 will produce an error. Also note that the maximum value for `num` is 10.
1331 ///
1332 /// Sets the *start* query property to the given value.
1333 pub fn start(mut self, new_value: u32) -> CseSiterestrictListCall<'a, C> {
1334 self._start = Some(new_value);
1335 self
1336 }
1337 /// The sort expression to apply to the results. The sort parameter specifies that the results be sorted according to the specified expression i.e. sort by date. [Example: sort=date](https://developers.google.com/custom-search/docs/structured_search#sort-by-attribute).
1338 ///
1339 /// Sets the *sort* query property to the given value.
1340 pub fn sort(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1341 self._sort = Some(new_value.to_string());
1342 self
1343 }
1344 /// Optional. Maximum length of snippet text, in characters, to be returned with results. Note: this feature is limited to specific engines. * Valid values are integers between 161 and 1000, inclusive.
1345 ///
1346 /// Sets the *snippet length* query property to the given value.
1347 pub fn snippet_length(mut self, new_value: i32) -> CseSiterestrictListCall<'a, C> {
1348 self._snippet_length = Some(new_value);
1349 self
1350 }
1351 /// Controls whether to include or exclude results from the site named in the `siteSearch` parameter. Acceptable values are: * `"e"`: exclude * `"i"`: include
1352 ///
1353 /// Sets the *site search filter* query property to the given value.
1354 pub fn site_search_filter(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1355 self._site_search_filter = Some(new_value.to_string());
1356 self
1357 }
1358 /// Specifies a given site which should always be included or excluded from results (see `siteSearchFilter` parameter, below).
1359 ///
1360 /// Sets the *site search* query property to the given value.
1361 pub fn site_search(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1362 self._site_search = Some(new_value.to_string());
1363 self
1364 }
1365 /// Specifies the search type: `image`. If unspecified, results are limited to webpages. Acceptable values are: * `"image"`: custom image search.
1366 ///
1367 /// Sets the *search type* query property to the given value.
1368 pub fn search_type(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1369 self._search_type = Some(new_value.to_string());
1370 self
1371 }
1372 /// Search safety level. Acceptable values are: * `"active"`: Enables SafeSearch filtering. * `"off"`: Disables SafeSearch filtering. (default)
1373 ///
1374 /// Sets the *safe* query property to the given value.
1375 pub fn safe(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1376 self._safe = Some(new_value.to_string());
1377 self
1378 }
1379 /// Filters based on licensing. Supported values include: `cc_publicdomain`, `cc_attribute`, `cc_sharealike`, `cc_noncommercial`, `cc_nonderived` and combinations of these. See [typical combinations](https://wiki.creativecommons.org/wiki/CC_Search_integration).
1380 ///
1381 /// Sets the *rights* query property to the given value.
1382 pub fn rights(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1383 self._rights = Some(new_value.to_string());
1384 self
1385 }
1386 /// Deprecated.
1387 ///
1388 /// Sets the *related site* query property to the given value.
1389 pub fn related_site(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1390 self._related_site = Some(new_value.to_string());
1391 self
1392 }
1393 /// Query
1394 ///
1395 /// Sets the *q* query property to the given value.
1396 pub fn q(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1397 self._q = Some(new_value.to_string());
1398 self
1399 }
1400 /// Provides additional search terms to check for in a document, where each document in the search results must contain at least one of the additional search terms.
1401 ///
1402 /// Sets the *or terms* query property to the given value.
1403 pub fn or_terms(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1404 self._or_terms = Some(new_value.to_string());
1405 self
1406 }
1407 /// Number of search results to return. * Valid values are integers between 1 and 10, inclusive.
1408 ///
1409 /// Sets the *num* query property to the given value.
1410 pub fn num(mut self, new_value: i32) -> CseSiterestrictListCall<'a, C> {
1411 self._num = Some(new_value);
1412 self
1413 }
1414 /// Restricts the search to documents written in a particular language (e.g., `lr=lang_ja`). Acceptable values are: * `"lang_ar"`: Arabic * `"lang_bg"`: Bulgarian * `"lang_ca"`: Catalan * `"lang_cs"`: Czech * `"lang_da"`: Danish * `"lang_de"`: German * `"lang_el"`: Greek * `"lang_en"`: English * `"lang_es"`: Spanish * `"lang_et"`: Estonian * `"lang_fi"`: Finnish * `"lang_fr"`: French * `"lang_hr"`: Croatian * `"lang_hu"`: Hungarian * `"lang_id"`: Indonesian * `"lang_is"`: Icelandic * `"lang_it"`: Italian * `"lang_iw"`: Hebrew * `"lang_ja"`: Japanese * `"lang_ko"`: Korean * `"lang_lt"`: Lithuanian * `"lang_lv"`: Latvian * `"lang_nl"`: Dutch * `"lang_no"`: Norwegian * `"lang_pl"`: Polish * `"lang_pt"`: Portuguese * `"lang_ro"`: Romanian * `"lang_ru"`: Russian * `"lang_sk"`: Slovak * `"lang_sl"`: Slovenian * `"lang_sr"`: Serbian * `"lang_sv"`: Swedish * `"lang_tr"`: Turkish * `"lang_zh-CN"`: Chinese (Simplified) * `"lang_zh-TW"`: Chinese (Traditional)
1415 ///
1416 /// Sets the *lr* query property to the given value.
1417 pub fn lr(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1418 self._lr = Some(new_value.to_string());
1419 self
1420 }
1421 /// Specifies the starting value for a search range. Use `lowRange` and `highRange` to append an inclusive search range of `lowRange...highRange` to the query.
1422 ///
1423 /// Sets the *low range* query property to the given value.
1424 pub fn low_range(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1425 self._low_range = Some(new_value.to_string());
1426 self
1427 }
1428 /// Specifies that all search results should contain a link to a particular URL.
1429 ///
1430 /// Sets the *link site* query property to the given value.
1431 pub fn link_site(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1432 self._link_site = Some(new_value.to_string());
1433 self
1434 }
1435 /// Returns images of a type. Acceptable values are: * `"clipart"` * `"face"` * `"lineart"` * `"stock"` * `"photo"` * `"animated"`
1436 ///
1437 /// Sets the *img type* query property to the given value.
1438 pub fn img_type(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1439 self._img_type = Some(new_value.to_string());
1440 self
1441 }
1442 /// Returns images of a specified size. Acceptable values are: * `"huge"` * `"icon"` * `"large"` * `"medium"` * `"small"` * `"xlarge"` * `"xxlarge"`
1443 ///
1444 /// Sets the *img size* query property to the given value.
1445 pub fn img_size(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1446 self._img_size = Some(new_value.to_string());
1447 self
1448 }
1449 /// Returns images of a specific dominant color. Acceptable values are: * `"black"` * `"blue"` * `"brown"` * `"gray"` * `"green"` * `"orange"` * `"pink"` * `"purple"` * `"red"` * `"teal"` * `"white"` * `"yellow"`
1450 ///
1451 /// Sets the *img dominant color* query property to the given value.
1452 pub fn img_dominant_color(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1453 self._img_dominant_color = Some(new_value.to_string());
1454 self
1455 }
1456 /// Returns black and white, grayscale, transparent, or color images. Acceptable values are: * `"color"` * `"gray"` * `"mono"`: black and white * `"trans"`: transparent background
1457 ///
1458 /// Sets the *img color type* query property to the given value.
1459 pub fn img_color_type(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1460 self._img_color_type = Some(new_value.to_string());
1461 self
1462 }
1463 /// Appends the specified query terms to the query, as if they were combined with a logical AND operator.
1464 ///
1465 /// Sets the *hq* query property to the given value.
1466 pub fn hq(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1467 self._hq = Some(new_value.to_string());
1468 self
1469 }
1470 /// Sets the user interface language. * Explicitly setting this parameter improves the performance and the quality of your search results. * See the [Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#wsInterfaceLanguages) section of [Internationalizing Queries and Results Presentation](https://developers.google.com/custom-search/docs/json_api_reference#wsInternationalizing) for more information, and [Supported Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#interfaceLanguages) for a list of supported languages.
1471 ///
1472 /// Sets the *hl* query property to the given value.
1473 pub fn hl(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1474 self._hl = Some(new_value.to_string());
1475 self
1476 }
1477 /// Specifies the ending value for a search range. * Use `lowRange` and `highRange` to append an inclusive search range of `lowRange...highRange` to the query.
1478 ///
1479 /// Sets the *high range* query property to the given value.
1480 pub fn high_range(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1481 self._high_range = Some(new_value.to_string());
1482 self
1483 }
1484 /// **Deprecated**. Use the `gl` parameter for a similar effect. The local Google domain (for example, google.com, google.de, or google.fr) to use to perform the search.
1485 ///
1486 /// Sets the *googlehost* query property to the given value.
1487 pub fn googlehost(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1488 self._googlehost = Some(new_value.to_string());
1489 self
1490 }
1491 /// Geolocation of end user. * The `gl` parameter value is a two-letter country code. The `gl` parameter boosts search results whose country of origin matches the parameter value. See the [Country Codes](https://developers.google.com/custom-search/docs/json_api_reference#countryCodes) page for a list of valid values. * Specifying a `gl` parameter value should lead to more relevant results. This is particularly true for international customers and, even more specifically, for customers in English- speaking countries other than the United States.
1492 ///
1493 /// Sets the *gl* query property to the given value.
1494 pub fn gl(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1495 self._gl = Some(new_value.to_string());
1496 self
1497 }
1498 /// Controls turning on or off the duplicate content filter. * See [Automatic Filtering](https://developers.google.com/custom-search/docs/json_api_reference#automaticFiltering) for more information about Google's search results filters. Note that host crowding filtering applies only to multi-site searches. * By default, Google applies filtering to all search results to improve the quality of those results. Acceptable values are: * `0`: Turns off duplicate content filter. * `1`: Turns on duplicate content filter.
1499 ///
1500 /// Sets the *filter* query property to the given value.
1501 pub fn filter(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1502 self._filter = Some(new_value.to_string());
1503 self
1504 }
1505 /// Restricts results to files of a specified extension. A list of file types indexable by Google can be found in Search Console [Help Center](https://support.google.com/webmasters/answer/35287).
1506 ///
1507 /// Sets the *file type* query property to the given value.
1508 pub fn file_type(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1509 self._file_type = Some(new_value.to_string());
1510 self
1511 }
1512 /// Identifies a word or phrase that should not appear in any documents in the search results.
1513 ///
1514 /// Sets the *exclude terms* query property to the given value.
1515 pub fn exclude_terms(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1516 self._exclude_terms = Some(new_value.to_string());
1517 self
1518 }
1519 /// Identifies a phrase that all documents in the search results must contain.
1520 ///
1521 /// Sets the *exact terms* query property to the given value.
1522 pub fn exact_terms(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1523 self._exact_terms = Some(new_value.to_string());
1524 self
1525 }
1526 /// Optional. Enables routing of Programmable Search Engine requests to an alternate search handler.
1527 ///
1528 /// Sets the *enable alternate search handler* query property to the given value.
1529 pub fn enable_alternate_search_handler(
1530 mut self,
1531 new_value: bool,
1532 ) -> CseSiterestrictListCall<'a, C> {
1533 self._enable_alternate_search_handler = Some(new_value);
1534 self
1535 }
1536 /// Restricts results to URLs based on date. Supported values include: * `d[number]`: requests results from the specified number of past days. * `w[number]`: requests results from the specified number of past weeks. * `m[number]`: requests results from the specified number of past months. * `y[number]`: requests results from the specified number of past years.
1537 ///
1538 /// Sets the *date restrict* query property to the given value.
1539 pub fn date_restrict(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1540 self._date_restrict = Some(new_value.to_string());
1541 self
1542 }
1543 /// The Programmable Search Engine ID to use for this request.
1544 ///
1545 /// Sets the *cx* query property to the given value.
1546 pub fn cx(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1547 self._cx = Some(new_value.to_string());
1548 self
1549 }
1550 /// Restricts search results to documents originating in a particular country. You may use [Boolean operators](https://developers.google.com/custom-search/docs/json_api_reference#booleanOperators) in the cr parameter's value. Google Search determines the country of a document by analyzing: * the top-level domain (TLD) of the document's URL * the geographic location of the Web server's IP address See the [Country Parameter Values](https://developers.google.com/custom-search/docs/json_api_reference#countryCollections) page for a list of valid values for this parameter.
1551 ///
1552 /// Sets the *cr* query property to the given value.
1553 pub fn cr(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1554 self._cr = Some(new_value.to_string());
1555 self
1556 }
1557 /// Enables or disables [Simplified and Traditional Chinese Search](https://developers.google.com/custom-search/docs/json_api_reference#chineseSearch). The default value for this parameter is 0 (zero), meaning that the feature is enabled. Supported values are: * `1`: Disabled * `0`: Enabled (default)
1558 ///
1559 /// Sets the *c2coff* query property to the given value.
1560 pub fn c2coff(mut self, new_value: &str) -> CseSiterestrictListCall<'a, C> {
1561 self._c2coff = Some(new_value.to_string());
1562 self
1563 }
1564 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1565 /// while executing the actual API request.
1566 ///
1567 /// ````text
1568 /// It should be used to handle progress information, and to implement a certain level of resilience.
1569 /// ````
1570 ///
1571 /// Sets the *delegate* property to the given value.
1572 pub fn delegate(
1573 mut self,
1574 new_value: &'a mut dyn common::Delegate,
1575 ) -> CseSiterestrictListCall<'a, C> {
1576 self._delegate = Some(new_value);
1577 self
1578 }
1579
1580 /// Set any additional parameter of the query string used in the request.
1581 /// It should be used to set parameters which are not yet available through their own
1582 /// setters.
1583 ///
1584 /// Please note that this method must not be used to set any of the known parameters
1585 /// which have their own setter method. If done anyway, the request will fail.
1586 ///
1587 /// # Additional Parameters
1588 ///
1589 /// * *$.xgafv* (query-string) - V1 error format.
1590 /// * *access_token* (query-string) - OAuth access token.
1591 /// * *alt* (query-string) - Data format for response.
1592 /// * *callback* (query-string) - JSONP
1593 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1594 /// * *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.
1595 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1596 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1597 /// * *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.
1598 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1599 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1600 pub fn param<T>(mut self, name: T, value: T) -> CseSiterestrictListCall<'a, C>
1601 where
1602 T: AsRef<str>,
1603 {
1604 self._additional_params
1605 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1606 self
1607 }
1608}
1609
1610/// Returns metadata about the search performed, metadata about the engine used for the search, and the search results.
1611///
1612/// A builder for the *list* method supported by a *cse* resource.
1613/// It is not used directly, but through a [`CseMethods`] instance.
1614///
1615/// # Example
1616///
1617/// Instantiate a resource method builder
1618///
1619/// ```test_harness,no_run
1620/// # extern crate hyper;
1621/// # extern crate hyper_rustls;
1622/// # extern crate google_customsearch1 as customsearch1;
1623/// # async fn dox() {
1624/// # use customsearch1::{CustomSearchAPI, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1625///
1626/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1627/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1628/// # .with_native_roots()
1629/// # .unwrap()
1630/// # .https_only()
1631/// # .enable_http2()
1632/// # .build();
1633///
1634/// # let executor = hyper_util::rt::TokioExecutor::new();
1635/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1636/// # secret,
1637/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1638/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1639/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1640/// # ),
1641/// # ).build().await.unwrap();
1642///
1643/// # let client = hyper_util::client::legacy::Client::builder(
1644/// # hyper_util::rt::TokioExecutor::new()
1645/// # )
1646/// # .build(
1647/// # hyper_rustls::HttpsConnectorBuilder::new()
1648/// # .with_native_roots()
1649/// # .unwrap()
1650/// # .https_or_http()
1651/// # .enable_http2()
1652/// # .build()
1653/// # );
1654/// # let mut hub = CustomSearchAPI::new(client, auth);
1655/// // You can configure optional parameters by calling the respective setters at will, and
1656/// // execute the final call using `doit()`.
1657/// // Values shown here are possibly random and not representative !
1658/// let result = hub.cse().list()
1659/// .start(5)
1660/// .sort("consetetur")
1661/// .snippet_length(-65)
1662/// .site_search_filter("est")
1663/// .site_search("aliquyam")
1664/// .search_type("elitr")
1665/// .safe("duo")
1666/// .rights("diam")
1667/// .related_site("est")
1668/// .q("sit")
1669/// .or_terms("sed")
1670/// .num(-75)
1671/// .lr("Lorem")
1672/// .low_range("ea")
1673/// .link_site("Stet")
1674/// .img_type("dolores")
1675/// .img_size("eos")
1676/// .img_dominant_color("et")
1677/// .img_color_type("sea")
1678/// .hq("et")
1679/// .hl("At")
1680/// .high_range("dolore")
1681/// .googlehost("eirmod")
1682/// .gl("Lorem")
1683/// .filter("accusam")
1684/// .file_type("amet")
1685/// .exclude_terms("erat")
1686/// .exact_terms("dolores")
1687/// .enable_alternate_search_handler(false)
1688/// .date_restrict("accusam")
1689/// .cx("sea")
1690/// .cr("takimata")
1691/// .c2coff("Lorem")
1692/// .doit().await;
1693/// # }
1694/// ```
1695pub struct CseListCall<'a, C>
1696where
1697 C: 'a,
1698{
1699 hub: &'a CustomSearchAPI<C>,
1700 _start: Option<u32>,
1701 _sort: Option<String>,
1702 _snippet_length: Option<i32>,
1703 _site_search_filter: Option<String>,
1704 _site_search: Option<String>,
1705 _search_type: Option<String>,
1706 _safe: Option<String>,
1707 _rights: Option<String>,
1708 _related_site: Option<String>,
1709 _q: Option<String>,
1710 _or_terms: Option<String>,
1711 _num: Option<i32>,
1712 _lr: Option<String>,
1713 _low_range: Option<String>,
1714 _link_site: Option<String>,
1715 _img_type: Option<String>,
1716 _img_size: Option<String>,
1717 _img_dominant_color: Option<String>,
1718 _img_color_type: Option<String>,
1719 _hq: Option<String>,
1720 _hl: Option<String>,
1721 _high_range: Option<String>,
1722 _googlehost: Option<String>,
1723 _gl: Option<String>,
1724 _filter: Option<String>,
1725 _file_type: Option<String>,
1726 _exclude_terms: Option<String>,
1727 _exact_terms: Option<String>,
1728 _enable_alternate_search_handler: Option<bool>,
1729 _date_restrict: Option<String>,
1730 _cx: Option<String>,
1731 _cr: Option<String>,
1732 _c2coff: Option<String>,
1733 _delegate: Option<&'a mut dyn common::Delegate>,
1734 _additional_params: HashMap<String, String>,
1735}
1736
1737impl<'a, C> common::CallBuilder for CseListCall<'a, C> {}
1738
1739impl<'a, C> CseListCall<'a, C>
1740where
1741 C: common::Connector,
1742{
1743 /// Perform the operation you have build so far.
1744 pub async fn doit(mut self) -> common::Result<(common::Response, Search)> {
1745 use std::borrow::Cow;
1746 use std::io::{Read, Seek};
1747
1748 use common::{url::Params, ToParts};
1749 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1750
1751 let mut dd = common::DefaultDelegate;
1752 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1753 dlg.begin(common::MethodInfo {
1754 id: "search.cse.list",
1755 http_method: hyper::Method::GET,
1756 });
1757
1758 for &field in [
1759 "alt",
1760 "start",
1761 "sort",
1762 "snippetLength",
1763 "siteSearchFilter",
1764 "siteSearch",
1765 "searchType",
1766 "safe",
1767 "rights",
1768 "relatedSite",
1769 "q",
1770 "orTerms",
1771 "num",
1772 "lr",
1773 "lowRange",
1774 "linkSite",
1775 "imgType",
1776 "imgSize",
1777 "imgDominantColor",
1778 "imgColorType",
1779 "hq",
1780 "hl",
1781 "highRange",
1782 "googlehost",
1783 "gl",
1784 "filter",
1785 "fileType",
1786 "excludeTerms",
1787 "exactTerms",
1788 "enableAlternateSearchHandler",
1789 "dateRestrict",
1790 "cx",
1791 "cr",
1792 "c2coff",
1793 ]
1794 .iter()
1795 {
1796 if self._additional_params.contains_key(field) {
1797 dlg.finished(false);
1798 return Err(common::Error::FieldClash(field));
1799 }
1800 }
1801
1802 let mut params = Params::with_capacity(35 + self._additional_params.len());
1803 if let Some(value) = self._start.as_ref() {
1804 params.push("start", value.to_string());
1805 }
1806 if let Some(value) = self._sort.as_ref() {
1807 params.push("sort", value);
1808 }
1809 if let Some(value) = self._snippet_length.as_ref() {
1810 params.push("snippetLength", value.to_string());
1811 }
1812 if let Some(value) = self._site_search_filter.as_ref() {
1813 params.push("siteSearchFilter", value);
1814 }
1815 if let Some(value) = self._site_search.as_ref() {
1816 params.push("siteSearch", value);
1817 }
1818 if let Some(value) = self._search_type.as_ref() {
1819 params.push("searchType", value);
1820 }
1821 if let Some(value) = self._safe.as_ref() {
1822 params.push("safe", value);
1823 }
1824 if let Some(value) = self._rights.as_ref() {
1825 params.push("rights", value);
1826 }
1827 if let Some(value) = self._related_site.as_ref() {
1828 params.push("relatedSite", value);
1829 }
1830 if let Some(value) = self._q.as_ref() {
1831 params.push("q", value);
1832 }
1833 if let Some(value) = self._or_terms.as_ref() {
1834 params.push("orTerms", value);
1835 }
1836 if let Some(value) = self._num.as_ref() {
1837 params.push("num", value.to_string());
1838 }
1839 if let Some(value) = self._lr.as_ref() {
1840 params.push("lr", value);
1841 }
1842 if let Some(value) = self._low_range.as_ref() {
1843 params.push("lowRange", value);
1844 }
1845 if let Some(value) = self._link_site.as_ref() {
1846 params.push("linkSite", value);
1847 }
1848 if let Some(value) = self._img_type.as_ref() {
1849 params.push("imgType", value);
1850 }
1851 if let Some(value) = self._img_size.as_ref() {
1852 params.push("imgSize", value);
1853 }
1854 if let Some(value) = self._img_dominant_color.as_ref() {
1855 params.push("imgDominantColor", value);
1856 }
1857 if let Some(value) = self._img_color_type.as_ref() {
1858 params.push("imgColorType", value);
1859 }
1860 if let Some(value) = self._hq.as_ref() {
1861 params.push("hq", value);
1862 }
1863 if let Some(value) = self._hl.as_ref() {
1864 params.push("hl", value);
1865 }
1866 if let Some(value) = self._high_range.as_ref() {
1867 params.push("highRange", value);
1868 }
1869 if let Some(value) = self._googlehost.as_ref() {
1870 params.push("googlehost", value);
1871 }
1872 if let Some(value) = self._gl.as_ref() {
1873 params.push("gl", value);
1874 }
1875 if let Some(value) = self._filter.as_ref() {
1876 params.push("filter", value);
1877 }
1878 if let Some(value) = self._file_type.as_ref() {
1879 params.push("fileType", value);
1880 }
1881 if let Some(value) = self._exclude_terms.as_ref() {
1882 params.push("excludeTerms", value);
1883 }
1884 if let Some(value) = self._exact_terms.as_ref() {
1885 params.push("exactTerms", value);
1886 }
1887 if let Some(value) = self._enable_alternate_search_handler.as_ref() {
1888 params.push("enableAlternateSearchHandler", value.to_string());
1889 }
1890 if let Some(value) = self._date_restrict.as_ref() {
1891 params.push("dateRestrict", value);
1892 }
1893 if let Some(value) = self._cx.as_ref() {
1894 params.push("cx", value);
1895 }
1896 if let Some(value) = self._cr.as_ref() {
1897 params.push("cr", value);
1898 }
1899 if let Some(value) = self._c2coff.as_ref() {
1900 params.push("c2coff", value);
1901 }
1902
1903 params.extend(self._additional_params.iter());
1904
1905 params.push("alt", "json");
1906 let mut url = self.hub._base_url.clone() + "customsearch/v1";
1907
1908 match dlg.api_key() {
1909 Some(value) => params.push("key", value),
1910 None => {
1911 dlg.finished(false);
1912 return Err(common::Error::MissingAPIKey);
1913 }
1914 }
1915
1916 let url = params.parse_with_url(&url);
1917
1918 loop {
1919 let mut req_result = {
1920 let client = &self.hub.client;
1921 dlg.pre_request();
1922 let mut req_builder = hyper::Request::builder()
1923 .method(hyper::Method::GET)
1924 .uri(url.as_str())
1925 .header(USER_AGENT, self.hub._user_agent.clone());
1926
1927 let request = req_builder
1928 .header(CONTENT_LENGTH, 0_u64)
1929 .body(common::to_body::<String>(None));
1930
1931 client.request(request.unwrap()).await
1932 };
1933
1934 match req_result {
1935 Err(err) => {
1936 if let common::Retry::After(d) = dlg.http_error(&err) {
1937 sleep(d).await;
1938 continue;
1939 }
1940 dlg.finished(false);
1941 return Err(common::Error::HttpError(err));
1942 }
1943 Ok(res) => {
1944 let (mut parts, body) = res.into_parts();
1945 let mut body = common::Body::new(body);
1946 if !parts.status.is_success() {
1947 let bytes = common::to_bytes(body).await.unwrap_or_default();
1948 let error = serde_json::from_str(&common::to_string(&bytes));
1949 let response = common::to_response(parts, bytes.into());
1950
1951 if let common::Retry::After(d) =
1952 dlg.http_failure(&response, error.as_ref().ok())
1953 {
1954 sleep(d).await;
1955 continue;
1956 }
1957
1958 dlg.finished(false);
1959
1960 return Err(match error {
1961 Ok(value) => common::Error::BadRequest(value),
1962 _ => common::Error::Failure(response),
1963 });
1964 }
1965 let response = {
1966 let bytes = common::to_bytes(body).await.unwrap_or_default();
1967 let encoded = common::to_string(&bytes);
1968 match serde_json::from_str(&encoded) {
1969 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1970 Err(error) => {
1971 dlg.response_json_decode_error(&encoded, &error);
1972 return Err(common::Error::JsonDecodeError(
1973 encoded.to_string(),
1974 error,
1975 ));
1976 }
1977 }
1978 };
1979
1980 dlg.finished(true);
1981 return Ok(response);
1982 }
1983 }
1984 }
1985 }
1986
1987 /// The index of the first result to return. The default number of results per page is 10, so `&start=11` would start at the top of the second page of results. **Note**: The JSON API will never return more than 100 results, even if more than 100 documents match the query, so setting the sum of `start + num` to a number greater than 100 will produce an error. Also note that the maximum value for `num` is 10.
1988 ///
1989 /// Sets the *start* query property to the given value.
1990 pub fn start(mut self, new_value: u32) -> CseListCall<'a, C> {
1991 self._start = Some(new_value);
1992 self
1993 }
1994 /// The sort expression to apply to the results. The sort parameter specifies that the results be sorted according to the specified expression i.e. sort by date. [Example: sort=date](https://developers.google.com/custom-search/docs/structured_search#sort-by-attribute).
1995 ///
1996 /// Sets the *sort* query property to the given value.
1997 pub fn sort(mut self, new_value: &str) -> CseListCall<'a, C> {
1998 self._sort = Some(new_value.to_string());
1999 self
2000 }
2001 /// Optional. Maximum length of snippet text, in characters, to be returned with results. Note: this feature is limited to specific engines. * Valid values are integers between 161 and 1000, inclusive.
2002 ///
2003 /// Sets the *snippet length* query property to the given value.
2004 pub fn snippet_length(mut self, new_value: i32) -> CseListCall<'a, C> {
2005 self._snippet_length = Some(new_value);
2006 self
2007 }
2008 /// Controls whether to include or exclude results from the site named in the `siteSearch` parameter. Acceptable values are: * `"e"`: exclude * `"i"`: include
2009 ///
2010 /// Sets the *site search filter* query property to the given value.
2011 pub fn site_search_filter(mut self, new_value: &str) -> CseListCall<'a, C> {
2012 self._site_search_filter = Some(new_value.to_string());
2013 self
2014 }
2015 /// Specifies a given site which should always be included or excluded from results (see `siteSearchFilter` parameter, below).
2016 ///
2017 /// Sets the *site search* query property to the given value.
2018 pub fn site_search(mut self, new_value: &str) -> CseListCall<'a, C> {
2019 self._site_search = Some(new_value.to_string());
2020 self
2021 }
2022 /// Specifies the search type: `image`. If unspecified, results are limited to webpages. Acceptable values are: * `"image"`: custom image search.
2023 ///
2024 /// Sets the *search type* query property to the given value.
2025 pub fn search_type(mut self, new_value: &str) -> CseListCall<'a, C> {
2026 self._search_type = Some(new_value.to_string());
2027 self
2028 }
2029 /// Search safety level. Acceptable values are: * `"active"`: Enables SafeSearch filtering. * `"off"`: Disables SafeSearch filtering. (default)
2030 ///
2031 /// Sets the *safe* query property to the given value.
2032 pub fn safe(mut self, new_value: &str) -> CseListCall<'a, C> {
2033 self._safe = Some(new_value.to_string());
2034 self
2035 }
2036 /// Filters based on licensing. Supported values include: `cc_publicdomain`, `cc_attribute`, `cc_sharealike`, `cc_noncommercial`, `cc_nonderived` and combinations of these. See [typical combinations](https://wiki.creativecommons.org/wiki/CC_Search_integration).
2037 ///
2038 /// Sets the *rights* query property to the given value.
2039 pub fn rights(mut self, new_value: &str) -> CseListCall<'a, C> {
2040 self._rights = Some(new_value.to_string());
2041 self
2042 }
2043 /// Deprecated.
2044 ///
2045 /// Sets the *related site* query property to the given value.
2046 pub fn related_site(mut self, new_value: &str) -> CseListCall<'a, C> {
2047 self._related_site = Some(new_value.to_string());
2048 self
2049 }
2050 /// Query
2051 ///
2052 /// Sets the *q* query property to the given value.
2053 pub fn q(mut self, new_value: &str) -> CseListCall<'a, C> {
2054 self._q = Some(new_value.to_string());
2055 self
2056 }
2057 /// Provides additional search terms to check for in a document, where each document in the search results must contain at least one of the additional search terms.
2058 ///
2059 /// Sets the *or terms* query property to the given value.
2060 pub fn or_terms(mut self, new_value: &str) -> CseListCall<'a, C> {
2061 self._or_terms = Some(new_value.to_string());
2062 self
2063 }
2064 /// Number of search results to return. * Valid values are integers between 1 and 10, inclusive.
2065 ///
2066 /// Sets the *num* query property to the given value.
2067 pub fn num(mut self, new_value: i32) -> CseListCall<'a, C> {
2068 self._num = Some(new_value);
2069 self
2070 }
2071 /// Restricts the search to documents written in a particular language (e.g., `lr=lang_ja`). Acceptable values are: * `"lang_ar"`: Arabic * `"lang_bg"`: Bulgarian * `"lang_ca"`: Catalan * `"lang_cs"`: Czech * `"lang_da"`: Danish * `"lang_de"`: German * `"lang_el"`: Greek * `"lang_en"`: English * `"lang_es"`: Spanish * `"lang_et"`: Estonian * `"lang_fi"`: Finnish * `"lang_fr"`: French * `"lang_hr"`: Croatian * `"lang_hu"`: Hungarian * `"lang_id"`: Indonesian * `"lang_is"`: Icelandic * `"lang_it"`: Italian * `"lang_iw"`: Hebrew * `"lang_ja"`: Japanese * `"lang_ko"`: Korean * `"lang_lt"`: Lithuanian * `"lang_lv"`: Latvian * `"lang_nl"`: Dutch * `"lang_no"`: Norwegian * `"lang_pl"`: Polish * `"lang_pt"`: Portuguese * `"lang_ro"`: Romanian * `"lang_ru"`: Russian * `"lang_sk"`: Slovak * `"lang_sl"`: Slovenian * `"lang_sr"`: Serbian * `"lang_sv"`: Swedish * `"lang_tr"`: Turkish * `"lang_zh-CN"`: Chinese (Simplified) * `"lang_zh-TW"`: Chinese (Traditional)
2072 ///
2073 /// Sets the *lr* query property to the given value.
2074 pub fn lr(mut self, new_value: &str) -> CseListCall<'a, C> {
2075 self._lr = Some(new_value.to_string());
2076 self
2077 }
2078 /// Specifies the starting value for a search range. Use `lowRange` and `highRange` to append an inclusive search range of `lowRange...highRange` to the query.
2079 ///
2080 /// Sets the *low range* query property to the given value.
2081 pub fn low_range(mut self, new_value: &str) -> CseListCall<'a, C> {
2082 self._low_range = Some(new_value.to_string());
2083 self
2084 }
2085 /// Specifies that all search results should contain a link to a particular URL.
2086 ///
2087 /// Sets the *link site* query property to the given value.
2088 pub fn link_site(mut self, new_value: &str) -> CseListCall<'a, C> {
2089 self._link_site = Some(new_value.to_string());
2090 self
2091 }
2092 /// Returns images of a type. Acceptable values are: * `"clipart"` * `"face"` * `"lineart"` * `"stock"` * `"photo"` * `"animated"`
2093 ///
2094 /// Sets the *img type* query property to the given value.
2095 pub fn img_type(mut self, new_value: &str) -> CseListCall<'a, C> {
2096 self._img_type = Some(new_value.to_string());
2097 self
2098 }
2099 /// Returns images of a specified size. Acceptable values are: * `"huge"` * `"icon"` * `"large"` * `"medium"` * `"small"` * `"xlarge"` * `"xxlarge"`
2100 ///
2101 /// Sets the *img size* query property to the given value.
2102 pub fn img_size(mut self, new_value: &str) -> CseListCall<'a, C> {
2103 self._img_size = Some(new_value.to_string());
2104 self
2105 }
2106 /// Returns images of a specific dominant color. Acceptable values are: * `"black"` * `"blue"` * `"brown"` * `"gray"` * `"green"` * `"orange"` * `"pink"` * `"purple"` * `"red"` * `"teal"` * `"white"` * `"yellow"`
2107 ///
2108 /// Sets the *img dominant color* query property to the given value.
2109 pub fn img_dominant_color(mut self, new_value: &str) -> CseListCall<'a, C> {
2110 self._img_dominant_color = Some(new_value.to_string());
2111 self
2112 }
2113 /// Returns black and white, grayscale, transparent, or color images. Acceptable values are: * `"color"` * `"gray"` * `"mono"`: black and white * `"trans"`: transparent background
2114 ///
2115 /// Sets the *img color type* query property to the given value.
2116 pub fn img_color_type(mut self, new_value: &str) -> CseListCall<'a, C> {
2117 self._img_color_type = Some(new_value.to_string());
2118 self
2119 }
2120 /// Appends the specified query terms to the query, as if they were combined with a logical AND operator.
2121 ///
2122 /// Sets the *hq* query property to the given value.
2123 pub fn hq(mut self, new_value: &str) -> CseListCall<'a, C> {
2124 self._hq = Some(new_value.to_string());
2125 self
2126 }
2127 /// Sets the user interface language. * Explicitly setting this parameter improves the performance and the quality of your search results. * See the [Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#wsInterfaceLanguages) section of [Internationalizing Queries and Results Presentation](https://developers.google.com/custom-search/docs/json_api_reference#wsInternationalizing) for more information, and [Supported Interface Languages](https://developers.google.com/custom-search/docs/json_api_reference#interfaceLanguages) for a list of supported languages.
2128 ///
2129 /// Sets the *hl* query property to the given value.
2130 pub fn hl(mut self, new_value: &str) -> CseListCall<'a, C> {
2131 self._hl = Some(new_value.to_string());
2132 self
2133 }
2134 /// Specifies the ending value for a search range. * Use `lowRange` and `highRange` to append an inclusive search range of `lowRange...highRange` to the query.
2135 ///
2136 /// Sets the *high range* query property to the given value.
2137 pub fn high_range(mut self, new_value: &str) -> CseListCall<'a, C> {
2138 self._high_range = Some(new_value.to_string());
2139 self
2140 }
2141 /// **Deprecated**. Use the `gl` parameter for a similar effect. The local Google domain (for example, google.com, google.de, or google.fr) to use to perform the search.
2142 ///
2143 /// Sets the *googlehost* query property to the given value.
2144 pub fn googlehost(mut self, new_value: &str) -> CseListCall<'a, C> {
2145 self._googlehost = Some(new_value.to_string());
2146 self
2147 }
2148 /// Geolocation of end user. * The `gl` parameter value is a two-letter country code. The `gl` parameter boosts search results whose country of origin matches the parameter value. See the [Country Codes](https://developers.google.com/custom-search/docs/json_api_reference#countryCodes) page for a list of valid values. * Specifying a `gl` parameter value should lead to more relevant results. This is particularly true for international customers and, even more specifically, for customers in English- speaking countries other than the United States.
2149 ///
2150 /// Sets the *gl* query property to the given value.
2151 pub fn gl(mut self, new_value: &str) -> CseListCall<'a, C> {
2152 self._gl = Some(new_value.to_string());
2153 self
2154 }
2155 /// Controls turning on or off the duplicate content filter. * See [Automatic Filtering](https://developers.google.com/custom-search/docs/json_api_reference#automaticFiltering) for more information about Google's search results filters. Note that host crowding filtering applies only to multi-site searches. * By default, Google applies filtering to all search results to improve the quality of those results. Acceptable values are: * `0`: Turns off duplicate content filter. * `1`: Turns on duplicate content filter.
2156 ///
2157 /// Sets the *filter* query property to the given value.
2158 pub fn filter(mut self, new_value: &str) -> CseListCall<'a, C> {
2159 self._filter = Some(new_value.to_string());
2160 self
2161 }
2162 /// Restricts results to files of a specified extension. A list of file types indexable by Google can be found in Search Console [Help Center](https://support.google.com/webmasters/answer/35287).
2163 ///
2164 /// Sets the *file type* query property to the given value.
2165 pub fn file_type(mut self, new_value: &str) -> CseListCall<'a, C> {
2166 self._file_type = Some(new_value.to_string());
2167 self
2168 }
2169 /// Identifies a word or phrase that should not appear in any documents in the search results.
2170 ///
2171 /// Sets the *exclude terms* query property to the given value.
2172 pub fn exclude_terms(mut self, new_value: &str) -> CseListCall<'a, C> {
2173 self._exclude_terms = Some(new_value.to_string());
2174 self
2175 }
2176 /// Identifies a phrase that all documents in the search results must contain.
2177 ///
2178 /// Sets the *exact terms* query property to the given value.
2179 pub fn exact_terms(mut self, new_value: &str) -> CseListCall<'a, C> {
2180 self._exact_terms = Some(new_value.to_string());
2181 self
2182 }
2183 /// Optional. Enables routing of Programmable Search Engine requests to an alternate search handler.
2184 ///
2185 /// Sets the *enable alternate search handler* query property to the given value.
2186 pub fn enable_alternate_search_handler(mut self, new_value: bool) -> CseListCall<'a, C> {
2187 self._enable_alternate_search_handler = Some(new_value);
2188 self
2189 }
2190 /// Restricts results to URLs based on date. Supported values include: * `d[number]`: requests results from the specified number of past days. * `w[number]`: requests results from the specified number of past weeks. * `m[number]`: requests results from the specified number of past months. * `y[number]`: requests results from the specified number of past years.
2191 ///
2192 /// Sets the *date restrict* query property to the given value.
2193 pub fn date_restrict(mut self, new_value: &str) -> CseListCall<'a, C> {
2194 self._date_restrict = Some(new_value.to_string());
2195 self
2196 }
2197 /// The Programmable Search Engine ID to use for this request.
2198 ///
2199 /// Sets the *cx* query property to the given value.
2200 pub fn cx(mut self, new_value: &str) -> CseListCall<'a, C> {
2201 self._cx = Some(new_value.to_string());
2202 self
2203 }
2204 /// Restricts search results to documents originating in a particular country. You may use [Boolean operators](https://developers.google.com/custom-search/docs/json_api_reference#booleanOperators) in the cr parameter's value. Google Search determines the country of a document by analyzing: * the top-level domain (TLD) of the document's URL * the geographic location of the Web server's IP address See the [Country Parameter Values](https://developers.google.com/custom-search/docs/json_api_reference#countryCollections) page for a list of valid values for this parameter.
2205 ///
2206 /// Sets the *cr* query property to the given value.
2207 pub fn cr(mut self, new_value: &str) -> CseListCall<'a, C> {
2208 self._cr = Some(new_value.to_string());
2209 self
2210 }
2211 /// Enables or disables [Simplified and Traditional Chinese Search](https://developers.google.com/custom-search/docs/json_api_reference#chineseSearch). The default value for this parameter is 0 (zero), meaning that the feature is enabled. Supported values are: * `1`: Disabled * `0`: Enabled (default)
2212 ///
2213 /// Sets the *c2coff* query property to the given value.
2214 pub fn c2coff(mut self, new_value: &str) -> CseListCall<'a, C> {
2215 self._c2coff = Some(new_value.to_string());
2216 self
2217 }
2218 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2219 /// while executing the actual API request.
2220 ///
2221 /// ````text
2222 /// It should be used to handle progress information, and to implement a certain level of resilience.
2223 /// ````
2224 ///
2225 /// Sets the *delegate* property to the given value.
2226 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CseListCall<'a, C> {
2227 self._delegate = Some(new_value);
2228 self
2229 }
2230
2231 /// Set any additional parameter of the query string used in the request.
2232 /// It should be used to set parameters which are not yet available through their own
2233 /// setters.
2234 ///
2235 /// Please note that this method must not be used to set any of the known parameters
2236 /// which have their own setter method. If done anyway, the request will fail.
2237 ///
2238 /// # Additional Parameters
2239 ///
2240 /// * *$.xgafv* (query-string) - V1 error format.
2241 /// * *access_token* (query-string) - OAuth access token.
2242 /// * *alt* (query-string) - Data format for response.
2243 /// * *callback* (query-string) - JSONP
2244 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2245 /// * *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.
2246 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2247 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2248 /// * *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.
2249 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2250 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2251 pub fn param<T>(mut self, name: T, value: T) -> CseListCall<'a, C>
2252 where
2253 T: AsRef<str>,
2254 {
2255 self._additional_params
2256 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2257 self
2258 }
2259}