google_factchecktools1_alpha1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// Read, create, update, and delete your ClaimReview data.
17 Full,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::Full => "https://www.googleapis.com/auth/factchecktools",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::Full
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all FactCheckTools related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
49/// use factchecktools1_alpha1::api::GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage;
50/// use factchecktools1_alpha1::{Result, Error};
51/// # async fn dox() {
52/// use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = FactCheckTools::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.pages().update(req, "name")
99/// .doit().await;
100///
101/// match result {
102/// Err(e) => match e {
103/// // The Error enum provides details about what exactly happened.
104/// // You can also just use its `Debug`, `Display` or `Error` traits
105/// Error::HttpError(_)
106/// |Error::Io(_)
107/// |Error::MissingAPIKey
108/// |Error::MissingToken(_)
109/// |Error::Cancelled
110/// |Error::UploadSizeLimitExceeded(_, _)
111/// |Error::Failure(_)
112/// |Error::BadRequest(_)
113/// |Error::FieldClash(_)
114/// |Error::JsonDecodeError(_, _) => println!("{}", e),
115/// },
116/// Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct FactCheckTools<C> {
122 pub client: common::Client<C>,
123 pub auth: Box<dyn common::GetToken>,
124 _user_agent: String,
125 _base_url: String,
126 _root_url: String,
127}
128
129impl<C> common::Hub for FactCheckTools<C> {}
130
131impl<'a, C> FactCheckTools<C> {
132 pub fn new<A: 'static + common::GetToken>(
133 client: common::Client<C>,
134 auth: A,
135 ) -> FactCheckTools<C> {
136 FactCheckTools {
137 client,
138 auth: Box::new(auth),
139 _user_agent: "google-api-rust-client/7.0.0".to_string(),
140 _base_url: "https://factchecktools.googleapis.com/".to_string(),
141 _root_url: "https://factchecktools.googleapis.com/".to_string(),
142 }
143 }
144
145 pub fn claims(&'a self) -> ClaimMethods<'a, C> {
146 ClaimMethods { hub: self }
147 }
148 pub fn pages(&'a self) -> PageMethods<'a, C> {
149 PageMethods { 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://factchecktools.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://factchecktools.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/// Information about the claim.
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 GoogleFactcheckingFactchecktoolsV1alpha1Claim {
188 /// The date that the claim was made.
189 #[serde(rename = "claimDate")]
190 pub claim_date: Option<chrono::DateTime<chrono::offset::Utc>>,
191 /// One or more reviews of this claim (namely, a fact-checking article).
192 #[serde(rename = "claimReview")]
193 pub claim_review: Option<Vec<GoogleFactcheckingFactchecktoolsV1alpha1ClaimReview>>,
194 /// A person or organization stating the claim. For instance, "John Doe".
195 pub claimant: Option<String>,
196 /// The claim text. For instance, "Crime has doubled in the last 2 years."
197 pub text: Option<String>,
198}
199
200impl common::Part for GoogleFactcheckingFactchecktoolsV1alpha1Claim {}
201
202/// Information about the claim author.
203///
204/// This type is not used in any activity, and only used as *part* of another schema.
205///
206#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
207#[serde_with::serde_as]
208#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
209pub struct GoogleFactcheckingFactchecktoolsV1alpha1ClaimAuthor {
210 /// Corresponds to `ClaimReview.itemReviewed.author.image`.
211 #[serde(rename = "imageUrl")]
212 pub image_url: Option<String>,
213 /// Corresponds to `ClaimReview.itemReviewed.author.jobTitle`.
214 #[serde(rename = "jobTitle")]
215 pub job_title: Option<String>,
216 /// A person or organization stating the claim. For instance, "John Doe". Corresponds to `ClaimReview.itemReviewed.author.name`.
217 pub name: Option<String>,
218 /// Corresponds to `ClaimReview.itemReviewed.author.sameAs`.
219 #[serde(rename = "sameAs")]
220 pub same_as: Option<String>,
221}
222
223impl common::Part for GoogleFactcheckingFactchecktoolsV1alpha1ClaimAuthor {}
224
225/// Information about the claim rating.
226///
227/// This type is not used in any activity, and only used as *part* of another schema.
228///
229#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
230#[serde_with::serde_as]
231#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
232pub struct GoogleFactcheckingFactchecktoolsV1alpha1ClaimRating {
233 /// For numeric ratings, the best value possible in the scale from worst to best. Corresponds to `ClaimReview.reviewRating.bestRating`.
234 #[serde(rename = "bestRating")]
235 pub best_rating: Option<i32>,
236 /// Corresponds to `ClaimReview.reviewRating.image`.
237 #[serde(rename = "imageUrl")]
238 pub image_url: Option<String>,
239 /// Corresponds to `ClaimReview.reviewRating.ratingExplanation`.
240 #[serde(rename = "ratingExplanation")]
241 pub rating_explanation: Option<String>,
242 /// A numeric rating of this claim, in the range worstRating — bestRating inclusive. Corresponds to `ClaimReview.reviewRating.ratingValue`.
243 #[serde(rename = "ratingValue")]
244 pub rating_value: Option<i32>,
245 /// The truthfulness rating as a human-readible short word or phrase. Corresponds to `ClaimReview.reviewRating.alternateName`.
246 #[serde(rename = "textualRating")]
247 pub textual_rating: Option<String>,
248 /// For numeric ratings, the worst value possible in the scale from worst to best. Corresponds to `ClaimReview.reviewRating.worstRating`.
249 #[serde(rename = "worstRating")]
250 pub worst_rating: Option<i32>,
251}
252
253impl common::Part for GoogleFactcheckingFactchecktoolsV1alpha1ClaimRating {}
254
255/// Information about a claim review.
256///
257/// This type is not used in any activity, and only used as *part* of another schema.
258///
259#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
260#[serde_with::serde_as]
261#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
262pub struct GoogleFactcheckingFactchecktoolsV1alpha1ClaimReview {
263 /// The language this review was written in. For instance, "en" or "de".
264 #[serde(rename = "languageCode")]
265 pub language_code: Option<String>,
266 /// The publisher of this claim review.
267 pub publisher: Option<GoogleFactcheckingFactchecktoolsV1alpha1Publisher>,
268 /// The date the claim was reviewed.
269 #[serde(rename = "reviewDate")]
270 pub review_date: Option<chrono::DateTime<chrono::offset::Utc>>,
271 /// Textual rating. For instance, "Mostly false".
272 #[serde(rename = "textualRating")]
273 pub textual_rating: Option<String>,
274 /// The title of this claim review, if it can be determined.
275 pub title: Option<String>,
276 /// The URL of this claim review.
277 pub url: Option<String>,
278}
279
280impl common::Part for GoogleFactcheckingFactchecktoolsV1alpha1ClaimReview {}
281
282/// Information about the claim review author.
283///
284/// This type is not used in any activity, and only used as *part* of another schema.
285///
286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
287#[serde_with::serde_as]
288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
289pub struct GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewAuthor {
290 /// Corresponds to `ClaimReview.author.image`.
291 #[serde(rename = "imageUrl")]
292 pub image_url: Option<String>,
293 /// Name of the organization that is publishing the fact check. Corresponds to `ClaimReview.author.name`.
294 pub name: Option<String>,
295}
296
297impl common::Part for GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewAuthor {}
298
299/// Fields for an individual `ClaimReview` element. Except for sub-messages that group fields together, each of these fields correspond those in https://schema.org/ClaimReview. We list the precise mapping for each field.
300///
301/// This type is not used in any activity, and only used as *part* of another schema.
302///
303#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
304#[serde_with::serde_as]
305#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
306pub struct GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkup {
307 /// A list of links to works in which this claim appears, aside from the one specified in `claim_first_appearance`. Corresponds to `ClaimReview.itemReviewed[@type=Claim].appearance.url`.
308 #[serde(rename = "claimAppearances")]
309 pub claim_appearances: Option<Vec<String>>,
310 /// Info about the author of this claim.
311 #[serde(rename = "claimAuthor")]
312 pub claim_author: Option<GoogleFactcheckingFactchecktoolsV1alpha1ClaimAuthor>,
313 /// The date when the claim was made or entered public discourse. Corresponds to `ClaimReview.itemReviewed.datePublished`.
314 #[serde(rename = "claimDate")]
315 pub claim_date: Option<String>,
316 /// A link to a work in which this claim first appears. Corresponds to `ClaimReview.itemReviewed[@type=Claim].firstAppearance.url`.
317 #[serde(rename = "claimFirstAppearance")]
318 pub claim_first_appearance: Option<String>,
319 /// The location where this claim was made. Corresponds to `ClaimReview.itemReviewed.name`.
320 #[serde(rename = "claimLocation")]
321 pub claim_location: Option<String>,
322 /// A short summary of the claim being evaluated. Corresponds to `ClaimReview.claimReviewed`.
323 #[serde(rename = "claimReviewed")]
324 pub claim_reviewed: Option<String>,
325 /// Info about the rating of this claim review.
326 pub rating: Option<GoogleFactcheckingFactchecktoolsV1alpha1ClaimRating>,
327 /// This field is optional, and will default to the page URL. We provide this field to allow you the override the default value, but the only permitted override is the page URL plus an optional anchor link ("page jump"). Corresponds to `ClaimReview.url`
328 pub url: Option<String>,
329}
330
331impl common::Part for GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkup {}
332
333/// Holds one or more instances of `ClaimReview` markup for a webpage.
334///
335/// # Activities
336///
337/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
338/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
339///
340/// * [create pages](PageCreateCall) (request|response)
341/// * [get pages](PageGetCall) (response)
342/// * [update pages](PageUpdateCall) (request|response)
343#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
344#[serde_with::serde_as]
345#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
346pub struct GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage {
347 /// Info about the author of this claim review. Similar to the above, semantically these are page-level fields, and each `ClaimReview` on this page will contain the same values.
348 #[serde(rename = "claimReviewAuthor")]
349 pub claim_review_author: Option<GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewAuthor>,
350 /// A list of individual claim reviews for this page. Each item in the list corresponds to one `ClaimReview` element.
351 #[serde(rename = "claimReviewMarkups")]
352 pub claim_review_markups:
353 Option<Vec<GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkup>>,
354 /// The name of this `ClaimReview` markup page resource, in the form of `pages/{page_id}`. Except for update requests, this field is output-only and should not be set by the user.
355 pub name: Option<String>,
356 /// The URL of the page associated with this `ClaimReview` markup. While every individual `ClaimReview` has its own URL field, semantically this is a page-level field, and each `ClaimReview` on this page will use this value unless individually overridden. Corresponds to `ClaimReview.url`
357 #[serde(rename = "pageUrl")]
358 pub page_url: Option<String>,
359 /// The date when the fact check was published. Similar to the URL, semantically this is a page-level field, and each `ClaimReview` on this page will contain the same value. Corresponds to `ClaimReview.datePublished`
360 #[serde(rename = "publishDate")]
361 pub publish_date: Option<String>,
362 /// The version ID for this markup. Except for update requests, this field is output-only and should not be set by the user.
363 #[serde(rename = "versionId")]
364 pub version_id: Option<String>,
365}
366
367impl common::RequestValue for GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage {}
368impl common::ResponseResult for GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage {}
369
370/// Response from searching fact-checked claims by image.
371///
372/// # Activities
373///
374/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
375/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
376///
377/// * [image search claims](ClaimImageSearchCall) (response)
378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
379#[serde_with::serde_as]
380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
381pub struct GoogleFactcheckingFactchecktoolsV1alpha1FactCheckedClaimImageSearchResponse {
382 /// The next pagination token in the Search response. It should be used as the `page_token` for the following request. An empty value means no more results.
383 #[serde(rename = "nextPageToken")]
384 pub next_page_token: Option<String>,
385 /// The list of claims and all of their associated information.
386 pub results: Option<
387 Vec<GoogleFactcheckingFactchecktoolsV1alpha1FactCheckedClaimImageSearchResponseResult>,
388 >,
389}
390
391impl common::ResponseResult
392 for GoogleFactcheckingFactchecktoolsV1alpha1FactCheckedClaimImageSearchResponse
393{
394}
395
396/// A claim and its associated information.
397///
398/// This type is not used in any activity, and only used as *part* of another schema.
399///
400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
401#[serde_with::serde_as]
402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
403pub struct GoogleFactcheckingFactchecktoolsV1alpha1FactCheckedClaimImageSearchResponseResult {
404 /// A claim which matched the query.
405 pub claim: Option<GoogleFactcheckingFactchecktoolsV1alpha1Claim>,
406}
407
408impl common::Part
409 for GoogleFactcheckingFactchecktoolsV1alpha1FactCheckedClaimImageSearchResponseResult
410{
411}
412
413/// Response from searching fact-checked claims.
414///
415/// # Activities
416///
417/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
418/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
419///
420/// * [search claims](ClaimSearchCall) (response)
421#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
422#[serde_with::serde_as]
423#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
424pub struct GoogleFactcheckingFactchecktoolsV1alpha1FactCheckedClaimSearchResponse {
425 /// The list of claims and all of their associated information.
426 pub claims: Option<Vec<GoogleFactcheckingFactchecktoolsV1alpha1Claim>>,
427 /// The next pagination token in the Search response. It should be used as the `page_token` for the following request. An empty value means no more results.
428 #[serde(rename = "nextPageToken")]
429 pub next_page_token: Option<String>,
430}
431
432impl common::ResponseResult
433 for GoogleFactcheckingFactchecktoolsV1alpha1FactCheckedClaimSearchResponse
434{
435}
436
437/// Response from listing `ClaimReview` markup.
438///
439/// # Activities
440///
441/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
442/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
443///
444/// * [list pages](PageListCall) (response)
445#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
446#[serde_with::serde_as]
447#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
448pub struct GoogleFactcheckingFactchecktoolsV1alpha1ListClaimReviewMarkupPagesResponse {
449 /// The result list of pages of `ClaimReview` markup.
450 #[serde(rename = "claimReviewMarkupPages")]
451 pub claim_review_markup_pages:
452 Option<Vec<GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage>>,
453 /// The next pagination token in the Search response. It should be used as the `page_token` for the following request. An empty value means no more results.
454 #[serde(rename = "nextPageToken")]
455 pub next_page_token: Option<String>,
456}
457
458impl common::ResponseResult
459 for GoogleFactcheckingFactchecktoolsV1alpha1ListClaimReviewMarkupPagesResponse
460{
461}
462
463/// Information about the publisher.
464///
465/// This type is not used in any activity, and only used as *part* of another schema.
466///
467#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
468#[serde_with::serde_as]
469#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
470pub struct GoogleFactcheckingFactchecktoolsV1alpha1Publisher {
471 /// The name of this publisher. For instance, "Awesome Fact Checks".
472 pub name: Option<String>,
473 /// Host-level site name, without the protocol or "www" prefix. For instance, "awesomefactchecks.com". This value of this field is based purely on the claim review URL.
474 pub site: Option<String>,
475}
476
477impl common::Part for GoogleFactcheckingFactchecktoolsV1alpha1Publisher {}
478
479/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
480///
481/// # Activities
482///
483/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
484/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
485///
486/// * [delete pages](PageDeleteCall) (response)
487#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
488#[serde_with::serde_as]
489#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
490pub struct GoogleProtobufEmpty {
491 _never_set: Option<bool>,
492}
493
494impl common::ResponseResult for GoogleProtobufEmpty {}
495
496// ###################
497// MethodBuilders ###
498// #################
499
500/// A builder providing access to all methods supported on *claim* resources.
501/// It is not used directly, but through the [`FactCheckTools`] hub.
502///
503/// # Example
504///
505/// Instantiate a resource builder
506///
507/// ```test_harness,no_run
508/// extern crate hyper;
509/// extern crate hyper_rustls;
510/// extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
511///
512/// # async fn dox() {
513/// use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
514///
515/// let secret: yup_oauth2::ApplicationSecret = Default::default();
516/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
517/// .with_native_roots()
518/// .unwrap()
519/// .https_only()
520/// .enable_http2()
521/// .build();
522///
523/// let executor = hyper_util::rt::TokioExecutor::new();
524/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
525/// secret,
526/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
527/// yup_oauth2::client::CustomHyperClientBuilder::from(
528/// hyper_util::client::legacy::Client::builder(executor).build(connector),
529/// ),
530/// ).build().await.unwrap();
531///
532/// let client = hyper_util::client::legacy::Client::builder(
533/// hyper_util::rt::TokioExecutor::new()
534/// )
535/// .build(
536/// hyper_rustls::HttpsConnectorBuilder::new()
537/// .with_native_roots()
538/// .unwrap()
539/// .https_or_http()
540/// .enable_http2()
541/// .build()
542/// );
543/// let mut hub = FactCheckTools::new(client, auth);
544/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
545/// // like `image_search(...)` and `search(...)`
546/// // to build up your call.
547/// let rb = hub.claims();
548/// # }
549/// ```
550pub struct ClaimMethods<'a, C>
551where
552 C: 'a,
553{
554 hub: &'a FactCheckTools<C>,
555}
556
557impl<'a, C> common::MethodsBuilder for ClaimMethods<'a, C> {}
558
559impl<'a, C> ClaimMethods<'a, C> {
560 /// Create a builder to help you perform the following task:
561 ///
562 /// Search through fact-checked claims using an image as the query.
563 pub fn image_search(&self) -> ClaimImageSearchCall<'a, C> {
564 ClaimImageSearchCall {
565 hub: self.hub,
566 _page_token: Default::default(),
567 _page_size: Default::default(),
568 _offset: Default::default(),
569 _language_code: Default::default(),
570 _image_uri: Default::default(),
571 _delegate: Default::default(),
572 _additional_params: Default::default(),
573 }
574 }
575
576 /// Create a builder to help you perform the following task:
577 ///
578 /// Search through fact-checked claims.
579 pub fn search(&self) -> ClaimSearchCall<'a, C> {
580 ClaimSearchCall {
581 hub: self.hub,
582 _review_publisher_site_filter: Default::default(),
583 _query: Default::default(),
584 _page_token: Default::default(),
585 _page_size: Default::default(),
586 _offset: Default::default(),
587 _max_age_days: Default::default(),
588 _language_code: Default::default(),
589 _delegate: Default::default(),
590 _additional_params: Default::default(),
591 }
592 }
593}
594
595/// A builder providing access to all methods supported on *page* resources.
596/// It is not used directly, but through the [`FactCheckTools`] hub.
597///
598/// # Example
599///
600/// Instantiate a resource builder
601///
602/// ```test_harness,no_run
603/// extern crate hyper;
604/// extern crate hyper_rustls;
605/// extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
606///
607/// # async fn dox() {
608/// use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
609///
610/// let secret: yup_oauth2::ApplicationSecret = Default::default();
611/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
612/// .with_native_roots()
613/// .unwrap()
614/// .https_only()
615/// .enable_http2()
616/// .build();
617///
618/// let executor = hyper_util::rt::TokioExecutor::new();
619/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
620/// secret,
621/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
622/// yup_oauth2::client::CustomHyperClientBuilder::from(
623/// hyper_util::client::legacy::Client::builder(executor).build(connector),
624/// ),
625/// ).build().await.unwrap();
626///
627/// let client = hyper_util::client::legacy::Client::builder(
628/// hyper_util::rt::TokioExecutor::new()
629/// )
630/// .build(
631/// hyper_rustls::HttpsConnectorBuilder::new()
632/// .with_native_roots()
633/// .unwrap()
634/// .https_or_http()
635/// .enable_http2()
636/// .build()
637/// );
638/// let mut hub = FactCheckTools::new(client, auth);
639/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
640/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `update(...)`
641/// // to build up your call.
642/// let rb = hub.pages();
643/// # }
644/// ```
645pub struct PageMethods<'a, C>
646where
647 C: 'a,
648{
649 hub: &'a FactCheckTools<C>,
650}
651
652impl<'a, C> common::MethodsBuilder for PageMethods<'a, C> {}
653
654impl<'a, C> PageMethods<'a, C> {
655 /// Create a builder to help you perform the following task:
656 ///
657 /// Create `ClaimReview` markup on a page.
658 ///
659 /// # Arguments
660 ///
661 /// * `request` - No description provided.
662 pub fn create(
663 &self,
664 request: GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage,
665 ) -> PageCreateCall<'a, C> {
666 PageCreateCall {
667 hub: self.hub,
668 _request: request,
669 _delegate: Default::default(),
670 _additional_params: Default::default(),
671 _scopes: Default::default(),
672 }
673 }
674
675 /// Create a builder to help you perform the following task:
676 ///
677 /// Delete all `ClaimReview` markup on a page.
678 ///
679 /// # Arguments
680 ///
681 /// * `name` - The name of the resource to delete, in the form of `pages/{page_id}`.
682 pub fn delete(&self, name: &str) -> PageDeleteCall<'a, C> {
683 PageDeleteCall {
684 hub: self.hub,
685 _name: name.to_string(),
686 _delegate: Default::default(),
687 _additional_params: Default::default(),
688 _scopes: Default::default(),
689 }
690 }
691
692 /// Create a builder to help you perform the following task:
693 ///
694 /// Get all `ClaimReview` markup on a page.
695 ///
696 /// # Arguments
697 ///
698 /// * `name` - The name of the resource to get, in the form of `pages/{page_id}`.
699 pub fn get(&self, name: &str) -> PageGetCall<'a, C> {
700 PageGetCall {
701 hub: self.hub,
702 _name: name.to_string(),
703 _delegate: Default::default(),
704 _additional_params: Default::default(),
705 _scopes: Default::default(),
706 }
707 }
708
709 /// Create a builder to help you perform the following task:
710 ///
711 /// List the `ClaimReview` markup pages for a specific URL or for an organization.
712 pub fn list(&self) -> PageListCall<'a, C> {
713 PageListCall {
714 hub: self.hub,
715 _url: Default::default(),
716 _page_token: Default::default(),
717 _page_size: Default::default(),
718 _organization: Default::default(),
719 _offset: Default::default(),
720 _delegate: Default::default(),
721 _additional_params: Default::default(),
722 _scopes: Default::default(),
723 }
724 }
725
726 /// Create a builder to help you perform the following task:
727 ///
728 /// Update for all `ClaimReview` markup on a page Note that this is a full update. To retain the existing `ClaimReview` markup on a page, first perform a Get operation, then modify the returned markup, and finally call Update with the entire `ClaimReview` markup as the body.
729 ///
730 /// # Arguments
731 ///
732 /// * `request` - No description provided.
733 /// * `name` - The name of this `ClaimReview` markup page resource, in the form of `pages/{page_id}`. Except for update requests, this field is output-only and should not be set by the user.
734 pub fn update(
735 &self,
736 request: GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage,
737 name: &str,
738 ) -> PageUpdateCall<'a, C> {
739 PageUpdateCall {
740 hub: self.hub,
741 _request: request,
742 _name: name.to_string(),
743 _delegate: Default::default(),
744 _additional_params: Default::default(),
745 _scopes: Default::default(),
746 }
747 }
748}
749
750// ###################
751// CallBuilders ###
752// #################
753
754/// Search through fact-checked claims using an image as the query.
755///
756/// A builder for the *imageSearch* method supported by a *claim* resource.
757/// It is not used directly, but through a [`ClaimMethods`] instance.
758///
759/// # Example
760///
761/// Instantiate a resource method builder
762///
763/// ```test_harness,no_run
764/// # extern crate hyper;
765/// # extern crate hyper_rustls;
766/// # extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
767/// # async fn dox() {
768/// # use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
769///
770/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
771/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
772/// # .with_native_roots()
773/// # .unwrap()
774/// # .https_only()
775/// # .enable_http2()
776/// # .build();
777///
778/// # let executor = hyper_util::rt::TokioExecutor::new();
779/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
780/// # secret,
781/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
782/// # yup_oauth2::client::CustomHyperClientBuilder::from(
783/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
784/// # ),
785/// # ).build().await.unwrap();
786///
787/// # let client = hyper_util::client::legacy::Client::builder(
788/// # hyper_util::rt::TokioExecutor::new()
789/// # )
790/// # .build(
791/// # hyper_rustls::HttpsConnectorBuilder::new()
792/// # .with_native_roots()
793/// # .unwrap()
794/// # .https_or_http()
795/// # .enable_http2()
796/// # .build()
797/// # );
798/// # let mut hub = FactCheckTools::new(client, auth);
799/// // You can configure optional parameters by calling the respective setters at will, and
800/// // execute the final call using `doit()`.
801/// // Values shown here are possibly random and not representative !
802/// let result = hub.claims().image_search()
803/// .page_token("ipsum")
804/// .page_size(-28)
805/// .offset(-27)
806/// .language_code("sanctus")
807/// .image_uri("sed")
808/// .doit().await;
809/// # }
810/// ```
811pub struct ClaimImageSearchCall<'a, C>
812where
813 C: 'a,
814{
815 hub: &'a FactCheckTools<C>,
816 _page_token: Option<String>,
817 _page_size: Option<i32>,
818 _offset: Option<i32>,
819 _language_code: Option<String>,
820 _image_uri: Option<String>,
821 _delegate: Option<&'a mut dyn common::Delegate>,
822 _additional_params: HashMap<String, String>,
823}
824
825impl<'a, C> common::CallBuilder for ClaimImageSearchCall<'a, C> {}
826
827impl<'a, C> ClaimImageSearchCall<'a, C>
828where
829 C: common::Connector,
830{
831 /// Perform the operation you have build so far.
832 pub async fn doit(
833 mut self,
834 ) -> common::Result<(
835 common::Response,
836 GoogleFactcheckingFactchecktoolsV1alpha1FactCheckedClaimImageSearchResponse,
837 )> {
838 use std::borrow::Cow;
839 use std::io::{Read, Seek};
840
841 use common::{url::Params, ToParts};
842 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
843
844 let mut dd = common::DefaultDelegate;
845 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
846 dlg.begin(common::MethodInfo {
847 id: "factchecktools.claims.imageSearch",
848 http_method: hyper::Method::GET,
849 });
850
851 for &field in [
852 "alt",
853 "pageToken",
854 "pageSize",
855 "offset",
856 "languageCode",
857 "imageUri",
858 ]
859 .iter()
860 {
861 if self._additional_params.contains_key(field) {
862 dlg.finished(false);
863 return Err(common::Error::FieldClash(field));
864 }
865 }
866
867 let mut params = Params::with_capacity(7 + self._additional_params.len());
868 if let Some(value) = self._page_token.as_ref() {
869 params.push("pageToken", value);
870 }
871 if let Some(value) = self._page_size.as_ref() {
872 params.push("pageSize", value.to_string());
873 }
874 if let Some(value) = self._offset.as_ref() {
875 params.push("offset", value.to_string());
876 }
877 if let Some(value) = self._language_code.as_ref() {
878 params.push("languageCode", value);
879 }
880 if let Some(value) = self._image_uri.as_ref() {
881 params.push("imageUri", value);
882 }
883
884 params.extend(self._additional_params.iter());
885
886 params.push("alt", "json");
887 let mut url = self.hub._base_url.clone() + "v1alpha1/claims:imageSearch";
888
889 match dlg.api_key() {
890 Some(value) => params.push("key", value),
891 None => {
892 dlg.finished(false);
893 return Err(common::Error::MissingAPIKey);
894 }
895 }
896
897 let url = params.parse_with_url(&url);
898
899 loop {
900 let mut req_result = {
901 let client = &self.hub.client;
902 dlg.pre_request();
903 let mut req_builder = hyper::Request::builder()
904 .method(hyper::Method::GET)
905 .uri(url.as_str())
906 .header(USER_AGENT, self.hub._user_agent.clone());
907
908 let request = req_builder
909 .header(CONTENT_LENGTH, 0_u64)
910 .body(common::to_body::<String>(None));
911
912 client.request(request.unwrap()).await
913 };
914
915 match req_result {
916 Err(err) => {
917 if let common::Retry::After(d) = dlg.http_error(&err) {
918 sleep(d).await;
919 continue;
920 }
921 dlg.finished(false);
922 return Err(common::Error::HttpError(err));
923 }
924 Ok(res) => {
925 let (mut parts, body) = res.into_parts();
926 let mut body = common::Body::new(body);
927 if !parts.status.is_success() {
928 let bytes = common::to_bytes(body).await.unwrap_or_default();
929 let error = serde_json::from_str(&common::to_string(&bytes));
930 let response = common::to_response(parts, bytes.into());
931
932 if let common::Retry::After(d) =
933 dlg.http_failure(&response, error.as_ref().ok())
934 {
935 sleep(d).await;
936 continue;
937 }
938
939 dlg.finished(false);
940
941 return Err(match error {
942 Ok(value) => common::Error::BadRequest(value),
943 _ => common::Error::Failure(response),
944 });
945 }
946 let response = {
947 let bytes = common::to_bytes(body).await.unwrap_or_default();
948 let encoded = common::to_string(&bytes);
949 match serde_json::from_str(&encoded) {
950 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
951 Err(error) => {
952 dlg.response_json_decode_error(&encoded, &error);
953 return Err(common::Error::JsonDecodeError(
954 encoded.to_string(),
955 error,
956 ));
957 }
958 }
959 };
960
961 dlg.finished(true);
962 return Ok(response);
963 }
964 }
965 }
966 }
967
968 /// Optional. The pagination token. You may provide the `next_page_token` returned from a previous List request, if any, in order to get the next page. All other fields must have the same values as in the previous request.
969 ///
970 /// Sets the *page token* query property to the given value.
971 pub fn page_token(mut self, new_value: &str) -> ClaimImageSearchCall<'a, C> {
972 self._page_token = Some(new_value.to_string());
973 self
974 }
975 /// Optional. The pagination size. We will return up to that many results. Defaults to 10 if not set.
976 ///
977 /// Sets the *page size* query property to the given value.
978 pub fn page_size(mut self, new_value: i32) -> ClaimImageSearchCall<'a, C> {
979 self._page_size = Some(new_value);
980 self
981 }
982 /// Optional. An integer that specifies the current offset (that is, starting result location) in search results. This field is only considered if `page_token` is unset. For example, 0 means to return results starting from the first matching result, and 10 means to return from the 11th result.
983 ///
984 /// Sets the *offset* query property to the given value.
985 pub fn offset(mut self, new_value: i32) -> ClaimImageSearchCall<'a, C> {
986 self._offset = Some(new_value);
987 self
988 }
989 /// Optional. The BCP-47 language code, such as "en-US" or "sr-Latn". Can be used to restrict results by language, though we do not currently consider the region.
990 ///
991 /// Sets the *language code* query property to the given value.
992 pub fn language_code(mut self, new_value: &str) -> ClaimImageSearchCall<'a, C> {
993 self._language_code = Some(new_value.to_string());
994 self
995 }
996 /// Required. The URI of the source image. This must be a publicly-accessible image HTTP/HTTPS URL. When fetching images from HTTP/HTTPS URLs, Google cannot guarantee that the request will be completed. Your request may fail if the specified host denies the request (e.g. due to request throttling or DOS prevention), or if Google throttles requests to the site for abuse prevention. You should not depend on externally-hosted images for production applications.
997 ///
998 /// Sets the *image uri* query property to the given value.
999 pub fn image_uri(mut self, new_value: &str) -> ClaimImageSearchCall<'a, C> {
1000 self._image_uri = Some(new_value.to_string());
1001 self
1002 }
1003 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1004 /// while executing the actual API request.
1005 ///
1006 /// ````text
1007 /// It should be used to handle progress information, and to implement a certain level of resilience.
1008 /// ````
1009 ///
1010 /// Sets the *delegate* property to the given value.
1011 pub fn delegate(
1012 mut self,
1013 new_value: &'a mut dyn common::Delegate,
1014 ) -> ClaimImageSearchCall<'a, C> {
1015 self._delegate = Some(new_value);
1016 self
1017 }
1018
1019 /// Set any additional parameter of the query string used in the request.
1020 /// It should be used to set parameters which are not yet available through their own
1021 /// setters.
1022 ///
1023 /// Please note that this method must not be used to set any of the known parameters
1024 /// which have their own setter method. If done anyway, the request will fail.
1025 ///
1026 /// # Additional Parameters
1027 ///
1028 /// * *$.xgafv* (query-string) - V1 error format.
1029 /// * *access_token* (query-string) - OAuth access token.
1030 /// * *alt* (query-string) - Data format for response.
1031 /// * *callback* (query-string) - JSONP
1032 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1033 /// * *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.
1034 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1035 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1036 /// * *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.
1037 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1038 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1039 pub fn param<T>(mut self, name: T, value: T) -> ClaimImageSearchCall<'a, C>
1040 where
1041 T: AsRef<str>,
1042 {
1043 self._additional_params
1044 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1045 self
1046 }
1047}
1048
1049/// Search through fact-checked claims.
1050///
1051/// A builder for the *search* method supported by a *claim* resource.
1052/// It is not used directly, but through a [`ClaimMethods`] instance.
1053///
1054/// # Example
1055///
1056/// Instantiate a resource method builder
1057///
1058/// ```test_harness,no_run
1059/// # extern crate hyper;
1060/// # extern crate hyper_rustls;
1061/// # extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
1062/// # async fn dox() {
1063/// # use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1064///
1065/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1066/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1067/// # .with_native_roots()
1068/// # .unwrap()
1069/// # .https_only()
1070/// # .enable_http2()
1071/// # .build();
1072///
1073/// # let executor = hyper_util::rt::TokioExecutor::new();
1074/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1075/// # secret,
1076/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1077/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1078/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1079/// # ),
1080/// # ).build().await.unwrap();
1081///
1082/// # let client = hyper_util::client::legacy::Client::builder(
1083/// # hyper_util::rt::TokioExecutor::new()
1084/// # )
1085/// # .build(
1086/// # hyper_rustls::HttpsConnectorBuilder::new()
1087/// # .with_native_roots()
1088/// # .unwrap()
1089/// # .https_or_http()
1090/// # .enable_http2()
1091/// # .build()
1092/// # );
1093/// # let mut hub = FactCheckTools::new(client, auth);
1094/// // You can configure optional parameters by calling the respective setters at will, and
1095/// // execute the final call using `doit()`.
1096/// // Values shown here are possibly random and not representative !
1097/// let result = hub.claims().search()
1098/// .review_publisher_site_filter("amet.")
1099/// .query("takimata")
1100/// .page_token("amet.")
1101/// .page_size(-20)
1102/// .offset(-55)
1103/// .max_age_days(-62)
1104/// .language_code("Lorem")
1105/// .doit().await;
1106/// # }
1107/// ```
1108pub struct ClaimSearchCall<'a, C>
1109where
1110 C: 'a,
1111{
1112 hub: &'a FactCheckTools<C>,
1113 _review_publisher_site_filter: Option<String>,
1114 _query: Option<String>,
1115 _page_token: Option<String>,
1116 _page_size: Option<i32>,
1117 _offset: Option<i32>,
1118 _max_age_days: Option<i32>,
1119 _language_code: Option<String>,
1120 _delegate: Option<&'a mut dyn common::Delegate>,
1121 _additional_params: HashMap<String, String>,
1122}
1123
1124impl<'a, C> common::CallBuilder for ClaimSearchCall<'a, C> {}
1125
1126impl<'a, C> ClaimSearchCall<'a, C>
1127where
1128 C: common::Connector,
1129{
1130 /// Perform the operation you have build so far.
1131 pub async fn doit(
1132 mut self,
1133 ) -> common::Result<(
1134 common::Response,
1135 GoogleFactcheckingFactchecktoolsV1alpha1FactCheckedClaimSearchResponse,
1136 )> {
1137 use std::borrow::Cow;
1138 use std::io::{Read, Seek};
1139
1140 use common::{url::Params, ToParts};
1141 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1142
1143 let mut dd = common::DefaultDelegate;
1144 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1145 dlg.begin(common::MethodInfo {
1146 id: "factchecktools.claims.search",
1147 http_method: hyper::Method::GET,
1148 });
1149
1150 for &field in [
1151 "alt",
1152 "reviewPublisherSiteFilter",
1153 "query",
1154 "pageToken",
1155 "pageSize",
1156 "offset",
1157 "maxAgeDays",
1158 "languageCode",
1159 ]
1160 .iter()
1161 {
1162 if self._additional_params.contains_key(field) {
1163 dlg.finished(false);
1164 return Err(common::Error::FieldClash(field));
1165 }
1166 }
1167
1168 let mut params = Params::with_capacity(9 + self._additional_params.len());
1169 if let Some(value) = self._review_publisher_site_filter.as_ref() {
1170 params.push("reviewPublisherSiteFilter", value);
1171 }
1172 if let Some(value) = self._query.as_ref() {
1173 params.push("query", value);
1174 }
1175 if let Some(value) = self._page_token.as_ref() {
1176 params.push("pageToken", value);
1177 }
1178 if let Some(value) = self._page_size.as_ref() {
1179 params.push("pageSize", value.to_string());
1180 }
1181 if let Some(value) = self._offset.as_ref() {
1182 params.push("offset", value.to_string());
1183 }
1184 if let Some(value) = self._max_age_days.as_ref() {
1185 params.push("maxAgeDays", value.to_string());
1186 }
1187 if let Some(value) = self._language_code.as_ref() {
1188 params.push("languageCode", value);
1189 }
1190
1191 params.extend(self._additional_params.iter());
1192
1193 params.push("alt", "json");
1194 let mut url = self.hub._base_url.clone() + "v1alpha1/claims:search";
1195
1196 match dlg.api_key() {
1197 Some(value) => params.push("key", value),
1198 None => {
1199 dlg.finished(false);
1200 return Err(common::Error::MissingAPIKey);
1201 }
1202 }
1203
1204 let url = params.parse_with_url(&url);
1205
1206 loop {
1207 let mut req_result = {
1208 let client = &self.hub.client;
1209 dlg.pre_request();
1210 let mut req_builder = hyper::Request::builder()
1211 .method(hyper::Method::GET)
1212 .uri(url.as_str())
1213 .header(USER_AGENT, self.hub._user_agent.clone());
1214
1215 let request = req_builder
1216 .header(CONTENT_LENGTH, 0_u64)
1217 .body(common::to_body::<String>(None));
1218
1219 client.request(request.unwrap()).await
1220 };
1221
1222 match req_result {
1223 Err(err) => {
1224 if let common::Retry::After(d) = dlg.http_error(&err) {
1225 sleep(d).await;
1226 continue;
1227 }
1228 dlg.finished(false);
1229 return Err(common::Error::HttpError(err));
1230 }
1231 Ok(res) => {
1232 let (mut parts, body) = res.into_parts();
1233 let mut body = common::Body::new(body);
1234 if !parts.status.is_success() {
1235 let bytes = common::to_bytes(body).await.unwrap_or_default();
1236 let error = serde_json::from_str(&common::to_string(&bytes));
1237 let response = common::to_response(parts, bytes.into());
1238
1239 if let common::Retry::After(d) =
1240 dlg.http_failure(&response, error.as_ref().ok())
1241 {
1242 sleep(d).await;
1243 continue;
1244 }
1245
1246 dlg.finished(false);
1247
1248 return Err(match error {
1249 Ok(value) => common::Error::BadRequest(value),
1250 _ => common::Error::Failure(response),
1251 });
1252 }
1253 let response = {
1254 let bytes = common::to_bytes(body).await.unwrap_or_default();
1255 let encoded = common::to_string(&bytes);
1256 match serde_json::from_str(&encoded) {
1257 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1258 Err(error) => {
1259 dlg.response_json_decode_error(&encoded, &error);
1260 return Err(common::Error::JsonDecodeError(
1261 encoded.to_string(),
1262 error,
1263 ));
1264 }
1265 }
1266 };
1267
1268 dlg.finished(true);
1269 return Ok(response);
1270 }
1271 }
1272 }
1273 }
1274
1275 /// The review publisher site to filter results by, e.g. nytimes.com.
1276 ///
1277 /// Sets the *review publisher site filter* query property to the given value.
1278 pub fn review_publisher_site_filter(mut self, new_value: &str) -> ClaimSearchCall<'a, C> {
1279 self._review_publisher_site_filter = Some(new_value.to_string());
1280 self
1281 }
1282 /// Textual query string. Required unless `review_publisher_site_filter` is specified.
1283 ///
1284 /// Sets the *query* query property to the given value.
1285 pub fn query(mut self, new_value: &str) -> ClaimSearchCall<'a, C> {
1286 self._query = Some(new_value.to_string());
1287 self
1288 }
1289 /// The pagination token. You may provide the `next_page_token` returned from a previous List request, if any, in order to get the next page. All other fields must have the same values as in the previous request.
1290 ///
1291 /// Sets the *page token* query property to the given value.
1292 pub fn page_token(mut self, new_value: &str) -> ClaimSearchCall<'a, C> {
1293 self._page_token = Some(new_value.to_string());
1294 self
1295 }
1296 /// The pagination size. We will return up to that many results. Defaults to 10 if not set.
1297 ///
1298 /// Sets the *page size* query property to the given value.
1299 pub fn page_size(mut self, new_value: i32) -> ClaimSearchCall<'a, C> {
1300 self._page_size = Some(new_value);
1301 self
1302 }
1303 /// An integer that specifies the current offset (that is, starting result location) in search results. This field is only considered if `page_token` is unset. For example, 0 means to return results starting from the first matching result, and 10 means to return from the 11th result.
1304 ///
1305 /// Sets the *offset* query property to the given value.
1306 pub fn offset(mut self, new_value: i32) -> ClaimSearchCall<'a, C> {
1307 self._offset = Some(new_value);
1308 self
1309 }
1310 /// The maximum age of the returned search results, in days. Age is determined by either claim date or review date, whichever is newer.
1311 ///
1312 /// Sets the *max age days* query property to the given value.
1313 pub fn max_age_days(mut self, new_value: i32) -> ClaimSearchCall<'a, C> {
1314 self._max_age_days = Some(new_value);
1315 self
1316 }
1317 /// The BCP-47 language code, such as "en-US" or "sr-Latn". Can be used to restrict results by language, though we do not currently consider the region.
1318 ///
1319 /// Sets the *language code* query property to the given value.
1320 pub fn language_code(mut self, new_value: &str) -> ClaimSearchCall<'a, C> {
1321 self._language_code = Some(new_value.to_string());
1322 self
1323 }
1324 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1325 /// while executing the actual API request.
1326 ///
1327 /// ````text
1328 /// It should be used to handle progress information, and to implement a certain level of resilience.
1329 /// ````
1330 ///
1331 /// Sets the *delegate* property to the given value.
1332 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ClaimSearchCall<'a, C> {
1333 self._delegate = Some(new_value);
1334 self
1335 }
1336
1337 /// Set any additional parameter of the query string used in the request.
1338 /// It should be used to set parameters which are not yet available through their own
1339 /// setters.
1340 ///
1341 /// Please note that this method must not be used to set any of the known parameters
1342 /// which have their own setter method. If done anyway, the request will fail.
1343 ///
1344 /// # Additional Parameters
1345 ///
1346 /// * *$.xgafv* (query-string) - V1 error format.
1347 /// * *access_token* (query-string) - OAuth access token.
1348 /// * *alt* (query-string) - Data format for response.
1349 /// * *callback* (query-string) - JSONP
1350 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1351 /// * *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.
1352 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1353 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1354 /// * *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.
1355 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1356 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1357 pub fn param<T>(mut self, name: T, value: T) -> ClaimSearchCall<'a, C>
1358 where
1359 T: AsRef<str>,
1360 {
1361 self._additional_params
1362 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1363 self
1364 }
1365}
1366
1367/// Create `ClaimReview` markup on a page.
1368///
1369/// A builder for the *create* method supported by a *page* resource.
1370/// It is not used directly, but through a [`PageMethods`] instance.
1371///
1372/// # Example
1373///
1374/// Instantiate a resource method builder
1375///
1376/// ```test_harness,no_run
1377/// # extern crate hyper;
1378/// # extern crate hyper_rustls;
1379/// # extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
1380/// use factchecktools1_alpha1::api::GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage;
1381/// # async fn dox() {
1382/// # use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1383///
1384/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1385/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1386/// # .with_native_roots()
1387/// # .unwrap()
1388/// # .https_only()
1389/// # .enable_http2()
1390/// # .build();
1391///
1392/// # let executor = hyper_util::rt::TokioExecutor::new();
1393/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1394/// # secret,
1395/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1396/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1397/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1398/// # ),
1399/// # ).build().await.unwrap();
1400///
1401/// # let client = hyper_util::client::legacy::Client::builder(
1402/// # hyper_util::rt::TokioExecutor::new()
1403/// # )
1404/// # .build(
1405/// # hyper_rustls::HttpsConnectorBuilder::new()
1406/// # .with_native_roots()
1407/// # .unwrap()
1408/// # .https_or_http()
1409/// # .enable_http2()
1410/// # .build()
1411/// # );
1412/// # let mut hub = FactCheckTools::new(client, auth);
1413/// // As the method needs a request, you would usually fill it with the desired information
1414/// // into the respective structure. Some of the parts shown here might not be applicable !
1415/// // Values shown here are possibly random and not representative !
1416/// let mut req = GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage::default();
1417///
1418/// // You can configure optional parameters by calling the respective setters at will, and
1419/// // execute the final call using `doit()`.
1420/// // Values shown here are possibly random and not representative !
1421/// let result = hub.pages().create(req)
1422/// .doit().await;
1423/// # }
1424/// ```
1425pub struct PageCreateCall<'a, C>
1426where
1427 C: 'a,
1428{
1429 hub: &'a FactCheckTools<C>,
1430 _request: GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage,
1431 _delegate: Option<&'a mut dyn common::Delegate>,
1432 _additional_params: HashMap<String, String>,
1433 _scopes: BTreeSet<String>,
1434}
1435
1436impl<'a, C> common::CallBuilder for PageCreateCall<'a, C> {}
1437
1438impl<'a, C> PageCreateCall<'a, C>
1439where
1440 C: common::Connector,
1441{
1442 /// Perform the operation you have build so far.
1443 pub async fn doit(
1444 mut self,
1445 ) -> common::Result<(
1446 common::Response,
1447 GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage,
1448 )> {
1449 use std::borrow::Cow;
1450 use std::io::{Read, Seek};
1451
1452 use common::{url::Params, ToParts};
1453 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1454
1455 let mut dd = common::DefaultDelegate;
1456 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1457 dlg.begin(common::MethodInfo {
1458 id: "factchecktools.pages.create",
1459 http_method: hyper::Method::POST,
1460 });
1461
1462 for &field in ["alt"].iter() {
1463 if self._additional_params.contains_key(field) {
1464 dlg.finished(false);
1465 return Err(common::Error::FieldClash(field));
1466 }
1467 }
1468
1469 let mut params = Params::with_capacity(3 + self._additional_params.len());
1470
1471 params.extend(self._additional_params.iter());
1472
1473 params.push("alt", "json");
1474 let mut url = self.hub._base_url.clone() + "v1alpha1/pages";
1475 if self._scopes.is_empty() {
1476 self._scopes.insert(Scope::Full.as_ref().to_string());
1477 }
1478
1479 let url = params.parse_with_url(&url);
1480
1481 let mut json_mime_type = mime::APPLICATION_JSON;
1482 let mut request_value_reader = {
1483 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1484 common::remove_json_null_values(&mut value);
1485 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1486 serde_json::to_writer(&mut dst, &value).unwrap();
1487 dst
1488 };
1489 let request_size = request_value_reader
1490 .seek(std::io::SeekFrom::End(0))
1491 .unwrap();
1492 request_value_reader
1493 .seek(std::io::SeekFrom::Start(0))
1494 .unwrap();
1495
1496 loop {
1497 let token = match self
1498 .hub
1499 .auth
1500 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1501 .await
1502 {
1503 Ok(token) => token,
1504 Err(e) => match dlg.token(e) {
1505 Ok(token) => token,
1506 Err(e) => {
1507 dlg.finished(false);
1508 return Err(common::Error::MissingToken(e));
1509 }
1510 },
1511 };
1512 request_value_reader
1513 .seek(std::io::SeekFrom::Start(0))
1514 .unwrap();
1515 let mut req_result = {
1516 let client = &self.hub.client;
1517 dlg.pre_request();
1518 let mut req_builder = hyper::Request::builder()
1519 .method(hyper::Method::POST)
1520 .uri(url.as_str())
1521 .header(USER_AGENT, self.hub._user_agent.clone());
1522
1523 if let Some(token) = token.as_ref() {
1524 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1525 }
1526
1527 let request = req_builder
1528 .header(CONTENT_TYPE, json_mime_type.to_string())
1529 .header(CONTENT_LENGTH, request_size as u64)
1530 .body(common::to_body(
1531 request_value_reader.get_ref().clone().into(),
1532 ));
1533
1534 client.request(request.unwrap()).await
1535 };
1536
1537 match req_result {
1538 Err(err) => {
1539 if let common::Retry::After(d) = dlg.http_error(&err) {
1540 sleep(d).await;
1541 continue;
1542 }
1543 dlg.finished(false);
1544 return Err(common::Error::HttpError(err));
1545 }
1546 Ok(res) => {
1547 let (mut parts, body) = res.into_parts();
1548 let mut body = common::Body::new(body);
1549 if !parts.status.is_success() {
1550 let bytes = common::to_bytes(body).await.unwrap_or_default();
1551 let error = serde_json::from_str(&common::to_string(&bytes));
1552 let response = common::to_response(parts, bytes.into());
1553
1554 if let common::Retry::After(d) =
1555 dlg.http_failure(&response, error.as_ref().ok())
1556 {
1557 sleep(d).await;
1558 continue;
1559 }
1560
1561 dlg.finished(false);
1562
1563 return Err(match error {
1564 Ok(value) => common::Error::BadRequest(value),
1565 _ => common::Error::Failure(response),
1566 });
1567 }
1568 let response = {
1569 let bytes = common::to_bytes(body).await.unwrap_or_default();
1570 let encoded = common::to_string(&bytes);
1571 match serde_json::from_str(&encoded) {
1572 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1573 Err(error) => {
1574 dlg.response_json_decode_error(&encoded, &error);
1575 return Err(common::Error::JsonDecodeError(
1576 encoded.to_string(),
1577 error,
1578 ));
1579 }
1580 }
1581 };
1582
1583 dlg.finished(true);
1584 return Ok(response);
1585 }
1586 }
1587 }
1588 }
1589
1590 ///
1591 /// Sets the *request* property to the given value.
1592 ///
1593 /// Even though the property as already been set when instantiating this call,
1594 /// we provide this method for API completeness.
1595 pub fn request(
1596 mut self,
1597 new_value: GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage,
1598 ) -> PageCreateCall<'a, C> {
1599 self._request = new_value;
1600 self
1601 }
1602 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1603 /// while executing the actual API request.
1604 ///
1605 /// ````text
1606 /// It should be used to handle progress information, and to implement a certain level of resilience.
1607 /// ````
1608 ///
1609 /// Sets the *delegate* property to the given value.
1610 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageCreateCall<'a, C> {
1611 self._delegate = Some(new_value);
1612 self
1613 }
1614
1615 /// Set any additional parameter of the query string used in the request.
1616 /// It should be used to set parameters which are not yet available through their own
1617 /// setters.
1618 ///
1619 /// Please note that this method must not be used to set any of the known parameters
1620 /// which have their own setter method. If done anyway, the request will fail.
1621 ///
1622 /// # Additional Parameters
1623 ///
1624 /// * *$.xgafv* (query-string) - V1 error format.
1625 /// * *access_token* (query-string) - OAuth access token.
1626 /// * *alt* (query-string) - Data format for response.
1627 /// * *callback* (query-string) - JSONP
1628 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1629 /// * *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.
1630 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1631 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1632 /// * *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.
1633 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1634 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1635 pub fn param<T>(mut self, name: T, value: T) -> PageCreateCall<'a, C>
1636 where
1637 T: AsRef<str>,
1638 {
1639 self._additional_params
1640 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1641 self
1642 }
1643
1644 /// Identifies the authorization scope for the method you are building.
1645 ///
1646 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1647 /// [`Scope::Full`].
1648 ///
1649 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1650 /// tokens for more than one scope.
1651 ///
1652 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1653 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1654 /// sufficient, a read-write scope will do as well.
1655 pub fn add_scope<St>(mut self, scope: St) -> PageCreateCall<'a, C>
1656 where
1657 St: AsRef<str>,
1658 {
1659 self._scopes.insert(String::from(scope.as_ref()));
1660 self
1661 }
1662 /// Identifies the authorization scope(s) for the method you are building.
1663 ///
1664 /// See [`Self::add_scope()`] for details.
1665 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageCreateCall<'a, C>
1666 where
1667 I: IntoIterator<Item = St>,
1668 St: AsRef<str>,
1669 {
1670 self._scopes
1671 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1672 self
1673 }
1674
1675 /// Removes all scopes, and no default scope will be used either.
1676 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1677 /// for details).
1678 pub fn clear_scopes(mut self) -> PageCreateCall<'a, C> {
1679 self._scopes.clear();
1680 self
1681 }
1682}
1683
1684/// Delete all `ClaimReview` markup on a page.
1685///
1686/// A builder for the *delete* method supported by a *page* resource.
1687/// It is not used directly, but through a [`PageMethods`] instance.
1688///
1689/// # Example
1690///
1691/// Instantiate a resource method builder
1692///
1693/// ```test_harness,no_run
1694/// # extern crate hyper;
1695/// # extern crate hyper_rustls;
1696/// # extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
1697/// # async fn dox() {
1698/// # use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1699///
1700/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1701/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1702/// # .with_native_roots()
1703/// # .unwrap()
1704/// # .https_only()
1705/// # .enable_http2()
1706/// # .build();
1707///
1708/// # let executor = hyper_util::rt::TokioExecutor::new();
1709/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1710/// # secret,
1711/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1712/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1713/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1714/// # ),
1715/// # ).build().await.unwrap();
1716///
1717/// # let client = hyper_util::client::legacy::Client::builder(
1718/// # hyper_util::rt::TokioExecutor::new()
1719/// # )
1720/// # .build(
1721/// # hyper_rustls::HttpsConnectorBuilder::new()
1722/// # .with_native_roots()
1723/// # .unwrap()
1724/// # .https_or_http()
1725/// # .enable_http2()
1726/// # .build()
1727/// # );
1728/// # let mut hub = FactCheckTools::new(client, auth);
1729/// // You can configure optional parameters by calling the respective setters at will, and
1730/// // execute the final call using `doit()`.
1731/// // Values shown here are possibly random and not representative !
1732/// let result = hub.pages().delete("name")
1733/// .doit().await;
1734/// # }
1735/// ```
1736pub struct PageDeleteCall<'a, C>
1737where
1738 C: 'a,
1739{
1740 hub: &'a FactCheckTools<C>,
1741 _name: String,
1742 _delegate: Option<&'a mut dyn common::Delegate>,
1743 _additional_params: HashMap<String, String>,
1744 _scopes: BTreeSet<String>,
1745}
1746
1747impl<'a, C> common::CallBuilder for PageDeleteCall<'a, C> {}
1748
1749impl<'a, C> PageDeleteCall<'a, C>
1750where
1751 C: common::Connector,
1752{
1753 /// Perform the operation you have build so far.
1754 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
1755 use std::borrow::Cow;
1756 use std::io::{Read, Seek};
1757
1758 use common::{url::Params, ToParts};
1759 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1760
1761 let mut dd = common::DefaultDelegate;
1762 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1763 dlg.begin(common::MethodInfo {
1764 id: "factchecktools.pages.delete",
1765 http_method: hyper::Method::DELETE,
1766 });
1767
1768 for &field in ["alt", "name"].iter() {
1769 if self._additional_params.contains_key(field) {
1770 dlg.finished(false);
1771 return Err(common::Error::FieldClash(field));
1772 }
1773 }
1774
1775 let mut params = Params::with_capacity(3 + self._additional_params.len());
1776 params.push("name", self._name);
1777
1778 params.extend(self._additional_params.iter());
1779
1780 params.push("alt", "json");
1781 let mut url = self.hub._base_url.clone() + "v1alpha1/{+name}";
1782 if self._scopes.is_empty() {
1783 self._scopes.insert(Scope::Full.as_ref().to_string());
1784 }
1785
1786 #[allow(clippy::single_element_loop)]
1787 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1788 url = params.uri_replacement(url, param_name, find_this, true);
1789 }
1790 {
1791 let to_remove = ["name"];
1792 params.remove_params(&to_remove);
1793 }
1794
1795 let url = params.parse_with_url(&url);
1796
1797 loop {
1798 let token = match self
1799 .hub
1800 .auth
1801 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1802 .await
1803 {
1804 Ok(token) => token,
1805 Err(e) => match dlg.token(e) {
1806 Ok(token) => token,
1807 Err(e) => {
1808 dlg.finished(false);
1809 return Err(common::Error::MissingToken(e));
1810 }
1811 },
1812 };
1813 let mut req_result = {
1814 let client = &self.hub.client;
1815 dlg.pre_request();
1816 let mut req_builder = hyper::Request::builder()
1817 .method(hyper::Method::DELETE)
1818 .uri(url.as_str())
1819 .header(USER_AGENT, self.hub._user_agent.clone());
1820
1821 if let Some(token) = token.as_ref() {
1822 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1823 }
1824
1825 let request = req_builder
1826 .header(CONTENT_LENGTH, 0_u64)
1827 .body(common::to_body::<String>(None));
1828
1829 client.request(request.unwrap()).await
1830 };
1831
1832 match req_result {
1833 Err(err) => {
1834 if let common::Retry::After(d) = dlg.http_error(&err) {
1835 sleep(d).await;
1836 continue;
1837 }
1838 dlg.finished(false);
1839 return Err(common::Error::HttpError(err));
1840 }
1841 Ok(res) => {
1842 let (mut parts, body) = res.into_parts();
1843 let mut body = common::Body::new(body);
1844 if !parts.status.is_success() {
1845 let bytes = common::to_bytes(body).await.unwrap_or_default();
1846 let error = serde_json::from_str(&common::to_string(&bytes));
1847 let response = common::to_response(parts, bytes.into());
1848
1849 if let common::Retry::After(d) =
1850 dlg.http_failure(&response, error.as_ref().ok())
1851 {
1852 sleep(d).await;
1853 continue;
1854 }
1855
1856 dlg.finished(false);
1857
1858 return Err(match error {
1859 Ok(value) => common::Error::BadRequest(value),
1860 _ => common::Error::Failure(response),
1861 });
1862 }
1863 let response = {
1864 let bytes = common::to_bytes(body).await.unwrap_or_default();
1865 let encoded = common::to_string(&bytes);
1866 match serde_json::from_str(&encoded) {
1867 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1868 Err(error) => {
1869 dlg.response_json_decode_error(&encoded, &error);
1870 return Err(common::Error::JsonDecodeError(
1871 encoded.to_string(),
1872 error,
1873 ));
1874 }
1875 }
1876 };
1877
1878 dlg.finished(true);
1879 return Ok(response);
1880 }
1881 }
1882 }
1883 }
1884
1885 /// The name of the resource to delete, in the form of `pages/{page_id}`.
1886 ///
1887 /// Sets the *name* path property to the given value.
1888 ///
1889 /// Even though the property as already been set when instantiating this call,
1890 /// we provide this method for API completeness.
1891 pub fn name(mut self, new_value: &str) -> PageDeleteCall<'a, C> {
1892 self._name = new_value.to_string();
1893 self
1894 }
1895 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1896 /// while executing the actual API request.
1897 ///
1898 /// ````text
1899 /// It should be used to handle progress information, and to implement a certain level of resilience.
1900 /// ````
1901 ///
1902 /// Sets the *delegate* property to the given value.
1903 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageDeleteCall<'a, C> {
1904 self._delegate = Some(new_value);
1905 self
1906 }
1907
1908 /// Set any additional parameter of the query string used in the request.
1909 /// It should be used to set parameters which are not yet available through their own
1910 /// setters.
1911 ///
1912 /// Please note that this method must not be used to set any of the known parameters
1913 /// which have their own setter method. If done anyway, the request will fail.
1914 ///
1915 /// # Additional Parameters
1916 ///
1917 /// * *$.xgafv* (query-string) - V1 error format.
1918 /// * *access_token* (query-string) - OAuth access token.
1919 /// * *alt* (query-string) - Data format for response.
1920 /// * *callback* (query-string) - JSONP
1921 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1922 /// * *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.
1923 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1924 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1925 /// * *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.
1926 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1927 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1928 pub fn param<T>(mut self, name: T, value: T) -> PageDeleteCall<'a, C>
1929 where
1930 T: AsRef<str>,
1931 {
1932 self._additional_params
1933 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1934 self
1935 }
1936
1937 /// Identifies the authorization scope for the method you are building.
1938 ///
1939 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1940 /// [`Scope::Full`].
1941 ///
1942 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1943 /// tokens for more than one scope.
1944 ///
1945 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1946 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1947 /// sufficient, a read-write scope will do as well.
1948 pub fn add_scope<St>(mut self, scope: St) -> PageDeleteCall<'a, C>
1949 where
1950 St: AsRef<str>,
1951 {
1952 self._scopes.insert(String::from(scope.as_ref()));
1953 self
1954 }
1955 /// Identifies the authorization scope(s) for the method you are building.
1956 ///
1957 /// See [`Self::add_scope()`] for details.
1958 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageDeleteCall<'a, C>
1959 where
1960 I: IntoIterator<Item = St>,
1961 St: AsRef<str>,
1962 {
1963 self._scopes
1964 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1965 self
1966 }
1967
1968 /// Removes all scopes, and no default scope will be used either.
1969 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1970 /// for details).
1971 pub fn clear_scopes(mut self) -> PageDeleteCall<'a, C> {
1972 self._scopes.clear();
1973 self
1974 }
1975}
1976
1977/// Get all `ClaimReview` markup on a page.
1978///
1979/// A builder for the *get* method supported by a *page* resource.
1980/// It is not used directly, but through a [`PageMethods`] instance.
1981///
1982/// # Example
1983///
1984/// Instantiate a resource method builder
1985///
1986/// ```test_harness,no_run
1987/// # extern crate hyper;
1988/// # extern crate hyper_rustls;
1989/// # extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
1990/// # async fn dox() {
1991/// # use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1992///
1993/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1994/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1995/// # .with_native_roots()
1996/// # .unwrap()
1997/// # .https_only()
1998/// # .enable_http2()
1999/// # .build();
2000///
2001/// # let executor = hyper_util::rt::TokioExecutor::new();
2002/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2003/// # secret,
2004/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2005/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2006/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2007/// # ),
2008/// # ).build().await.unwrap();
2009///
2010/// # let client = hyper_util::client::legacy::Client::builder(
2011/// # hyper_util::rt::TokioExecutor::new()
2012/// # )
2013/// # .build(
2014/// # hyper_rustls::HttpsConnectorBuilder::new()
2015/// # .with_native_roots()
2016/// # .unwrap()
2017/// # .https_or_http()
2018/// # .enable_http2()
2019/// # .build()
2020/// # );
2021/// # let mut hub = FactCheckTools::new(client, auth);
2022/// // You can configure optional parameters by calling the respective setters at will, and
2023/// // execute the final call using `doit()`.
2024/// // Values shown here are possibly random and not representative !
2025/// let result = hub.pages().get("name")
2026/// .doit().await;
2027/// # }
2028/// ```
2029pub struct PageGetCall<'a, C>
2030where
2031 C: 'a,
2032{
2033 hub: &'a FactCheckTools<C>,
2034 _name: String,
2035 _delegate: Option<&'a mut dyn common::Delegate>,
2036 _additional_params: HashMap<String, String>,
2037 _scopes: BTreeSet<String>,
2038}
2039
2040impl<'a, C> common::CallBuilder for PageGetCall<'a, C> {}
2041
2042impl<'a, C> PageGetCall<'a, C>
2043where
2044 C: common::Connector,
2045{
2046 /// Perform the operation you have build so far.
2047 pub async fn doit(
2048 mut self,
2049 ) -> common::Result<(
2050 common::Response,
2051 GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage,
2052 )> {
2053 use std::borrow::Cow;
2054 use std::io::{Read, Seek};
2055
2056 use common::{url::Params, ToParts};
2057 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2058
2059 let mut dd = common::DefaultDelegate;
2060 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2061 dlg.begin(common::MethodInfo {
2062 id: "factchecktools.pages.get",
2063 http_method: hyper::Method::GET,
2064 });
2065
2066 for &field in ["alt", "name"].iter() {
2067 if self._additional_params.contains_key(field) {
2068 dlg.finished(false);
2069 return Err(common::Error::FieldClash(field));
2070 }
2071 }
2072
2073 let mut params = Params::with_capacity(3 + self._additional_params.len());
2074 params.push("name", self._name);
2075
2076 params.extend(self._additional_params.iter());
2077
2078 params.push("alt", "json");
2079 let mut url = self.hub._base_url.clone() + "v1alpha1/{+name}";
2080 if self._scopes.is_empty() {
2081 self._scopes.insert(Scope::Full.as_ref().to_string());
2082 }
2083
2084 #[allow(clippy::single_element_loop)]
2085 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2086 url = params.uri_replacement(url, param_name, find_this, true);
2087 }
2088 {
2089 let to_remove = ["name"];
2090 params.remove_params(&to_remove);
2091 }
2092
2093 let url = params.parse_with_url(&url);
2094
2095 loop {
2096 let token = match self
2097 .hub
2098 .auth
2099 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2100 .await
2101 {
2102 Ok(token) => token,
2103 Err(e) => match dlg.token(e) {
2104 Ok(token) => token,
2105 Err(e) => {
2106 dlg.finished(false);
2107 return Err(common::Error::MissingToken(e));
2108 }
2109 },
2110 };
2111 let mut req_result = {
2112 let client = &self.hub.client;
2113 dlg.pre_request();
2114 let mut req_builder = hyper::Request::builder()
2115 .method(hyper::Method::GET)
2116 .uri(url.as_str())
2117 .header(USER_AGENT, self.hub._user_agent.clone());
2118
2119 if let Some(token) = token.as_ref() {
2120 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2121 }
2122
2123 let request = req_builder
2124 .header(CONTENT_LENGTH, 0_u64)
2125 .body(common::to_body::<String>(None));
2126
2127 client.request(request.unwrap()).await
2128 };
2129
2130 match req_result {
2131 Err(err) => {
2132 if let common::Retry::After(d) = dlg.http_error(&err) {
2133 sleep(d).await;
2134 continue;
2135 }
2136 dlg.finished(false);
2137 return Err(common::Error::HttpError(err));
2138 }
2139 Ok(res) => {
2140 let (mut parts, body) = res.into_parts();
2141 let mut body = common::Body::new(body);
2142 if !parts.status.is_success() {
2143 let bytes = common::to_bytes(body).await.unwrap_or_default();
2144 let error = serde_json::from_str(&common::to_string(&bytes));
2145 let response = common::to_response(parts, bytes.into());
2146
2147 if let common::Retry::After(d) =
2148 dlg.http_failure(&response, error.as_ref().ok())
2149 {
2150 sleep(d).await;
2151 continue;
2152 }
2153
2154 dlg.finished(false);
2155
2156 return Err(match error {
2157 Ok(value) => common::Error::BadRequest(value),
2158 _ => common::Error::Failure(response),
2159 });
2160 }
2161 let response = {
2162 let bytes = common::to_bytes(body).await.unwrap_or_default();
2163 let encoded = common::to_string(&bytes);
2164 match serde_json::from_str(&encoded) {
2165 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2166 Err(error) => {
2167 dlg.response_json_decode_error(&encoded, &error);
2168 return Err(common::Error::JsonDecodeError(
2169 encoded.to_string(),
2170 error,
2171 ));
2172 }
2173 }
2174 };
2175
2176 dlg.finished(true);
2177 return Ok(response);
2178 }
2179 }
2180 }
2181 }
2182
2183 /// The name of the resource to get, in the form of `pages/{page_id}`.
2184 ///
2185 /// Sets the *name* path property to the given value.
2186 ///
2187 /// Even though the property as already been set when instantiating this call,
2188 /// we provide this method for API completeness.
2189 pub fn name(mut self, new_value: &str) -> PageGetCall<'a, C> {
2190 self._name = new_value.to_string();
2191 self
2192 }
2193 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2194 /// while executing the actual API request.
2195 ///
2196 /// ````text
2197 /// It should be used to handle progress information, and to implement a certain level of resilience.
2198 /// ````
2199 ///
2200 /// Sets the *delegate* property to the given value.
2201 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageGetCall<'a, C> {
2202 self._delegate = Some(new_value);
2203 self
2204 }
2205
2206 /// Set any additional parameter of the query string used in the request.
2207 /// It should be used to set parameters which are not yet available through their own
2208 /// setters.
2209 ///
2210 /// Please note that this method must not be used to set any of the known parameters
2211 /// which have their own setter method. If done anyway, the request will fail.
2212 ///
2213 /// # Additional Parameters
2214 ///
2215 /// * *$.xgafv* (query-string) - V1 error format.
2216 /// * *access_token* (query-string) - OAuth access token.
2217 /// * *alt* (query-string) - Data format for response.
2218 /// * *callback* (query-string) - JSONP
2219 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2220 /// * *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.
2221 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2222 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2223 /// * *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.
2224 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2225 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2226 pub fn param<T>(mut self, name: T, value: T) -> PageGetCall<'a, C>
2227 where
2228 T: AsRef<str>,
2229 {
2230 self._additional_params
2231 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2232 self
2233 }
2234
2235 /// Identifies the authorization scope for the method you are building.
2236 ///
2237 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2238 /// [`Scope::Full`].
2239 ///
2240 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2241 /// tokens for more than one scope.
2242 ///
2243 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2244 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2245 /// sufficient, a read-write scope will do as well.
2246 pub fn add_scope<St>(mut self, scope: St) -> PageGetCall<'a, C>
2247 where
2248 St: AsRef<str>,
2249 {
2250 self._scopes.insert(String::from(scope.as_ref()));
2251 self
2252 }
2253 /// Identifies the authorization scope(s) for the method you are building.
2254 ///
2255 /// See [`Self::add_scope()`] for details.
2256 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageGetCall<'a, C>
2257 where
2258 I: IntoIterator<Item = St>,
2259 St: AsRef<str>,
2260 {
2261 self._scopes
2262 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2263 self
2264 }
2265
2266 /// Removes all scopes, and no default scope will be used either.
2267 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2268 /// for details).
2269 pub fn clear_scopes(mut self) -> PageGetCall<'a, C> {
2270 self._scopes.clear();
2271 self
2272 }
2273}
2274
2275/// List the `ClaimReview` markup pages for a specific URL or for an organization.
2276///
2277/// A builder for the *list* method supported by a *page* resource.
2278/// It is not used directly, but through a [`PageMethods`] instance.
2279///
2280/// # Example
2281///
2282/// Instantiate a resource method builder
2283///
2284/// ```test_harness,no_run
2285/// # extern crate hyper;
2286/// # extern crate hyper_rustls;
2287/// # extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
2288/// # async fn dox() {
2289/// # use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2290///
2291/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2292/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2293/// # .with_native_roots()
2294/// # .unwrap()
2295/// # .https_only()
2296/// # .enable_http2()
2297/// # .build();
2298///
2299/// # let executor = hyper_util::rt::TokioExecutor::new();
2300/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2301/// # secret,
2302/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2303/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2304/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2305/// # ),
2306/// # ).build().await.unwrap();
2307///
2308/// # let client = hyper_util::client::legacy::Client::builder(
2309/// # hyper_util::rt::TokioExecutor::new()
2310/// # )
2311/// # .build(
2312/// # hyper_rustls::HttpsConnectorBuilder::new()
2313/// # .with_native_roots()
2314/// # .unwrap()
2315/// # .https_or_http()
2316/// # .enable_http2()
2317/// # .build()
2318/// # );
2319/// # let mut hub = FactCheckTools::new(client, auth);
2320/// // You can configure optional parameters by calling the respective setters at will, and
2321/// // execute the final call using `doit()`.
2322/// // Values shown here are possibly random and not representative !
2323/// let result = hub.pages().list()
2324/// .url("dolor")
2325/// .page_token("ea")
2326/// .page_size(-55)
2327/// .organization("invidunt")
2328/// .offset(-47)
2329/// .doit().await;
2330/// # }
2331/// ```
2332pub struct PageListCall<'a, C>
2333where
2334 C: 'a,
2335{
2336 hub: &'a FactCheckTools<C>,
2337 _url: Option<String>,
2338 _page_token: Option<String>,
2339 _page_size: Option<i32>,
2340 _organization: Option<String>,
2341 _offset: Option<i32>,
2342 _delegate: Option<&'a mut dyn common::Delegate>,
2343 _additional_params: HashMap<String, String>,
2344 _scopes: BTreeSet<String>,
2345}
2346
2347impl<'a, C> common::CallBuilder for PageListCall<'a, C> {}
2348
2349impl<'a, C> PageListCall<'a, C>
2350where
2351 C: common::Connector,
2352{
2353 /// Perform the operation you have build so far.
2354 pub async fn doit(
2355 mut self,
2356 ) -> common::Result<(
2357 common::Response,
2358 GoogleFactcheckingFactchecktoolsV1alpha1ListClaimReviewMarkupPagesResponse,
2359 )> {
2360 use std::borrow::Cow;
2361 use std::io::{Read, Seek};
2362
2363 use common::{url::Params, ToParts};
2364 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2365
2366 let mut dd = common::DefaultDelegate;
2367 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2368 dlg.begin(common::MethodInfo {
2369 id: "factchecktools.pages.list",
2370 http_method: hyper::Method::GET,
2371 });
2372
2373 for &field in [
2374 "alt",
2375 "url",
2376 "pageToken",
2377 "pageSize",
2378 "organization",
2379 "offset",
2380 ]
2381 .iter()
2382 {
2383 if self._additional_params.contains_key(field) {
2384 dlg.finished(false);
2385 return Err(common::Error::FieldClash(field));
2386 }
2387 }
2388
2389 let mut params = Params::with_capacity(7 + self._additional_params.len());
2390 if let Some(value) = self._url.as_ref() {
2391 params.push("url", value);
2392 }
2393 if let Some(value) = self._page_token.as_ref() {
2394 params.push("pageToken", value);
2395 }
2396 if let Some(value) = self._page_size.as_ref() {
2397 params.push("pageSize", value.to_string());
2398 }
2399 if let Some(value) = self._organization.as_ref() {
2400 params.push("organization", value);
2401 }
2402 if let Some(value) = self._offset.as_ref() {
2403 params.push("offset", value.to_string());
2404 }
2405
2406 params.extend(self._additional_params.iter());
2407
2408 params.push("alt", "json");
2409 let mut url = self.hub._base_url.clone() + "v1alpha1/pages";
2410 if self._scopes.is_empty() {
2411 self._scopes.insert(Scope::Full.as_ref().to_string());
2412 }
2413
2414 let url = params.parse_with_url(&url);
2415
2416 loop {
2417 let token = match self
2418 .hub
2419 .auth
2420 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2421 .await
2422 {
2423 Ok(token) => token,
2424 Err(e) => match dlg.token(e) {
2425 Ok(token) => token,
2426 Err(e) => {
2427 dlg.finished(false);
2428 return Err(common::Error::MissingToken(e));
2429 }
2430 },
2431 };
2432 let mut req_result = {
2433 let client = &self.hub.client;
2434 dlg.pre_request();
2435 let mut req_builder = hyper::Request::builder()
2436 .method(hyper::Method::GET)
2437 .uri(url.as_str())
2438 .header(USER_AGENT, self.hub._user_agent.clone());
2439
2440 if let Some(token) = token.as_ref() {
2441 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2442 }
2443
2444 let request = req_builder
2445 .header(CONTENT_LENGTH, 0_u64)
2446 .body(common::to_body::<String>(None));
2447
2448 client.request(request.unwrap()).await
2449 };
2450
2451 match req_result {
2452 Err(err) => {
2453 if let common::Retry::After(d) = dlg.http_error(&err) {
2454 sleep(d).await;
2455 continue;
2456 }
2457 dlg.finished(false);
2458 return Err(common::Error::HttpError(err));
2459 }
2460 Ok(res) => {
2461 let (mut parts, body) = res.into_parts();
2462 let mut body = common::Body::new(body);
2463 if !parts.status.is_success() {
2464 let bytes = common::to_bytes(body).await.unwrap_or_default();
2465 let error = serde_json::from_str(&common::to_string(&bytes));
2466 let response = common::to_response(parts, bytes.into());
2467
2468 if let common::Retry::After(d) =
2469 dlg.http_failure(&response, error.as_ref().ok())
2470 {
2471 sleep(d).await;
2472 continue;
2473 }
2474
2475 dlg.finished(false);
2476
2477 return Err(match error {
2478 Ok(value) => common::Error::BadRequest(value),
2479 _ => common::Error::Failure(response),
2480 });
2481 }
2482 let response = {
2483 let bytes = common::to_bytes(body).await.unwrap_or_default();
2484 let encoded = common::to_string(&bytes);
2485 match serde_json::from_str(&encoded) {
2486 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2487 Err(error) => {
2488 dlg.response_json_decode_error(&encoded, &error);
2489 return Err(common::Error::JsonDecodeError(
2490 encoded.to_string(),
2491 error,
2492 ));
2493 }
2494 }
2495 };
2496
2497 dlg.finished(true);
2498 return Ok(response);
2499 }
2500 }
2501 }
2502 }
2503
2504 /// The URL from which to get `ClaimReview` markup. There will be at most one result. If markup is associated with a more canonical version of the URL provided, we will return that URL instead. Cannot be specified along with an organization.
2505 ///
2506 /// Sets the *url* query property to the given value.
2507 pub fn url(mut self, new_value: &str) -> PageListCall<'a, C> {
2508 self._url = Some(new_value.to_string());
2509 self
2510 }
2511 /// The pagination token. You may provide the `next_page_token` returned from a previous List request, if any, in order to get the next page. All other fields must have the same values as in the previous request.
2512 ///
2513 /// Sets the *page token* query property to the given value.
2514 pub fn page_token(mut self, new_value: &str) -> PageListCall<'a, C> {
2515 self._page_token = Some(new_value.to_string());
2516 self
2517 }
2518 /// The pagination size. We will return up to that many results. Defaults to 10 if not set. Has no effect if a URL is requested.
2519 ///
2520 /// Sets the *page size* query property to the given value.
2521 pub fn page_size(mut self, new_value: i32) -> PageListCall<'a, C> {
2522 self._page_size = Some(new_value);
2523 self
2524 }
2525 /// The organization for which we want to fetch markups for. For instance, "site.com". Cannot be specified along with an URL.
2526 ///
2527 /// Sets the *organization* query property to the given value.
2528 pub fn organization(mut self, new_value: &str) -> PageListCall<'a, C> {
2529 self._organization = Some(new_value.to_string());
2530 self
2531 }
2532 /// An integer that specifies the current offset (that is, starting result location) in search results. This field is only considered if `page_token` is unset, and if the request is not for a specific URL. For example, 0 means to return results starting from the first matching result, and 10 means to return from the 11th result.
2533 ///
2534 /// Sets the *offset* query property to the given value.
2535 pub fn offset(mut self, new_value: i32) -> PageListCall<'a, C> {
2536 self._offset = Some(new_value);
2537 self
2538 }
2539 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2540 /// while executing the actual API request.
2541 ///
2542 /// ````text
2543 /// It should be used to handle progress information, and to implement a certain level of resilience.
2544 /// ````
2545 ///
2546 /// Sets the *delegate* property to the given value.
2547 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageListCall<'a, C> {
2548 self._delegate = Some(new_value);
2549 self
2550 }
2551
2552 /// Set any additional parameter of the query string used in the request.
2553 /// It should be used to set parameters which are not yet available through their own
2554 /// setters.
2555 ///
2556 /// Please note that this method must not be used to set any of the known parameters
2557 /// which have their own setter method. If done anyway, the request will fail.
2558 ///
2559 /// # Additional Parameters
2560 ///
2561 /// * *$.xgafv* (query-string) - V1 error format.
2562 /// * *access_token* (query-string) - OAuth access token.
2563 /// * *alt* (query-string) - Data format for response.
2564 /// * *callback* (query-string) - JSONP
2565 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2566 /// * *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.
2567 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2568 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2569 /// * *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.
2570 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2571 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2572 pub fn param<T>(mut self, name: T, value: T) -> PageListCall<'a, C>
2573 where
2574 T: AsRef<str>,
2575 {
2576 self._additional_params
2577 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2578 self
2579 }
2580
2581 /// Identifies the authorization scope for the method you are building.
2582 ///
2583 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2584 /// [`Scope::Full`].
2585 ///
2586 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2587 /// tokens for more than one scope.
2588 ///
2589 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2590 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2591 /// sufficient, a read-write scope will do as well.
2592 pub fn add_scope<St>(mut self, scope: St) -> PageListCall<'a, C>
2593 where
2594 St: AsRef<str>,
2595 {
2596 self._scopes.insert(String::from(scope.as_ref()));
2597 self
2598 }
2599 /// Identifies the authorization scope(s) for the method you are building.
2600 ///
2601 /// See [`Self::add_scope()`] for details.
2602 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageListCall<'a, C>
2603 where
2604 I: IntoIterator<Item = St>,
2605 St: AsRef<str>,
2606 {
2607 self._scopes
2608 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2609 self
2610 }
2611
2612 /// Removes all scopes, and no default scope will be used either.
2613 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2614 /// for details).
2615 pub fn clear_scopes(mut self) -> PageListCall<'a, C> {
2616 self._scopes.clear();
2617 self
2618 }
2619}
2620
2621/// Update for all `ClaimReview` markup on a page Note that this is a full update. To retain the existing `ClaimReview` markup on a page, first perform a Get operation, then modify the returned markup, and finally call Update with the entire `ClaimReview` markup as the body.
2622///
2623/// A builder for the *update* method supported by a *page* resource.
2624/// It is not used directly, but through a [`PageMethods`] instance.
2625///
2626/// # Example
2627///
2628/// Instantiate a resource method builder
2629///
2630/// ```test_harness,no_run
2631/// # extern crate hyper;
2632/// # extern crate hyper_rustls;
2633/// # extern crate google_factchecktools1_alpha1 as factchecktools1_alpha1;
2634/// use factchecktools1_alpha1::api::GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage;
2635/// # async fn dox() {
2636/// # use factchecktools1_alpha1::{FactCheckTools, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2637///
2638/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2639/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2640/// # .with_native_roots()
2641/// # .unwrap()
2642/// # .https_only()
2643/// # .enable_http2()
2644/// # .build();
2645///
2646/// # let executor = hyper_util::rt::TokioExecutor::new();
2647/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2648/// # secret,
2649/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2650/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2651/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2652/// # ),
2653/// # ).build().await.unwrap();
2654///
2655/// # let client = hyper_util::client::legacy::Client::builder(
2656/// # hyper_util::rt::TokioExecutor::new()
2657/// # )
2658/// # .build(
2659/// # hyper_rustls::HttpsConnectorBuilder::new()
2660/// # .with_native_roots()
2661/// # .unwrap()
2662/// # .https_or_http()
2663/// # .enable_http2()
2664/// # .build()
2665/// # );
2666/// # let mut hub = FactCheckTools::new(client, auth);
2667/// // As the method needs a request, you would usually fill it with the desired information
2668/// // into the respective structure. Some of the parts shown here might not be applicable !
2669/// // Values shown here are possibly random and not representative !
2670/// let mut req = GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage::default();
2671///
2672/// // You can configure optional parameters by calling the respective setters at will, and
2673/// // execute the final call using `doit()`.
2674/// // Values shown here are possibly random and not representative !
2675/// let result = hub.pages().update(req, "name")
2676/// .doit().await;
2677/// # }
2678/// ```
2679pub struct PageUpdateCall<'a, C>
2680where
2681 C: 'a,
2682{
2683 hub: &'a FactCheckTools<C>,
2684 _request: GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage,
2685 _name: String,
2686 _delegate: Option<&'a mut dyn common::Delegate>,
2687 _additional_params: HashMap<String, String>,
2688 _scopes: BTreeSet<String>,
2689}
2690
2691impl<'a, C> common::CallBuilder for PageUpdateCall<'a, C> {}
2692
2693impl<'a, C> PageUpdateCall<'a, C>
2694where
2695 C: common::Connector,
2696{
2697 /// Perform the operation you have build so far.
2698 pub async fn doit(
2699 mut self,
2700 ) -> common::Result<(
2701 common::Response,
2702 GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage,
2703 )> {
2704 use std::borrow::Cow;
2705 use std::io::{Read, Seek};
2706
2707 use common::{url::Params, ToParts};
2708 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2709
2710 let mut dd = common::DefaultDelegate;
2711 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2712 dlg.begin(common::MethodInfo {
2713 id: "factchecktools.pages.update",
2714 http_method: hyper::Method::PUT,
2715 });
2716
2717 for &field in ["alt", "name"].iter() {
2718 if self._additional_params.contains_key(field) {
2719 dlg.finished(false);
2720 return Err(common::Error::FieldClash(field));
2721 }
2722 }
2723
2724 let mut params = Params::with_capacity(4 + self._additional_params.len());
2725 params.push("name", self._name);
2726
2727 params.extend(self._additional_params.iter());
2728
2729 params.push("alt", "json");
2730 let mut url = self.hub._base_url.clone() + "v1alpha1/{+name}";
2731 if self._scopes.is_empty() {
2732 self._scopes.insert(Scope::Full.as_ref().to_string());
2733 }
2734
2735 #[allow(clippy::single_element_loop)]
2736 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2737 url = params.uri_replacement(url, param_name, find_this, true);
2738 }
2739 {
2740 let to_remove = ["name"];
2741 params.remove_params(&to_remove);
2742 }
2743
2744 let url = params.parse_with_url(&url);
2745
2746 let mut json_mime_type = mime::APPLICATION_JSON;
2747 let mut request_value_reader = {
2748 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2749 common::remove_json_null_values(&mut value);
2750 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2751 serde_json::to_writer(&mut dst, &value).unwrap();
2752 dst
2753 };
2754 let request_size = request_value_reader
2755 .seek(std::io::SeekFrom::End(0))
2756 .unwrap();
2757 request_value_reader
2758 .seek(std::io::SeekFrom::Start(0))
2759 .unwrap();
2760
2761 loop {
2762 let token = match self
2763 .hub
2764 .auth
2765 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2766 .await
2767 {
2768 Ok(token) => token,
2769 Err(e) => match dlg.token(e) {
2770 Ok(token) => token,
2771 Err(e) => {
2772 dlg.finished(false);
2773 return Err(common::Error::MissingToken(e));
2774 }
2775 },
2776 };
2777 request_value_reader
2778 .seek(std::io::SeekFrom::Start(0))
2779 .unwrap();
2780 let mut req_result = {
2781 let client = &self.hub.client;
2782 dlg.pre_request();
2783 let mut req_builder = hyper::Request::builder()
2784 .method(hyper::Method::PUT)
2785 .uri(url.as_str())
2786 .header(USER_AGENT, self.hub._user_agent.clone());
2787
2788 if let Some(token) = token.as_ref() {
2789 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2790 }
2791
2792 let request = req_builder
2793 .header(CONTENT_TYPE, json_mime_type.to_string())
2794 .header(CONTENT_LENGTH, request_size as u64)
2795 .body(common::to_body(
2796 request_value_reader.get_ref().clone().into(),
2797 ));
2798
2799 client.request(request.unwrap()).await
2800 };
2801
2802 match req_result {
2803 Err(err) => {
2804 if let common::Retry::After(d) = dlg.http_error(&err) {
2805 sleep(d).await;
2806 continue;
2807 }
2808 dlg.finished(false);
2809 return Err(common::Error::HttpError(err));
2810 }
2811 Ok(res) => {
2812 let (mut parts, body) = res.into_parts();
2813 let mut body = common::Body::new(body);
2814 if !parts.status.is_success() {
2815 let bytes = common::to_bytes(body).await.unwrap_or_default();
2816 let error = serde_json::from_str(&common::to_string(&bytes));
2817 let response = common::to_response(parts, bytes.into());
2818
2819 if let common::Retry::After(d) =
2820 dlg.http_failure(&response, error.as_ref().ok())
2821 {
2822 sleep(d).await;
2823 continue;
2824 }
2825
2826 dlg.finished(false);
2827
2828 return Err(match error {
2829 Ok(value) => common::Error::BadRequest(value),
2830 _ => common::Error::Failure(response),
2831 });
2832 }
2833 let response = {
2834 let bytes = common::to_bytes(body).await.unwrap_or_default();
2835 let encoded = common::to_string(&bytes);
2836 match serde_json::from_str(&encoded) {
2837 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2838 Err(error) => {
2839 dlg.response_json_decode_error(&encoded, &error);
2840 return Err(common::Error::JsonDecodeError(
2841 encoded.to_string(),
2842 error,
2843 ));
2844 }
2845 }
2846 };
2847
2848 dlg.finished(true);
2849 return Ok(response);
2850 }
2851 }
2852 }
2853 }
2854
2855 ///
2856 /// Sets the *request* property to the given value.
2857 ///
2858 /// Even though the property as already been set when instantiating this call,
2859 /// we provide this method for API completeness.
2860 pub fn request(
2861 mut self,
2862 new_value: GoogleFactcheckingFactchecktoolsV1alpha1ClaimReviewMarkupPage,
2863 ) -> PageUpdateCall<'a, C> {
2864 self._request = new_value;
2865 self
2866 }
2867 /// The name of this `ClaimReview` markup page resource, in the form of `pages/{page_id}`. Except for update requests, this field is output-only and should not be set by the user.
2868 ///
2869 /// Sets the *name* path property to the given value.
2870 ///
2871 /// Even though the property as already been set when instantiating this call,
2872 /// we provide this method for API completeness.
2873 pub fn name(mut self, new_value: &str) -> PageUpdateCall<'a, C> {
2874 self._name = new_value.to_string();
2875 self
2876 }
2877 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2878 /// while executing the actual API request.
2879 ///
2880 /// ````text
2881 /// It should be used to handle progress information, and to implement a certain level of resilience.
2882 /// ````
2883 ///
2884 /// Sets the *delegate* property to the given value.
2885 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PageUpdateCall<'a, C> {
2886 self._delegate = Some(new_value);
2887 self
2888 }
2889
2890 /// Set any additional parameter of the query string used in the request.
2891 /// It should be used to set parameters which are not yet available through their own
2892 /// setters.
2893 ///
2894 /// Please note that this method must not be used to set any of the known parameters
2895 /// which have their own setter method. If done anyway, the request will fail.
2896 ///
2897 /// # Additional Parameters
2898 ///
2899 /// * *$.xgafv* (query-string) - V1 error format.
2900 /// * *access_token* (query-string) - OAuth access token.
2901 /// * *alt* (query-string) - Data format for response.
2902 /// * *callback* (query-string) - JSONP
2903 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2904 /// * *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.
2905 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2906 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2907 /// * *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.
2908 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2909 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2910 pub fn param<T>(mut self, name: T, value: T) -> PageUpdateCall<'a, C>
2911 where
2912 T: AsRef<str>,
2913 {
2914 self._additional_params
2915 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2916 self
2917 }
2918
2919 /// Identifies the authorization scope for the method you are building.
2920 ///
2921 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2922 /// [`Scope::Full`].
2923 ///
2924 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2925 /// tokens for more than one scope.
2926 ///
2927 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2928 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2929 /// sufficient, a read-write scope will do as well.
2930 pub fn add_scope<St>(mut self, scope: St) -> PageUpdateCall<'a, C>
2931 where
2932 St: AsRef<str>,
2933 {
2934 self._scopes.insert(String::from(scope.as_ref()));
2935 self
2936 }
2937 /// Identifies the authorization scope(s) for the method you are building.
2938 ///
2939 /// See [`Self::add_scope()`] for details.
2940 pub fn add_scopes<I, St>(mut self, scopes: I) -> PageUpdateCall<'a, C>
2941 where
2942 I: IntoIterator<Item = St>,
2943 St: AsRef<str>,
2944 {
2945 self._scopes
2946 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2947 self
2948 }
2949
2950 /// Removes all scopes, and no default scope will be used either.
2951 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2952 /// for details).
2953 pub fn clear_scopes(mut self) -> PageUpdateCall<'a, C> {
2954 self._scopes.clear();
2955 self
2956 }
2957}